56 #include "L3_Reader.hh"
63 using namespace OLDEVP;
86 mTime = mBankL3P->time;
87 mGl3Id = mBankL3P->gl3Id;
93 L3_Reader::~L3_Reader()
107 if (mBankL3P->header.FormatNumber < 4) {
108 L3ERROR(INFO_MISSING_BANK,
"wrong data format, no L3_SUMD bank");
113 if (mBankL3P->summary_data.length==0) {
114 L3ERROR(INFO_MISSING_BANK,
"no L3_SUMD bank");
118 mBankL3SUMD = (
Bank_L3_SUMD *) ((INT32 *)mBankL3P + mBankL3P->summary_data.offset);
119 if (strncmp(mBankL3SUMD->header.BankType, CHAR_L3_SUMD, 8) != 0) {
120 L3ERROR(ERR_BAD_HEADER,
"bad L3_SUMD header");
125 if (mBankL3SUMD->swap() < 0) L3ERROR(ERR_SWAP,
"swap L3_SUMD");
134 if (mBankL3P->tracks.length==0) {
135 L3ERROR(INFO_MISSING_BANK,
"no L3_GTD bank");
139 mBankL3GTD = (
Bank_L3_GTD *) ((INT32 *)mBankL3P + mBankL3P->tracks.offset);
140 if (strncmp(mBankL3GTD->header.BankType, CHAR_L3_GTD, 8) != 0) {
141 L3ERROR(ERR_BAD_HEADER,
"bad L3_GTD header");
146 if (mBankL3GTD->swap() < 0) L3ERROR(ERR_SWAP,
"swap L3_GTD");
155 if (mBankL3P->sector[sec-1].length==0) {
156 L3secERROR(INFO_MISSING_BANK,
"no L3_SECP bank", sec);
161 mBankL3SECP = (
Bank_L3_SECP *) ((INT32 *)mBankL3P + mBankL3P->sector[sec-1].offset);
162 if (strncmp(mBankL3SECP->header.BankType, CHAR_L3_SECP, 8) != 0) {
163 L3secERROR(ERR_BAD_HEADER,
"bad L3_SECP header", sec);
168 if (mBankL3SECP->swap() < 0) L3secERROR(ERR_SWAP,
"swap L3_SECP", sec);
178 mBankL3SECP = getL3_SECP(sec);
179 if (mBankL3SECP==NULL) {
185 if (mBankL3SECP->sl3clusterp.length==0) {
186 L3secERROR(INFO_MISSING_BANK,
"no L3_SECCD bank", sec);
191 mBankL3SECCD = (
Bank_L3_SECCD *) ((INT32 *)mBankL3SECP + mBankL3SECP->sl3clusterp.offset);
192 if (strncmp(mBankL3SECCD->header.BankType, CHAR_L3_SECCD, 8) != 0) {
193 L3secERROR(ERR_BAD_HEADER,
"bad L3_SECCD header", sec);
198 if (mBankL3SECCD->swap() < 0) L3secERROR(ERR_SWAP,
"swap L3_SECCD", sec);
208 mBankL3SECP = getL3_SECP(sec);
209 if (mBankL3SECP==NULL) {
215 if (mBankL3SECP->trackp.length==0) {
216 L3secERROR(INFO_MISSING_BANK,
"no L3_SECTP bank", sec);
221 mBankL3SECTP = (
Bank_L3_SECTP *) ((INT32 *)mBankL3SECP + mBankL3SECP->trackp.offset);
222 if (strncmp(mBankL3SECTP->header.BankType, CHAR_L3_SECTP, 8) != 0) {
223 L3secERROR(ERR_BAD_HEADER,
"bad L3_SECTP header", sec);
228 if (mBankL3SECTP->swap() < 0) L3secERROR(ERR_SWAP,
"swap L3_SECTP", sec);
238 mBankL3SECP = getL3_SECP(sec);
239 if (mBankL3SECP==NULL) {
240 mBankTPCSECLP = NULL;
241 return mBankTPCSECLP;
245 if (mBankL3SECP->clusterp.length==0) {
246 L3secERROR(INFO_MISSING_BANK,
"no TPCSECLP bank", sec);
247 mBankTPCSECLP = NULL;
248 return mBankTPCSECLP;
251 mBankTPCSECLP = (
Bank_TPCSECLP *) ((INT32 *)mBankL3SECP + mBankL3SECP->clusterp.offset);
252 if (strncmp(mBankTPCSECLP->header.BankType, CHAR_TPCSECLP, 8) != 0) {
253 L3secERROR(ERR_BAD_HEADER,
"bad TPCSECLP header", sec);
254 mBankTPCSECLP = NULL;
255 return mBankTPCSECLP;
258 if (mBankTPCSECLP->swap() < 0) L3secERROR(ERR_SWAP,
"swap TPCSECLP", sec);
260 return mBankTPCSECLP;
268 mBankTPCSECLP = getTPCSECLP(sec);
269 if (mBankTPCSECLP==NULL) {
270 mBankTPCRBCLP = NULL;
271 return mBankTPCRBCLP;
275 if (mBankTPCSECLP->receiverBoard[rb-1].length==0) {
276 L3secERROR(INFO_MISSING_BANK,
"no TPCRBCLP bank", sec);
277 mBankTPCRBCLP = NULL;
278 return mBankTPCRBCLP;
281 mBankTPCRBCLP = (
Bank_TPCRBCLP *) ((INT32 *)mBankTPCSECLP + mBankTPCSECLP->receiverBoard[rb-1].offset);
282 if (strncmp(mBankTPCRBCLP->header.BankType, CHAR_TPCRBCLP, 8) != 0) {
283 L3secERROR(ERR_BAD_HEADER,
"bad TPCRBCLP header", sec);
284 mBankTPCRBCLP = NULL;
285 return mBankTPCRBCLP;
288 if (mBankTPCRBCLP->swap() < 0) L3secERROR(ERR_SWAP,
"swap TPCRBCLP", sec);
290 return mBankTPCRBCLP;
296 Bank_TPCMZCLD * L3_Reader::getTPCMZCLD (
int sec,
int rb,
int mz)
298 mBankTPCRBCLP = getTPCRBCLP(sec, rb);
299 if (mBankTPCRBCLP==NULL) {
300 mBankTPCMZCLD = NULL;
301 return mBankTPCMZCLD;
305 if (mBankTPCRBCLP->mezzBoard[mz-1].length==0) {
306 L3secERROR(INFO_MISSING_BANK,
"no TPCMZCLD bank", sec);
307 mBankTPCMZCLD = NULL;
308 return mBankTPCMZCLD;
311 mBankTPCMZCLD = (
Bank_TPCMZCLD *) ((INT32 *)mBankTPCRBCLP + mBankTPCRBCLP->mezzBoard[mz-1].offset);
312 if (strncmp(mBankTPCMZCLD->header.BankType, CHAR_TPCMZCLD, 8) != 0) {
313 L3secERROR(ERR_BAD_HEADER,
"bad TPCMZCLD header", sec);
314 mBankTPCMZCLD = NULL;
315 return mBankTPCMZCLD;
318 if (mBankTPCMZCLD->swap() < 0) L3secERROR(ERR_SWAP,
"swap TPCMZCLD", sec);
320 return mBankTPCMZCLD;
325 int * L3_Reader::getSVT_Bank(
int sector)
328 if (mBankL3P->header.FormatNumber < 4) {
329 L3ERROR(INFO_MISSING_BANK,
"wrong data format, no SVT");
334 if (mBankL3P->svt[sector-1].length==0) {
335 L3ERROR(INFO_MISSING_BANK,
"no SVT bank");
339 mSVT = (INT32 *)mBankL3P + mBankL3P->svt[sector-1].offset;
346 int * L3_Reader::getFTPC_Bank(
int sector)
349 if (mBankL3P->header.FormatNumber < 4) {
350 L3ERROR(INFO_MISSING_BANK,
"wrong data format, no FTPC");
355 if (mBankL3P->ftpc[sector-1].length==0) {
356 L3ERROR(INFO_MISSING_BANK,
"no FTPC bank");
360 mFTPC = (INT32 *)mBankL3P + mBankL3P->ftpc[sector-1].offset;
367 int * L3_Reader::getEMC_Bank()
370 if (mBankL3P->header.FormatNumber < 4) {
371 L3ERROR(INFO_MISSING_BANK,
"wrong data format, no EMC");
376 if (mBankL3P->emc.length==0) {
377 L3ERROR(INFO_MISSING_BANK,
"no EMC bank");
381 mEMC = (INT32 *)mBankL3P + mBankL3P->emc.offset;
394 if (!mAlr->initialize()) {
410 if (!mGtr->initialize()) {
423 if (!mScr->initialize(sec)) {
435 if (!mStr->initialize(sec)) {
447 if (!mIcr->initialize(sec)) {
459 Gl3AlgorithmReader::Gl3AlgorithmReader(
L3_Reader *l3r)
470 int Gl3AlgorithmReader::initialize()
472 mL3SUMD = mL3r->getL3_SUMD();
473 if (mL3SUMD == NULL) {
478 mNProcessed = mL3SUMD->nProcessed;
479 mNReconstructed = mL3SUMD->nReconstructed;
480 mNAlg = mL3SUMD->nAlg;
481 mAlgData = mL3SUMD->alg;
491 GlobalTrackReader::GlobalTrackReader (
L3_Reader *l3r)
504 int GlobalTrackReader::initialize ()
506 mL3GTD = mL3->getL3_GTD();
507 if (mL3GTD == NULL) {
512 mTracks = mL3GTD->track;
513 mNTracks = mL3GTD->nTracks;
514 mNHits = mL3GTD->nHits;
516 mGlobalVertex.x = mL3GTD->xVert;
517 mGlobalVertex.y = mL3GTD->yVert;
518 mGlobalVertex.z = mL3GTD->zVert;
529 Sl3ClusterReader::Sl3ClusterReader (
L3_Reader *l3r)
539 int Sl3ClusterReader::initialize (
int sec)
545 mL3SECCD = mL3->getL3_SECCD(mSector);
546 if (mL3SECCD == NULL) {
550 mCluster = mL3SECCD->cluster;
551 mNCluster = mL3SECCD->nrClusters_in_sector;
562 I960ClusterReader::I960ClusterReader (
L3_Reader *l3r)
566 mCluster =
new L3_Cluster[maxClusterPerSector];
568 for (
int rb=0; rb<12; rb++) {
569 for (
int mz=0; mz<3; mz++) {
570 mBankTPCMZCLD[rb][mz] = NULL;
576 I960ClusterReader::~I960ClusterReader ()
582 int I960ClusterReader::initialize (
int sec)
593 unsigned short flags;
604 for (rb=1; rb<=12; rb++) {
605 for (
int mz=1; mz<=3; mz++) {
607 mBankTPCMZCLD[rb-1][mz-1] = mL3->getTPCMZCLD(mSector, rb, mz);
608 cld = mBankTPCMZCLD[rb-1][mz-1];
610 int *ptr = (
int *)&cld->stuff;
612 for (
int ir=0; ir<cld->numberOfRows; ir++) {
615 int nHitsThisRow = *ptr++;
616 mNCluster += nHitsThisRow;
617 ptr += 2 * nHitsThisRow;
624 if (mNCluster>maxClusterPerSector) {
625 cout <<
"ERROR: L3_Reader: reached maxClusterPerSector limit!" << endl;
628 if (mCluster==NULL) {
629 cout <<
"failed to allocate cluster structures " << endl;
635 cout <<
"no i960 clusters found" << endl;
644 for ( rb=1; rb<=12; rb++) {
645 for (
int mz=1; mz<=3; mz++) {
646 cld = mBankTPCMZCLD[rb-1][mz-1];
648 int *ptr = &cld->stuff[0];
649 for (
int ir=0; ir<cld->numberOfRows; ir++){
652 for (
int isp=0; isp<nsp; isp++, ptr+=2) {
654 pcluster->pad = hit->centroids.x;
655 pcluster->time = hit->centroids.t;
656 pcluster->charge = hit->q;
657 pcluster->flags = hit->flags;
658 pcluster->padrow = row;
659 pcluster->RB_MZ = 16 * rb + mz;
660 pcluster->trackId = 0;
676 Sl3TrackReader::Sl3TrackReader (
L3_Reader *l3r)
693 int Sl3TrackReader::initialize (
int sec)
699 mL3SECTP = mL3->getL3_SECTP(mSector);
700 if (mL3SECTP == NULL) {
706 if (mL3SECTP->banks[0].length == 0) {
707 pL3secERROR(INFO_MISSING_BANK,
"no L3_LTD bank", mSector);
711 mL3LTD = (
Bank_L3_LTD *) ((INT32 *)mL3SECTP + mL3SECTP->banks[0].offset);
712 if (strncmp(mL3LTD->header.BankType, CHAR_L3_LTD, 8) != 0) {
713 pL3secERROR(ERR_BAD_HEADER,
"bad L3_LTD header", mSector);
717 if (mL3LTD->swap() < 0) pL3secERROR(ERR_SWAP,
"swap L3_LTD", mSector);
724 mTracks = mL3LTD->track;
725 mNTracks = mL3SECTP->nTracks;
726 mNHits = mL3SECTP->nHits;
727 mCpuTime = mL3SECTP->cpuTime;
728 mRealTime = mL3SECTP->realTime;
729 mParaSet = mL3SECTP->para;
730 mSectorVertex.x = mL3SECTP->xVert;
731 mSectorVertex.y = mL3SECTP->yVert;
732 mSectorVertex.z = mL3SECTP->zVert;