1 #include "StTofMuDstReader.h"
15 #include "PhysicalConstants.h"
16 #include "SystemOfUnits.h"
17 #include "StThreeVector.hh"
18 #include "StThreeVectorF.hh"
19 #include "StThreeVectorD.hh"
20 #include "StLorentzVectorD.hh"
22 #include "StTriggerIdCollection.h"
23 #include "StTriggerId.h"
25 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
26 #include "StMuDSTMaker/COMMON/StMuEvent.h"
27 #include "StMuDSTMaker/COMMON/StMuDst.h"
28 #include "StMuDSTMaker/COMMON/StMuTrack.h"
29 #include "StMuDSTMaker/COMMON/StMuTofHit.h"
31 #include "StTofMuDstEval.h"
32 #include "tofHitTree.h"
37 StTofMuDstReader::StTofMuDstReader(
const char *name,
const char *file,
StMuDstMaker* maker):
StMaker(name)
42 mOutputFile =
new TFile(file,
"RECREATE");
43 mOutputFile->SetCompressionLevel(1);
44 int BufSize=(int)pow(2.,16.);
46 mTree =
new TTree(
"T",
"T",BufSize);
47 mTree->SetAutoSave(10000);
48 mTree->Branch(
"runId",&mTofHit.runId,
"runId/I");
49 mTree->Branch(
"evtId",&mTofHit.evtId,
"evtId/I");
50 mTree->Branch(
"vz",&mTofHit.vz,
"vz/F");
51 mTree->Branch(
"mult",&mTofHit.mult,
"mult/I");
52 mTree->Branch(
"neast",&mTofHit.neast,
"neast/I");
53 mTree->Branch(
"nwest",&mTofHit.nwest,
"nwest/I");
54 mTree->Branch(
"module",&mTofHit.module,
"module/I");
55 mTree->Branch(
"cell",&mTofHit.cell,
"cell/I");
56 mTree->Branch(
"tot",&mTofHit.tot,
"tot/F");
57 mTree->Branch(
"tof",&mTofHit.tof,
"tof/F");
58 mTree->Branch(
"L",&mTofHit.L,
"L/F");
59 mTree->Branch(
"beta",&mTofHit.beta,
"beta/F");
60 mTree->Branch(
"localY",&mTofHit.localY,
"localY/F");
61 mTree->Branch(
"localZ",&mTofHit.localZ,
"localZ/F");
62 mTree->Branch(
"deltaY",&mTofHit.deltaY,
"deltaY/F");
63 mTree->Branch(
"m2",&mTofHit.m2,
"m2/F");
64 mTree->Branch(
"trkId",&mTofHit.trkId,
"trkId/I");
65 mTree->Branch(
"nHitsFit",&mTofHit.nHitsFit,
"nHitsFit/I");
66 mTree->Branch(
"pt",&mTofHit.pt,
"pt/F");
67 mTree->Branch(
"eta",&mTofHit.eta,
"eta/F");
68 mTree->Branch(
"phi",&mTofHit.phi,
"phi/F");
69 mTree->Branch(
"dca",&mTofHit.dca,
"dca/F");
70 mTree->Branch(
"dEdx",&mTofHit.dEdx,
"dEdx/F");
71 mTree->Branch(
"nSigmaPi",&mTofHit.nSigmaPi,
"nSigmaPi/F");
72 mTree->Branch(
"nSigmaK",&mTofHit.nSigmaK,
"nSigmaK/F");
73 mTree->Branch(
"nSigmaP",&mTofHit.nSigmaP,
"nSigmaP/F");
74 mTree->Branch(
"nSigmaE",&mTofHit.nSigmaE,
"nSigmaE/F");
75 mTree->Branch(
"nSigmaMu",&mTofHit.nSigmaMu,
"nSigmaMu/F");
76 mTree->Branch(
"nSigmaTofPi",&mTofHit.nSigmaTofPi,
"nSigmaTofPi/F");
77 mTree->Branch(
"nSigmaTofK",&mTofHit.nSigmaTofK,
"nSigmaTofK/F");
78 mTree->Branch(
"nSigmaTofP",&mTofHit.nSigmaTofP,
"nSigmaTofP/F");
79 mTree->Branch(
"nSigmaTofE",&mTofHit.nSigmaTofE,
"nSigmaTofE/F");
85 StTofMuDstReader::~StTofMuDstReader()
91 void StTofMuDstReader::Clear(
const char*)
104 mTofHit.beta = -999.;
105 mTofHit.localY = -999;
106 mTofHit.localZ = -999.;
107 mTofHit.deltaY = -999.;
110 mTofHit.nHitsFit = 0;
115 mTofHit.dEdx = -999.;
116 mTofHit.nSigmaPi = -999.;
117 mTofHit.nSigmaK = -999.;
118 mTofHit.nSigmaP = -999.;
119 mTofHit.nSigmaE = -999.;
120 mTofHit.nSigmaMu = -999.;
121 mTofHit.nSigmaTofPi = -999.;
122 mTofHit.nSigmaTofK = -999.;
123 mTofHit.nSigmaTofP = -999.;
124 mTofHit.nSigmaTofE = -999.;
132 mOutputFile->Write();
133 mOutputFile->Close();
139 Int_t StTofMuDstReader::Init()
147 cout <<
"StTofMuDstReader::Make()" << endl;
149 if( mMuDstMaker != NULL ) {
150 mMuDst = mMuDstMaker->
muDst();
153 if(!mMuDst)
return kStOK;
156 if(!tofEval)
return kStOK;
159 if(!vtx)
return kStOK;
162 if(!muEvent)
return kStOK;
165 if(fabs(vertexPos.x())<1.0e-5 && fabs(vertexPos.y())<1.0e-5 && fabs(vertexPos.z())<1.0e-5)
return kStOK;
167 int runId = muEvent->runId();
168 int evtId = muEvent->eventId();
173 tofEval->GetPvpdNHits(nEast , nWest);
174 cout <<
" nEast = " << nEast <<
" nWest = " << nWest << endl;
176 int nTofHits = mMuDst->numberOfTofHit();
177 int n = mMuDst->numberOfPrimaryTracks();
178 cout <<
" There are " << nTofHits <<
" TofHits in this event." << endl;
179 for(
int i=0;i<nTofHits;i++) {
182 int trkId = tof->associatedTrackId();
184 for(
int j=0;j<n;j++) {
192 if(index<0||index>=n) {
193 cout <<
"Warning! no matched TPC track, strange!" << endl;
200 tofEval->GetLocalHitPosition(tof, &local[0]);
201 Double_t yCenter = (tof->cellIndex()-1-2.5)*3.45;
203 float m2 = pow(trk->
pt()*TMath::CosH(trk->
eta()),2.0)*(1./tof->beta()/tof->beta()-1.);
205 mTofHit.runId = runId;
206 mTofHit.evtId = evtId;
207 mTofHit.vz = vertexPos.z();
208 mTofHit.mult = refMult;
209 mTofHit.neast = nEast;
210 mTofHit.nwest = nWest;
211 mTofHit.module = tof->moduleIndex();
212 mTofHit.cell = tof->cellIndex();
213 mTofHit.tot = tofEval->GetUncorrectedTot(tof);
214 mTofHit.tof = tof->timeOfFlight();
215 mTofHit.L = tof->pathLength();
216 mTofHit.beta = tof->beta();
217 mTofHit.localY = local[1];
218 mTofHit.localZ = local[2];
219 mTofHit.deltaY = local[1]-yCenter;
221 mTofHit.trkId = index;
223 mTofHit.pt = trk->
pt();
224 mTofHit.eta = trk->
eta();
225 mTofHit.phi = trk->
phi();
227 mTofHit.dEdx = trk->
dEdx()*1.e+6;
232 mTofHit.nSigmaMu = -999.;
233 mTofHit.nSigmaTofPi = tof->sigmaPion()/2.;
234 mTofHit.nSigmaTofK = tof->sigmaKaon()/2.;
235 mTofHit.nSigmaTofP = tof->sigmaProton()/2.;
236 mTofHit.nSigmaTofE = tof->sigmaElectron()/2.;
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
StThreeVectorF primaryVertexPosition(int vtx_id=-1) const
The StMuDst is supposed to be structured in 'physical events'. Therefore there is only 1 primary vert...
unsigned short refMultNeg(int vtx_id=-1)
Reference multiplicity of negative particles as defined in StEventUtilities/StuRefMult.hh for vertex vtx_id (-1 is default index from StMuDst)
Double_t pt() const
Returns pT at point of dca to primary vertex.
short id() const
Returns the track id(or key), is unique for a track node, i.e. global and primary tracks have the sam...
virtual void Clear(Option_t *option="")
User defined functions.
UShort_t nHitsFit() const
Return total number of hits used in fit.
Short_t charge() const
Returns charge.
Double_t nSigmaPion() const
Returns Craig's distance to the calculated dE/dx band for pions in units of sigma.
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Double_t nSigmaElectron() const
Returns Craig's distance to the calculated dE/dx band for electrons in units of sigma.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
static StMuTofHit * tofHit(int i)
returns pointer to the i-th muTofHit
Double_t dEdx() const
Returns measured dE/dx value.
Double_t phi() const
Returns phi at point of dca to primary vertex.
Double_t nSigmaProton() const
Returns Craig's distance to the calculated dE/dx band for protons in units of sigma.
StThreeVectorF dcaGlobal(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex of associated global track.
Double_t nSigmaKaon() const
Returns Craig's distance to the calculated dE/dx band for kaons in units of sigma.
unsigned short refMultPos(int vtx_id=-1)
Reference multiplicity of positive particles as defined in StEventUtilities/StuRefMult.hh for vertex vtx_id (-1 is default index from StMuDst)