StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructGevsim.cxx
1 #include "StEStructGevsim.h"
2 #include "StEStructPool/AnalysisMaker/StEStructEventCuts.h"
3 #include "StEStructPool/AnalysisMaker/StEStructTrackCuts.h"
4 #include "StEStructPool/EventMaker/StEStructEvent.h"
5 #include "StEStructPool/EventMaker/StEStructTrack.h"
6 
7 #include "TParticle.h"
8 
9 StEStructGevsim::StEStructGevsim(): mgevsim(0), meventCount(0), meventsToDo(0), mAmDone(false) {};
10 
11 StEStructGevsim::StEStructGevsim(int nevents, TGeVSim* gevsim, StEStructEventCuts* ecuts, StEStructTrackCuts* tcuts): meventCount(0), mAmDone(false){
12  meventsToDo=nevents;
13  mgevsim=gevsim;
14  mECuts=ecuts;
15  mTCuts=tcuts;
16 
17  mtrackArray = mgevsim->GetListOfParticles(); // pointer to gevsim's internal TClonesArray
18 
19 };
20 
21 bool StEStructGevsim::hasGenerator() { return (mgevsim) ? true : false ; };
22 
23 //-------------------------------------------------------------------------
24 StEStructEvent* StEStructGevsim::next() {
25 
26  if(!mgevsim || meventCount==meventsToDo){
27  mAmDone=true;
28  return (StEStructEvent*)NULL;
29  }
30  return generateEvent();
31 }
32 
33 //--------------------------------------------------------------------------
34 StEStructEvent* StEStructGevsim::generateEvent(){
35 
36  StEStructEvent* retVal=NULL;
37 
38  if(mgevsim) mgevsim->GenerateEvent(); // fills mtrackArray with TParticles
39 
40  retVal = new StEStructEvent();
41 
42  fillTracks(retVal);
43  retVal->SetCentrality((double) mrefMult);
44  //bool useEvent= (mECuts->goodNumberOfTracks(mrefMult));
45  bool useEvent= (mECuts->goodCentrality(mrefMult));
46  if(!useEvent){
47  delete retVal;
48  retVal=NULL;
49  } else {
50  retVal->FillChargeCollections();
51  }
52  mECuts->fillHistogram(mECuts->centralityName(),(float)mrefMult,useEvent);
53 
54  return retVal;
55 }
56 
57 //--------------------------------------------------------------------------
58 void StEStructGevsim::fillTracks(StEStructEvent* estructEvent){
59 
60  mrefMult=0;
61  int numParticles=mtrackArray->GetEntries();
62 
63  StEStructTrack* eTrack= new StEStructTrack();
64 
65  for(int i=0;i<numParticles;i++){
66  TParticle* track = (TParticle*)mtrackArray->At(i);
67 
68  // From here on, this is similar to the mudst reader with muTrack->TParticle
69 
70  eTrack->SetInComplete();
71 
72  // check cuts first, then fill
73  bool useTrack=true;
74  float pt = track->Pt();
75  if(pt<0.15)continue;
76 
77  float eta = track->Eta();
78  useTrack = (mTCuts->goodEta(eta) && useTrack);
79  float phi = track->Phi();
80  if(phi>M_PI) phi -= 2*M_PI;
81  useTrack = (mTCuts->goodPhi(phi) && useTrack);
82  useTrack = (mTCuts->goodPt(pt) && useTrack);
83  float _r=pt/0.139;
84  float yt=log(sqrt(1+_r*_r)+_r);
85  useTrack = (mTCuts->goodYt(yt) && useTrack);
86  float mt = sqrt(pt*pt + 0.139*0.139);
87  float xt = 1 - exp( -1*(mt-0.139)/0.4 );
88  useTrack = (mTCuts->goodXt(xt) && useTrack);
89 
90  int pdgCode = track->GetPdgCode();
91  int charge = 0;
92  if(pdgCode>0) charge = 1;
93  else charge = -1;
94  useTrack = ( mTCuts->goodCharge(charge) && useTrack);
95 
96  if(useTrack) {
97  mrefMult++;
98  mTCuts->fillHistograms(useTrack);
99 
100  // now fill the eTrack
101  eTrack->SetPx(track->Px());
102  eTrack->SetPy(track->Py());
103  eTrack->SetPz(track->Pz());
104  eTrack->SetBx(0);
105  eTrack->SetBy(0);
106  eTrack->SetBz(0);
107  eTrack->SetBxGlobal(0);
108  eTrack->SetByGlobal(0);
109  eTrack->SetBzGlobal(0);
110  eTrack->SetEta(eta);
111  eTrack->SetPhi(phi);
112  eTrack->SetDetectorID(1); //TPC
113  eTrack->SetCharge(charge);
114 
115  estructEvent->AddTrack(eTrack);
116  } //useTrack
117 
118 
119  }; // particle loop
120 
121 
122  delete eTrack;
123  return;
124 
125 }
126