StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StJetMuEvent.cxx
1 //StJetMuEvent.cxx
2 
3 //std
4 #include "Stiostream.h"
5 #include <cmath>
6 #include <vector>
7 using namespace std;
8 
9 //ROOT
10 #include "TObject.h"
11 #include "TTree.h"
12 #include "TClonesArray.h"
13 
14 //SCL
15 #include "SystemOfUnits.h"
16 #include "PhysicalConstants.h"
17 #include "StThreeVectorF.hh"
18 #include "StLorentzVectorF.hh"
19 
20 //StEvent
21 #include "StEventTypes.h"
22 
23 //StMuDSTMaker
24 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
25 #include "StMuDSTMaker/COMMON/StMuDst.h"
26 #include "StMuDSTMaker/COMMON/StMuEvent.h"
27 #include "StMuDSTMaker/COMMON/StMuTrack.h"
28 
29 //UpsilonAna
30 #include "StJetMuEvent.h"
31 
32 ClassImp(StJetMuEvent)
33 
34  StJetMuEvent::StJetMuEvent() : mTracks(new TClonesArray("StMuTrack",100))
35 {
36  //cout <<"StJetMuEvent::StJetMuEvent()"<<endl;
37 }
38 
39 StJetMuEvent::~StJetMuEvent()
40 {
41  //cout <<"StJetMuEvent::~StJetMuEvent()"<<endl;
42 }
43 
44 bool StJetMuEvent::fill(StMuDstMaker* maker)
45 {
46  StMuEvent* e = maker->muDst()->event();
47  if (!e) {
48  cout <<"Error, null event. Return False"<<endl;
49  return false;
50  }
51 
52  reset();
53 
54  if (accept(maker)) {
55  return true;
56  }
57  return false;
58 }
59 
60 bool StJetMuEvent::accept(StMuDstMaker* maker)
61 {
62  StMuEvent* e = maker->muDst()->event();
63  if (!e) {
64  cout <<"StJetMuEvent::accept(StMuDstMaker*). Error:\t"
65  <<"Null event. Return false"<<endl;
66  return false;
67  }
68 
69  fillBasicTypes(e);
70  vector<StMuTrack*> vec;
71 
72  int n = maker->muDst()->primaryTracks()->GetLast()+1; // get number of primary tracks
73 
74  for (int i=0; i<n; ++i) {
75  StMuTrack* track = maker->muDst()->primaryTracks(i); // get pointer to primary track
76 
77  if (acceptTrack(track)) {
78  //push back vector
79  vec.push_back(track);
80  }
81  }
82 
83  if (mCuts.verbose) {
84  cout <<"\t Accepted "<<vec.size()<<" tracks of "<<n<<" possible"<<endl;
85  }
86 
87  if (vec.empty()==false) {
88 
89  //cout <<"\t-------------- vector ------------"<<endl;
90  //Fill tracks in TClonesArray:
91  for (vector<StMuTrack*>::iterator it=vec.begin(); it!=vec.end(); ++it) {
92  StMuTrack& track = **it;
93  //cout <<"momentum:\t"<<track.p()<<endl;
94  TClonesArray& cArr = *mTracks;
95  new(cArr[mTrackCounter++]) StMuTrack(track); //I know this works...
96  }
97  /*
98  //Test
99  cout <<"\t-------------- TClonesArray ------------"<<endl;
100  int nTracks = mTracks->GetLast()+1; //don't know why, but they don't have a size method
101  for (int i=0; i<nTracks; ++i) {
102  TClonesArray& cArr = *mTracks;
103  StMuTrack* track = static_cast<StMuTrack*>(cArr[i]);
104  cout <<"momentum:\t"<<track->p()<<endl;
105  }
106  */
107 
108  return true;
109  }
110  else {
111  return false;
112  }
113 }
114 
115 bool StJetMuEvent::acceptTrack(StMuTrack* track)
116 {
117  if (track->flag() >= 0 &&
118  track->momentum().perp() > mCuts.ptCut &&
119  fabs(track->momentum().pseudoRapidity()) < mCuts.pseudoRapidityCutOff &&
120  track->nHitsFit() >= mCuts.minNumberOfFitPoints &&
121  track->nHits() >= mCuts.minNumberOfPoints) {
122  return true;
123  }
124  else {
125  return false;
126  }
127 }
128 
129 void StJetMuEvent::reset()
130 {
131  mPlusPlus = 0;
132  mMinusMinus = 0;
133  mPlusMinus = 0;
134  mL3Fired=false;
135 
136  mEventId=0;
137  mEventNumber=0;
138  mRunId=0;
139  mRunNumber=0;
140  mTriggerWord=0;
141 
142  mRefMultPos=0;
143  mRefMultNeg=0;
144  mRefMult=0;
145 
146  mMagneticField=0.;
147  mZdcAdcAttenuatedSumWest=0.;
148  mZdcAdcAttenuatedSumEast=0.;
149  mCtbMultiplicity=0.;
150 
151  mPrimaryVertexPosition.setX(0.);
152  mPrimaryVertexPosition.setY(0.);
153  mPrimaryVertexPosition.setZ(0.);
154 
155  mTrackCounter=0;
156  mTracks->Clear();
157 }
158 
159 void StJetMuEvent::fillBasicTypes(StMuEvent* event)
160 {
161  //Basic event info
162  mEventId = event->eventId();
163  mEventNumber = event->eventNumber();
164  mRunId = event->runId();
165  mRunNumber = event->runNumber();
166  mTriggerWord = event->l0Trigger().triggerWord(); //StEvent->l0Trigger()->triggerWord();
167 
168  //Event characterization
169  mRefMultPos = event->refMultPos();
170  mRefMultNeg = event->refMultNeg();
171  mRefMult = event->refMult();
172 
173  mMagneticField = event->magneticField();
174  mZdcAdcAttenuatedSumWest = event->zdcAdcAttentuatedSumWest();
175  mZdcAdcAttenuatedSumEast = event->zdcAdcAttentuatedSumEast();
176  mCtbMultiplicity = event->ctbMultiplicity();
177  mPrimaryVertexPosition = event->primaryVertexPosition();
178 
179  //reactionPlane(unsigned short);
180  //reactionPlanePtWgt(unsigned short);
181 }
StMuDst * muDst()
Definition: StMuDstMaker.h:425
UShort_t nHitsFit() const
Return total number of hits used in fit.
Definition: StMuTrack.h:239
short flag() const
Returns flag, (see StEvent manual for type information)
Definition: StMuTrack.h:230
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
const StThreeVectorF & momentum() const
Returns 3-momentum at dca to primary vertex.
Definition: StMuTrack.h:260
UShort_t nHits() const
Bingchu.
Definition: StMuTrack.h:237