StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TPCV2P0_ADCR_SR.cxx
1 /***************************************************************************
2  * $Id: TPCV2P0_ADCR_SR.cxx,v 1.6 2007/12/24 06:04:32 fine Exp $
3  * Author: Jeff Landgraf and M.J. LeVine
4  ***************************************************************************
5  * Description: // TPC V2.0 ADC Raw Reader
6  *
7  *
8  * change log
9  * 06-Jun-99 MJL added return TRUE to TPCV2P0_ADCR_SR::initialize()
10  * 06-Jun-99 MJL added return TRUE to TPCV2P0_PRMS_SR::initialize()
11  * 06-Jun-99 MJL added return TRUE to TPCV2P0_PEDR_SR::initialize()
12  * 29-Aug-99 MJL #include <Stiostream.h> for HP platform
13  *
14  ***************************************************************************
15  * $Log: TPCV2P0_ADCR_SR.cxx,v $
16  * Revision 1.6 2007/12/24 06:04:32 fine
17  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
18  *
19  * Revision 1.5 2003/09/02 17:55:33 perev
20  * gcc 3.2 updates + WarnOff
21  *
22  * Revision 1.4 2000/01/04 20:55:04 levine
23  * Implemented memory-mapped file access in EventReader.cxx. Old method
24  * (via seeks) is still possible by setting mmapp=0 in
25  *
26  * getEventReader(fd,offset,(const char *)logfile,mmapp);
27  *
28  *
29  * but memory-mapped access is much more effective.
30  *
31  * Revision 1.3 1999/09/02 21:47:11 fisyak
32  * HP corrections
33  *
34  * Revision 1.2 1999/07/02 04:43:24 levine
35  * Many changes -
36  * navigates to head of TPCP bank independent of position.
37  * move declarations out of loops where they were upsetting some compilers
38  * suppress output from class libraries with run-time switch EventReader.verbose
39  * added TPCV2P0_CPP_SR::getAsicParams()
40  *
41  *
42  **************************************************************************/
43 #include <Stiostream.h>
44 
45 
46 #include "StDaqLib/GENERIC/EventReader.hh"
47 #include "TPCV2P0.hh"
48 
49 //==================== ADC Raw Reader =============================
50 using namespace OLDEVP;
51 
52 TPCV2P0_ADCR_SR::TPCV2P0_ADCR_SR(int s, TPCV2P0_Reader *det)
53 {
54  // cout << "Constructing TPCV2P0_ADCR_SR" << endl;
55  sector = s-1; // convert the sector into internal representation
56  detector = det;
57 
58  // NULLS in banks array
59  memset((char *)banks, 0, sizeof(banks));
60 }
61 
62 int TPCV2P0_ADCR_SR::initialize()
63 {
64  // get a sector reader for PADK
65  padkr = detector->getPADKReader(sector);
66  if (!padkr) return FALSE;
67 
68  // store pointers to the ADCR banks
69  for(int rcb = 0; rcb < 6; rcb++)
70  {
71  for(int mz = 0; mz < 3; mz++)
72  {
73  banks[rcb][mz] = detector->getBankTPCADCR(sector,rcb,mz);
74  }
75  }
76  return TRUE;
77 }
78 
79 TPCV2P0_ADCR_SR::~TPCV2P0_ADCR_SR()
80 {
81  // cout << "Deleting TPCV2P0_ADCR_SR" << endl;
82 }
83 
84 int TPCV2P0_ADCR_SR::getPadList(int PadRow, u_char **padList)
85 {
86  // Construct the padlist array for this PadRow
87  int i;
88  PADK_entry ent;
89 
90  // Fill in padrows
91  int j=0;
92  for(i=1; i<=TPC_MAXPADS; i++)
93  {
94  padkr->get(PadRow, i, &ent);
95  if((ent.mz == 0) || (ent.rb == 0)) continue;
96  padlist[PadRow-1][j++] = i;
97  }
98  // confusing syntax but correct
99  *padList = &padlist[PadRow-1][0];
100  return j;
101 }
102 
103 int TPCV2P0_ADCR_SR::getSequences(int PadRow, int Pad, int *nArray,
104  u_char **Array)
105 {
106  PADK_entry ent;
107  padkr->get(PadRow, Pad, &ent);
108  if((ent.mz == 0) || (ent.rb == 0))
109  {
110  *nArray = 0;
111  *Array = NULL;
112  spERROR(ERR_BANK);
113  return -1;
114  }
115 
116  int offset = ent.offset * padkr->getADCBytes();
117  *nArray = padkr->getADCBytes();
118 
119  // printf("Offset = %d\n",offset);
120  // printf("array coord: rb=%d, mz=%d\n",ent.rb,ent.mz);
121  if (banks[ent.rb-1][ent.mz-1] != NULL)
122  {
123  *Array = (((u_char *)banks[ent.rb-1][ent.mz-1]->ADC) + offset);
124  return 1;
125  }
126  return 0;
127 }
128 
129 int TPCV2P0_ADCR_SR::MemUsed()
130 {
131  return 0;
132 }
133 
134 //==================== Pedestal Reader ===========================
135 
136 TPCV2P0_PEDR_SR::TPCV2P0_PEDR_SR(int s, TPCV2P0_Reader *det)
137 {
138  // cout << "Constructing TPCV2P0_PEDR_SR" << endl;
139  sector = s-1; // convert the sector into internal representation
140  detector = det;
141 
142  // NULLS in banks array
143  memset((char *)banks, 0, sizeof(banks));
144  numEvents = 0;
145 }
146 
147 int TPCV2P0_PEDR_SR::initialize()
148 {
149  // get a sector reader for PADK
150  padkr = detector->getPADKReader(sector);
151  if (!padkr) return FALSE;
152 
153  // store pointers to the PEDR banks
154  for(int rcb = 0; rcb < 6; rcb++)
155  {
156  for(int mz = 0; mz < 3; mz++)
157  {
158  banks[rcb][mz] = detector->getBankTPCPEDR(sector,rcb,mz);
159  if (banks[rcb][mz] !=NULL)
160  numEvents = banks[rcb][mz]->NumEvents;
161  }
162  }
163  return TRUE;
164 }
165 
166 TPCV2P0_PEDR_SR::~TPCV2P0_PEDR_SR()
167 {
168  // cout << "Deleting TPCV2P0_PEDR_SR" << endl;
169 }
170 
171 int TPCV2P0_PEDR_SR::getPadList(int PadRow, u_char **padList)
172 {
173  // Construct the padlist array for this PadRow
174  int i;
175  PADK_entry ent;
176 
177  // Fill in padrows
178  int j=0;
179  for(i=1; i<=TPC_MAXPADS; i++)
180  {
181  padkr->get(PadRow, i, &ent);
182  if((ent.mz == 0) || (ent.rb == 0)) continue;
183  padlist[PadRow-1][j++] = i;
184  }
185  // confusing syntax but correct
186  *padList = &padlist[PadRow-1][0];
187  return j;
188 }
189 
190 int TPCV2P0_PEDR_SR::getSequences(int PadRow, int Pad, int *nArray,
191  u_char **Array)
192 {
193  PADK_entry ent;
194  padkr->get(PadRow, Pad, &ent);
195  if((ent.mz == 0) || (ent.rb == 0))
196  {
197  *nArray = 0;
198  *Array = NULL;
199  spERROR(ERR_BANK);
200  return -1;
201  }
202 
203  int offset = ent.offset * padkr->getPEDBytes();
204  *nArray = padkr->getPEDBytes();
205 
206  if (banks[ent.rb-1][ent.mz-1] != NULL)
207  {
208  // printf("Offset = %d\n",offset);
209  // printf("array coord: rb=%d, mz=%d\n",ent.rb,ent.mz);
210  *Array = (((u_char *)banks[ent.rb-1][ent.mz-1]->pedestal) + offset);
211  return 1;
212  }
213  return 0;
214 }
215 
216 int TPCV2P0_PEDR_SR::getNumberOfEvents()
217 {
218  return numEvents;
219 }
220 
221 int TPCV2P0_PEDR_SR::MemUsed()
222 {
223  return 0;
224 }
225 
226 
227 //==================== RMS Reader =============================
228 
229 TPCV2P0_PRMS_SR::TPCV2P0_PRMS_SR(int s, TPCV2P0_Reader *det)
230 {
231  // cout << "Constructing TPCV2P0_PRMS_SR" << endl;
232  sector = s-1; // convert the sector into internal representation
233  detector = det;
234 
235  // NULLS in banks array
236  memset((char *)banks, 0, sizeof(banks));
237  numEvents = 0;
238 
239 }
240 
241 int TPCV2P0_PRMS_SR::initialize()
242 {
243  // get a sector reader for PADK
244  padkr = detector->getPADKReader(sector);
245  if (!padkr) return FALSE;
246 
247  // store pointers to the PRMS banks
248  for(int rcb = 0; rcb < 6; rcb++)
249  {
250  for(int mz = 0; mz < 3; mz++)
251  {
252  banks[rcb][mz] = detector->getBankTPCRMSR(sector,rcb,mz);
253  if (banks[rcb][mz] !=NULL)
254  numEvents = banks[rcb][mz]->NumEvents;
255  }
256  }
257  return TRUE;
258 }
259 
260 TPCV2P0_PRMS_SR::~TPCV2P0_PRMS_SR()
261 {
262  // cout << "Deleting TPCV2P0_PRMS_SR" << endl;
263 }
264 
265 int TPCV2P0_PRMS_SR::getPadList(int PadRow, u_char **padList)
266 {
267  // Construct the padlist array for this PadRow
268  int i;
269  PADK_entry ent;
270 
271  // Fill in padrows
272  int j=0;
273  for(i=1; i<=TPC_MAXPADS; i++)
274  {
275  padkr->get(PadRow, i, &ent);
276  if((ent.mz == 0) || (ent.rb == 0)) continue;
277  padlist[PadRow-1][j++] = i;
278  }
279  // confusing syntax but correct
280  *padList = &padlist[PadRow-1][0];
281  return j;
282 }
283 
284 int TPCV2P0_PRMS_SR::getSequences(int PadRow, int Pad, int *nArray,
285  u_char **Array)
286 {
287  PADK_entry ent;
288  padkr->get(PadRow, Pad, &ent);
289  if((ent.mz == 0) || (ent.rb == 0))
290  {
291  *nArray = 0;
292  *Array = NULL;
293  spERROR(ERR_BANK);
294  return -1;
295  }
296 
297  int offset = ent.offset * padkr->getRMSBytes();
298  *nArray = padkr->getRMSBytes();
299 
300  if (banks[ent.rb-1][ent.mz-1] != NULL)
301  {
302 // printf("Offset = %d\n",offset);
303 // printf("array coord: rb=%d, mz=%d\n",ent.rb,ent.mz);
304  *Array = (((u_char *)banks[ent.rb-1][ent.mz-1]->pedRMSt16) + offset);
305  return 1;
306  }
307  return 0;
308 }
309 
310 int TPCV2P0_PRMS_SR::getNumberOfEvents()
311 {
312  return numEvents;
313 }
314 
315 int TPCV2P0_PRMS_SR::MemUsed()
316 {
317  return 0;
318 }
319 
320 
Definition: TPCV1P0.hh:217