StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TPCV1P0_ADCR_SR.cxx
1 /***************************************************************************
2  * $Id: TPCV1P0_ADCR_SR.cxx,v 1.6 2007/12/24 06:04:31 fine Exp $
3  * Author: Jeff Landgraf
4  ***************************************************************************
5  * Description: TPC (v1.0) raw ADC reader
6  *
7  *
8  * change log
9  * 03-Jun-99 MJL added return TRUE to TPCV1P0_ADCR_SR::initialize()
10  * 03-Jun-99 MJL added return TRUE to TPCV1P0_PRMS_SR::initialize()
11  * 03-Jun-99 MJL added return TRUE to TPCV1P0_PEDR_SR::initialize()
12  * 29-Aug-99 MJL #include <Stiostream.h> for HP platform
13  *
14  ***************************************************************************
15  * $Log: TPCV1P0_ADCR_SR.cxx,v $
16  * Revision 1.6 2007/12/24 06:04:31 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:10 fisyak
32  * HP corrections
33  *
34  * Revision 1.2 1999/07/02 04:43:23 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 "TPCV1P0.hh"
48 
49 //==================== ADC Raw Reader =============================
50 
51 using namespace OLDEVP;
52 
53 TPCV1P0_ADCR_SR::TPCV1P0_ADCR_SR(int s, TPCV1P0_Reader *det)
54 {
55  // cout << "Constructing TPCV1P0_ADCR_SR" << endl;
56  sector = s-1; // convert the sector into internal representation
57  detector = det;
58 
59  // NULLS in banks array
60  memset((char *)banks, 0, sizeof(banks));
61 }
62 
63 int TPCV1P0_ADCR_SR::initialize()
64 {
65  // get a sector reader for PADK
66  padkr = detector->getPADKReader(sector);
67  if (!padkr) return FALSE;
68 
69  // store pointers to the ADCR banks
70  for(int rcb = 0; rcb < 6; rcb++)
71  {
72  for(int mz = 0; mz < 3; mz++)
73  {
74  banks[rcb][mz] = detector->getBankTPCADCR(sector,rcb,mz);
75  }
76  }
77  return TRUE;
78 }
79 
80 TPCV1P0_ADCR_SR::~TPCV1P0_ADCR_SR()
81 {
82  // cout << "Deleting TPCV1P0_ADCR_SR" << endl;
83 }
84 
85 int TPCV1P0_ADCR_SR::getPadList(int PadRow, u_char **padList)
86 {
87  // Construct the padlist array for this PadRow
88  int i;
89  PADK_entry ent;
90 
91  // Fill in padrows
92  int j=0;
93  for(i=1; i<=TPC_MAXPADS; i++)
94  {
95  padkr->get(PadRow, i, &ent);
96  if((ent.mz == 0) || (ent.rb == 0)) continue;
97  padlist[PadRow-1][j++] = i;
98  }
99  // confusing syntax but correct
100  *padList = &padlist[PadRow-1][0];
101  return j;
102 }
103 
104 int TPCV1P0_ADCR_SR::getSequences(int PadRow, int Pad, int *nArray,
105  u_char **Array)
106 {
107  PADK_entry ent;
108  padkr->get(PadRow, Pad, &ent);
109  if((ent.mz == 0) || (ent.rb == 0))
110  {
111  *nArray = 0;
112  *Array = NULL;
113  spERROR(ERR_BANK);
114  return -1;
115  }
116 
117  int offset = ent.offset * padkr->getADCBytes();
118  *nArray = padkr->getADCBytes();
119 
120  // printf("Offset = %d\n",offset);
121  // printf("array coord: rb=%d, mz=%d\n",ent.rb,ent.mz);
122  if (banks[ent.rb-1][ent.mz-1] != NULL)
123  {
124  *Array = (((u_char *)banks[ent.rb-1][ent.mz-1]->ADC) + offset);
125  return 1;
126  }
127  return 0;
128 }
129 
130 int TPCV1P0_ADCR_SR::MemUsed()
131 {
132  return 0;
133 }
134 
135 //==================== Pedestal Reader ===========================
136 
137 TPCV1P0_PEDR_SR::TPCV1P0_PEDR_SR(int s, TPCV1P0_Reader *det)
138 {
139  // cout << "Constructing TPCV1P0_PEDR_SR" << endl;
140  sector = s-1; // convert the sector into internal representation
141  detector = det;
142 
143  // NULLS in banks array
144  memset((char *)banks, 0, sizeof(banks));
145  numEvents = 0;
146 }
147 
148 int TPCV1P0_PEDR_SR::initialize()
149 {
150  // get a sector reader for PADK
151  padkr = detector->getPADKReader(sector);
152  if (!padkr) return FALSE;
153 
154  // store pointers to the PEDR banks
155  for(int rcb = 0; rcb < 6; rcb++)
156  {
157  for(int mz = 0; mz < 3; mz++)
158  {
159  banks[rcb][mz] = detector->getBankTPCPEDR(sector,rcb,mz);
160  if (banks[rcb][mz] !=NULL)
161  numEvents = banks[rcb][mz]->NumEvents;
162  }
163  }
164  return TRUE;
165 }
166 
167 TPCV1P0_PEDR_SR::~TPCV1P0_PEDR_SR()
168 {
169  // cout << "Deleting TPCV1P0_PEDR_SR" << endl;
170 }
171 
172 int TPCV1P0_PEDR_SR::getPadList(int PadRow, u_char **padList)
173 {
174  // Construct the padlist array for this PadRow
175  int i;
176  PADK_entry ent;
177 
178  // Fill in padrows
179  int j=0;
180  for(i=1; i<=TPC_MAXPADS; i++)
181  {
182  padkr->get(PadRow, i, &ent);
183  if((ent.mz == 0) || (ent.rb == 0)) continue;
184  padlist[PadRow-1][j++] = i;
185  }
186  // confusing syntax but correct
187  *padList = &padlist[PadRow-1][0];
188  return j;
189 }
190 
191 int TPCV1P0_PEDR_SR::getSequences(int PadRow, int Pad, int *nArray,
192  u_char **Array)
193 {
194  PADK_entry ent;
195  padkr->get(PadRow, Pad, &ent);
196  if((ent.mz == 0) || (ent.rb == 0))
197  {
198  *nArray = 0;
199  *Array = NULL;
200  spERROR(ERR_BANK);
201  return -1;
202  }
203 
204  int offset = ent.offset * padkr->getPEDBytes();
205  *nArray = padkr->getPEDBytes();
206 
207  if (banks[ent.rb-1][ent.mz-1] != NULL)
208  {
209  // printf("Offset = %d\n",offset);
210  // printf("array coord: rb=%d, mz=%d\n",ent.rb,ent.mz);
211  *Array = (((u_char *)banks[ent.rb-1][ent.mz-1]->pedestal) + offset);
212  return 1;
213  }
214  return 0;
215 }
216 
217 int TPCV1P0_PEDR_SR::getNumberOfEvents()
218 {
219  return numEvents;
220 }
221 
222 int TPCV1P0_PEDR_SR::MemUsed()
223 {
224  return 0;
225 }
226 
227 
228 //==================== RMS Reader =============================
229 
230 TPCV1P0_PRMS_SR::TPCV1P0_PRMS_SR(int s, TPCV1P0_Reader *det)
231 {
232  // cout << "Constructing TPCV1P0_PRMS_SR" << endl;
233  sector = s-1; // convert the sector into internal representation
234  detector = det;
235 
236  // NULLS in banks array
237  memset((char *)banks, 0, sizeof(banks));
238  numEvents = 0;
239 
240 }
241 
242 int TPCV1P0_PRMS_SR::initialize()
243 {
244  // get a sector reader for PADK
245  padkr = detector->getPADKReader(sector);
246  if (!padkr) return FALSE;
247 
248  // store pointers to the PRMS banks
249  for(int rcb = 0; rcb < 6; rcb++)
250  {
251  for(int mz = 0; mz < 3; mz++)
252  {
253  banks[rcb][mz] = detector->getBankTPCRMSR(sector,rcb,mz);
254  if (banks[rcb][mz] !=NULL)
255  numEvents = banks[rcb][mz]->NumEvents;
256  }
257  }
258  return TRUE;
259 }
260 
261 TPCV1P0_PRMS_SR::~TPCV1P0_PRMS_SR()
262 {
263  // cout << "Deleting TPCV1P0_PRMS_SR" << endl;
264 }
265 
266 int TPCV1P0_PRMS_SR::getPadList(int PadRow, u_char **padList)
267 {
268  // Construct the padlist array for this PadRow
269  int i;
270  PADK_entry ent;
271 
272  // Fill in padrows
273  int j=0;
274  for(i=1; i<=TPC_MAXPADS; i++)
275  {
276  padkr->get(PadRow, i, &ent);
277  if((ent.mz == 0) || (ent.rb == 0)) continue;
278  padlist[PadRow-1][j++] = i;
279  }
280  // confusing syntax but correct
281  *padList = &padlist[PadRow-1][0];
282  return j;
283 }
284 
285 int TPCV1P0_PRMS_SR::getSequences(int PadRow, int Pad, int *nArray,
286  u_char **Array)
287 {
288  PADK_entry ent;
289  padkr->get(PadRow, Pad, &ent);
290  if((ent.mz == 0) || (ent.rb == 0))
291  {
292  *nArray = 0;
293  *Array = NULL;
294  spERROR(ERR_BANK);
295  return -1;
296  }
297 
298  int offset = ent.offset * padkr->getRMSBytes();
299  *nArray = padkr->getRMSBytes();
300 
301  if (banks[ent.rb-1][ent.mz-1] != NULL)
302  {
303 // printf("Offset = %d\n",offset);
304 // printf("array coord: rb=%d, mz=%d\n",ent.rb,ent.mz);
305  *Array = (((u_char *)banks[ent.rb-1][ent.mz-1]->pedRMSt16) + offset);
306  return 1;
307  }
308  return 0;
309 }
310 
311 int TPCV1P0_PRMS_SR::getNumberOfEvents()
312 {
313  return numEvents;
314 }
315 
316 int TPCV1P0_PRMS_SR::MemUsed()
317 {
318  return 0;
319 }
320 
321 
Definition: TPCV1P0.hh:217