37 using namespace OLDEVP;
46 int TPCV1P0_PADK_SR::initialize()
51 memset((
char *)packed_address, 0,
sizeof(packed_address));
57 for(
int rcb = 0; rcb < 6; rcb++)
59 for(
int mz = 0; mz < 3; mz++)
61 classname(Bank_TPCPADK) *raw_bank = detector->getBankTPCPADK(sector, rcb, mz);
73 for(
int i=0; i < TPC_MZPADS; i++)
75 int padrow = raw_bank->index[i].pad_row;
76 int pad = raw_bank->index[i].pad;
77 if((padrow == 0xFF) && (pad == 0xFF))
continue;
83 place(padrow, pad, &ent);
91 void TPCV1P0_PADK_SR::place(
short padrow,
short pad,
PADK_entry *p)
94 packed_address[padrow][pad] = pack(p->rb, p->mz, p->offset);
97 void TPCV1P0_PADK_SR::get(
short padrow,
short pad,
PADK_entry *p)
100 unpack(p,packed_address[padrow][pad]);
103 short TPCV1P0_PADK_SR::pack(
short rcb,
short mz,
short offset)
113 void TPCV1P0_PADK_SR::unpack(
PADK_entry *entry,
short paddress)
115 entry->offset = paddress & 0x03FF;
116 entry->mz = (paddress & 0x0C00) >> 10;
117 entry->rb = paddress >> 12;
122 cout <<
"getTPCV1P0_ZS_SR sector(" << sector <<
")" << endl;
125 if(!zsp->initialize())
127 cout <<
"ERROR: getTPCV1P0_ZS_SR FAILED sector(" << sector <<
")" << endl;
135 ADCRawReader *TPCV1P0_Reader::getADCRawReader(
int sector)
139 if(!adc->initialize())
152 if(!ped->initialize())
165 if(!rms->initialize())
174 GainReader *TPCV1P0_Reader::getGainReader(
int sector)
176 cout <<
"getTPCV1P0_G_SR" << endl;
180 CPPReader *TPCV1P0_Reader::getCPPReader(
int sector)
184 if(!cpp->initialize())
194 cout <<
"getTPCV1P0_BC_SR" << endl;
198 ConfigReader *TPCV1P0_Reader::getConfigReader(
int sector)
200 cout <<
"getTPCV1P0_CR_SR" << endl;
215 cout <<
"Error Reading PADK banks, sector=" << sector
216 <<
": " << errstr().c_str() << endl;
225 TPCV1P0_Reader::TPCV1P0_Reader(
EventReader *er, classname(Bank_TPCP) *ptpc)
229 if (!pBankTPCP->test_CRC()) ERROR(ERR_CRC);
230 if (pBankTPCP->swap() < 0) ERROR(ERR_SWAP);
231 pBankTPCP->header.CRC = 0;
234 for(
int i=0;i<TPC_SECTORS;i++)
240 TPCV1P0_Reader::~TPCV1P0_Reader()
247 for(
int i=0;i<TPC_SECTORS;i++)
249 if(padk[i] != NULL)
delete padk[i];
253 int TPCV1P0_Reader::MemUsed()
263 classname(Bank_TPCSECP) *TPCV1P0_Reader::getBankTPCSECP(
int hypersector)
265 if((hypersector <= 0) || (hypersector >= 24))
272 if((!pBankTPCP->HyperSector[hypersector].offset) ||
273 (!pBankTPCP->HyperSector[hypersector].length))
279 classname(Bank_TPCSECP) *ptr = (classname(Bank_TPCSECP) *)
280 (((INT32 *)pBankTPCP) +
281 pBankTPCP->HyperSector[hypersector].offset);
283 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
284 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
290 classname(Bank_TPCRBP) *TPCV1P0_Reader::getBankTPCRBP(
int interleaved_rb,
291 classname(Bank_TPCSECP) *secp)
293 if ((interleaved_rb < 0) || (interleaved_rb >= 12))
302 if ((!secp->RcvBoard[interleaved_rb].offset) ||
303 (!secp->RcvBoard[interleaved_rb].length) )
309 classname(Bank_TPCRBP) *ptr = (classname(Bank_TPCRBP) *)
311 secp->RcvBoard[interleaved_rb].offset);
313 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
314 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
320 classname(Bank_TPCMZP) *TPCV1P0_Reader::getBankTPCMZP(
int mz, classname(Bank_TPCRBP) *rbp)
322 if ((mz < 0) || (mz >= 3))
328 if ((!rbp->Mz[mz].offset) || (!rbp->Mz[mz].length))
334 classname(Bank_TPCMZP) *ptr = (classname(Bank_TPCMZP) *)
338 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
339 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
348 classname(Bank_TPCMZP) *TPCV1P0_Reader::getBankTPCMZP(
int sector,
int rb,
int mz)
350 if ((sector < 0) || (sector >= TPC_SECTORS))
355 if ((rb < 0) || (rb >= 6))
360 if ((mz < 0) || (mz >= 3))
366 classname(Bank_TPCSECP) *secp = getBankTPCSECP(2*(sector/2)+1);
368 if(!secp)
return NULL;
370 classname(Bank_TPCRBP) *rbp;
373 rbp = getBankTPCRBP(rb + 6, secp);
377 rbp = getBankTPCRBP(rb, secp);
379 if(!rbp)
return NULL;
381 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(mz,rbp);
385 classname(Bank_TPCADCD) *TPCV1P0_Reader::getBankTPCADCD(
int sector,
int rb,
int mz)
390 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
391 if(!mzp)
return NULL;
396 if((!mzp->TPCADCD.offset) || (!mzp->TPCADCD.length))
402 classname(Bank_TPCADCD) *ptr = (classname(Bank_TPCADCD) *)
404 mzp->TPCADCD.offset);
406 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
407 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
413 classname(Bank_TPCSEQD) *TPCV1P0_Reader::getBankTPCSEQD(
int sector,
int rb,
int mz)
418 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
419 if(!mzp)
return NULL;
424 if((!mzp->TPCSEQD.offset) || (!mzp->TPCSEQD.length))
430 classname(Bank_TPCSEQD) *ptr = (classname(Bank_TPCSEQD) *)
432 mzp->TPCSEQD.offset);
434 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
435 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
440 classname(Bank_TPCADCX) *TPCV1P0_Reader::getBankTPCADCX(
int sector,
int rb,
int mz)
445 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
446 if(!mzp)
return NULL;
451 if((!mzp->TPCADCX.offset) || (!mzp->TPCADCX.length))
457 classname(Bank_TPCADCX) *ptr = (classname(Bank_TPCADCX) *)
459 mzp->TPCADCX.offset);
461 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
462 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
467 classname(Bank_TPCPADK) *TPCV1P0_Reader::getBankTPCPADK(
int sector,
int rb,
int mz)
472 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
473 if(!mzp)
return NULL;
478 if((!mzp->TPCPADK.offset) || (!mzp->TPCPADK.length))
484 classname(Bank_TPCPADK) *ptr = (classname(Bank_TPCPADK) *)
486 mzp->TPCPADK.offset);
488 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
489 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
495 classname(Bank_TPCCPPR) *TPCV1P0_Reader::getBankTPCCPPR(
int sector,
int rb,
int mz)
500 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
501 if(!mzp)
return NULL;
503 if((!mzp->TPCCPPR.offset) || (!mzp->TPCCPPR.length))
509 classname(Bank_TPCCPPR) *ptr = (classname(Bank_TPCCPPR) *)
511 mzp->TPCCPPR.offset);
513 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
514 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
520 classname(Bank_TPCADCR) *TPCV1P0_Reader::getBankTPCADCR(
int sector,
int rb,
int mz)
525 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
526 if(!mzp)
return NULL;
528 if((!mzp->TPCADCR.offset) || (!mzp->TPCADCR.length))
534 classname(Bank_TPCADCR) *ptr = (classname(Bank_TPCADCR) *)
536 mzp->TPCADCR.offset);
538 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
539 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
545 classname(Bank_TPCCFGR) *TPCV1P0_Reader::getBankTPCCFGR(
int sector,
int rb,
int mz)
550 classname(Bank_TPCPEDR) *TPCV1P0_Reader::getBankTPCPEDR(
int sector,
int rb,
int mz)
556 classname(Bank_TPCRMSR) *TPCV1P0_Reader::getBankTPCRMSR(
int sector,
int rb,
int mz)
561 classname(Bank_TPCGAINR) *TPCV1P0_Reader::getBankTPCGAINR(
int sector,
int rb,
int mz)
566 classname(Bank_TPCBADR) *TPCV1P0_Reader::getBankTPCBADR(
int sector,
int rb,
int mz)