12 #include "StMessMgr.h"
13 #include "TGraphErrors.h"
19 #include "tables/St_g2t_vertex_Table.h"
21 #include "StPPVertexFinder.h"
22 #include <StEventTypes.h>
23 #include "TrackData.h"
24 #include "VertexData.h"
26 #include "StGenericVertexMaker.h"
27 #include "St_VertexCutsC.h"
29 #include "StEventToolkit.h"
30 #include "StEvent/StGlobalTrack.h"
31 #include "StEvent/StContainers.h"
33 #include "St_db_Maker/St_db_Maker.h"
34 #include "StIOMaker/StIOMaker.h"
35 #include "StBFChain/StBFChain.h"
37 #include "TGeoManager.h"
39 #define xL(t) (t->getX())
40 #define yL(t) (t->getY())
41 #define eyL(t) sqrt(t->getCyy())
42 #define zL(t) (t->getZ())
43 #define ezL(t) sqrt(t->getCzz())
44 #define rxyL(t) sqrt(xL(t)*xL(t) + yL(t)*yL(t))
45 #define xG(t) (t->x_g())
46 #define yG(t) (t->y_g())
47 #define zG(t) (t->z_g())
48 #define rxyG(t) sqrt(xG(t)*xG(t) + yG(t)*yG(t))
50 #include "StEEmcUtil/database/StEEmcDb.h"
51 #include "StEEmcUtil/database/EEmcDbItem.h"
52 #include "StEEmcUtil/database/cstructs/eemcConstDB.hh"
53 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
55 #include "BtofHitList.h"
56 #include "CtbHitList.h"
57 #include "BemcHitList.h"
58 #include "EemcHitList.h"
60 #include "StEmcCollection.h"
61 #include "StBTofCollection.h"
62 #include "StBTofUtil/StBTofGeometry.h"
63 #include "TObjectSet.h"
65 enum { kImpImp=0, kZZ = 2 ,kPsiImp=3, kPsiPsi=5 };
66 enum { RxyMin=59, RxyMax=199, zMax=200,zMembraneDepth=1,nWrongZHitCut=2};
70 Float_t mPsiImp, mPsiZ, mPsiPsi;
71 Float_t mPtiImp, mPtiZ, mPtiPsi, mPtiPti;
72 Float_t mTanImp, mTanZ, mTanPsi, mTanPti, mTanTan;
78 StPPVertexFinder::StPPVertexFinder()
83 memset(hA,0,
sizeof(hA));
87 setDropPostCrossingTrack(
true);
93 mAlgoSwitches|=kSwitchOneHighPT;
100 hL=
new TH1D(
"ppvL",
"Vertex likelyhood; Z /cm",nb,-zRange,zRange);
102 hM=
new TH1D(
"ppvM",
"cumulative track multiplicity; Z /cm",nb,-zRange,zRange);
103 hW=
new TH1D(
"ppvW",
"cumulative track weight; Z /cm",nb,-zRange,zRange);
110 void StPPVertexFinder::Init()
113 LOG_INFO << Form(
"PPV-algo switches=0x%0x, following cuts have been activated:",mAlgoSwitches)<<endm;
115 mStoreUnqualifiedVertex=5;
116 mFitPossWeighting=
false;
119 mToolkit = StEventToolkit::instance();
129 eeDb = (
StEEmcDb*)StMaker::GetChain()->GetDataSet(
"StEEmcDb");
131 LOG_INFO <<
"eeDb done" <<endm;
134 unsigned int killStatEEmc=EEMCSTAT_ONLPED | EEMCSTAT_STKBT| EEMCSTAT_HOTHT | EEMCSTAT_HOTJP | EEMCSTAT_JUMPED ;
135 eemcList =
new EemcHitList(eeDb, killStatEEmc,geomE);
137 HList=
new TObjArray(0);
139 LOG_INFO <<
"initiated histos" << endm;
141 btofList->initHisto( HList);
142 ctbList->initHisto( HList);
143 bemcList->initHisto( HList);
144 eemcList->initHisto( HList);
145 LOG_INFO <<
"Finished Init" << endm;
150 void StPPVertexFinder::InitRun(
int runnumber)
152 LOG_INFO <<
"PPV InitRun() runNo="<<runnumber<<endm;
154 int dateY=mydb->GetDateTime().GetYear();
162 LOG_INFO <<
" Found btofGeometry ... " << endm;
164 btofGeom =
new StBTofGeometry(
"btofGeometry",
"btofGeometry in VertexFinder");
165 geom =
new TObjectSet(
"btofGeometry",btofGeom);
166 LOG_INFO <<
" Create a new btofGeometry ... " << endm;
167 mydb->AddConst(geom);
169 if(btofGeom && !btofGeom->IsInitDone()) {
170 LOG_INFO <<
" BTofGeometry initialization ... " << endm;
171 TVolume *starHall = gGeoManager ?
nullptr : (
TVolume *) (mydb->GetDataSet(
"HALL"));
172 btofGeom->Init(mydb, starHall, gGeoManager);
181 if (runnumber >= 6000000 && runnumber < 13000000) {
184 LOG_INFO <<
"PPV InitRun() using old, hardwired cuts" << endm;
192 mMaxTrkDcaRxy = vtxCuts->RImpactMax();
193 mMinTrkPt = vtxCuts->MinTrackPt();
194 mMinFitPfrac = vtxCuts->MinFracOfPossFitPointsOnTrack();
195 mMaxZradius = vtxCuts->DcaZMax();
196 mMinMatchTr = vtxCuts->MinTrack();
197 mFitPossWeighting =
true;
221 vertex3D->setCuts(0.8,8.0, 3.3,5);
222 vertex3D->initHisto( HList);
229 <<
"\n MinNumberOfFitPointsOnTrack = unused"
230 <<
"\n MinFitPfrac=nFit/nPos = " << mMinFitPfrac
231 <<
"\n MaxTrkDcaRxy/cm= " << mMaxTrkDcaRxy
232 <<
"\n MinTrkPt GeV/c = " << mMinTrkPt
233 <<
"\n MinMatchTr of prim tracks = " << mMinMatchTr
234 <<
"\n MaxZrange (cm)for glob tracks = " << mMaxZrange
235 <<
"\n MaxZradius (cm) for prim tracks &Likelihood = " << mMaxZradius
236 <<
"\n DeltaY (cm) for BTOF local posision = "<< mDyBtof
237 <<
"\n Min/Max Z position for BTOF hit = " << mMinZBtof<<
" "<<mMaxZBtof
238 <<
"\n MinAdcBemc for MIP = " << mMinAdcBemc
239 <<
"\n MinAdcEemc for MIP = " << mMinAdcEemc
240 <<
"\n bool useCtb = " << mUseCtb
241 <<
"\n bool useBtof = " << mUseBtof
242 <<
"\n bool nFit/nPoss weighting = " << mFitPossWeighting
243 <<
"\n bool DropPostCrossingTrack = " << mDropPostCrossingTrack
244 <<
"\n Store # of UnqualifiedVertex = " << mStoreUnqualifiedVertex
245 <<
"\n Store="<<(mAlgoSwitches & kSwitchOneHighPT) <<
246 " oneTrack-vertex if track PT/GeV>"<< mCut_oneTrackPT
247 <<
"\n dump tracks for beamLine study = " << mBeamLineTracks
256 void StPPVertexFinder::initHisto()
259 hA[0]=
new TH1F(
"ppvStat",
"event types; 1=inp, 2=trg, 3=-, 4=w/trk, 5=anyMch, 6=Bmch 7=Emch 8=anyV, 9=mulV",10,0.5,10.5);
260 hA[1]=
new TH1F(
"ch1",
"chi2/Dof, ppv pool tracks",100,0,10);
261 hA[2]=
new TH1F(
"nP",
"No. of fit points, ppv pool tracks",30,-.5,59.5);
262 hA[3]=
new TH1F(
"zV",
"reconstructed vertices ; Z (cm)",100,-200,200);
263 hA[4]=
new TH1F(
"nV",
"No. of vertices per eve",20,-0.5,19.5);
265 hA[5]=
new TH1F(
"rxyDca",
"Rxy to beam @ DCA ; (cm)",40,-0.1,3.9);
266 hA[6]=
new TH1F(
"nTpcM",
"No. tracks: tpcMatch /eve ",60,-.5,59.5);
267 hA[7]=
new TH1F(
"nTpcV",
"No. tracks: tpcVeto /eve ",60,-.5,59.5);
271 hA[9]=
new TH1F(
"zDca",
"Z DCA for all accepted tracks; Z (cm)",100,-200,200);
273 hA[10]=
new TH1F(
"zCtb",
"Z @CTB for all accepted tracks; Z (cm)",50,-250,250);
274 hA[11]=
new TH1F(
"zBemc",
"Z @Bemc for all accepted tracks; Z (cm)",100,-400,400);
275 hA[12]=
new TH1F(
"dzVerTr",
"zVerGeant - zDca of tracks used by any vertex ; (cm)",100,-5,5);
276 hA[13]=
new TH1F(
"dzVerVer",
"zVerGeant - best reco vertex ; (cm)",100,-5,5);
278 hA[14]=
new TH1F(
"EzDca",
"Error of Z DCA for all accepted tracks; Z (cm)",100,-0.,4);
279 hA[15]=
new TH1F(
"nTpcT",
"No. tracks: accepted Dca /eve ",201,-.5,200.5);
280 hA[16]=
new TH1F(
"ptTr",
"pT, ppv pool tracks; pT (GeV/c) ",50,0.,10.);
281 hA[17]=
new TH1F(
"vRL",
"PPV Vertex rank, 'funny' X-axis; X=Log10(rank-1e6)+offset", 150, -11,25);
283 hACorr=
new TH2F(
"BTOFvsBEMC",
"BTOF vs BEMC", 5,-2.5,2.5,5,-2.5,2.5);
286 for(i=0;i<mxH; i++)
if(hA[i]) HList->Add(hA[i]);
292 void StPPVertexFinder::Clear()
294 LOG_DEBUG <<
"PPVertex::Clear nEve="<<mTotEve<< endm;
295 StGenericVertexFinder::Clear();
315 StPPVertexFinder::~StPPVertexFinder()
325 void StPPVertexFinder::printInfo(ostream& os)
const
327 os <<
"StPPVertexFinder ver=1 - Fit Statistics:" << endl;
329 os <<
"StPPVertexFinder::result "<<mVertexData.size()<<
" vertices found\n" << endl;
331 int nTpcM=0, nTpcV=0;
334 for(i=0;i<mTrackData.size();i++) {
336 if( t->mTpc>0) nTpcM++;
337 else if ( t->mTpc<0) nTpcV++;
338 hA[9]->Fill(t->zDca);
339 hA[14]->Fill(t->ezDca);
344 Form(
"%d track@z0=%.2f +/- %.2f gPt=%.3f vertID=%d match: bin,Fired,Track:\n",
345 k,t->zDca,t->ezDca,t->gPt,t->
vertexID)
346 << Form(
" Btof %3d,%d,%d",t->btofBin,btofList->getFired(t->btofBin),btofList->getTrack(t->btofBin))
347 << Form(
" CTB %3d,%d,%d",t->ctbBin,ctbList->getFired(t->ctbBin),ctbList->getTrack(t->ctbBin))
348 << Form(
" Bemc %3d,%d,%d",t->bemcBin,bemcList->getFired(t->bemcBin),bemcList->getTrack(t->bemcBin))
349 << Form(
" Eemc %3d,%d,%d",t->eemcBin,eemcList->getFired(t->eemcBin),bemcList->getTrack(t->bemcBin))
350 << Form(
" TPC %d",t->mTpc)
355 hA[15]->Fill(mTrackData.size());
357 LOG_INFO<< Form(
"PPVend eveID=%d, list of found %d vertices from pool of %d tracks\n",eveID,mVertexData.size(),mTrackData.size())<<endm;
358 for(i=0;i<mVertexData.size();i++) {
363 LOG_DEBUG<< Form(
"---- end of PPVertex Info\n")<<endm;
370 int StPPVertexFinder::fit(
StEvent* event) {
371 LOG_INFO <<
"***** START FIT" << endm;
372 if(mBeamLineTracks) vertex3D->clearEvent();
376 StEventToolkit::instance()->SetEvent(event);
379 LOG_INFO <<
"\n @@@@@@ PPVertex::Fit START nEve="<<mTotEve<<
" eveID="<<eveID<< endm;
381 TString tt=
"Vertex likelyhood, eveID=";
388 LOG_WARN <<
"no Sti tool kit, PPV is OFF"<<endm;
397 LOG_WARN <<
"no btofCollection , continue THE SAME eve"<<endm;
399 btofList->build(btofColl);
406 ctbList->buildFromData(trgD);
412 LOG_WARN <<
"no emcCollection , continue THE SAME eve"<<endm;
417 LOG_WARN <<
"no BEMC in emcColl , continue THE SAME eve"<<endm;
420 bemcList->build(btow, mMinAdcBemc);
425 LOG_WARN <<
"no EEMC in emcColl , continue THE SAME eve"<<endm;
428 eemcList->build(etow, mMinAdcEemc);
433 const StSPtrVecTrackNode* tracks = mToolkit->getTrackContainer();
435 LOG_WARN <<
"no STi tracks , skip eve"<<endm;
444 int kBtof=0,kCtb=0,kBemc=0, kEemc=0,kTpc=0;
447 int ntrk[7];
for(
int i=0; i<7; i++) ntrk[i]=0;
449 int nTk = tracks->size();
450 for (
int it=0; it<nTk; ++it)
454 if (!track->dcaGeometry())
continue;
458 if(track->flag()<0) {ntrk[1]++;
continue;}
460 double myPt = track->dcaGeometry()->pt();
461 if(myPt<mMinTrkPt) {ntrk[2]++;
continue;}
462 if(mDropPostCrossingTrack){
463 if(isPostCrossingTrack(track)) {ntrk[3]++;
continue;}
465 if(!examinTrackDca(track,t)) {ntrk[4]++;
continue;}
466 if(!matchTrack2Membrane(track,t)) {ntrk[5]++;
continue;}
472 hA[ 1]->Fill(track->fitTraits().chi2());
473 hA[ 2]->Fill(track->fitTraits().numberOfFitPoints());
478 if(mUseBtof) matchTrack2BTOF(track,t,btofGeom);
479 if(mUseCtb) matchTrack2CTB(track,t);
480 matchTrack2BEMC(track,t,242);
481 matchTrack2EEMC(track,t,288);
484 mTrackData.push_back(t);
486 hA[5]->Fill(t.rxyDca);
488 if( t.mBtof>0 ) kBtof++;
489 if( t.mCtb>0 ) kCtb++;
490 if( t.mBemc>0) kBemc++;
491 if( t.mEemc>0) kEemc++;
492 if( t.mTpc>0 ) kTpc++;
494 if(t.mBtof>0 || t.mCtb>0 || t.mBemc>0 || t.mEemc>0 || t.mTpc>0 ) nmAny++ ;
496 hACorr->Fill(t.mBtof, t.mBemc);
500 LOG_INFO<< Form(
"PPV:: # of input track = %d",ntrk[0])<<endm;
501 LOG_INFO<< Form(
"PPV:: dropped due to flag = %d",ntrk[1])<<endm;
502 LOG_INFO<< Form(
"PPV:: dropped due to pt = %d",ntrk[2])<<endm;
503 LOG_INFO<< Form(
"PPV:: dropped due to PCT check = %d",ntrk[3])<<endm;
504 LOG_INFO<< Form(
"PPV:: dropped due to DCA check = %d",ntrk[4])<<endm;
505 LOG_INFO<< Form(
"PPV:: dropped due to NHit check = %d",ntrk[5])<<endm;
506 LOG_INFO<< Form(
"PPV:: # of track after all cuts = %d",ntrk[6])<<endm;
520 LOG_INFO<< Form(
"PPV::TpcList size=%d nMatched=%d\n\n",mTrackData.size(),kTpc)<<endm;
525 LOG_INFO <<
"PPV::fit() nEve="<<mTotEve<<
" , "<<nmAny<<
" traks with good DCA, matching: BTOF="<<kBtof<<
" CTB="<<kCtb<<
" BEMC="<<kBemc<<
" EEMC="<<kEemc<<endm;
528 if(nmAny<mMinMatchTr && mStoreUnqualifiedVertex<=0){
529 LOG_INFO <<
"StPPVertexFinder::fit() nEve="<<mTotEve<<
" Quit, to few matched tracks"<<endm;
535 if(kBemc) hA[0]->Fill(6);
536 if(kEemc) hA[0]->Fill(7);
542 const float par_rankOffset=1e6;
547 if(! buildLikelihoodZ() )
break;
550 if(! findVertexZ(V))
break;
552 bool trigV=evalVertexZ(V);
554 if(V.nAnyMatch>=mMinMatchTr) V.Lmax+=par_rankOffset;
556 if( nBadVertex>=mStoreUnqualifiedVertex)
continue;
562 V.Lmax-=par_rankOffset;
567 if(rank>1e6) hA[17]->Fill(log(rank-1e6)+10);
568 else if(rank>0) hA[17]->Fill(log(rank));
569 else hA[17]->Fill(log(rank+1e6)-10);
572 mVertexData.push_back(V);
573 if(trigV && mBeamLineTracks) vertex3D->study(V.r,eveID);
576 LOG_INFO <<
"StPPVertexFinder::fit(totEve="<<mTotEve<<
") "<<mVertexData.size()<<
" vertices found, nBadVertex=" <<nBadVertex<< endm;
578 if(mVertexData.size()>0) hA[0]->Fill(8);
579 if(mVertexData.size()>1) hA[0]->Fill(9);
584 hA[4]->Fill(mVertexData.size());
586 for(i=0;i<mVertexData.size();i++) {
588 hA[3]->Fill(V->r.z());
591 if(mVertexData.size()<=0) {
601 bool StPPVertexFinder::buildLikelihoodZ()
607 float dzMax2=mMaxZradius*mMaxZradius;
609 int nt=mTrackData.size();
610 LOG_DEBUG<< Form(
"PPV::buildLikelihood() pool of nTracks=%d",nt)<<endm;
611 if(nt<=0)
return false;
616 double *La=hL->GetArray();
617 double *Ma=hM->GetArray();
618 double *Wa=hW->GetArray();
623 if(t->anyMatch) n1++;
628 int j1=hL->FindBin(z0-mMaxZradius-.1);
629 int j2=hL->FindBin(z0+mMaxZradius+.1);
630 float base=dzMax2/2/ez2;
631 float totW=t->weight;
635 for(j=j1;j<=j2;j++) {
636 float z=hL->GetBinCenter(j);
638 float xx=base-dz*dz/2/ez2;
648 LOG_DEBUG<< Form(
"PPV::buildLikelihood() %d tracks w/ matched @ Lmax=%f",n1,hL->GetMaximum())<<endm;
651 return (n1>=mMinMatchTr) || (mStoreUnqualifiedVertex>0 );
656 bool StPPVertexFinder::findVertexZ(
VertexData &V) {
658 if(hL->GetMaximum()<=0)
return false;
660 int iMax=hL-> GetMaximumBin();
661 float z0=hL-> GetBinCenter(iMax);
662 float Lmax=hL-> GetBinContent(iMax);
663 float accM=hM-> GetBinContent(iMax);
664 float accW=hW-> GetBinContent(iMax);
666 float avrW=accW/accM;
669 float Llow=0.9* Lmax;
670 if((Lmax-Llow)<8*avrW ) Llow=Lmax-8*avrW;
672 double *L=hL->GetArray();
674 int iLow=-1, iHigh=-1;
675 for(i=iMax;i<=hL->GetNbinsX();i++) {
676 if(L[i] >Llow)
continue;
680 for(i=iMax;i>=1;i--) {
681 if(L[i] >Llow)
continue;
686 float zLow=hL-> GetBinCenter(iLow);
687 float zHigh=hL-> GetBinCenter(iHigh);
689 float kSig= sqrt(2*(Lmax-Llow)/avrW);
690 float sigZ= (zHigh-zLow)/2/kSig;
691 LOG_DEBUG<< Form(
"PPV:: iLow/iMax/iHigh=%d/%d/%d\n",iLow,iMax,iHigh)
692 <<Form(
" accM=%f accW=%f avrW=%f\n",accM,accW,avrW)
693 <<Form(
" Z low/max/high=%f %f %f, kSig=%f, sig=%f\n",zLow,z0,zHigh,kSig,sigZ)
694 <<Form(
" found PPVertex(ID=%d,neve=%d) z0 =%.2f +/- %.2f\n",V.id,mTotEve,z0,sigZ)<<endm;
695 if(sigZ<0.1) sigZ=0.1;
699 V.er=TVector3(0.1,0.1,sigZ);
707 bool StPPVertexFinder::evalVertexZ(
VertexData &V) {
709 if(mBeamLineTracks) vertex3D->clearTracks();
710 int nt=mTrackData.size();
711 LOG_DEBUG <<
"StPPVertexFinder::evalVertex Vid="<<V.id<<
" start ..."<<endm;
718 if(! t->matchVertex(V,mMaxZradius))
continue;
723 if(mBeamLineTracks) vertex3D->addTrack(t);
724 if( t->gPt>mCut_oneTrackPT && ( t->mBemc>0|| t->mEemc>0) ) nHiPt++;
726 if( t->mTpc>0) V.nTpc++;
727 else if ( t->mTpc<0) V.nTpcV++;
729 if( t->mBtof>0) V.nBtof++;
730 else if ( t->mBtof<0) V.nBtofV++;
732 if( t->mCtb>0) V.nCtb++;
733 else if ( t->mCtb<0) V.nCtbV++;
735 if( t->mBemc>0) V.nBemc++;
736 else if ( t->mBemc<0) V.nBemcV++;
738 if( t->mEemc>0) V.nEemc++;
739 else if ( t->mEemc<0) V.nEemcV++;
741 if( t->anyMatch) V.nAnyMatch++;
742 else if (t->anyVeto) V.nAnyVeto++;
746 bool validVertex = V.nAnyMatch>=mMinMatchTr;
747 if((mAlgoSwitches & kSwitchOneHighPT) && ( nHiPt>0)) {
754 LOG_DEBUG <<
"StPPVertexFinder::evalVertex Vid="<<V.id<<
" rejected"<<endm;
763 LOG_INFO <<
"StPPVertexFinder::evalVertex Vid="<<V.id<<
" accepted, nAnyMatch="<<V.nAnyMatch<<
" nAnyVeto="<<V.nAnyVeto<<endm;
770 void StPPVertexFinder::exportVertices(){
771 if ( ! mVertexConstrain ){
773 LOG_FATAL <<
"StPPVertexFinder code is not ready for reco w/o beamLine" << endm;
774 assert(mVertexConstrain);
777 for(i=0;i<mVertexData.size();i++) {
782 memset(cov,0,
sizeof(cov));
783 cov[0]=V->er.x()*V->er.x();
784 cov[2]=V->er.y()*V->er.y();
785 cov[5]=V->er.z()*V->er.z();
788 primV.setPosition(r);
789 primV.setCovariantMatrix(cov);
791 if(mUseCtb) primV.setVertexFinderId(ppvVertexFinder);
792 else primV.setVertexFinderId(ppvNoCtbVertexFinder);
794 primV.setNumTracksUsedInFinder(V->nUsedTrack);
795 primV.setNumMatchesWithBTOF(V->nBtof);
796 primV.setNumMatchesWithCTB(V->nCtb);
797 primV.setNumMatchesWithBEMC(V->nBemc);
798 primV.setNumMatchesWithEEMC(V->nEemc);
799 primV.setNumTracksCrossingCentralMembrane(V->nTpc);
800 primV.setSumOfTrackPt(V->gPtSum);
801 primV.setRanking(V->Lmax);
807 LOG_DEBUG <<
"StPPVertexFinder::exportVertices(), size="<<size()<<endm;
812 void StPPVertexFinder::Finish()
815 if(mBeamLineTracks) {
821 const char *fname=ioMk->GetFileName();
822 tt=strstr(fname,
"st_");
823 tt.ReplaceAll(
".daq",
".ppv");
825 tt= ((
StBFChain*)StMaker::GetChain())->GetFileOut() ;
826 tt.ReplaceAll(
".root",
".ppv");
828 LOG_INFO <<
"PPV save local histo="<<tt<<endm;
829 saveHisto(tt.Data());
832 LOG_INFO <<
"StPPVertexFinder::Finish() done, seen eve=" <<mTotEve<< endm;
839 void StPPVertexFinder::saveHisto(TString fname){
840 TString outName=fname+
".hist.root";
841 TFile f( outName,
"recreate");
843 printf(
"%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
853 assert(0 &&
"dumpKalmanNodes");
866 if (!dcaGeo)
return false;
868 double rxy=dcaGeo->impact();
871 if(fabs(rxy) > mMaxTrkDcaRxy)
return false;
872 if(fabs(dcaGeo->z()) > mMaxZrange )
return false ;
874 const float *dcaErr = dcaGeo->errMatrix();
875 double impimp = dcaErr[kImpImp];
876 double psipsi = dcaErr[kPsiPsi];
877 double xyErr = (0.5*(impimp + rxy*rxy*psipsi));
882 t.ezDca=sqrt(dcaErr[kZZ]);
887 t.dcaTrack.R.SetXYZ(myXYZ.x(),myXYZ.y(),myXYZ.z());
891 t.dcaTrack.sigYloc=sqrt(xyErr);
892 t.dcaTrack.sigZ=t.ezDca;
895 t.dcaTrack.gP.SetXYZ(globP3.x(),globP3.y(),globP3.z());
897 t.dcaTrack.gChi2=track->fitTraits().chi2();
898 t.dcaTrack.nFitPoint=track->fitTraits().numberOfFitPoints();
918 for(
size_t i=0;i<idVec.size();i++) {
919 int itray, imodule, icell;
920 geom->DecodeCellId(idVec[i], icell, imodule, itray);
922 Double_t local[3], global[3];
923 for(
int j=0;j<3;j++) local[j] = 0;
924 global[0] = crossVec[i].x();
925 global[1] = crossVec[i].y();
926 global[2] = crossVec[i].z();
929 LOG_WARN <<
"no sensitive module in this projection??? - weird" << endm;
932 sensor->Master2Local(&global[0],&local[0]);
938 if(local[2]<mMinZBtof||local[2]>mMaxZBtof)
continue;
939 int iBin = btofList->cell2bin(itray, imodule, icell);
940 iBinVec.push_back(iBin);
941 btofList->addBtofTrack(itray, imodule, icell);
942 LOG_DEBUG <<
" !!! Push to the list ...tray/module/cell " << itray <<
"/" << imodule <<
"/" << icell << endm;
946 bool btofMatch=btofList->isMatched(iBinVec);
947 bool btofVeto =btofList->isVetoed(iBinVec);
948 float btofW =btofList->getWeight(iBinVec);
949 btofList->addBtofMatch(iBinVec);
951 LOG_DEBUG <<
" ** BTOF ** match/veto/weight = " << btofMatch <<
" " << btofVeto <<
" " << btofW << endm;
953 t.updateAnyMatch(btofMatch,btofVeto,t.mBtof);
955 t.btofBin= iBinVec.size() ? iBinVec[0] : -1;
962 const double Rctb=213.6;
970 if(d2.first>=0 || d2.second<=0) {
971 LOG_DEBUG <<Form(
"WARN MatchTrk , unexpected solution for track crossing CTB\n")<<
972 Form(
" d2.firts=%f, second=%f, try first", d2.first, d2.second)<<endm;
975 posCTB = hlx.at(path);
980 float phi=posCTB.phi();
981 if(phi<0) phi+=2*M_PI;
982 float eta=posCTB.pseudoRapidity();
984 if(fabs(eta)<1) hA[10]->Fill(posCTB.z());
986 int iBin=ctbList->addTrack(eta,phi);
988 bool ctbMatch=ctbList->isMatched(iBin);
989 bool ctbVeto =ctbList->isVetoed(iBin);
990 float ctbW =ctbList->getWeight(iBin);
992 t.updateAnyMatch(ctbMatch,ctbVeto,t.mCtb);
1008 if(d2.first>=0 || d2.second<=0) {
1009 LOG_DEBUG <<Form(
"WARN MatchTrk , unexpected solution for track crossing BEMC Cyl\n")<<
1010 Form(
" d2.firts=%f, second=%f, try first\n", d2.first, d2.second)<<endm;
1013 posCyl = hlx.at(path);
1017 float phi=posCyl.phi();
1018 if(phi<0) phi+=2*M_PI;
1019 float eta=posCyl.pseudoRapidity();
1023 if(fabs(eta)<1) hA[11]->Fill(posCyl.z());
1025 int iBin=bemcList->addTrack(eta,phi);
1026 bool bemcMatch=bemcList->isMatched(iBin);
1027 bool bemcVeto =bemcList->isVetoed(iBin);
1028 float bemcW =bemcList->getWeight(iBin);
1030 t.updateAnyMatch(bemcMatch,bemcVeto,t.mBemc);
1042 const float minEta=0.7 ;
1043 const float maxPath=200 ;
1050 if(dcaGeo->z() > outGeo->origin().z())
return;
1053 if(dcaGeo->momentum().pseudoRapidity() < minEta)
return;
1060 if(path>maxPath)
return;
1063 float periodL=hlx. period();
1065 if(periodL<2*path) {
1066 LOG_DEBUG <<Form(
" Warn, long path fac=%.1f ",path/periodL)<<
1067 Form(
" punchEEMC1 x,y,z=%.1f, %.1f, %.1f path=%.1f period=%.1f\n",r.x(),r.y(),r.z(),path,periodL)<<endm;
1071 if(phi<0) phi+=2*M_PI;
1072 float eta=r.pseudoRapidity();
1074 int iBin=eemcList->addTrack(eta,phi);
1075 bool eemcMatch=eemcList->isMatched(iBin);
1076 bool eemcVeto =eemcList->isVetoed(iBin);
1077 float eemcW =eemcList->getWeight(iBin);
1079 t.updateAnyMatch(eemcMatch,eemcVeto,t.mEemc);
1090 int nPos=0,nFit=0,jz0=0;
1092 if (!dcaGeo)
return 0;
1093 float rxy=fabs(dcaGeo->impact());
1094 float z=dcaGeo->z();
1095 if(rxy >RxyMax)
return 0;
1096 if(fabs(z)>zMax)
return 0;
1098 vector<int> hitPatt; hitPatt.resize(200);
1099 const StPtrVecHit& hits = track->detectorInfo()->hits();
1100 int nHits = hits.size();
1102 int zignOld = (hit->position().z()<0)? -1:1;
1103 int rowMin=999,rowMax=-999;
1105 for (
int it=0;it<nHits;it++) {
1108 if (hit->detector()!=kTpcId)
continue;
1109 float z = hit->position().z();
1110 if(fabs(z)>zMax)
continue;
1111 if (hit->position().perp()<RxyMin)
continue;
1112 if (hit->position().perp()>RxyMax)
continue;
1113 if(fabs(z)<zMembraneDepth )
continue;
1115 int row = tpcHit->padrow();
1116 if (rowMin>row) rowMin=row;
1117 if (rowMax<row) rowMax=row;
1118 hitPatt[row-1]=1; nFit++;
1120 int zignNow = (z<0)? -1:1;
1121 if (zignNow!=zignOld) jz0 = row;
1124 if (rowMax<0)
return 0;
1126 for (
int jl=0,jr=rowMin-1;jr<rowMax;jl++,jr++) {
1127 hitPatt[jl]=hitPatt[jr];
1129 jz0-= rowMin-1; nPos = rowMax-rowMin+1;
1130 hitPatt.resize(nPos);
1132 if(nFit< mMinFitPfrac * nPos)
return false;
1134 if( mFitPossWeighting)
1135 t.weight*=double(nFit)/nPos;
1137 t.scanNodes(hitPatt,jz0);
1145 bool StPPVertexFinder::isPostCrossingTrack(
const StGlobalTrack* track)
1149 const StPtrVecHit& hits = track->detectorInfo()->hits();
1150 int nHits = hits.size();
1151 for (
int it=0; it<nHits;it++)
1154 if(hit->detector()!=kTpcId)
continue;
1155 float r=hit->position().perp();
1156 if (r < RxyMin)
continue;
1157 if (r > RxyMax)
continue;
1158 float z=hit->position().z();
1159 if (fabs(z) > zMax)
continue;
1160 if ((z < -zMembraneDepth && hit->sector() <= 12) ||
1161 (z > zMembraneDepth && hit->sector() > 12)) {
1163 if(nWrongZHit>=nWrongZHitCut) {
return true;}
Bool_t HelixCrossCellIds(const StHelixD &helix, IntVec &idVec, DoubleVec &pathVec, PointVec &crossVec) const
const void * mother
Pointer to original track.
double beamX(double z) const
double beamY(double z) const
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)