12 #include "StEventTypes.h"
14 #include "StThreeVectorF.hh"
16 #include "StTrackGeometry.h"
17 #include "StDedxPidTraits.h"
18 #include "StTrackPidTraits.h"
19 #include "StBTofPidTraits.h"
20 #include "StarClassLibrary/StParticleTypes.hh"
21 #include "StarClassLibrary/StParticleDefinition.hh"
22 #include "StTpcDedxPidAlgorithm.h"
23 #include "StEventUtilities/StuRefMult.hh"
24 #include "PhysicalConstants.h"
30 #include "StMessMgr.h"
31 #include "StMemoryInfo.hh"
33 #include "StBTofMatchEffMaker.h"
41 mAcceptedEventCounter = 0;
45 setMinFitPointsPerTrack(15);
46 setMinFitPointsOverMax(0.52);
49 setCreateHistoFlag(kFALSE);
50 setHistoFileName(
"tofana.root");
51 doPrintMemoryInfo = kFALSE;
52 doPrintCpuInfo = kFALSE;
55 StBTofMatchEffMaker::~StBTofMatchEffMaker(){ }
60 Int_t StBTofMatchEffMaker::Init(){
61 LOG_INFO <<
"StBTofMatchEffMaker -- initializing ..." << endm;
63 LOG_INFO <<
"Minimum fitpoints per track: " << mMinFitPointsPerTrack << endm;
64 LOG_INFO <<
"Minimum fitpoints over max: " << mMinFitPointsOverMax << endm;
65 LOG_INFO <<
"Maximum DCA: " << mMaxDCA << endm;
77 LOG_INFO <<
"Histograms are booked" << endm;
78 if (mHistoFileName!=
"") {
79 LOG_INFO <<
"Histograms will be stored in " << mHistoFileName.c_str() << endm;
85 mAcceptedEventCounter = 0;
95 LOG_INFO <<
"StBTofMatchEffMaker ----- RUN SUMMARY ----- (Finish)\n"
96 <<
"\tProcessed " << mEventCounter <<
" events."
97 <<
" Accepted " << mAcceptedEventCounter <<
" events."
98 <<
" Rejected " << mEventCounter - mAcceptedEventCounter <<
" events\n"
99 <<
"\tTOF events " << mTofEventCounter
100 <<
"\t Accept & Beam " << mAcceptAndBeam <<
" events" << endm;
103 if (mHistoFileName!=
"") writeHistogramsToFile();
110 LOG_INFO <<
"StBTofMatchEffMaker -- welcome" << endm;
111 if(Debug()) LOG_INFO <<
" processing event ... " << endm;
113 if(mHisto) mEventCounterHisto->Fill(0);
115 mEvent = (
StEvent *) GetInputDS(
"StEvent");
116 if (!validEvent(mEvent)){
117 LOG_INFO <<
"StBTofMatchEffMaker -- nothing to do ... bye-bye" << endm;
123 if (doPrintCpuInfo) timer.start();
124 if (doPrintMemoryInfo) StMemoryInfo::instance()->snapshot();
134 StSPtrVecTrackNode& nodes = mEvent->trackNodes();
136 for (
unsigned int iNode=0; iNode<nodes.size(); iNode++){
138 if(!validTrack(theTrack))
continue;
141 float pt = mom.perp();
142 float eta = mom.pseudoRapidity();
143 int q = theTrack->geometry()->charge();
145 float nSigmaPion = -999.;
146 float nSigmaKaon = -999.;
147 float nSigmaProton = -999.;
148 static StPionPlus* Pion = StPionPlus::instance();
149 static StKaonPlus* Kaon = StKaonPlus::instance();
150 static StProton* Proton = StProton::instance();
155 nSigmaPion = PidAlgorithm.numberOfSigma(Pion);
156 nSigmaKaon = PidAlgorithm.numberOfSigma(Kaon);
157 nSigmaProton = PidAlgorithm.numberOfSigma(Proton);
163 if(fabs(nSigmaPion)<2.) mPionDen->Fill(pt, eta);
164 if(fabs(nSigmaKaon)<2.) mKaonDen->Fill(pt, eta);
165 if(fabs(nSigmaProton)<2.) {
166 if(q>0) mProtonDen->Fill(pt, eta);
167 else mAntiPDen->Fill(pt, eta);
171 const StPtrVecTrackPidTraits& theTofPidTraits = theTrack->pidTraits(kTofId);
172 if(theTofPidTraits.size())
continue;
174 StTrackPidTraits *theSelectedTrait = theTofPidTraits[theTofPidTraits.size()-1];
175 if(!theSelectedTrait)
continue;
178 if(!pidTof)
continue;
183 if(fabs(nSigmaPion)<2.) mPionNum->Fill(pt, eta);
184 if(fabs(nSigmaKaon)<2.) mKaonNum->Fill(pt, eta);
185 if(fabs(nSigmaProton)<2.) {
186 if(q>0) mProtonNum->Fill(pt, eta);
187 else mAntiPNum->Fill(pt, eta);
195 if (doPrintMemoryInfo) {
196 StMemoryInfo::instance()->snapshot();
197 StMemoryInfo::instance()->print();
199 if (doPrintCpuInfo) {
201 LOG_INFO <<
"CPU time for StBTofMatchEffMaker::Make(): "
202 << timer.elapsedTime() <<
" sec" << endm;
205 LOG_INFO <<
"StBTofMatchEffMaker -- bye-bye" << endm;
212 void StBTofMatchEffMaker::bookHistograms(
void){
214 mEventCounterHisto =
new TH1D(
"eventCounter",
"eventCounter",20,0,20);
216 mPionDen =
new TH2D(
"pionDen",
"pionDen",500,0.,5.,40,-1.,1.);
217 mKaonDen =
new TH2D(
"kaonDen",
"kaonDen",500,0.,5.,40,-1.,1.);
218 mProtonDen =
new TH2D(
"protonDen",
"protonDen",500,0.,5.,40,-1.,1.);
219 mAntiPDen =
new TH2D(
"antiPDen",
"antiPDen",500,0.,5.,40,-1.,1.);
221 mPionNum =
new TH2D(
"pionNum",
"pionNum",500,0.,5.,40,-1.,1.);
222 mKaonNum =
new TH2D(
"kaonNum",
"kaonNum",500,0.,5.,40,-1.,1.);
223 mProtonNum =
new TH2D(
"protonNum",
"protonNum",500,0.,5.,40,-1.,1.);
224 mAntiPNum =
new TH2D(
"antiPNum",
"antiPNum",500,0.,5.,40,-1.,1.);
232 void StBTofMatchEffMaker::writeHistogramsToFile(){
234 TFile *theHistoFile =
new TFile(mHistoFileName.c_str(),
"RECREATE");
235 LOG_INFO <<
"StBTofMatchEffMaker::writeHistogramsToFile()"
236 <<
" histogram file " << mHistoFileName << endm;
242 mEventCounterHisto->Write();
254 theHistoFile->Write();
255 theHistoFile->Close();
264 bool StBTofMatchEffMaker::validEvent(
StEvent *event){
267 if (!event)
return false;
268 if(mHisto) mEventCounterHisto->Fill(1);
271 if (!event->primaryVertex())
return false;
272 mAcceptedEventCounter++;
273 if(mHisto) mEventCounterHisto->Fill(2);
283 if (!track)
return false;
286 if (track->flag()<=0)
return false;
291 if (track->fitTraits().numberOfFitPoints(kTpcId) < mMinFitPointsPerTrack)
return false;
293 float ratio = (1.0*track->fitTraits().numberOfFitPoints(kTpcId)) / (1.0*track->numberOfPossiblePoints(kTpcId));
294 if (ratio < mMinFitPointsOverMax)
return false;
296 if (track->impactParameter() > mMaxDCA)
return false;
unsigned char matchFlag() const
Matching information.
Int_t Make()
initial functions - DaqMap, Geometry Alignment, INL are extracted from db
StBTofMatchEffMaker(const Char_t *name="btofMatch")
Default constructor.