107 #include "StEventTypes.h"
109 #include "StThreeVectorD.hh"
110 #include "StThreeVectorF.hh"
111 #include "StHelix.hh"
112 #include "StTrackGeometry.h"
113 #include "StDcaGeometry.h"
114 #include "StDedxPidTraits.h"
115 #include "StTrackPidTraits.h"
116 #include "StBTofPidTraits.h"
117 #include "StarClassLibrary/StParticleTypes.hh"
118 #include "StarClassLibrary/StParticleDefinition.hh"
119 #include "StTpcDedxPidAlgorithm.h"
120 #include "StEventUtilities/StuRefMult.hh"
121 #include "PhysicalConstants.h"
122 #include "StPhysicalHelixD.hh"
123 #include "StHelix.hh"
124 #include "StBTofCollection.h"
125 #include "StBTofUtil/tofPathLength.hh"
126 #include "StBTofUtil/StBTofGeometry.h"
127 #include "StBTofUtil/StBTofHitCollection.h"
128 #include "tables/St_tofConfig_Table.h"
129 #include "tables/St_tofTrayConfig_Table.h"
134 #include "StMessMgr.h"
135 #include "StMemoryInfo.hh"
136 #include "StTimer.hh"
137 #include "TGeoManager.h"
139 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
140 #include "StMuDSTMaker/COMMON/StMuDst.h"
141 #include "StMuDSTMaker/COMMON/StMuBTofHit.h"
142 #include "StMuDSTMaker/COMMON/StMuTrack.h"
143 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
144 #include "StMuDSTMaker/COMMON/StMuBTofPidTraits.h"
146 #include "StBTofMatchMaker.h"
154 mAcceptedEventCounter = 0;
155 mTofEventCounter = 0;
173 mInitFromOther = kFALSE;
174 mUseIdealGeometry = kFALSE;
175 mCalculateAlign = kFALSE;
177 doPrintMemoryInfo = kFALSE;
178 doPrintCpuInfo = kFALSE;
185 StBTofMatchMaker::~StBTofMatchMaker(){ }
191 LOG_INFO <<
"Initializing match settings:" << endm;
192 LOG_INFO <<
" Minimum fitpoints per track: " << mMinFitPointsPerTrack << endm;
193 LOG_INFO <<
" Maximum DCA: " << mMaxDCA << endm;
195 if (!mOuterTrackGeometry) {
196 LOG_WARN <<
"using standard trackgeometry()" << endm;
208 LOG_INFO <<
"Histograms are booked" << endm;
209 if (mHistoFileName!=
"") {
210 LOG_INFO <<
"Histograms will be stored in " << mHistoFileName.c_str() << endm;
216 mAcceptedEventCounter = 0;
217 mTofEventCounter = 0;
221 if(mCalculateAlign) {
222 if (mAlignFileName==
"") mUseIdealGeometry = kTRUE;
234 LOG_INFO <<
"Initializing BTOF Geometry:" << endm;
242 if(
TDataSet *geom = GetDataSet(
"btofGeometry")) {
244 LOG_INFO <<
" Found btofGeometry ... " << endm;
245 mInitFromOther = kTRUE;
247 mBTofGeom =
new StBTofGeometry(
"btofGeometry",
"btofGeometry in MatchMaker");
248 LOG_INFO <<
" Create a new btofGeometry ... " << endm;
249 AddConst(
new TObjectSet(
"btofGeometry",mBTofGeom));
251 if(mBTofGeom && !mBTofGeom->IsInitDone()) {
252 LOG_INFO <<
" BTofGeometry initialization ... " << endm;
254 if (mUseIdealGeometry) mBTofGeom->SetMCOn();
255 else mBTofGeom->SetMCOff();
256 LOG_INFO <<
" Alignment file: " << mAlignFileName.c_str() << endm;
257 mBTofGeom->SetAlignFile(mAlignFileName.c_str());
258 TVolume *starHall = gGeoManager ?
nullptr : (
TVolume *) GetDataSet(
"HALL");
259 mBTofGeom->Init(
this, starHall, gGeoManager);
263 LOG_INFO <<
"CPU time for StBTofGeometry initialization : " << geomTimer.elapsedTime() <<
" sec" << endm;
269 Int_t StBTofMatchMaker::FinishRun(Int_t runnumber){
271 LOG_INFO <<
"StBTofMatchMaker -- cleaning up geometry (Finish)" << endm;
272 if (!mInitFromOther && mBTofGeom)
delete mBTofGeom;
282 LOG_DEBUG <<
"StBTofMatchMaker ----- RUN SUMMARY ----- (Finish)\n"
283 <<
"\tProcessed " << mEventCounter <<
" events."
284 <<
" Accepted " << mAcceptedEventCounter <<
" events."
285 <<
" Rejected " << mEventCounter - mAcceptedEventCounter <<
" events\n"
286 <<
"\tTOF events " << mTofEventCounter
287 <<
"\t Accept & Beam " << mAcceptAndBeam <<
" events" << endm;
290 if (mHistoFileName!=
"") writeHistogramsToFile();
298 LOG_INFO <<
"StBTofMatchMaker -- welcome" << endm;
300 if(mMuDstIn) processMuDst();
301 else processStEvent();
307 void StBTofMatchMaker::processStEvent(){
309 if(mHisto) mEventCounterHisto->Fill(0);
311 mEvent = (
StEvent *) GetInputDS(
"StEvent");
312 if(!mEvent || !(mEvent->btofCollection()) || !(mEvent->btofCollection()->hitsPresent()) ) {
313 if (!mEvent) {LOG_INFO <<
"no StEvent" << endm;}
315 if (!(mEvent->btofCollection())) {LOG_INFO <<
"no BTof Collection" << endm;}
317 if (!(mEvent->btofCollection()->hitsPresent()) ) LOG_INFO <<
"no BTOF hits present" << endm;
318 LOG_INFO <<
"StBTofMatchMaker -- nothing to do ... bye-bye" << endm;
321 if(mHisto) mEventCounterHisto->Fill(1);
325 if (doPrintCpuInfo) timer.start();
326 if (doPrintMemoryInfo) StMemoryInfo::instance()->snapshot();
336 tofCellHitVector daqCellsHitVec;
337 idVector validModuleVec;
340 StSPtrVecBTofHit& tofHits = theTof->tofHits();
341 LOG_INFO <<
" Number of BTOF Hits = " << tofHits.size() << endm;
342 for(
size_t i=0;i<tofHits.size();i++) {
346 if(aHit->tray()<=0||aHit->tray()>mNTray)
continue;
348 int trayId = aHit->tray();
349 int moduleId = aHit->module();
350 int cellId = aHit->cell();
352 if(Debug()) { LOG_INFO <<
"A: fired hit in " <<
" tray="<< trayId <<
" module="<<moduleId<<
" cell="<<cellId<<endm; }
354 StructCellHit aDaqCellHit;
355 aDaqCellHit.tray = trayId;
356 aDaqCellHit.module = moduleId;
357 aDaqCellHit.cell = cellId;
358 aDaqCellHit.tot = aHit->tot();
359 aDaqCellHit.index2BTofHit = i;
360 daqCellsHitVec.push_back(aDaqCellHit);
363 int id = trayId*100+moduleId;
372 if (find(validModuleVec.begin(), validModuleVec.end(), id) == validModuleVec.end())
373 validModuleVec.push_back(
id);
376 mDaqOccupancy[trayId-1]->Fill((moduleId-1)*mNCell+(cellId-1));
382 LOG_INFO <<
" total # of cells = " << daqCellsHitVec.size() << endm;
383 for(
size_t iv = 0;iv<validModuleVec.size();iv++) {
384 LOG_DEBUG <<
" module # " << validModuleVec[iv] <<
" Valid! " << endm;
388 mCellsMultInEvent->Fill(daqCellsHitVec.size());
389 if(daqCellsHitVec.size()) mEventCounterHisto->Fill(6);
392 if (doPrintCpuInfo) {
394 LOG_INFO <<
"CPU time after Step A - loading hits : "
395 << timer.elapsedTime() <<
" sec" << endm;
402 tofCellHitVector allCellsHitVec;
403 StructCellHit cellHit;
405 StSPtrVecTrackNode& nodes = mEvent->trackNodes();
407 Int_t nPrimaryHits = 0;
408 for (
unsigned int iNode=0; iNode<nodes.size(); iNode++){
409 tofCellHitVector cellHitVec;
412 if(!theTrack)
continue;
414 bool isPrimary = kFALSE;
416 if(pTrack) isPrimary = kTRUE;
419 float pt = mom.perp();
420 float eta = mom.pseudoRapidity();
421 float phi = mom.phi();
423 if (phi<0.) phi += 2.*M_PI;
427 float nSigmaPion = -999.;
429 static StPionPlus* Pion = StPionPlus::instance();
433 nSigmaPion = PidAlgorithm.numberOfSigma(Pion);
435 if ( PidAlgorithm.traits() ) {
436 dEdx = PidAlgorithm.traits()->mean();
437 ndEdxpts = PidAlgorithm.traits()->numberOfPoints();
439 int nfitpts = theTrack->fitTraits().numberOfFitPoints(kTpcId);
442 if (validTrack(theTrack)){
444 mTrackPtEta->Fill(pt, eta);
445 mTrackPtPhi->Fill(pt, phi);
446 mTrackNFitPts->Fill(nfitpts);
447 if(dEdx>0.) mTrackdEdxvsp->Fill(mom.mag(), dEdx*1.e6);
448 if(fabs(nSigmaPion)<5.) mNSigmaPivsPt->Fill(pt, nSigmaPion+5.*theTrack->geometry()->charge());
455 trackTree.nfitpts = nfitpts;
456 trackTree.dEdx = dEdx*1.e6;
457 trackTree.ndEdxpts = ndEdxpts;
458 trackTree.charge = theTrack->geometry()->charge();
459 trackTree.projTrayId = 0;
460 trackTree.projCellChan = -1;
461 trackTree.projY = -999.;
462 trackTree.projZ = -999.;
472 DoubleVec pathVec, thetaVec;
482 Int_t cells = idVec.size();
483 for (Int_t i=0; i<cells; i++) {
484 Int_t icell,imodule,itray;
485 Double_t local[3],global[3];
486 for(Int_t i2=0;i2<3;i2++){
489 global[0]=crossVec[i].x();
490 global[1]=crossVec[i].y();
491 global[2]=crossVec[i].z();
492 mBTofGeom->DecodeCellId(idVec[i], icell, imodule, itray);
496 LOG_WARN <<
" No sensitive module in the projection??? -- Something weird!!! " << endm;
499 sensor->Master2Local(&global[0],&local[0]);
500 icell = sensor->FindCellIndex(local);
505 if (fabs(local[2])<mZLocalCut) {
510 cellHit.tray = itray;
511 cellHit.module = imodule;
512 cellHit.cell = icell;
513 cellHit.trackIdVec.push_back((Int_t)iNode);
514 cellHit.hitPosition = glo;
515 cellHit.zhit = (Float_t)hitPos.z();
516 cellHit.yhit = (Float_t)hitPos.y();
517 cellHit.theta = (Double_t)thetaVec[i];
518 cellHitVec.push_back(cellHit);
519 allCellsHitVec.push_back(cellHit);
521 if(isPrimary) nPrimaryHits++;
524 mDaqOccupancyProj[itray-1]->Fill((imodule-1)*mNCell+(icell-1));
525 mHitsPosition->Fill(hitPos.y(), hitPos.z());
529 trackTree.projTrayId = itray;
530 trackTree.projCellChan = (imodule-1)*mNCell+(icell-1);
531 trackTree.projY = local[1];
532 trackTree.projZ = local[2];
536 LOG_DEBUG <<
"B: nodeid=" << iNode <<
" projected in " <<
" tray="<< itray <<
" module="<<imodule<<
" cell="<<icell<<endm;
537 LOG_DEBUG <<
" hit position " << hitPos << endm;
543 if(ncells>0&&mHisto) mHitsMultPerTrack->Fill(ncells);
545 if(mHisto && mSaveTree) mTrackTree->Fill();
549 if(Debug()) { LOG_INFO <<
"B: matched/available/total #tracknodes: " <<allCellsHitVec.size() <<
"/" <<nAllTracks <<
"/" << nodes.size() << endm; }
551 mHitsMultInEvent->Fill(allCellsHitVec.size());
552 mHitsPrimaryInEvent->Fill(nPrimaryHits);
553 if(allCellsHitVec.size()) mEventCounterHisto->Fill(7);
556 if (doPrintCpuInfo) {
558 LOG_INFO <<
"CPU time after Step B - projection : "
559 << timer.elapsedTime() <<
" sec" << endm;
566 tofCellHitVector matchHitCellsVec;
568 tofCellHitVectorIter daqIter = daqCellsHitVec.begin();
569 for(
unsigned int idaq=0;idaq<daqCellsHitVec.size();idaq++, daqIter++) {
570 tofCellHitVectorIter proIter = allCellsHitVec.begin();
571 for(
unsigned int ipro=0;ipro<allCellsHitVec.size();ipro++, proIter++) {
573 int daqIndex = (daqIter->module-1)*6 + (daqIter->cell-1);
574 int proIndex = (proIter->module-1)*6 + (proIter->cell-1);
575 int hisIndex = daqIter->tray - 1;
578 if(daqIter->tray==proIter->tray) {
580 if(hisIndex>=0&&hisIndex<mNTray) {
581 mHitCorr[hisIndex]->Fill(proIndex,daqIndex);
582 mHitCorrModule[hisIndex]->Fill(proIter->module-1,daqIter->module-1);
584 LOG_WARN <<
" weird tray # " << daqIter->tray << endm;
588 if( (daqIter->tray==proIter->tray)&&
589 (daqIter->module==proIter->module) &&
590 ( ( (proIter->cell==6)&&((proIter->cell==daqIter->cell) ||
591 (proIter->cell==daqIter->cell+1)) )
592 || ( (proIter->cell==1)&&((proIter->cell==daqIter->cell) ||
593 (proIter->cell==daqIter->cell-1)) )
594 || ( (proIter->cell>=2&&proIter->cell<=6) &&
595 ( (proIter->cell==daqIter->cell) ||
596 (proIter->cell==daqIter->cell-1) ||
597 (proIter->cell==daqIter->cell+1) ) ) ) ) {
598 cellHit.tray = daqIter->tray;
599 cellHit.module = daqIter->module;
600 cellHit.cell = daqIter->cell;
601 cellHit.hitPosition = proIter->hitPosition;
602 cellHit.trackIdVec = proIter->trackIdVec;
603 cellHit.zhit = proIter->zhit;
604 cellHit.yhit = proIter->yhit;
605 cellHit.tot = daqIter->tot;
606 cellHit.index2BTofHit = daqIter->index2BTofHit;
607 cellHit.theta = proIter->theta;
608 matchHitCellsVec.push_back(cellHit);
612 if(Debug()) { LOG_INFO <<
"C: before/after: " << allCellsHitVec.size() <<
"/" << matchHitCellsVec.size() << endm; }
613 if(mHisto&&matchHitCellsVec.size()) mEventCounterHisto->Fill(8);
614 if (doPrintCpuInfo) {
616 LOG_INFO <<
"CPU time after Step C - matching : "
617 << timer.elapsedTime() <<
" sec" << endm;
624 Int_t nSingleHitCells(0);
625 Int_t nMultiHitsCells(0);
627 tofCellHitVector singleHitCellsVec;
628 tofCellHitVector multiHitsCellsVec;
630 tofCellHitVector tempVec = matchHitCellsVec;
631 tofCellHitVector erasedVec = tempVec;
632 while (tempVec.size() != 0) {
636 tofCellHitVectorIter tempIter=tempVec.begin();
637 tofCellHitVectorIter erasedIter=erasedVec.begin();
638 while(erasedIter!= erasedVec.end()) {
639 if(tempIter->tray == erasedIter->tray &&
640 tempIter->module == erasedIter->module &&
641 tempIter->cell == erasedIter->cell) {
643 trackIdVec.push_back(erasedIter->trackIdVec.back());
644 erasedVec.erase(erasedIter);
650 cellHit.cell = tempIter->cell;
651 cellHit.module = tempIter->module;
652 cellHit.tray = tempIter->tray;
653 cellHit.hitPosition = tempIter->hitPosition;
654 cellHit.trackIdVec = trackIdVec;
655 cellHit.zhit = tempIter->zhit;
656 cellHit.yhit = tempIter->yhit;
657 cellHit.tot = tempIter->tot;
658 cellHit.index2BTofHit = tempIter->index2BTofHit;
659 cellHit.theta = tempIter->theta;
661 Float_t ycenter = (tempIter->cell-1-2.5)*mWidthPad;
662 Float_t dy = tempIter->yhit - ycenter;
663 Float_t dz = tempIter->zhit;
666 mTracksPerCellMatch1->Fill(trackIdVec.size());
668 mDeltaHitMatch1->Fill(dy, dz);
673 singleHitCellsVec.push_back(cellHit);
674 }
else if (nTracks>1){
676 multiHitsCellsVec.push_back(cellHit);
680 LOG_WARN <<
"D: no tracks extrapolate to matched cell ... should not happen!" << endm;
684 LOG_DEBUG <<
"D: itray=" << cellHit.tray <<
" imodule=" << cellHit.module <<
" icell=" << cellHit.cell <<
"\ttrackid:";
685 idVectorIter ij=trackIdVec.begin();
686 while (ij != trackIdVec.end()) { LOG_DEBUG <<
" " << *ij; ij++; }
692 if(Debug()) { LOG_INFO <<
"D: before/after: " << matchHitCellsVec.size() <<
"/" << singleHitCellsVec.size() << endm; }
696 mCellsPerEventMatch1->Fill(singleHitCellsVec.size()+multiHitsCellsVec.size());
697 if(singleHitCellsVec.size()) mEventCounterHisto->Fill(9);
699 if (doPrintCpuInfo) {
701 LOG_INFO <<
"CPU time after Step D - erasing : "
702 << timer.elapsedTime() <<
" sec" << endm;
709 tofCellHitVector FinalMatchedCellsVec;
711 tempVec = singleHitCellsVec;
713 mCellsPerEventMatch2->Fill(tempVec.size());
714 for(
unsigned int ii=0;ii<tempVec.size();ii++) {
715 mTracksPerCellMatch2->Fill(tempVec[ii].trackIdVec.size());
717 Float_t ycenter = (tempVec[ii].cell-1-2.5)*mWidthPad;
718 Float_t dy = tempVec[ii].yhit-ycenter;
719 Float_t dz = tempVec[ii].zhit;
720 mDeltaHitMatch2->Fill(dy, dz);
725 while (tempVec.size() != 0) {
726 StructCellHit cellHit;
729 vector<StThreeVectorD> vPosition;
730 vector<Int_t> vchannel, vtray, vmodule, vcell;
731 vector<Float_t> vzhit, vyhit;
732 vector<Double_t> vtot, vtheta;
733 vector<Int_t> vindex2BTofHit;
735 tofCellHitVectorIter tempIter=tempVec.begin();
736 tofCellHitVectorIter erasedIter=erasedVec.begin();
737 while(erasedIter!= erasedVec.end()) {
738 if(tempIter->trackIdVec.back() == erasedIter->trackIdVec.back()) {
740 vtray.push_back(erasedIter->tray);
741 vmodule.push_back(erasedIter->module);
742 vcell.push_back(erasedIter->cell);
743 vPosition.push_back(erasedIter->hitPosition);
744 vTrackId.push_back(erasedIter->trackIdVec.back());
745 vzhit.push_back(erasedIter->zhit);
746 vyhit.push_back(erasedIter->yhit);
747 vtot.push_back(erasedIter->tot);
748 vindex2BTofHit.push_back(erasedIter->index2BTofHit);
749 vtheta.push_back(erasedIter->theta);
751 erasedVec.erase(erasedIter);
759 cellHit.tray = vtray[0];
760 cellHit.module = vmodule[0];
761 cellHit.cell = vcell[0];
762 cellHit.trackIdVec.push_back(vTrackId[0]);
763 cellHit.hitPosition = vPosition[0];
764 cellHit.matchFlag = 1;
765 cellHit.zhit = vzhit[0];
766 cellHit.yhit = vyhit[0];
767 cellHit.tot = vtot[0];
768 cellHit.index2BTofHit = vindex2BTofHit[0];
769 cellHit.theta = vtheta[0];
771 FinalMatchedCellsVec.push_back(cellHit);
775 LOG_DEBUG <<
"E: itray=" << cellHit.tray <<
" imodule=" << cellHit.module <<
" icell=" << cellHit.cell <<
"\ttrackid:";
776 idVectorIter ij=vTrackId.begin();
777 while (ij != vTrackId.end()) { LOG_DEBUG <<
" " << *ij; ij++; }
783 Int_t thiscandidate(-99);
784 Int_t thisMatchFlag(0);
788 vector<Int_t> ttCandidates;
789 for (Int_t i=0;i<nCells;i++) {
790 Double_t tt = vtot[i];
793 ttCandidates.clear();
794 ttCandidates.push_back(i);
795 }
else if (tt==tot) {
796 ttCandidates.push_back(i);
799 if (ttCandidates.size()==1) {
800 thiscandidate = ttCandidates[0];
802 }
else if (ttCandidates.size()>1) {
804 vector<Int_t> ssCandidates;
805 for(
size_t j=0;j<ttCandidates.size();j++) {
806 Float_t yy = vyhit[ttCandidates[j]];
807 Float_t ycell = (vcell[ttCandidates[j]]-1-2.5)*mWidthPad;
808 Float_t ll = fabs(yy-ycell);
811 ssCandidates.clear();
812 ssCandidates.push_back(ttCandidates[j]);
814 ssCandidates.push_back(ttCandidates[j]);
816 if (ssCandidates.size()==1){
817 thiscandidate = ssCandidates[0];
822 if (thiscandidate>=0) {
823 cellHit.tray = vtray[thiscandidate];
824 cellHit.module = vmodule[thiscandidate];
825 cellHit.cell = vcell[thiscandidate];
826 cellHit.trackIdVec.push_back(vTrackId[thiscandidate]);
827 cellHit.hitPosition = vPosition[thiscandidate];
828 cellHit.matchFlag = thisMatchFlag;
829 cellHit.zhit = vzhit[thiscandidate];
830 cellHit.yhit = vyhit[thiscandidate];
831 cellHit.tot = vtot[thiscandidate];
832 cellHit.index2BTofHit = vindex2BTofHit[thiscandidate];
833 cellHit.theta = vtheta[thiscandidate];
835 FinalMatchedCellsVec.push_back(cellHit);
838 if(Debug()) { LOG_DEBUG <<
"E: itray=" << cellHit.tray <<
" imodule=" << cellHit.module <<
" icell=" << cellHit.cell <<
"\ttrackid:" << vTrackId[thiscandidate] << endm; }
842 LOG_WARN <<
"E: no cells belong to this track ... should not happen!" << endm;
848 if(Debug()) { LOG_INFO <<
"E: before/after: " << singleHitCellsVec.size() <<
"/" << FinalMatchedCellsVec.size() << endm; }
850 if (doPrintCpuInfo) {
852 LOG_INFO <<
"CPU time after Step E - sorting : "
853 << timer.elapsedTime() <<
" sec" << endm;
861 if(FinalMatchedCellsVec.size()) mEventCounterHisto->Fill(10);
862 mCellsPerEventMatch3->Fill(FinalMatchedCellsVec.size());
866 Int_t nValidSingleHitCells(0), nValidSinglePrimHitCells(0);
868 for (
size_t ii=0; ii < FinalMatchedCellsVec.size(); ii++){
869 Int_t tray = FinalMatchedCellsVec[ii].tray;
870 Int_t module = FinalMatchedCellsVec[ii].module;
871 Int_t cell = FinalMatchedCellsVec[ii].cell;
873 Float_t ycenter = (cell-1-2.5)*mWidthPad;
874 Float_t dy = FinalMatchedCellsVec[ii].yhit - ycenter;
875 Float_t dz = FinalMatchedCellsVec[ii].zhit;
876 if (FinalMatchedCellsVec[ii].trackIdVec.size()!=1)
877 LOG_WARN <<
"F: WHAT!?! mult.matched cell in single cell list " << tray <<
" " << module <<
" " << cell << endm;
880 mTracksPerCellMatch3->Fill(FinalMatchedCellsVec[ii].trackIdVec.size());
882 mDeltaHitMatch3->Fill(dy, dz);
883 mDeltaHitFinal[tray-1]->Fill(dy,dz);
887 int trackNode = FinalMatchedCellsVec[ii].trackIdVec[0];
890 LOG_WARN <<
"Wrong global track!" << endm;
896 StBTofHit *tofHit = tofHits[FinalMatchedCellsVec[ii].index2BTofHit];
897 if(tofHit->tray()!=tray || tofHit->module()!=module || tofHit->cell()!=cell) {
898 LOG_WARN <<
"Wrong hit in the BTofHitCollection!" << endm;
901 nValidSingleHitCells++;
904 tofHit->setAssociatedTrack(globalTrack);
908 pidTof->setTofHit(tofHit);
909 pidTof->setMatchFlag(FinalMatchedCellsVec[ii].matchFlag);
910 pidTof->setYLocal(dy);
911 pidTof->setZLocal(FinalMatchedCellsVec[ii].zhit);
912 pidTof->setPosition(FinalMatchedCellsVec[ii].hitPosition);
913 pidTof->setThetaLocal(FinalMatchedCellsVec[ii].theta);
914 globalTrack->addPidTraits(pidTof);
918 nValidSinglePrimHitCells++;
920 ppidTof->setTofHit(tofHit);
921 ppidTof->setMatchFlag(FinalMatchedCellsVec[ii].matchFlag);
922 ppidTof->setYLocal(dy);
923 ppidTof->setZLocal(FinalMatchedCellsVec[ii].zhit);
924 ppidTof->setPosition(FinalMatchedCellsVec[ii].hitPosition);
925 ppidTof->setThetaLocal(FinalMatchedCellsVec[ii].theta);
926 pTrack->addPidTraits(ppidTof);
932 mCellsPrimaryPerEventMatch3->Fill(nValidSinglePrimHitCells);
935 if(Debug()) { LOG_INFO <<
"F: before/after" << FinalMatchedCellsVec.size() <<
"/" <<nValidSinglePrimHitCells << endm; }
937 if (doPrintCpuInfo) {
939 LOG_INFO <<
"CPU time after Step F - final : "
940 << timer.elapsedTime() <<
" sec" << endm;
944 LOG_INFO <<
"#(daq): " << daqCellsHitVec.size()
945 <<
" #(proj): " << allCellsHitVec.size()
946 <<
" #(prim proj): " << nPrimaryHits
947 <<
" #(matched): " << FinalMatchedCellsVec.size()
948 <<
" #(single valid): " << nValidSingleHitCells
949 <<
" #(single prim valid): " << nValidSinglePrimHitCells
953 if (theTof->hitsPresent()){
954 LOG_DEBUG <<
" BTofCollection: hit container present."<<endm;
956 StSPtrVecBTofHit& tmpCellTofVec = theTof->tofHits();
957 LOG_INFO <<
" # of hits in this event:" << tmpCellTofVec.size() << endm;
958 for (
size_t i = 0; i < tmpCellTofVec.size(); i++) {
960 LOG_INFO << (*p) << endm;
967 if (doPrintMemoryInfo) {
968 StMemoryInfo::instance()->snapshot();
969 StMemoryInfo::instance()->print();
971 if (doPrintCpuInfo) {
973 LOG_INFO <<
"CPU time for StBTofMatchMaker::Make(): "
974 << timer.elapsedTime() <<
" sec" << endm;
977 LOG_DEBUG <<
"StBTofMatchMaker -- bye-bye" << endm;
983 void StBTofMatchMaker::processMuDst(){
985 if(mHisto) mEventCounterHisto->Fill(0);
989 LOG_WARN <<
" No MuDstMaker ... bye-bye ... " << endm;
992 mMuDst = mMuDstMaker->
muDst();
994 LOG_WARN <<
" No MuDst ... bye-bye" << endm;
1000 if (doPrintCpuInfo) timer.start();
1001 if (doPrintMemoryInfo) StMemoryInfo::instance()->snapshot();
1007 tofCellHitVector daqCellsHitVec;
1008 idVector validModuleVec;
1011 Int_t nhits = mMuDst->numberOfBTofHit();
1012 LOG_INFO <<
" Number of BTOF Hits = " << nhits << endm;
1013 if(mHisto&&nhits>0) mEventCounterHisto->Fill(1);
1014 for(
int i=0;i<nhits;i++) {
1017 if(aHit->tray()<=0||aHit->tray()>mNTray)
continue;
1020 aHit->setIndex2Primary(-1);
1021 aHit->setIndex2Global(-1);
1022 aHit->setAssociatedTrackId(-1);
1024 int trayId = aHit->tray();
1025 int moduleId = aHit->module();
1026 int cellId = aHit->cell();
1028 if(Debug()) { LOG_INFO <<
"A: fired hit in " <<
" tray="<< trayId <<
" module="<<moduleId<<
" cell="<<cellId<<endm; }
1030 StructCellHit aDaqCellHit;
1031 aDaqCellHit.tray = trayId;
1032 aDaqCellHit.module = moduleId;
1033 aDaqCellHit.cell = cellId;
1034 aDaqCellHit.tot = aHit->tot();
1035 aDaqCellHit.index2BTofHit = i;
1036 daqCellsHitVec.push_back(aDaqCellHit);
1039 int id = trayId*100+moduleId;
1048 if (find(validModuleVec.begin(), validModuleVec.end(), id) == validModuleVec.end())
1049 validModuleVec.push_back(
id);
1052 mDaqOccupancy[trayId-1]->Fill((moduleId-1)*mNCell+(cellId-1));
1058 LOG_DEBUG <<
" total # of cells = " << daqCellsHitVec.size() << endm;
1059 for(
size_t iv = 0;iv<validModuleVec.size();iv++) {
1060 LOG_DEBUG <<
" module # " << validModuleVec[iv] <<
" Valid! " << endm;
1064 mCellsMultInEvent->Fill(daqCellsHitVec.size());
1065 if(daqCellsHitVec.size()) mEventCounterHisto->Fill(6);
1068 if (doPrintCpuInfo) {
1070 LOG_INFO <<
"CPU time after Step A - loading hits : "
1071 << timer.elapsedTime() <<
" sec" << endm;
1079 Int_t index2Primary[50000];
1080 memset(index2Primary, -1,
sizeof(index2Primary));
1081 for(
int ip=0;ip<(int)mMuDst->
array(muPrimary)->GetEntries();ip++) {
1083 if(!pTrack)
continue;
1085 if(gIndex<0)
continue;
1086 index2Primary[gIndex] = ip;
1089 tofCellHitVector allCellsHitVec;
1090 StructCellHit cellHit;
1092 Int_t nGlobals = mMuDst->numberOfGlobalTracks();
1094 Int_t nPrimaryHits = 0;
1095 for (
int iNode=0; iNode<nGlobals; iNode++){
1096 tofCellHitVector cellHitVec;
1099 if(!theTrack)
continue;
1103 theTrack->setBTofPidTraits(pidTof);
1104 theTrack->setIndex2BTofHit(-1);
1106 bool isPrimary = kFALSE;
1107 int pIndex = index2Primary[iNode];
1112 pTrack->setBTofPidTraits(pidTof);
1113 pTrack->setIndex2BTofHit(-1);
1118 float pt = mom.perp();
1119 float eta = mom.pseudoRapidity();
1120 float phi = mom.phi();
1122 if (phi<0.) phi += 2.*M_PI;
1125 float dEdx = theTrack->
dEdx();
1127 int nfitpts = theTrack->
nHitsFit(kTpcId);
1130 if (validTrack(theTrack)){
1132 mTrackPtEta->Fill(pt, eta);
1133 mTrackPtPhi->Fill(pt, phi);
1134 mTrackNFitPts->Fill(nfitpts);
1135 if(dEdx>0.) mTrackdEdxvsp->Fill(mom.mag(), dEdx*1.e6);
1136 if(fabs(nSigmaPion)<5.) mNSigmaPivsPt->Fill(pt, nSigmaPion+5.*theTrack->
charge());
1141 trackTree.eta = eta;
1142 trackTree.phi = phi;
1143 trackTree.nfitpts = nfitpts;
1144 trackTree.dEdx = dEdx*1.e6;
1145 trackTree.ndEdxpts = ndEdxpts;
1146 trackTree.charge = theTrack->
charge();
1147 trackTree.projTrayId = 0;
1148 trackTree.projCellChan = -1;
1149 trackTree.projY = -999.;
1150 trackTree.projZ = -999.;
1160 DoubleVec pathVec, thetaVec;
1170 Int_t cells = idVec.size();
1171 for (Int_t i=0; i<cells; i++) {
1172 Int_t icell,imodule,itray;
1173 Double_t local[3],global[3];
1174 for(Int_t i2=0;i2<3;i2++){
1177 global[0]=crossVec[i].
x();
1178 global[1]=crossVec[i].y();
1179 global[2]=crossVec[i].z();
1180 mBTofGeom->DecodeCellId(idVec[i], icell, imodule, itray);
1184 LOG_WARN <<
" No sensitive module in the projection??? -- Something weird!!! " << endm;
1187 sensor->Master2Local(&global[0],&local[0]);
1188 icell = sensor->FindCellIndex(local);
1193 if (fabs(local[2])<mZLocalCut) {
1198 cellHit.tray = itray;
1199 cellHit.module = imodule;
1200 cellHit.cell = icell;
1201 cellHit.trackIdVec.push_back(iNode);
1202 cellHit.hitPosition = glo;
1203 cellHit.zhit = (Float_t)hitPos.z();
1204 cellHit.yhit = (Float_t)hitPos.y();
1205 cellHit.theta = (Double_t)thetaVec[i];
1206 cellHitVec.push_back(cellHit);
1207 allCellsHitVec.push_back(cellHit);
1209 if(isPrimary) nPrimaryHits++;
1212 mDaqOccupancyProj[itray-1]->Fill((imodule-1)*mNCell+(icell-1));
1213 mHitsPosition->Fill(hitPos.y(), hitPos.z());
1217 trackTree.projTrayId = itray;
1218 trackTree.projCellChan = (imodule-1)*mNCell+(icell-1);
1219 trackTree.projY = local[1];
1220 trackTree.projZ = local[2];
1224 LOG_DEBUG <<
"B: nodeid=" << iNode <<
" projected in " <<
" tray="<< itray <<
" module="<<imodule<<
" cell="<<icell<<endm;
1225 LOG_DEBUG <<
" hit position " << hitPos << endm;
1231 if(ncells>0&&mHisto) mHitsMultPerTrack->Fill(ncells);
1233 if(mHisto && mSaveTree) mTrackTree->Fill();
1237 if(Debug()) { LOG_INFO <<
"B: matched/available/total #tracknodes: " <<allCellsHitVec.size() <<
"/" <<nAllTracks <<
"/" << nGlobals << endm; }
1239 mHitsMultInEvent->Fill(allCellsHitVec.size());
1240 mHitsPrimaryInEvent->Fill(nPrimaryHits);
1241 if(allCellsHitVec.size()) mEventCounterHisto->Fill(7);
1244 if (doPrintCpuInfo) {
1246 LOG_INFO <<
"CPU time after Step B - projection : "
1247 << timer.elapsedTime() <<
" sec" << endm;
1254 tofCellHitVector matchHitCellsVec;
1256 tofCellHitVectorIter daqIter = daqCellsHitVec.begin();
1257 for(
unsigned int idaq=0;idaq<daqCellsHitVec.size();idaq++, daqIter++) {
1258 tofCellHitVectorIter proIter = allCellsHitVec.begin();
1259 for(
unsigned int ipro=0;ipro<allCellsHitVec.size();ipro++, proIter++) {
1261 int daqIndex = (daqIter->module-1)*6 + (daqIter->cell-1);
1262 int proIndex = (proIter->module-1)*6 + (proIter->cell-1);
1263 int hisIndex = daqIter->tray - 1;
1266 if(daqIter->tray==proIter->tray) {
1268 if(hisIndex>=0&&hisIndex<mNTray) {
1269 mHitCorr[hisIndex]->Fill(proIndex,daqIndex);
1270 mHitCorrModule[hisIndex]->Fill(proIter->module-1,daqIter->module-1);
1272 LOG_WARN <<
" weird tray # " << daqIter->tray << endm;
1276 if( (daqIter->tray==proIter->tray)&&
1277 (daqIter->module==proIter->module) &&
1278 ( ( (proIter->cell==6)&&((proIter->cell==daqIter->cell) ||
1279 (proIter->cell==daqIter->cell+1)) )
1280 || ( (proIter->cell==1)&&((proIter->cell==daqIter->cell) ||
1281 (proIter->cell==daqIter->cell-1)) )
1282 || ( (proIter->cell>=2&&proIter->cell<=6) &&
1283 ( (proIter->cell==daqIter->cell) ||
1284 (proIter->cell==daqIter->cell-1) ||
1285 (proIter->cell==daqIter->cell+1) ) ) ) ) {
1286 cellHit.tray = daqIter->tray;
1287 cellHit.module = daqIter->module;
1288 cellHit.cell = daqIter->cell;
1289 cellHit.hitPosition = proIter->hitPosition;
1290 cellHit.trackIdVec = proIter->trackIdVec;
1291 cellHit.zhit = proIter->zhit;
1292 cellHit.yhit = proIter->yhit;
1293 cellHit.tot = daqIter->tot;
1294 cellHit.index2BTofHit = daqIter->index2BTofHit;
1295 cellHit.theta = proIter->theta;
1296 matchHitCellsVec.push_back(cellHit);
1300 if(Debug()) { LOG_INFO <<
"C: before/after: " << allCellsHitVec.size() <<
"/" << matchHitCellsVec.size() << endm; }
1301 if(mHisto&&matchHitCellsVec.size()) mEventCounterHisto->Fill(8);
1302 if (doPrintCpuInfo) {
1304 LOG_INFO <<
"CPU time after Step C - matching : "
1305 << timer.elapsedTime() <<
" sec" << endm;
1312 Int_t nSingleHitCells(0);
1313 Int_t nMultiHitsCells(0);
1315 tofCellHitVector singleHitCellsVec;
1316 tofCellHitVector multiHitsCellsVec;
1318 tofCellHitVector tempVec = matchHitCellsVec;
1319 tofCellHitVector erasedVec = tempVec;
1320 while (tempVec.size() != 0) {
1322 idVector trackIdVec;
1324 tofCellHitVectorIter tempIter=tempVec.begin();
1325 tofCellHitVectorIter erasedIter=erasedVec.begin();
1326 while(erasedIter!= erasedVec.end()) {
1327 if(tempIter->tray == erasedIter->tray &&
1328 tempIter->module == erasedIter->module &&
1329 tempIter->cell == erasedIter->cell) {
1331 trackIdVec.push_back(erasedIter->trackIdVec.back());
1332 erasedVec.erase(erasedIter);
1338 cellHit.cell = tempIter->cell;
1339 cellHit.module = tempIter->module;
1340 cellHit.tray = tempIter->tray;
1341 cellHit.hitPosition = tempIter->hitPosition;
1342 cellHit.trackIdVec = trackIdVec;
1343 cellHit.zhit = tempIter->zhit;
1344 cellHit.yhit = tempIter->yhit;
1345 cellHit.tot = tempIter->tot;
1346 cellHit.index2BTofHit = tempIter->index2BTofHit;
1347 cellHit.theta = tempIter->theta;
1349 Float_t ycenter = (tempIter->cell-1-2.5)*mWidthPad;
1350 Float_t dy = tempIter->yhit - ycenter;
1351 Float_t dz = tempIter->zhit;
1354 mTracksPerCellMatch1->Fill(trackIdVec.size());
1356 mDeltaHitMatch1->Fill(dy, dz);
1361 singleHitCellsVec.push_back(cellHit);
1362 }
else if (nTracks>1){
1364 multiHitsCellsVec.push_back(cellHit);
1368 LOG_WARN <<
"D: no tracks extrapolate to matched cell ... should not happen!" << endm;
1372 LOG_DEBUG <<
"D: itray=" << cellHit.tray <<
" imodule=" << cellHit.module <<
" icell=" << cellHit.cell <<
"\ttrackid:";
1373 idVectorIter ij=trackIdVec.begin();
1374 while (ij != trackIdVec.end()) { LOG_DEBUG <<
" " << *ij; ij++; }
1378 tempVec = erasedVec;
1380 if(Debug()) { LOG_INFO <<
"D: before/after: " << matchHitCellsVec.size() <<
"/" << singleHitCellsVec.size() << endm; }
1384 mCellsPerEventMatch1->Fill(singleHitCellsVec.size()+multiHitsCellsVec.size());
1385 if(singleHitCellsVec.size()) mEventCounterHisto->Fill(9);
1387 if (doPrintCpuInfo) {
1389 LOG_INFO <<
"CPU time after Step D - erasing : "
1390 << timer.elapsedTime() <<
" sec" << endm;
1397 tofCellHitVector FinalMatchedCellsVec;
1399 tempVec = singleHitCellsVec;
1401 mCellsPerEventMatch2->Fill(tempVec.size());
1402 for(
unsigned int ii=0;ii<tempVec.size();ii++) {
1403 mTracksPerCellMatch2->Fill(tempVec[ii].trackIdVec.size());
1405 Float_t ycenter = (tempVec[ii].cell-1-2.5)*mWidthPad;
1406 Float_t dy = tempVec[ii].yhit-ycenter;
1407 Float_t dz = tempVec[ii].zhit;
1408 mDeltaHitMatch2->Fill(dy, dz);
1412 erasedVec = tempVec;
1413 while (tempVec.size() != 0) {
1414 StructCellHit cellHit;
1417 vector<StThreeVectorD> vPosition;
1418 vector<Int_t> vchannel, vtray, vmodule, vcell;
1419 vector<Float_t> vzhit, vyhit;
1420 vector<Double_t> vtot, vtheta;
1421 vector<Int_t> vindex2BTofHit;
1423 tofCellHitVectorIter tempIter=tempVec.begin();
1424 tofCellHitVectorIter erasedIter=erasedVec.begin();
1425 while(erasedIter!= erasedVec.end()) {
1426 if(tempIter->trackIdVec.back() == erasedIter->trackIdVec.back()) {
1428 vtray.push_back(erasedIter->tray);
1429 vmodule.push_back(erasedIter->module);
1430 vcell.push_back(erasedIter->cell);
1431 vPosition.push_back(erasedIter->hitPosition);
1432 vTrackId.push_back(erasedIter->trackIdVec.back());
1433 vzhit.push_back(erasedIter->zhit);
1434 vyhit.push_back(erasedIter->yhit);
1435 vtot.push_back(erasedIter->tot);
1436 vindex2BTofHit.push_back(erasedIter->index2BTofHit);
1437 vtheta.push_back(erasedIter->theta);
1439 erasedVec.erase(erasedIter);
1447 cellHit.tray = vtray[0];
1448 cellHit.module = vmodule[0];
1449 cellHit.cell = vcell[0];
1450 cellHit.trackIdVec.push_back(vTrackId[0]);
1451 cellHit.hitPosition = vPosition[0];
1452 cellHit.matchFlag = 1;
1453 cellHit.zhit = vzhit[0];
1454 cellHit.yhit = vyhit[0];
1455 cellHit.tot = vtot[0];
1456 cellHit.index2BTofHit = vindex2BTofHit[0];
1457 cellHit.theta = vtheta[0];
1459 FinalMatchedCellsVec.push_back(cellHit);
1463 LOG_DEBUG <<
"E: itray=" << cellHit.tray <<
" imodule=" << cellHit.module <<
" icell=" << cellHit.cell <<
"\ttrackid:";
1464 idVectorIter ij=vTrackId.begin();
1465 while (ij != vTrackId.end()) { LOG_DEBUG <<
" " << *ij; ij++; }
1471 Int_t thiscandidate(-99);
1472 Int_t thisMatchFlag(0);
1476 vector<Int_t> ttCandidates;
1477 for (Int_t i=0;i<nCells;i++) {
1478 Double_t tt = vtot[i];
1479 if(tt<40.&&tt>tot) {
1481 ttCandidates.clear();
1482 ttCandidates.push_back(i);
1483 }
else if (tt==tot) {
1484 ttCandidates.push_back(i);
1487 if (ttCandidates.size()==1) {
1488 thiscandidate = ttCandidates[0];
1490 }
else if (ttCandidates.size()>1) {
1492 vector<Int_t> ssCandidates;
1493 for(
size_t j=0;j<ttCandidates.size();j++) {
1494 Float_t yy = vyhit[ttCandidates[j]];
1495 Float_t ycell = (vcell[ttCandidates[j]]-1-2.5)*mWidthPad;
1496 Float_t ll = fabs(yy-ycell);
1499 ssCandidates.clear();
1500 ssCandidates.push_back(ttCandidates[j]);
1502 ssCandidates.push_back(ttCandidates[j]);
1504 if (ssCandidates.size()==1){
1505 thiscandidate = ssCandidates[0];
1510 if (thiscandidate>=0) {
1511 cellHit.tray = vtray[thiscandidate];
1512 cellHit.module = vmodule[thiscandidate];
1513 cellHit.cell = vcell[thiscandidate];
1514 cellHit.trackIdVec.push_back(vTrackId[thiscandidate]);
1515 cellHit.hitPosition = vPosition[thiscandidate];
1516 cellHit.matchFlag = thisMatchFlag;
1517 cellHit.zhit = vzhit[thiscandidate];
1518 cellHit.yhit = vyhit[thiscandidate];
1519 cellHit.tot = vtot[thiscandidate];
1520 cellHit.index2BTofHit = vindex2BTofHit[thiscandidate];
1521 cellHit.theta = vtheta[thiscandidate];
1523 FinalMatchedCellsVec.push_back(cellHit);
1526 if(Debug()) { LOG_DEBUG <<
"E: itray=" << cellHit.tray <<
" imodule=" << cellHit.module <<
" icell=" << cellHit.cell <<
"\ttrackid:" << vTrackId[thiscandidate] << endm; }
1530 LOG_WARN <<
"E: no cells belong to this track ... should not happen!" << endm;
1533 tempVec = erasedVec;
1536 if(Debug()) { LOG_INFO <<
"E: before/after: " << singleHitCellsVec.size() <<
"/" << FinalMatchedCellsVec.size() << endm; }
1538 if (doPrintCpuInfo) {
1540 LOG_INFO <<
"CPU time after Step E - sorting : "
1541 << timer.elapsedTime() <<
" sec" << endm;
1549 if(FinalMatchedCellsVec.size()) mEventCounterHisto->Fill(10);
1550 mCellsPerEventMatch3->Fill(FinalMatchedCellsVec.size());
1554 Int_t nValidSingleHitCells(0), nValidSinglePrimHitCells(0);
1556 for (
size_t ii=0; ii < FinalMatchedCellsVec.size(); ii++){
1557 Int_t tray = FinalMatchedCellsVec[ii].tray;
1558 Int_t module = FinalMatchedCellsVec[ii].module;
1559 Int_t cell = FinalMatchedCellsVec[ii].cell;
1561 Float_t ycenter = (cell-1-2.5)*mWidthPad;
1562 Float_t dy = FinalMatchedCellsVec[ii].yhit - ycenter;
1563 Float_t dz = FinalMatchedCellsVec[ii].zhit;
1564 if (FinalMatchedCellsVec[ii].trackIdVec.size()!=1)
1565 LOG_WARN <<
"F: WHAT!?! mult.matched cell in single cell list " << tray <<
" " << module <<
" " << cell << endm;
1568 mTracksPerCellMatch3->Fill(FinalMatchedCellsVec[ii].trackIdVec.size());
1570 mDeltaHitMatch3->Fill(dy, dz);
1571 mDeltaHitFinal[tray-1]->Fill(dy,dz);
1575 int trackNode = FinalMatchedCellsVec[ii].trackIdVec[0];
1578 LOG_WARN <<
"Wrong global track!" << endm;
1584 if(tofHit->tray()!=tray || tofHit->module()!=module || tofHit->cell()!=cell) {
1585 LOG_WARN <<
"Wrong hit in the MuBTofHit!" << endm;
1588 nValidSingleHitCells++;
1591 tofHit->setAssociatedTrackId(globalTrack->
id());
1592 tofHit->setIndex2Global(trackNode);
1593 globalTrack->setIndex2BTofHit(FinalMatchedCellsVec[ii].index2BTofHit);
1595 int ip = index2Primary[trackNode];
1598 nValidSinglePrimHitCells++;
1599 tofHit->setIndex2Primary(ip);
1600 primaryTrack = (
StMuTrack *)mMuDst->
array(muPrimary)->UncheckedAt(ip);
1602 primaryTrack->setIndex2BTofHit(FinalMatchedCellsVec[ii].index2BTofHit);
1608 pidTof.setMatchFlag(FinalMatchedCellsVec[ii].matchFlag);
1609 pidTof.setYLocal(dy);
1610 pidTof.setZLocal(FinalMatchedCellsVec[ii].zhit);
1611 pidTof.setPosition(FinalMatchedCellsVec[ii].hitPosition);
1612 pidTof.setThetaLocal(FinalMatchedCellsVec[ii].theta);
1613 globalTrack->setBTofPidTraits(pidTof);
1617 ppidTof.setMatchFlag(FinalMatchedCellsVec[ii].matchFlag);
1618 ppidTof.setYLocal(dy);
1619 ppidTof.setZLocal(FinalMatchedCellsVec[ii].zhit);
1620 ppidTof.setPosition(FinalMatchedCellsVec[ii].hitPosition);
1621 ppidTof.setThetaLocal(FinalMatchedCellsVec[ii].theta);
1622 primaryTrack->setBTofPidTraits(ppidTof);
1628 mCellsPrimaryPerEventMatch3->Fill(nValidSinglePrimHitCells);
1631 if(Debug()) { LOG_INFO <<
"F: before/after" << FinalMatchedCellsVec.size() <<
"/" <<nValidSinglePrimHitCells << endm; }
1633 if (doPrintCpuInfo) {
1635 LOG_INFO <<
"CPU time after Step F - final : "
1636 << timer.elapsedTime() <<
" sec" << endm;
1640 LOG_INFO <<
" #(daq hits): " << daqCellsHitVec.size()
1641 <<
"\t#(proj hits): " << allCellsHitVec.size()
1642 <<
"\t#(prim proj hits): " << nPrimaryHits
1643 <<
"\n#(matched hits): " << FinalMatchedCellsVec.size()
1644 <<
"\n#(single valid hits): " << nValidSingleHitCells
1645 <<
"\t#(single prim valid hits): " << nValidSinglePrimHitCells
1648 if (doPrintMemoryInfo) {
1649 StMemoryInfo::instance()->snapshot();
1650 StMemoryInfo::instance()->print();
1652 if (doPrintCpuInfo) {
1654 LOG_INFO <<
"CPU time for StBTofMatchMaker::Make(): "
1655 << timer.elapsedTime() <<
" sec" << endm;
1658 LOG_INFO <<
"StBTofMatchMaker -- bye-bye" << endm;
1665 void StBTofMatchMaker::bookHistograms(
void){
1667 mEventCounterHisto =
new TH1D(
"eventCounter",
"eventCounter",20,0,20);
1669 mCellsMultInEvent =
new TH1D(
"cellsPerEvent",
"cellsPerEvent",1000,0,1000);
1670 mHitsMultInEvent =
new TH1D(
"hitsPerEvent",
"hitsPerEvent",1000,0,1000);
1671 mHitsPrimaryInEvent =
new TH1D(
"hitsPrimaryPerEvent",
"hitsPrimaryPerEvent",1000,0,1000);
1672 mHitsMultPerTrack =
new TH1D(
"hitsPerTrack",
"hitsPerTrack",10,0,10);
1673 mHitsPosition =
new TH2D(
"hitsPosition",
"hitsPositions",300,-15.,15.,200,-5.,5.);
1676 for(
int i=0;i<mNTray;i++) {
1678 sprintf(hisname,
"Occupancy_Tray_%d",i+1);
1679 mDaqOccupancy[i] =
new TH1D(hisname,
"",192,0,192);
1680 sprintf(hisname,
"OccupancyProj_Tray_%d",i+1);
1681 mDaqOccupancyProj[i] =
new TH1D(hisname,
"",192,0,192);
1685 for(
int i=0;i<mNTray;i++) {
1687 sprintf(hisname,
"Corr_Tray_%d",i+1);
1688 mHitCorr[i] =
new TH2D(hisname,
"",192,0,192,192,0,192);
1689 sprintf(hisname,
"Corr_Tray_%d_module",i+1);
1690 mHitCorrModule[i] =
new TH2D(hisname,
"",32,0,32,32,0,32);
1694 for(
int i=0;i<mNTray;i++) {
1696 sprintf(hisname,
"LocalYZ_Tray_%d",i+1);
1697 mDeltaHitFinal[i] =
new TH2D(hisname,
"",300,-15.,15.,200,-5.,5.);
1702 mTrackTree =
new TTree(
"track",
"track");
1703 mTrackTree->Branch(
"pt",&trackTree.pt,
"pt/F");
1704 mTrackTree->Branch(
"eta",&trackTree.eta,
"eta/F");
1705 mTrackTree->Branch(
"phi",&trackTree.phi,
"phi/F");
1706 mTrackTree->Branch(
"nfitpts",&trackTree.nfitpts,
"nfitpts/I");
1707 mTrackTree->Branch(
"dEdx",&trackTree.dEdx,
"dEdx/F");
1708 mTrackTree->Branch(
"ndEdxpts",&trackTree.ndEdxpts,
"ndEdxpts/I");
1709 mTrackTree->Branch(
"charge",&trackTree.charge,
"charge/I");
1710 mTrackTree->Branch(
"projTrayId",&trackTree.projTrayId,
"projTrayId/I");
1711 mTrackTree->Branch(
"projCellChan",&trackTree.projCellChan,
"projCellChan/I");
1712 mTrackTree->Branch(
"projY",&trackTree.projY,
"projY/F");
1713 mTrackTree->Branch(
"projZ",&trackTree.projZ,
"projZ/F");
1716 mTrackPtEta =
new TH2D(
"trackPtEta",
"",100,0.,5.,60,-1.5,1.5);
1718 mTrackPtPhi =
new TH2D(
"trackPtPhi",
"",100,0.,5.,120,0.,2.*M_PI);
1719 mTrackNFitPts =
new TH1D(
"trackNFitPts",
"",50,0.,50.);
1720 mTrackdEdxvsp =
new TH2D(
"trackdEdxvsp",
"",500,0.,5.,1000,0.,10.);
1721 mNSigmaPivsPt =
new TH2D(
"nSigmaPivsPt",
"",500,0.,5.,1000,-10.,10.);
1724 mCellsPerEventMatch1 =
new TH1D(
"cellsPerEventMatch1",
"cellPerEventMatch1",100,0,100);
1725 mHitsPerEventMatch1 =
new TH1D(
"hitsPerEventMatch1",
"hitsPerEventMatch1",100,0,100);
1726 mCellsPerTrackMatch1 =
new TH1D(
"cellsPerTrackMatch1",
"cellsPerTrackMatch1",100,0,100);
1727 mTracksPerCellMatch1 =
new TH1D(
"tracksPerCellMatch1",
"tracksPerCellMatch1",100,0,100);
1728 mDeltaHitMatch1 =
new TH2D(
"deltaHitMatch1",
"deltaHitMatch1",300,-15,15,200,-5.,5.);
1731 mCellsPerEventMatch2 =
new TH1D(
"cellsPerEventMatch2",
"cellPerEventMatch2",100,0,100);
1732 mHitsPerEventMatch2 =
new TH1D(
"hitsPerEventMatch2",
"hitsPerEventMatch2",100,0,100);
1733 mCellsPerTrackMatch2 =
new TH1D(
"cellsPerTrackMatch2",
"cellsPerTrackMatch2",100,0,100);
1734 mTracksPerCellMatch2 =
new TH1D(
"tracksPerCellMatch2",
"tracksPerCellMatch2",100,0,100);
1735 mDeltaHitMatch2 =
new TH2D(
"deltaHitMatch2",
"deltaHitMatch2",300,-15,15,200,-5.,5.);
1738 mCellsPerEventMatch3 =
new TH1D(
"cellsPerEventMatch3",
"cellsPerEventMatch3",100,0,100);
1739 mHitsPerEventMatch3 =
new TH1D(
"hitsPerEventMatch3",
"hitsPerEventMatch3",100,0,100);
1740 mCellsPerTrackMatch3 =
new TH1D(
"cellsPerTrackMatch3",
"cellsPerTrackMatch3",100,0,100);
1741 mTracksPerCellMatch3 =
new TH1D(
"tracksPerCellMatch3",
"tracksPerCellMatch3",100,0,100);
1742 mDeltaHitMatch3 =
new TH2D(
"deltaHitMatch3",
"deltaHitMatch3",300,-15,15,200,-5.,5.);
1744 mCellsPrimaryPerEventMatch3 =
new TH1D(
"cellsPrimaryPerEventMatch3",
"cellsPrimaryPerEventMatch3",100,0,100);
1752 void StBTofMatchMaker::writeHistogramsToFile(){
1754 TFile *theHistoFile =
new TFile(mHistoFileName.c_str(),
"RECREATE");
1755 LOG_INFO <<
"StBTofMatchMaker::writeHistogramsToFile()"
1756 <<
" histogram file " << mHistoFileName << endm;
1763 for(
int i=0;i<mNTray;i++) {
1764 mDaqOccupancy[i]->Write();
1765 mDaqOccupancyProj[i]->Write();
1766 mHitCorr[i]->Write();
1767 mHitCorrModule[i]->Write();
1768 mDeltaHitFinal[i]->Write();
1771 mEventCounterHisto->Write();
1772 mCellsMultInEvent->Write();
1773 mHitsMultInEvent->Write();
1774 mHitsPrimaryInEvent->Write();
1775 mHitsMultPerTrack->Write();
1776 mHitsPosition->Write();
1778 mTrackPtEta->Write();
1779 mTrackPtPhi->Write();
1780 mTrackNFitPts->Write();
1781 mTrackdEdxvsp->Write();
1782 mNSigmaPivsPt->Write();
1784 mCellsPerEventMatch1->Write();
1785 mHitsPerEventMatch1->Write();
1786 mCellsPerTrackMatch1->Write();
1787 mTracksPerCellMatch1->Write();
1788 mDeltaHitMatch1->Write();
1790 mCellsPerEventMatch2->Write();
1791 mHitsPerEventMatch2->Write();
1792 mCellsPerTrackMatch2->Write();
1793 mTracksPerCellMatch2->Write();
1794 mDeltaHitMatch2->Write();
1796 mCellsPerEventMatch3->Write();
1797 mHitsPerEventMatch3->Write();
1798 mCellsPerTrackMatch3->Write();
1799 mTracksPerCellMatch3->Write();
1800 mDeltaHitMatch3->Write();
1802 mCellsPrimaryPerEventMatch3->Write();
1804 theHistoFile->Write();
1805 theHistoFile->Close();
1810 TFile *theTreeFile =
new TFile((mHistoFileName+
".tree.root").c_str(),
"RECREATE");
1812 mTrackTree->Write();
1813 theTreeFile->Write();
1814 theTreeFile->Close();
1824 if (!track)
return false;
1827 if (track->flag()<=0 || track->flag()>=1000)
return false;
1832 if (track->fitTraits().numberOfFitPoints(kTpcId) < mMinFitPointsPerTrack)
return false;
1835 float ratio = (float)track->fitTraits().numberOfFitPoints(kTpcId) / (1.0*track->numberOfPossiblePoints(kTpcId));
1836 if (ratio < mMinFitPointsOverMax)
return false;
1843 bool StBTofMatchMaker::validTrack(
StMuTrack *track){
1845 if (!track)
return false;
1848 if (track->
flag()<=0 || track->
flag()>=1000)
return false;
1853 if (track->
nHitsFit(kTpcId) < mMinFitPointsPerTrack)
return false;
1857 if (ratio < mMinFitPointsOverMax)
return false;
1866 if (!track)
return 0;
1868 if (mOuterTrackGeometry)
1869 thisTrackGeometry = track->outerGeometry();
1871 thisTrackGeometry = track->geometry();
1872 return thisTrackGeometry;
void setMaxDCA(Float_t)
set maximum distance of closest approach
Bool_t HelixCrossCellIds(const StHelixD &helix, IntVec &idVec, DoubleVec &pathVec, PointVec &crossVec) const
static StMuBTofHit * btofHit(int i)
returns pointer to the i-th muBTofHit
static TObjArray * globalTracks()
returns pointer to the global tracks list
Int_t index2Global() const
Returns index of associated global track. If not in order can be set with StMuDst::fixTrackIndeces() ...
void setAlignFileName(const Char_t *infile="")
input file for alignment parameters
Int_t Make()
Main match algorithm.
short id() const
Returns the track id(or key), is unique for a track node, i.e. global and primary tracks have the sam...
double x(double s) const
coordinates of helix at point s
UShort_t nHitsDedx() const
Return number of hits used for dEdx.
void setMinHitsPerTrack(Int_t)
set minimum hits per track
void setMinFitPointsPerTrack(Int_t)
set minimum fit points per track
Int_t Finish()
Print run summary, and write QA histograms.
Int_t Init()
process start-up options
void setCreateTreeFlag(Bool_t tree=kTRUE)
enable track-tree filling
StPhysicalHelixD helix() const
Returns inner helix (first measured point)
UShort_t nHitsFit() const
Return total number of hits used in fit.
Int_t InitRun(Int_t)
initialize DaqMap, Geometry, and INL
short flag() const
Returns flag, (see StEvent manual for type information)
Short_t charge() const
Returns charge.
void setOuterTrackGeometry()
selection of inner or outer geometry. By default - outerGeometry
void setHistoFileName(const Char_t *)
set histogram output file name
Double_t nSigmaPion() const
Returns Craig's distance to the calculated dE/dx band for pions in units of sigma.
void setSaveGeometry(const Bool_t geomSave=kFALSE)
save geometry if it will be used by following makers in the chain
UShort_t nHitsPoss() const
Return number of possible hits on track.
const StThreeVectorF & momentum() const
Returns 3-momentum at dca to primary vertex.
Double_t dEdx() const
Returns measured dE/dx value.
void setMinFitPointsOverMax(Float_t)
set minimum fit-points/max-points ratio
StBTofMatchMaker(const Char_t *name="btofMatch")
Default constructor.
static TClonesArray * array(int type)
returns pointer to the n-th TClonesArray
void setCreateHistoFlag(Bool_t histos=kTRUE)
enable QA histogram filling
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)