7 #include "StiForwardTrackMaker.h"
9 #include "StPrimaryVertex.h"
13 #include "Sti/StiKalmanTrackNode.h"
14 #include "StiMaker/StiMaker.h"
15 #include "Sti/StiTrackContainer.h"
17 #include "Sti/StiHitContainer.h"
18 #include "Sti/StiLocalTrackSeedFinder.h"
19 #include "Sti/StiHit.h"
20 #include "Sti/StiSortedHitIterator.h"
21 #include "Sti/StiDetectorContainer.h"
22 #include "Sti/StiKalmanTrackFinder.h"
24 #include "StDetectorId.h"
27 #define xG(t) (t->x_g())
28 #define yG(t) (t->y_g())
29 #define zG(t) (t->z_g())
30 #define rxyG(t) sqrt(xG(t)*xG(t) + yG(t)*yG(t))
31 #define rG(t) sqrt(xG(t)*xG(t) + yG(t)*yG(t) + zG(t)*zG(t))
32 #define xL(t) (t->getX())
33 #define yL(t) (t->getY())
34 #define zL(t) (t->getZ())
35 #define ezL(t) sqrt(t->getCzz())
36 #define eyL(t) sqrt(t->getCyy())
48 memset(hA,0,
sizeof(hA));
62 StiForwardTrackMaker::~StiForwardTrackMaker(){
74 gMessMgr->Warning() <<
GetName()<<
"no STi Maker, it is fatal"<<endm;
79 mToolkit = sti->getToolkit();
83 mAllHits = mToolkit->getHitContainer();
87 mForwardHits =
new StiHitContainer(
"mForwardHits",
"forward hits",mToolkit->getHitFactory());
93 mSeedGenerator =
new StiLocalTrackSeedFinder(
"mSeedGenerator",
"builds track seeds",mToolkit->getTrackFactory(), mForwardHits,mToolkit->getDetectorContainer());
99 HList=
new TObjArray(0);
105 <<
"\n MaxTrkDcaRxy/cm = "<< mMaxTrkDcaRxy
106 <<
"\n mMaxZdca = "<< mMaxZdca
107 <<
"\n mMinEta = "<< mMinEta
110 return StMaker::Init();
125 gMessMgr->Warning()<<
GetName()<<
"no Sti tool kit "<<
GetName()<<
" is OFF"<<endm;
128 else if(mAllHits==0) {
129 gMessMgr->Warning() <<
"no Sti hits present: "<<
GetName()<<
" is OFF"<<endm;
137 gMessMgr->Info() <<
"\n JJJ1 "<<
GetName()<<
":: MakeInSti(), eveID="<<
event->id()<<
" nVert="<<nV<<endm;
141 for(iv=0;iv<nV;iv++) {
143 printf(
"iv=%d Vz=%.2f +/-%.2f \n",iv,V.z,V.ez );
147 getForwardHits(mAllHits, mForwardHits, mToolkit->getDetectorContainer(), mMinEta);
148 cout<<
"We started with " << mAllHits->
size() <<
" hits and ended with " << mForwardHits->
size() <<
" in the forward region" << endl;
150 buildTrackSeeds(mForwardHits, mTrackSeeds, mSeedGenerator);
165 hA[2]->Fill( -log( rxyG(hit)/(zG(hit)+rG(hit)) ) );
168 phi = atan(yG(hit)/xG(hit));
169 if(xG(hit)<0 && yG(hit)<0) phi = phi - 3.14;
170 else if(xG(hit)<0) phi = phi + 3.14;
180 gMessMgr->Warning() <<
"no STi tracks , skip eve"<<endm;
184 cout<<
"There are "<<tracks->
getTrackCount(0)<<
" original tracks and "<<mTrackSeeds->
getTrackCount(0)<<
" forward track seeds"<<endl;
186 matchVertex(tracks,vertL,mMaxZdca,nV,hA[9],mTotMatchedTracks);
188 matchVertex(mTrackSeeds,vertL,mMaxZdca,nV,hA[8],mTotMatchedSeeds);
201 int nV=
event->numberOfPrimaryVertices();
203 gMessMgr->Info() <<
"\n JJJ2 "<<
GetName()<<
"MakeAfterSti(), START nEve="<<mTotEve<<
" eveID="<<eveID<<
" nPrimVertex="<<nV<< endm;
208 gMessMgr->Info() <<
GetName()<<
" event dropped, no vertex found"<<endm;
219 StiForwardTrackMaker::Clear(
const char* opt){
220 gMessMgr->Info() <<
GetName()<<
"::Clear()"<< endm;
223 mForwardHits->
clear();
224 mTrackSeeds->clear();
225 mSeedGenerator->
reset();
231 StiForwardTrackMaker::initHisto() {
233 hA[0]=
new TH1F(
"nV",
"No. of vertices per eve",20,-0.5,19.5);
234 hA[1]=
new TH1F(
"zV",
"reconstructed vertices (any); Z (cm)",200,-200,200);
236 hA[2] =
new TH1F(
"etaNotUsed",
"eta of unused forward hits",20,0.8,2.1);
237 hA[3] =
new TH1F(
"phiNotUsed",
"phi of unused forward hits",20,-3.14,3.14);
238 hA[4] =
new TH1F(
"etaUsed",
"eta of hits used by previous tracker",20,0.8,2.1);
239 hA[5] =
new TH1F(
"phiUsed",
"phi of hits used by previous tracker",20,-3.14,3.14);
240 hA[6] =
new TH1F(
"seedHits",
"number of seed hits used for each track",20,1,20);
241 hA[7] =
new TH1F(
"trackHits1",
"total # of hits/track after inward Kalman",20,1,20);
242 hA[10] =
new TH1F(
"trackHits2",
"total # of hits/track after outward Kalman",20,1,20);
243 hA[8] =
new TH1F(
"deltaZkalman",
"zDCA-zVertex for tracks after Kalman",200,-200,200);
244 hA[9] =
new TH1F(
"deltaZtracks",
"zDCA-zVertex for old tracks",200,-200,200);
247 for(i=0;i<mxHA; i++)
if(hA[i]) HList->Add(hA[i]);
253 StiForwardTrackMaker::saveHisto(TString fname){
254 TString outName=fname+
".hist.root";
255 TFile f( outName,
"recreate");
257 printf(
"%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
268 cout<<
"Total matched track seeds: "<<mTotMatchedSeeds<<
" and total matched tracks: "<<mTotMatchedTracks<<endl;
283 StDetectorId
id = (static_cast <
const StHit*>(hit->stHit()))->detector();
284 if( rxyG(hit)/(zG(hit)+rG(hit)) < exp(-minEta) &&
id==kTpcId)
286 if(hit->timesUsed()==0)forwardHits->
add(hit);
289 hA[4]->Fill( -log( rxyG(hit)/(zG(hit)+rG(hit)) ) );
292 float phi = atan(yG(hit)/xG(hit));
293 if(xG(hit)<0 && yG(hit)<0) phi = phi - 3.14;
294 else if(xG(hit)<0) phi = phi + 3.14;
311 hA[6]->Fill(track->getPointCount());
312 trackSeeds->
add(track);
317 void StiForwardTrackMaker::extendTracks()
322 float zDCA, ezDCA, RxyDCA;
325 for(StiTrackContainer::const_iterator it=mTrackSeeds->begin(); it!=mTrackSeeds->end(); it++)
327 while(mTrackFinder->
find(*it,0,2)){};
328 hA[7]->Fill((*it)->getPointCount());
329 while(mTrackFinder->
find(*it,1,0)){};
330 hA[10]->Fill((*it)->getPointCount());
332 if(examineTrackDca(static_cast<StiKalmanTrack*>(*it), zDCA, ezDCA, RxyDCA)){
334 cout <<
"This track passed the cut "<<**it<<endl;
344 void StiForwardTrackMaker::matchVertex(
StiTrackContainer* tracks, vector <VertexV> &vertL,
double &mMaxZdca,
int &nV, TH1* h,
int &totalMatched)
346 int nAll=0, nAny=0, nTry=0, nAcc=0;
347 for (StiTrackContainer::const_iterator it=(*tracks).begin(); it!=(*tracks).end(); ++it) {
350 if(track->getFlag()!=
true) nAny++;
355 float zDca, ezDca, rxyDca;
356 if(!examineTrackDca(track, zDca, ezDca, rxyDca))
continue;
361 for(
int iv=0;iv<nV;iv++) {
364 if( fabs(zDca-V.z) > mMaxZdca )
continue;
371 gMessMgr->Info() <<
"\n"<<
GetName()<<
" We have "<<nAll<<
" tracks, found "<<nAny<<
" flagged tracks, try ZDca for "<<nTry<<
", match to vertex:"<<nAcc<<
"\n"<<endm;
372 totalMatched = nAcc + totalMatched;
377 float &zDca,
float &ezDca,
float &rxyDca){
389 float rxy=rxyG(bmNode);
391 if(rxy>mMaxTrkDcaRxy)
return false;
405 StiForwardTrackMaker::addVertex(
float z,
float ez){
virtual void initialize()
Initialize the finder.
virtual void add(StiHit *)
Definition of Kalman Track.
bool find(StiTrack *track, int direction, double rmin=0)
Find/extend the given track, in the given direction.
Abstract definition of a Track.
virtual Int_t Make()
Make - this method is called in loop for each event.
Int_t MakeInSti()
Inside Sti.
virtual void reset()
Reset the tracker.
Definition of Kalman Track.
virtual Int_t Init()
Init - is a first method the top level StChain calls to initialize all its makers.
StiKalmanTrackNode * extrapolateToBeam()
StiTrack * findTrack(double rMin=0)
virtual unsigned int size() const
virtual const char * GetName() const
special overload
int getTrackCount(Filter< StiTrack > *filter) const
void add(StiTrack *track)
Add the given track to the container.
Int_t MakeAfterSti()
Inside Sti.