13 #include "StEStructEStructReader.h"
15 #include "StEStructEventCuts.h"
16 #include "StEStructTrackCuts.h"
17 #include "StEStructPool/EventMaker/StEStructEvent.h"
18 #include "StEStructPool/EventMaker/StEStructTrack.h"
19 #include "StEStructPool/EventMaker/StEStructCentrality.h"
21 #include "StDetectorId.h"
26 StEStructEStructReader::StEStructEStructReader() {
30 mhasVertexRadiusCuts = 0;
39 mUseGlobalTracks=
false;
42 StEStructEStructReader::StEStructEStructReader(
char* estructFormatFile,
48 mhasVertexRadiusCuts = 0;
49 mFile =
new TFile(estructFormatFile);
51 mkeyList = mFile->GetListOfKeys();
52 mnEvents = mkeyList->GetEntries();
57 mUseGlobalTracks=
false;
62 StEStructEStructReader::~StEStructEStructReader() {
69 if (!mECuts->doFillHists()) {
72 if ( mECuts->hasToFFractionCut() ) {
74 ToFBefore =
new TH2F(
"dEdxToFNoCut2D",
"dEdxToFNoCut2D",50,1,1000,50,1,750);
75 ToFAfter =
new TH2F(
"dEdxToFCut2D",
"dEdxToFCut2D",50,1,1000,50,1,750);
76 mECuts->addCutHists(ToFBefore, ToFAfter,
"ToFPlots2D");
78 if ( mECuts->hasPrimaryFractionCut() ) {
80 PrimaryBefore =
new TH2F(
"PrimVGlobNoCut2D",
"PrimVGlobNoCut2D",120,1,1200,200,1,2000);
81 PrimaryAfter =
new TH2F(
"PrimVGlobCut2D",
"PrimVGlobCut2D",120,1,1200,200,1,2000);
82 mECuts->addCutHists(PrimaryBefore, PrimaryAfter,
"PrimaryPlots2D");
84 if ( mECuts->hasPrimaryVertexRadiusCut() ) {
85 mhasVertexRadiusCuts = 1;
86 VRadiusBefore =
new TH2F(
"VertexRadiusNoCut2D",
"VertexRadiusNoCut2D",50,-10,10,50,-10,10);
87 VRadiusAfter =
new TH2F(
"VertexRadiusCut2D",
"VertexRadiusCut2D",50,-10,10,50,-10,10);
88 mECuts->addCutHists(VRadiusBefore, VRadiusAfter,
"VertexRadiusPlots2D");
93 if (!mTCuts->doFillHists()) {
96 if ( mTCuts->hasElectronCut() ) {
98 dEdxBefore =
new TH2F(
"dEdxNoCut2D",
"dEdxNoCut2D",150,-1.5,1.5,150,0,0.000015);
99 dEdxAfter =
new TH2F(
"dEdxCut2D",
"dEdxCut2D",150,-1.5,1.5,150,0,0.000015);
100 mTCuts->addCutHists(dEdxBefore, dEdxAfter,
"dEdxPlots2D");
102 dEdxBetaBefore =
new TH3F(
"dEdxBetaNoCut3D",
"dEdxBetaNoCut3D",100,-2.0,2.0,100,0.0000015,0.000006,100,0.55,1.05);
103 dEdxBetaAfter =
new TH3F(
"dEdxBetaCut3D",
"dEdxBetaCut3D",100,-2.0,2.0,100,0.0000015,0.000006,100,0.55,1.05);
104 mTCuts->addCutHists(dEdxBetaBefore, dEdxBetaAfter,
"dEdxBetaPlots3D");
111 if(!mkeyList)
return retVal;
113 mEventIn = (
StEStructEvent *) mFile->Get(mkeyList->At(miEvent)->GetName());
115 mEventIn->FillChargeCollections();
127 bool useEvent =
true;
138 if ((fabs(x) < 1e-5) && (fabs(y) < 1e-5) && (fabs(z) < 1e-5)) {
140 }
else if ( !mECuts->goodPrimaryVertexZ(z) ) {
145 if (!mECuts->goodPrimaryVertexRadius(sqrt(x*x+y*y))) {
155 int nTracks = countGoodTracks(&ndEdx, &nToF);
156 if (!mECuts->goodToFFraction(ndEdx, nToF)) {
168 retVal->SetCentrality((
double)nTracks);
169 if(!mECuts->goodCentrality(retVal->Centrality())) useEvent=
false;
171 retVal->SetRefMult( mEventIn->RefMult() );
172 retVal->SetctbMult( mEventIn->ctbMult() );
173 retVal->SetNumPrim( mEventIn->NumPrim() );
177 retVal->SetEventID(mEventIn->EventID());
178 retVal->SetRunID(mEventIn->RunID());
179 retVal->SetVertex(x,y,z);
180 retVal->SetZDCe((
float)mEventIn->ZDCe());
181 retVal->SetZDCw((
float)mEventIn->ZDCw());
186 retVal->SetZDCCoincidence((
float)mEventIn->ZDCCoincidence());
187 retVal->SetBField((
float)mEventIn->BField());
189 if (!fillTracks(retVal)) useEvent=
false;
193 mECuts->fillHistogram(mECuts->primaryVertexZName(),z,useEvent);
198 mECuts->fillHistogram(mECuts->centralityName(),(float)nTracks,useEvent);
199 mECuts->fillHistogram(mECuts->goodtoffractionName(),(float)ndEdx,(
float)nToF,useEvent);
201 mECuts->fillHistogram(
"ToFPlots",(
double)ndEdx,(
double)nToF,useEvent);
203 mECuts->fillHistogram(
"VertexRadiusPlots",x,y,useEvent);
239 if (retVal) retVal->FillChargeCollections();
246 bool StEStructEStructReader::fillTracks(
StEStructEvent* estructEvent) {
254 int numTracks = mEventIn->Ntrack();
259 for (
int ich=0;ich<2;ich++) {
260 StEStructTrackCollection *tc;
262 tc=mEventIn->TrackCollectionP();
264 tc=mEventIn->TrackCollectionM();
266 for (StEStructTrackIterator iter = tc->begin(); iter != tc->end(); iter++) {
270 float ptot = track->Charge() * track->Ptot();
271 float beta = track->beta();
273 useTrack = isTrackGoodToUse( track );
274 mTCuts->fillHistograms(useTrack);
276 mTCuts->fillHistogram(
"dEdxPlots",ptot,track->Dedx(),useTrack);
278 mTCuts->fillHistogram(
"dEdxBetaPlots",ptot,track->Dedx(),beta,useTrack);
282 estructEvent->AddTrack(track);
301 mDCA = track->DcaGlobal();
304 useTrack = (mTCuts->goodEta(mEta) && useTrack);
305 useTrack = (mTCuts->goodFlag(track->Flag()) && useTrack);
306 useTrack = (mTCuts->goodCharge(track->Charge()) && useTrack);
307 useTrack = (mTCuts->goodNFitPoints(track->NFitPoints()) && useTrack);
308 useTrack = (mTCuts->goodNFitNMax((
float)((
float)track->NFitPoints()/(float)track->NMaxPoints())) && useTrack);
309 useTrack = (mTCuts->goodGlobalDCA(mDCA) && useTrack);
310 useTrack = (mTCuts->goodChi2(track->Chi2()) && useTrack);
311 useTrack = (mTCuts->goodPhi(mPhi) && useTrack);
312 if(track->Pt() < 0.15) useTrack =
false;
316 if (mhasdEdxCuts && mTCuts->goodElectron( track->PIDe_dEdx() ) && useTrack ) {
317 float p = track->Ptot();
318 if( (p>0.2 && p<0.45) || (p>0.7 && p<0.8) ) {
328 bool StEStructEStructReader::isTrackGoodToUse(
StEStructTrack* track){
330 bool useTrack=isTrackGood(track);
333 float pt = track->Pt();
334 useTrack = (mTCuts->goodPt(pt) && useTrack);
335 float yt = track->Yt();
336 useTrack = (mTCuts->goodYt(yt) && useTrack);
337 float xt = track->Xt();
338 useTrack = (mTCuts->goodXt(xt) && useTrack);
348 int StEStructEStructReader::countGoodTracks(
int *ndEdx,
int *nToF) {
353 int numTracks = mEventIn->Ntrack();
367 for (
int ich=0;ich<2;ich++) {
368 StEStructTrackCollection *tc;
370 tc=mEventIn->TrackCollectionP();
372 tc=mEventIn->TrackCollectionM();
374 for (StEStructTrackIterator iter = tc->begin(); iter != tc->end(); iter++) {
376 if (isTrackGood(track)) {
378 if ((fabs(track->PIDpi_dEdx()) < 2) ||
379 (fabs(track->PIDk_dEdx()) < 2) ||
380 (fabs(track->PIDp_dEdx()) < 2)) {
383 if ((fabs(track->PIDpi_ToF()) < 2) ||
384 (fabs(track->PIDpi_ToF()) < 2) ||
385 (fabs(track->PIDpi_ToF()) < 2)) {
395 return mNumGoodTracks;
401 eTrack->SetPx(mTrack->Px());
402 eTrack->SetPy(mTrack->Py());
403 eTrack->SetPz(mTrack->Pz());
405 eTrack->SetBx(mTrack->Bx());
406 eTrack->SetBy(mTrack->By());
407 eTrack->SetBz(mTrack->Bz());
409 if (0 == mTrack->BxGlobal() && 0 == mTrack->ByGlobal() && 0 == mTrack->BzGlobal()) {
410 printf(
"Found track with dca = (0,0,0)\n");
412 eTrack->SetBxGlobal(mTrack->BxGlobal());
413 eTrack->SetByGlobal(mTrack->ByGlobal());
414 eTrack->SetBzGlobal(mTrack->BzGlobal());
416 eTrack->SetEta(mEta);
417 eTrack->SetPhi(mPhi);
418 eTrack->SetDedx(mTrack->Dedx());
419 eTrack->SetChi2(mTrack->Chi2());
420 eTrack->SetHelix(mTrack->Helix());
425 eTrack->SetPIDe_dEdx(mTrack->PIDe_dEdx());
426 eTrack->SetPIDpi_dEdx(mTrack->PIDpi_dEdx());
427 eTrack->SetPIDp_dEdx(mTrack->PIDp_dEdx());
428 eTrack->SetPIDk_dEdx(mTrack->PIDk_dEdx());
429 eTrack->SetPIDd_dEdx(10000.);
432 eTrack->SetPIDe_ToF(mTrack->PIDe_ToF());
433 eTrack->SetPIDpi_ToF(mTrack->PIDpi_ToF());
434 eTrack->SetPIDp_ToF(mTrack->PIDp_ToF());
435 eTrack->SetPIDk_ToF(mTrack->PIDk_ToF());
436 eTrack->SetPIDd_ToF(999);
437 eTrack->SetBeta(mTrack->beta());
439 eTrack->SetNFitPoints(mTrack->NFitPoints());
440 eTrack->SetNFoundPoints(mTrack->NFoundPoints());
441 eTrack->SetNMaxPoints(mTrack->NMaxPoints());
443 eTrack->SetTopologyMapTPCNHits(mTrack->TopologyMapTPCNHits());
444 eTrack->SetTopologyMapData(0,mTrack->TopologyMapData(0));
445 eTrack->SetTopologyMapData(1,mTrack->TopologyMapData(1));
447 eTrack->SetDetectorID(1);
448 eTrack->SetFlag(mTrack->Flag());
449 eTrack->SetCharge(mTrack->Charge());