StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TPCV2P0.cxx
1 /***************************************************************************
2  * $Id: TPCV2P0.cxx,v 1.11 2007/12/24 06:04:32 fine Exp $
3  * Author: Jeff Landgraf and M.J. LeVine
4  ***************************************************************************
5  * Description: common TPC (V2) implementation stuff
6  *
7  *
8  * change log
9  * 02-Jun-99 MJL fixed test on hypersector arg of getBankTPCSECP
10  * 11-Jun-99 MJL merged PEDR PedRMS readers from RAW version
11  * 23-Jun-99 MJL most output now supressed with EventReader.verbose
12  * 23-Jun-99 MJL can now navigate DATAP even though offset/len to various
13  * lower banks are at arbitrary positions
14  * 09-Jul-99 MJL removed navigation code from TPC_Reader. Introduced
15  * Bank_TPCP argument to TPCV2P0_Reader constructor
16  * 20-Jul-99 MJL add error logging. Add bank type checking for every getBank...()
17  * 27-Jul-99 MJL implement TPCV2P0_Reader::getBankTPCPEDR()
18  * 27-Jul-99 MJL implement TPCV2P0_Reader::getBankTPCRMSR()
19  *
20  ***************************************************************************
21  * $Log: TPCV2P0.cxx,v $
22  * Revision 1.11 2007/12/24 06:04:32 fine
23  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
24  *
25  * Revision 1.10 2004/03/04 21:51:29 ward
26  * Replaced MERGE_SEQUENCES with a StDAQMaker chain parameter, as suggested by Landgraf and Lauret.
27  *
28  * Revision 1.9 2002/10/13 20:43:37 ward
29  * Support for decoding DAQ100 data and writing it into a table.
30  *
31  * Revision 1.8 2000/01/11 22:03:44 levine
32  * convert string to char* via c_str() member
33  * (from Brian Lasiuk)
34  *
35  * Revision 1.7 1999/07/27 23:19:32 levine
36  * implemented methods TPCV2P0_Reader::getBankTPCPEDR()
37  * TPCV2P0_Reader::getBankTPCRMSR()
38  *
39  * Revision 1.6 1999/07/21 21:32:39 levine
40  *
41  *
42  * changes to include error logging to file.
43  *
44  * There are now 2 constructors for EventReader:
45  *
46  * EventReader();
47  * EventReader(const char *logfilename);
48  *
49  * Constructed with no argument, there is no error logging. Supplying a file name
50  * sends all diagnostic output to the named file (N.B. opens in append mode)
51  *
52  * See example in client.cxx for constructing a log file name based on the
53  * datafile name.
54  *
55  * It is strongly advised to use the log file capability. You can grep it for
56  * instances of "ERROR:" to trap anything noteworthy (i.e., corrupted data files).
57  *
58  * Revision 1.5 1999/07/10 21:31:25 levine
59  * Detectors RICH, EMC, TRG now have their own (defined by each detector) interfaces.
60  * Existing user code will not have to change any calls to TPC-like detector
61  * readers.
62  *
63  * Revision 1.4 1999/07/03 04:25:48 levine
64  * changes to get past Linux cyyyYompiler
65  *
66  * Revision 1.3 1999/07/02 04:43:24 levine
67  * Many changes -
68  * navigates to head of TPCP bank independent of position.
69  * move declarations out of loops where they were upsetting some compilers
70  * suppress output from class libraries with run-time switch EventReader.verbose
71  * added TPCV2P0_CPP_SR::getAsicParams()
72  *
73  *
74  **************************************************************************/
75 // TPCV2P0 implementation
76 #include "TPCV2P0.hh"
77 
78 using namespace OLDEVP;
79 
80 TPCV2P0_PADK_SR::TPCV2P0_PADK_SR(int s, TPCV2P0_Reader *det)
81 {
82  sector = s;
83  detector = det;
84 }
85 
86 int TPCV2P0_PADK_SR::initialize()
87 {
88  // cout << "Initializing PADK sector: " << sector << endl;
89 
90  // zero out lookup array
91  memset((char *)packed_address, 0, sizeof(packed_address));
92 
93  // cout << "Sizeof() = " << sizeof(packed_address) << endl;
94 
95  PADK_entry ent;
96 
97  for(int rcb = 0; rcb < 6; rcb++)
98  {
99  for(int mz = 0; mz < 3; mz++)
100  {
101  classname(Bank_TPCPADK) *raw_bank = detector->getBankTPCPADK(sector, rcb, mz);
102  if(raw_bank)
103  {
104  // printf("PADK DATA for sector %d, rcb %d, mz %d\n",sector,rcb,mz);
105  }
106  else
107  {// missing PADK bank
108  // printf("No PADK DATA, sector %d, rcb %d, mz %d\n",sector,rcb,mz);
109  // printf("ERR: %s\n",detector->errstr0);
110  continue;
111  }
112 
113  for(int i=0; i < TPC_MZPADS; i++)
114  {
115  int padrow = raw_bank->index[i].pad_row;
116  int pad = raw_bank->index[i].pad;
117  if((padrow == 0xFF) && (pad == 0xFF)) continue;
118 
119  ent.offset = i;
120  ent.mz = mz+1;
121  ent.rb = rcb+1;
122 
123  place(padrow, pad, &ent);
124  }
125  }
126  }
127 
128  return TRUE;
129 }
130 
131 void TPCV2P0_PADK_SR::place(short padrow, short pad, PADK_entry *p)
132 {
133  padrow--; pad--; // use c standard for array
134  packed_address[padrow][pad] = pack(p->rb, p->mz, p->offset);
135 }
136 
137 void TPCV2P0_PADK_SR::get(short padrow, short pad, PADK_entry *p)
138 {
139  padrow--; pad--; // use c standard for array
140  unpack(p,packed_address[padrow][pad]);
141 }
142 
143 short TPCV2P0_PADK_SR::pack(short rcb, short mz, short offset)
144 {
145  short p = rcb; // 4 bits
146  p = p << 2;
147  p += mz; // 2 bits
148  p = p << 10;
149  p += offset; // 10 bits
150  return p;
151 }
152 
153 void TPCV2P0_PADK_SR::unpack(PADK_entry *entry, short paddress)
154 {
155  entry->offset = paddress & 0x03FF;
156  entry->mz = (paddress & 0x0C00) >> 10;
157  entry->rb = paddress >> 12;
158 }
159 
160 ZeroSuppressedReader *TPCV2P0_Reader::getZeroSuppressedReader(int sector)
161 {
162  char mergeSequences;
163  if(sector>=100) { sector-=100; mergeSequences=1; } else mergeSequences=0;
164  if (ercpy->verbose) cout << "getTPCV2P0_ZS_SR sector(" << sector <<")" << endl;
165 
166  TPCV2P0_ZS_SR *zsp = new TPCV2P0_ZS_SR(sector, this, mergeSequences);
167  if(!zsp->initialize())
168  {
169  if (ercpy->verbose)
170  cout << "ERROR: getTPCV2P0_ZS_SR FAILED sector(" << sector <<")" << endl;
171  delete zsp;
172  zsp = NULL;
173  }
174 
175  return (ZeroSuppressedReader *)zsp;
176 }
177 
178 ADCRawReader *TPCV2P0_Reader::getADCRawReader(int sector)
179 {
180  // cout << "getTPCV2P0_ADCR_SR" << endl;
181  TPCV2P0_ADCR_SR *adc = new TPCV2P0_ADCR_SR(sector, this);
182  if(!adc->initialize())
183  {
184  delete adc;
185  adc = NULL;
186  }
187 
188  return (ADCRawReader *)adc;
189 }
190 
191 PedestalReader *TPCV2P0_Reader::getPedestalReader(int sector)
192 {
193  // cout << "getTPCV2P0_P_SR" << endl;
194  TPCV2P0_PEDR_SR *ped = new TPCV2P0_PEDR_SR(sector, this);
195  if(!ped->initialize())
196  {
197  delete ped;
198  ped = NULL;
199  }
200 
201  return (PedestalReader *)ped;
202 }
203 
204 PedestalRMSReader *TPCV2P0_Reader::getPedestalRMSReader(int sector)
205 {
206  // cout << "getTPCV2P0_PRMS_SR" << endl;
207  TPCV2P0_PRMS_SR *rms = new TPCV2P0_PRMS_SR(sector, this);
208  if(!rms->initialize())
209  {
210  delete rms;
211  rms = NULL;
212  }
213 
214  return (PedestalRMSReader *)rms;
215 }
216 
217 GainReader *TPCV2P0_Reader::getGainReader(int sector)
218 {
219  if (ercpy->verbose) cout << "getTPCV2P0_G_SR" << endl;
220  return NULL;
221 }
222 
223 CPPReader *TPCV2P0_Reader::getCPPReader(int sector)
224 {
225  // cout << "getTPCV2P0_CPP_SR" << endl;
226  TPCV2P0_CPP_SR *cpp = new TPCV2P0_CPP_SR(sector, this);
227  if(!cpp->initialize())
228  {
229  delete cpp;
230  cpp = NULL;
231  }
232 
233  return (CPPReader *)cpp;}
234 
235 BadChannelReader *TPCV2P0_Reader::getBadChannelReader(int sector)
236 {
237  if (ercpy->verbose) cout << "getTPCV2P0_BC_SR" << endl;
238  return NULL;
239 }
240 
241 ConfigReader *TPCV2P0_Reader::getConfigReader(int sector)
242 {
243  if (ercpy->verbose) cout << "getTPCV2P0_CR_SR" << endl;
244  return NULL;
245 }
246 
247 TPCV2P0_PADK_SR *TPCV2P0_Reader::getPADKReader(int sector)
248 {
249  // cout << "GetPADKReader" << endl;
250 
251  TPCV2P0_PADK_SR *p;
252  p = padk[sector];
253  if(p == NULL)
254  {
255  p = new TPCV2P0_PADK_SR(sector, this);
256  if(!p->initialize())
257  {
258  if (ercpy->verbose) cout << "Error Reading PADK banks, sector=" << sector
259  << ": " << errstr().c_str() << endl;
260  delete p;
261  return NULL;
262  }
263  }
264  padk[sector] = p;
265  return p;
266 }
267 
268 TPCV2P0_Reader::TPCV2P0_Reader(EventReader *er, classname(Bank_TPCP) *ptpc)
269 {
270  pBankTPCP = ptpc; // copy pointer into class variable
271  motherPointerBank=pBankTPCP; // Herb Oct 2002 for DAQ100.
272  ercpy = er; // squirrel away pointer eventreader for our friends
273 
274  if (!pBankTPCP->test_CRC()) ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,"TPCP");
275  if (pBankTPCP->swap() < 0) ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,"TPCP");
276  pBankTPCP->header.CRC = 0;
277  // We can have a padk for each of 24 sectors
278  for(int i=0;i<TPC_SECTORS;i++)
279  {
280  padk[i] = NULL;
281  }
282 }
283 
284 TPCV2P0_Reader::~TPCV2P0_Reader()
285 {
286  // cout << "TPCV2P0 destructor" << endl;
287 
288  // Delete Sector Readers buffers (The actual readers are deleted by client)
289 
290  // Delete PADK's
291  for(int i=0;i<TPC_SECTORS;i++)
292  {
293  if(padk[i] != NULL) delete padk[i];
294  }
295 }
296 
297 int TPCV2P0_Reader::MemUsed()
298 {
299  return 0;
300 }
301 
302 // -----------------------------------------------------
303 // Here lie bank retrieval functions
304 // ---- These NAVAGATE to the raw banks
305 // -----------------------------------------------------
306 
307 classname(Bank_TPCSECP) *TPCV2P0_Reader::getBankTPCSECP(int hypersector)
308 {
309  if((hypersector <= 0) || (hypersector >= 24))
310  {
311  ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,"TPCSECP");
312  return NULL;
313  }
314  hypersector--; //convert to internal represenation
315 
316  if((!pBankTPCP->HyperSector[hypersector].offset) ||
317  (!pBankTPCP->HyperSector[hypersector].length))
318  {
319  char str0[40];
320  sprintf(str0,"getBankTPCSECP(hs %d)",hypersector);
321  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
322  return NULL;
323  }
324 
325  classname(Bank_TPCSECP) *ptr = (classname(Bank_TPCSECP) *)
326  (((INT32 *)pBankTPCP) +
327  pBankTPCP->HyperSector[hypersector].offset);
328 
329  if(strncmp(ptr->header.BankType,"TPCSECP",7)) {
330  char str0[40];
331  sprintf(str0,"getBankTPCSECP(hs %d)",hypersector);
332  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0); return NULL;
333  }
334  if(!ptr->test_CRC()) {
335  char str0[40];
336  sprintf(str0,"getBankTPCSECP(hs %d)",hypersector);
337  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
338  }
339  if(ptr->swap() < 0) {
340  char str0[40];
341  sprintf(str0,"getBankTPCSECP(hs %d)",hypersector);
342  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
343  }
344  ptr->header.CRC = 0;
345 
346  return ptr;
347 }
348 
349 classname(Bank_TPCRBP) *TPCV2P0_Reader::getBankTPCRBP(int interleaved_rb,
350  classname(Bank_TPCSECP) *secp)
351 {
352  int sector = secp->header.BankId;
353  if ((interleaved_rb < 0) || (interleaved_rb >= 12))
354  {
355  char str0[40];
356  sprintf(str0,"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
357  ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
358  return NULL;
359  }
360 
361 // printf("getBankTPCRBP RB: %d\n",interleaved_rb);
362 // secp->print();
363 
364  if ((!secp->RcvBoard[interleaved_rb].offset) ||
365  (!secp->RcvBoard[interleaved_rb].length) )
366  {
367  // pERROR(ERR_BANK);
368  return NULL;
369  }
370 
371  classname(Bank_TPCRBP) *ptr = (classname(Bank_TPCRBP) *)
372  (((INT32 *)secp) +
373  secp->RcvBoard[interleaved_rb].offset);
374 
375  if(strncmp(ptr->header.BankType,"TPCRBP",6)) {
376  char str0[40];
377  sprintf(str0,"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
378  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
379  }
380  if(!ptr->test_CRC()) {
381  char str0[40];
382  sprintf(str0,"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
383  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
384  }
385  if(ptr->swap() < 0) {
386  char str0[40];
387  sprintf(str0,"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
388  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
389  }
390  ptr->header.CRC = 0;
391 
392  return ptr;
393 }
394 
395 classname(Bank_TPCMZP) *TPCV2P0_Reader::getBankTPCMZP(int mz, classname(Bank_TPCRBP) *rbp)
396 {
397  int rb = rbp->header.BankId;
398  if ((mz < 0) || (mz >= 3))
399  {
400  char str0[40];
401  sprintf(str0,"getBankTPCMZP(rb %d mz %d )",rb,mz);
402  ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
403  return NULL;
404  }
405 
406  if ((!rbp->Mz[mz].offset) || (!rbp->Mz[mz].length))
407  {
408  char str0[40];
409  sprintf(str0,"getBankTPCMZP(rb %d mz %d )",rb,mz);
410  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
411  return NULL;
412  }
413 
414  classname(Bank_TPCMZP) *ptr = (classname(Bank_TPCMZP) *)
415  (((INT32 *)rbp) +
416  rbp->Mz[mz].offset);
417 
418  if(strncmp(ptr->header.BankType,"TPCMZP",6)) {
419  char str0[40];
420  sprintf(str0,"getBankTPCMZP(rb %d mz %d )",rb,mz);
421  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
422  }
423  if(!ptr->test_CRC()) {
424  char str0[40];
425  sprintf(str0,"getBankTPCMZP(rb %d mz %d )",rb,mz);
426  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
427  }
428  if(ptr->swap() < 0) {
429  char str0[40];
430  sprintf(str0,"getBankTPCMZP(rb %d mz %d )",rb,mz);
431  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
432  }
433  ptr->header.CRC = 0;
434 
435 // printf("getBankTPCMZP Mezz: %d\n",mz);
436 // ptr->print();
437 
438  return ptr;
439 }
440 
441 classname(Bank_TPCMZP) *TPCV2P0_Reader::getBankTPCMZP(int sector, int rb, int mz)
442 {
443  if ((sector < 0) || (sector >= TPC_SECTORS))
444  {
445  char str0[40];
446  sprintf(str0,"getBankTPCMZP(sec %d, rb %d, mz %d )",sector,rb,mz);
447  ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
448  return NULL;
449  }
450  if ((rb < 0) || (rb >= 6))
451  {
452  char str0[40];
453  sprintf(str0,"getBankTPCMZP(sec %d, rb %d, mz %d )",sector,rb,mz);
454  ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
455  return NULL;
456  }
457  if ((mz < 0) || (mz >= 3))
458  {
459  char str0[40];
460  sprintf(str0,"getBankTPCMZP(sec %d, rb %d, mz %d )",sector,rb,mz);
461  ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
462  return NULL;
463  }
464 
465  classname(Bank_TPCSECP) *secp = getBankTPCSECP(2*(sector/2)+1);
466  // use odd slots 1,...,23
467  if(!secp) return NULL;
468 
469  classname(Bank_TPCRBP) *rbp;
470  if (sector%2) // internal sector odd->sector even->7..12
471  {
472  rbp = getBankTPCRBP(rb + 6, secp);
473  }
474  else // internal sector even->sector odd->1..6
475  {
476  rbp = getBankTPCRBP(rb, secp);
477  }
478  if(!rbp) return NULL;
479 
480  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(mz,rbp);
481  return mzp;
482 }
483 
484 classname(Bank_TPCADCD) *TPCV2P0_Reader::getBankTPCADCD(int sector, int rb, int mz)
485 {
486  errnum = 0;
487  errstr0[0] = '\0';
488 
489  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
490  if(!mzp) return NULL;
491 
492 // printf(" sector: %d RB: %d MZ: %d\n", sector, rb, mz);
493 // mzp->print();
494 
495  if((!mzp->TPCADCD.offset) || (!mzp->TPCADCD.length))
496  {
497  char str0[40];
498  sprintf(str0,"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
499  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
500  return NULL;
501  }
502 
503  classname(Bank_TPCADCD) *ptr = (classname(Bank_TPCADCD) *)
504  (((INT32 *)mzp) +
505  mzp->TPCADCD.offset);
506 
507  if(strncmp(ptr->header.BankType,"TPCADCD",7)) {
508  char str0[40];
509  sprintf(str0,"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
510  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
511  }
512  if(!ptr->test_CRC()) {
513  char str0[40];
514  sprintf(str0,"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
515  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
516  }
517  if(ptr->swap() < 0) {
518  char str0[40];
519  sprintf(str0,"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
520  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
521  }
522  ptr->header.CRC = 0;
523 
524  return ptr;
525 }
526 
527 classname(Bank_TPCSEQD) *TPCV2P0_Reader::getBankTPCSEQD(int sector, int rb, int mz)
528 {
529  errnum = 0;
530  errstr0[0] = '\0';
531 
532  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
533  if(!mzp) return NULL;
534 
535 // printf(" sector: %d RB: %d MZ: %d\n", sector, rb, mz);
536 // mzp->print();
537 
538  if((!mzp->TPCSEQD.offset) || (!mzp->TPCSEQD.length))
539  {
540  char str0[40];
541  sprintf(str0,"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
542  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
543  return NULL;
544  }
545 
546  classname(Bank_TPCSEQD) *ptr = (classname(Bank_TPCSEQD) *)
547  (((INT32 *)mzp) +
548  mzp->TPCSEQD.offset);
549 
550  if(strncmp(ptr->header.BankType,"TPCSEQD",7)) {
551  char str0[40];
552  sprintf(str0,"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
553  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
554  }
555  if(!ptr->test_CRC()) {
556  char str0[40];
557  sprintf(str0,"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
558  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
559  }
560  if(ptr->swap() < 0) {
561  char str0[40];
562  sprintf(str0,"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
563  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
564  }
565  ptr->header.CRC = 0;
566 
567  return ptr;}
568 
569 classname(Bank_TPCADCX) *TPCV2P0_Reader::getBankTPCADCX(int sector, int rb, int mz)
570 {
571  errnum = 0;
572  errstr0[0] = '\0';
573 
574  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
575  if(!mzp) return NULL;
576 
577 // printf(" sector: %d RB: %d MZ: %d\n", sector, rb, mz);
578 // mzp->print();
579 
580  if((!mzp->TPCADCX.offset) || (!mzp->TPCADCX.length))
581  {
582  char str0[40];
583  sprintf(str0,"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
584  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
585  return NULL;
586  }
587 
588  classname(Bank_TPCADCX) *ptr = (classname(Bank_TPCADCX) *)
589  (((INT32 *)mzp) +
590  mzp->TPCADCX.offset);
591 
592  if(strncmp(ptr->header.BankType,"TPCADCX",7)) {
593  char str0[40];
594  sprintf(str0,"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
595  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
596  }
597  if(!ptr->test_CRC()) {
598  char str0[40];
599  sprintf(str0,"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
600  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
601  }
602  if(ptr->swap() < 0) {
603  char str0[40];
604  sprintf(str0,"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
605  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
606  }
607  ptr->header.CRC = 0;
608 
609  return ptr;}
610 
611 classname(Bank_TPCPADK) *TPCV2P0_Reader::getBankTPCPADK(int sector, int rb, int mz)
612 {
613  errnum = 0;
614  errstr0[0] = '\0';
615 
616  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
617  if(!mzp) return NULL;
618 
619 // printf(" sector: %d RB: %d MZ: %d\n", sector, rb, mz);
620 // mzp->print();
621 
622  if((!mzp->TPCPADK.offset) || (!mzp->TPCPADK.length))
623  {
624  char str0[40];
625  sprintf(str0,"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
626  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
627  return NULL;
628  }
629 
630  classname(Bank_TPCPADK) *ptr = (classname(Bank_TPCPADK) *)
631  (((INT32 *)mzp) +
632  mzp->TPCPADK.offset);
633 
634  if(strncmp(ptr->header.BankType,"TPCPADK",7)) {
635  char str0[40];
636  sprintf(str0,"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
637  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
638  }
639  if(!ptr->test_CRC()) {
640  char str0[40];
641  sprintf(str0,"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
642  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
643  }
644  if(ptr->swap() < 0) {
645  char str0[40];
646  sprintf(str0,"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
647  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
648  }
649  ptr->header.CRC = 0;
650 
651  return ptr;
652 };
653 
654 classname(Bank_TPCCPPR) *TPCV2P0_Reader::getBankTPCCPPR(int sector, int rb, int mz)
655 {
656  errnum = 0;
657  errstr0[0] = '\0';
658 
659  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
660  if(!mzp) return NULL;
661 
662  if((!mzp->TPCCPPR.offset) || (!mzp->TPCCPPR.length))
663  {
664  char str0[40];
665  sprintf(str0,"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
666  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
667  return NULL;
668  }
669 
670  classname(Bank_TPCCPPR) *ptr = (classname(Bank_TPCCPPR) *)
671  (((INT32 *)mzp) +
672  mzp->TPCCPPR.offset);
673 
674  if(strncmp(ptr->header.BankType,"TPCCPPR",7)) {
675  char str0[40];
676  sprintf(str0,"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
677  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
678  }
679  if(!ptr->test_CRC()) {
680  char str0[40];
681  sprintf(str0,"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
682  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
683  }
684  if(ptr->swap() < 0) {
685  char str0[40];
686  sprintf(str0,"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
687  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
688  }
689  ptr->header.CRC = 0;
690 
691  return ptr;
692 }
693 
694 classname(Bank_TPCADCR) *TPCV2P0_Reader::getBankTPCADCR(int sector, int rb, int mz)
695 {
696  errnum = 0;
697  errstr0[0] = '\0';
698 
699  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
700  if(!mzp) return NULL;
701 
702  if((!mzp->TPCADCR.offset) || (!mzp->TPCADCR.length))
703  {
704  char str0[40];
705  sprintf(str0,"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
706  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
707  return NULL;
708  }
709 
710  classname(Bank_TPCADCR) *ptr = (classname(Bank_TPCADCR) *)
711  (((INT32 *)mzp) +
712  mzp->TPCADCR.offset);
713 
714  if(strncmp(ptr->header.BankType,"TPCADCR",7)) {
715  char str0[40];
716  sprintf(str0,"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
717  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
718  }
719  if(!ptr->test_CRC()) {
720  char str0[40];
721  sprintf(str0,"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
722  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
723  }
724  if(ptr->swap() < 0) {
725  char str0[40];
726  sprintf(str0,"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
727  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
728  }
729  ptr->header.CRC = 0;
730 
731  return ptr;
732 }
733 
734 classname(Bank_TPCMZCLD) *TPCV2P0_Reader::getBankTPCMZCLD(int sector, int rb, int mz)
735 {
736  errnum = 0;
737  errstr0[0] = '\0';
738 
739  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
740  if(!mzp) return NULL;
741 
742  if((!mzp->TPCMZCLD.offset) || (!mzp->TPCMZCLD.length))
743  {
744  char str0[40];
745  sprintf(str0,"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
746  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
747  return NULL;
748  }
749 
750  classname(Bank_TPCMZCLD) *ptr = (classname(Bank_TPCMZCLD) *)
751  (((INT32 *)mzp) +
752  mzp->TPCMZCLD.offset);
753 
754  if(strncmp(ptr->header.BankType,"TPCMZCLD",8)) {
755  char str0[40];
756  sprintf(str0,"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
757  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
758  }
759  if(!ptr->test_CRC()) {
760  char str0[40];
761  sprintf(str0,"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
762  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
763  }
764  if(ptr->swap() < 0) {
765  char str0[40];
766  sprintf(str0,"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
767  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
768  }
769  ptr->header.CRC = 0;
770 
771  return ptr;
772 }
773 
774 
775 classname(Bank_TPCCFGR) *TPCV2P0_Reader::getBankTPCCFGR(int sector, int rb, int mz)
776 {
777  return NULL;
778 }
779 
780 classname(Bank_TPCPEDR) *TPCV2P0_Reader::getBankTPCPEDR(int sector, int rb, int mz)
781 {
782  errnum = 0;
783  errstr0[0] = '\0';
784 
785  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
786  if(!mzp) return NULL;
787 
788  if((!mzp->TPCPEDR.offset) || (!mzp->TPCPEDR.length))
789  {
790  char str0[40];
791  sprintf(str0,"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
792  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
793  return NULL;
794  }
795 
796  classname(Bank_TPCPEDR) *ptr = (classname(Bank_TPCPEDR) *)
797  (((INT32 *)mzp) +
798  mzp->TPCPEDR.offset);
799 
800  if(strncmp(ptr->header.BankType,"TPCPEDR",7)) {
801  char str0[40];
802  sprintf(str0,"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
803  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
804  }
805  if(!ptr->test_CRC()) {
806  char str0[40];
807  sprintf(str0,"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
808  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
809  }
810  if(ptr->swap() < 0) {
811  char str0[40];
812  sprintf(str0,"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
813  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
814  }
815  ptr->header.CRC = 0;
816 
817  return ptr;
818 }
819 
820 
821 classname(Bank_TPCRMSR) *TPCV2P0_Reader::getBankTPCRMSR(int sector, int rb, int mz)
822 {
823  errnum = 0;
824  errstr0[0] = '\0';
825 
826  classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
827  if(!mzp) return NULL;
828 
829  if((!mzp->TPCRMSR.offset) || (!mzp->TPCRMSR.length))
830  {
831  char str0[40];
832  sprintf(str0,"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
833  ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
834  return NULL;
835  }
836 
837  classname(Bank_TPCRMSR) *ptr = (classname(Bank_TPCRMSR) *)
838  (((INT32 *)mzp) +
839  mzp->TPCRMSR.offset);
840 
841  if(strncmp(ptr->header.BankType,"TPCRMSR",7)) {
842  char str0[40];
843  sprintf(str0,"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
844  ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0); return NULL;
845  }
846  if(!ptr->test_CRC()) {
847  char str0[40];
848  sprintf(str0,"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
849  ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0); return NULL;
850  }
851  if(ptr->swap() < 0) {
852  char str0[40];
853  sprintf(str0,"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
854  ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0); return NULL;
855  }
856  ptr->header.CRC = 0;
857 
858  return ptr;
859 }
860 
861 classname(Bank_TPCGAINR) *TPCV2P0_Reader::getBankTPCGAINR(int sector, int rb, int mz)
862 {
863  return NULL;
864 }
865 
866 classname(Bank_TPCBADR) *TPCV2P0_Reader::getBankTPCBADR(int sector, int rb, int mz)
867 {
868  return NULL;
869 }
870 
Definition: rb.hh:21
Definition: TPCV1P0.hh:217