78 using namespace OLDEVP;
86 int TPCV2P0_PADK_SR::initialize()
91 memset((
char *)packed_address, 0,
sizeof(packed_address));
97 for(
int rcb = 0; rcb < 6; rcb++)
99 for(
int mz = 0; mz < 3; mz++)
101 classname(Bank_TPCPADK) *raw_bank = detector->getBankTPCPADK(sector, rcb, mz);
113 for(
int i=0; i < TPC_MZPADS; i++)
115 int padrow = raw_bank->index[i].pad_row;
116 int pad = raw_bank->index[i].pad;
117 if((padrow == 0xFF) && (pad == 0xFF))
continue;
123 place(padrow, pad, &ent);
131 void TPCV2P0_PADK_SR::place(
short padrow,
short pad,
PADK_entry *p)
134 packed_address[padrow][pad] = pack(p->rb, p->mz, p->offset);
137 void TPCV2P0_PADK_SR::get(
short padrow,
short pad,
PADK_entry *p)
140 unpack(p,packed_address[padrow][pad]);
143 short TPCV2P0_PADK_SR::pack(
short rcb,
short mz,
short offset)
153 void TPCV2P0_PADK_SR::unpack(
PADK_entry *entry,
short paddress)
155 entry->offset = paddress & 0x03FF;
156 entry->mz = (paddress & 0x0C00) >> 10;
157 entry->rb = paddress >> 12;
163 if(sector>=100) { sector-=100; mergeSequences=1; }
else mergeSequences=0;
164 if (ercpy->verbose) cout <<
"getTPCV2P0_ZS_SR sector(" << sector <<
")" << endl;
167 if(!zsp->initialize())
170 cout <<
"ERROR: getTPCV2P0_ZS_SR FAILED sector(" << sector <<
")" << endl;
178 ADCRawReader *TPCV2P0_Reader::getADCRawReader(
int sector)
182 if(!adc->initialize())
195 if(!ped->initialize())
208 if(!rms->initialize())
217 GainReader *TPCV2P0_Reader::getGainReader(
int sector)
219 if (ercpy->verbose) cout <<
"getTPCV2P0_G_SR" << endl;
223 CPPReader *TPCV2P0_Reader::getCPPReader(
int sector)
227 if(!cpp->initialize())
237 if (ercpy->verbose) cout <<
"getTPCV2P0_BC_SR" << endl;
241 ConfigReader *TPCV2P0_Reader::getConfigReader(
int sector)
243 if (ercpy->verbose) cout <<
"getTPCV2P0_CR_SR" << endl;
258 if (ercpy->verbose) cout <<
"Error Reading PADK banks, sector=" << sector
259 <<
": " << errstr().c_str() << endl;
268 TPCV2P0_Reader::TPCV2P0_Reader(
EventReader *er, classname(Bank_TPCP) *ptpc)
271 motherPointerBank=pBankTPCP;
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;
278 for(
int i=0;i<TPC_SECTORS;i++)
284 TPCV2P0_Reader::~TPCV2P0_Reader()
291 for(
int i=0;i<TPC_SECTORS;i++)
293 if(padk[i] != NULL)
delete padk[i];
297 int TPCV2P0_Reader::MemUsed()
307 classname(Bank_TPCSECP) *TPCV2P0_Reader::getBankTPCSECP(
int hypersector)
309 if((hypersector <= 0) || (hypersector >= 24))
311 ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,
"TPCSECP");
316 if((!pBankTPCP->HyperSector[hypersector].offset) ||
317 (!pBankTPCP->HyperSector[hypersector].length))
320 sprintf(str0,
"getBankTPCSECP(hs %d)",hypersector);
321 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
325 classname(Bank_TPCSECP) *ptr = (classname(Bank_TPCSECP) *)
326 (((INT32 *)pBankTPCP) +
327 pBankTPCP->HyperSector[hypersector].offset);
329 if(strncmp(ptr->header.BankType,
"TPCSECP",7)) {
331 sprintf(str0,
"getBankTPCSECP(hs %d)",hypersector);
332 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0);
return NULL;
334 if(!ptr->test_CRC()) {
336 sprintf(str0,
"getBankTPCSECP(hs %d)",hypersector);
337 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
339 if(ptr->swap() < 0) {
341 sprintf(str0,
"getBankTPCSECP(hs %d)",hypersector);
342 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
349 classname(Bank_TPCRBP) *TPCV2P0_Reader::getBankTPCRBP(
int interleaved_rb,
350 classname(Bank_TPCSECP) *secp)
352 int sector = secp->header.BankId;
353 if ((interleaved_rb < 0) || (interleaved_rb >= 12))
356 sprintf(str0,
"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
357 ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
364 if ((!secp->RcvBoard[interleaved_rb].offset) ||
365 (!secp->RcvBoard[interleaved_rb].length) )
371 classname(Bank_TPCRBP) *ptr = (classname(Bank_TPCRBP) *)
373 secp->RcvBoard[interleaved_rb].offset);
375 if(strncmp(ptr->header.BankType,
"TPCRBP",6)) {
377 sprintf(str0,
"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
378 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
380 if(!ptr->test_CRC()) {
382 sprintf(str0,
"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
383 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
385 if(ptr->swap() < 0) {
387 sprintf(str0,
"getBankTPCRBP(sec %d rb %d )",sector,interleaved_rb);
388 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
395 classname(Bank_TPCMZP) *TPCV2P0_Reader::getBankTPCMZP(
int mz, classname(Bank_TPCRBP) *rbp)
397 int rb = rbp->header.BankId;
398 if ((mz < 0) || (mz >= 3))
401 sprintf(str0,
"getBankTPCMZP(rb %d mz %d )",rb,mz);
402 ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
406 if ((!rbp->Mz[mz].offset) || (!rbp->Mz[mz].length))
409 sprintf(str0,
"getBankTPCMZP(rb %d mz %d )",rb,mz);
410 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
414 classname(Bank_TPCMZP) *ptr = (classname(Bank_TPCMZP) *)
418 if(strncmp(ptr->header.BankType,
"TPCMZP",6)) {
420 sprintf(str0,
"getBankTPCMZP(rb %d mz %d )",rb,mz);
421 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
423 if(!ptr->test_CRC()) {
425 sprintf(str0,
"getBankTPCMZP(rb %d mz %d )",rb,mz);
426 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
428 if(ptr->swap() < 0) {
430 sprintf(str0,
"getBankTPCMZP(rb %d mz %d )",rb,mz);
431 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
441 classname(Bank_TPCMZP) *TPCV2P0_Reader::getBankTPCMZP(
int sector,
int rb,
int mz)
443 if ((sector < 0) || (sector >= TPC_SECTORS))
446 sprintf(str0,
"getBankTPCMZP(sec %d, rb %d, mz %d )",sector,rb,mz);
447 ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
450 if ((rb < 0) || (rb >= 6))
453 sprintf(str0,
"getBankTPCMZP(sec %d, rb %d, mz %d )",sector,rb,mz);
454 ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
457 if ((mz < 0) || (mz >= 3))
460 sprintf(str0,
"getBankTPCMZP(sec %d, rb %d, mz %d )",sector,rb,mz);
461 ercpy->fprintError(ERR_BAD_ARG,__FILE__,__LINE__,str0);
465 classname(Bank_TPCSECP) *secp = getBankTPCSECP(2*(sector/2)+1);
467 if(!secp)
return NULL;
469 classname(Bank_TPCRBP) *rbp;
472 rbp = getBankTPCRBP(rb + 6, secp);
476 rbp = getBankTPCRBP(rb, secp);
478 if(!rbp)
return NULL;
480 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(mz,rbp);
484 classname(Bank_TPCADCD) *TPCV2P0_Reader::getBankTPCADCD(
int sector,
int rb,
int mz)
489 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
490 if(!mzp)
return NULL;
495 if((!mzp->TPCADCD.offset) || (!mzp->TPCADCD.length))
498 sprintf(str0,
"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
499 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
503 classname(Bank_TPCADCD) *ptr = (classname(Bank_TPCADCD) *)
505 mzp->TPCADCD.offset);
507 if(strncmp(ptr->header.BankType,
"TPCADCD",7)) {
509 sprintf(str0,
"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
510 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
512 if(!ptr->test_CRC()) {
514 sprintf(str0,
"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
515 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
517 if(ptr->swap() < 0) {
519 sprintf(str0,
"getBankTPCADCD(sec %d rb %d mz %d )",sector,rb,mz);
520 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
527 classname(Bank_TPCSEQD) *TPCV2P0_Reader::getBankTPCSEQD(
int sector,
int rb,
int mz)
532 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
533 if(!mzp)
return NULL;
538 if((!mzp->TPCSEQD.offset) || (!mzp->TPCSEQD.length))
541 sprintf(str0,
"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
542 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
546 classname(Bank_TPCSEQD) *ptr = (classname(Bank_TPCSEQD) *)
548 mzp->TPCSEQD.offset);
550 if(strncmp(ptr->header.BankType,
"TPCSEQD",7)) {
552 sprintf(str0,
"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
553 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
555 if(!ptr->test_CRC()) {
557 sprintf(str0,
"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
558 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
560 if(ptr->swap() < 0) {
562 sprintf(str0,
"getBankTPCSEQD(sec %d rb %d mz %d )",sector,rb,mz);
563 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
569 classname(Bank_TPCADCX) *TPCV2P0_Reader::getBankTPCADCX(
int sector,
int rb,
int mz)
574 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
575 if(!mzp)
return NULL;
580 if((!mzp->TPCADCX.offset) || (!mzp->TPCADCX.length))
583 sprintf(str0,
"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
584 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
588 classname(Bank_TPCADCX) *ptr = (classname(Bank_TPCADCX) *)
590 mzp->TPCADCX.offset);
592 if(strncmp(ptr->header.BankType,
"TPCADCX",7)) {
594 sprintf(str0,
"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
595 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
597 if(!ptr->test_CRC()) {
599 sprintf(str0,
"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
600 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
602 if(ptr->swap() < 0) {
604 sprintf(str0,
"getBankTPCADCX(sec %d rb %d mz %d )",sector,rb,mz);
605 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
611 classname(Bank_TPCPADK) *TPCV2P0_Reader::getBankTPCPADK(
int sector,
int rb,
int mz)
616 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
617 if(!mzp)
return NULL;
622 if((!mzp->TPCPADK.offset) || (!mzp->TPCPADK.length))
625 sprintf(str0,
"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
626 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
630 classname(Bank_TPCPADK) *ptr = (classname(Bank_TPCPADK) *)
632 mzp->TPCPADK.offset);
634 if(strncmp(ptr->header.BankType,
"TPCPADK",7)) {
636 sprintf(str0,
"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
637 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
639 if(!ptr->test_CRC()) {
641 sprintf(str0,
"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
642 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
644 if(ptr->swap() < 0) {
646 sprintf(str0,
"getBankTPCPADK(sec %d rb %d mz %d )",sector,rb,mz);
647 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
654 classname(Bank_TPCCPPR) *TPCV2P0_Reader::getBankTPCCPPR(
int sector,
int rb,
int mz)
659 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
660 if(!mzp)
return NULL;
662 if((!mzp->TPCCPPR.offset) || (!mzp->TPCCPPR.length))
665 sprintf(str0,
"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
666 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
670 classname(Bank_TPCCPPR) *ptr = (classname(Bank_TPCCPPR) *)
672 mzp->TPCCPPR.offset);
674 if(strncmp(ptr->header.BankType,
"TPCCPPR",7)) {
676 sprintf(str0,
"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
677 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
679 if(!ptr->test_CRC()) {
681 sprintf(str0,
"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
682 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
684 if(ptr->swap() < 0) {
686 sprintf(str0,
"getBankTPCCPPR(sec %d rb %d mz %d )",sector,rb,mz);
687 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
694 classname(Bank_TPCADCR) *TPCV2P0_Reader::getBankTPCADCR(
int sector,
int rb,
int mz)
699 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
700 if(!mzp)
return NULL;
702 if((!mzp->TPCADCR.offset) || (!mzp->TPCADCR.length))
705 sprintf(str0,
"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
706 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
710 classname(Bank_TPCADCR) *ptr = (classname(Bank_TPCADCR) *)
712 mzp->TPCADCR.offset);
714 if(strncmp(ptr->header.BankType,
"TPCADCR",7)) {
716 sprintf(str0,
"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
717 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
719 if(!ptr->test_CRC()) {
721 sprintf(str0,
"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
722 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
724 if(ptr->swap() < 0) {
726 sprintf(str0,
"getBankTPCADCR(sec %d rb %d mz %d )",sector,rb,mz);
727 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
734 classname(
Bank_TPCMZCLD) *TPCV2P0_Reader::getBankTPCMZCLD(
int sector,
int rb,
int mz)
739 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
740 if(!mzp)
return NULL;
742 if((!mzp->TPCMZCLD.offset) || (!mzp->TPCMZCLD.length))
745 sprintf(str0,
"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
746 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
752 mzp->TPCMZCLD.offset);
754 if(strncmp(ptr->header.BankType,
"TPCMZCLD",8)) {
756 sprintf(str0,
"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
757 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
759 if(!ptr->test_CRC()) {
761 sprintf(str0,
"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
762 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
764 if(ptr->swap() < 0) {
766 sprintf(str0,
"getBankTPCMZCLD(sec %d rb %d mz %d )",sector,rb,mz);
767 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
775 classname(Bank_TPCCFGR) *TPCV2P0_Reader::getBankTPCCFGR(
int sector,
int rb,
int mz)
780 classname(Bank_TPCPEDR) *TPCV2P0_Reader::getBankTPCPEDR(
int sector,
int rb,
int mz)
785 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
786 if(!mzp)
return NULL;
788 if((!mzp->TPCPEDR.offset) || (!mzp->TPCPEDR.length))
791 sprintf(str0,
"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
792 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
796 classname(Bank_TPCPEDR) *ptr = (classname(Bank_TPCPEDR) *)
798 mzp->TPCPEDR.offset);
800 if(strncmp(ptr->header.BankType,
"TPCPEDR",7)) {
802 sprintf(str0,
"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
803 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
805 if(!ptr->test_CRC()) {
807 sprintf(str0,
"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
808 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
810 if(ptr->swap() < 0) {
812 sprintf(str0,
"getBankTPCPEDR(sec %d rb %d mz %d )",sector,rb,mz);
813 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
821 classname(Bank_TPCRMSR) *TPCV2P0_Reader::getBankTPCRMSR(
int sector,
int rb,
int mz)
826 classname(Bank_TPCMZP) *mzp = getBankTPCMZP(sector, rb, mz);
827 if(!mzp)
return NULL;
829 if((!mzp->TPCRMSR.offset) || (!mzp->TPCRMSR.length))
832 sprintf(str0,
"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
833 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
837 classname(Bank_TPCRMSR) *ptr = (classname(Bank_TPCRMSR) *)
839 mzp->TPCRMSR.offset);
841 if(strncmp(ptr->header.BankType,
"TPCRMSR",7)) {
843 sprintf(str0,
"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
844 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__,str0);
return NULL;
846 if(!ptr->test_CRC()) {
848 sprintf(str0,
"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
849 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
return NULL;
851 if(ptr->swap() < 0) {
853 sprintf(str0,
"getBankTPCRMSR(sec %d rb %d mz %d )",sector,rb,mz);
854 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
return NULL;
861 classname(Bank_TPCGAINR) *TPCV2P0_Reader::getBankTPCGAINR(
int sector,
int rb,
int mz)
866 classname(Bank_TPCBADR) *TPCV2P0_Reader::getBankTPCBADR(
int sector,
int rb,
int mz)