StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMiniMcEvent.cxx
1 //
2 // $Id: StMiniMcEvent.cxx,v 1.9 2012/03/15 23:37:20 perev Exp $
3 //
4 
5 #include "StMiniMcEvent.h"
6 #include "StContamPair.h"
7 
8 #include "Stiostream.h"
9 
10 Int_t StMiniMcEvent::mSFirst=1;
11 ClassImp(StMiniMcEvent)
12 
13 //___________________
14 
16  mEventId(0),
17  mRunId(0),
18  mOriginMult(0),
19  mCentralMult(0),
20  mCentrality(0),
21  mNUncorrectedNegativePrimaries(0),
22  mNUncorrectedPrimaries(0),
23  mNUncorrectedGlobals(0),
24  mNFtpcWUncorrectedPrimaries(0),
25  mNFtpcEUncorrectedPrimaries(0),
26  mMcMult(0),
27  mNMcNch(0),
28  mNMcFtpcWNch(0),
29  mNMcFtpcENch(0),
30  mNMcHminus(0),
31  mNMcGlobal(0),
32  mNMcGoodGlobal20(0),
33  mNRcGlobal(0),
34  mNRcGoodGlobal20(0),
35  mVertexX(999),
36  mVertexY(999),
37  mVertexZ(999),
38  mMcVertexX(999),
39  mMcVertexY(999),
40  mMcVertexZ(999),
41  mMagField(0),
42  mCenterOfMassEnergy(0),
43  mBackgroundRate(0),
44  mBeamMassNumberEast(0),
45  mBeamMassNumberWest(0),
46  mCtb(0),
47  mZdcE(0),
48  mZdcW(0),
49  mNMcTrack(0),
50  mNMatchedPair(0),
51  mNMergedPair(0),
52  mNSplitPair(0),
53  mNGhostPair(0),
54  mNContamPair(0),
55  mNMatGlobPair(0)
56 {
57  cout << "###StMiniMcEvent::StMiniMcEvent()" << endl;
58  //
59  // TClonesArray only created on the heap
60  // the first time a StMiniMcEvent object is constructed
61  //
62 
63  //
64  // initialize the size of the track array
65  //
66  const Int_t nMcTrack = 6000;
67  const Int_t nMatchedPair = 6000;
68  const Int_t nMergedPair = 500;
69  const Int_t nSplitPair = 500;
70  const Int_t nGhostPair = 500;
71  const Int_t nContamPair = 500;
72  const Int_t nMatGlobPair = 6000;
73  if(mSFirst){
74  cout << "\tCreating the clones arrays" << endl;
75  mSFirst = 0; // flag so we dont create any more arrays;
76  }
77  mMcTracks = new TClonesArray("StTinyMcTrack",nMcTrack);
78  mMatchedPairs = new TClonesArray("StMiniMcPair",nMatchedPair);
79  mMergedPairs = new TClonesArray("StMiniMcPair",nMergedPair);
80  mSplitPairs = new TClonesArray("StMiniMcPair",nSplitPair);
81 
82  mGhostPairs = new TClonesArray("StMiniMcPair",nGhostPair);
83  mContamPairs = new TClonesArray("StContamPair",nContamPair);
84  mMatGlobPairs = new TClonesArray("StMiniMcPair",nMatGlobPair);
85  memset (mVertexCovMatrix, 0, 6*sizeof(Float_t));
86 }
87 
88 //__________________
89 
90 StMiniMcEvent::~StMiniMcEvent()
91 {
92 }
93 
94 //_________________
95 
96 
97 StTinyMcTrack *StMiniMcEvent::addMcTrack(StTinyMcTrack* trk)
98 {
99  TClonesArray &tracks = *mMcTracks;
100  if (trk)
101  return new(tracks[mNMcTrack++]) StTinyMcTrack(*trk);
102  else
103  return new(tracks[mNMcTrack++]) StTinyMcTrack();
104 }
105 //________________________________________________________________________________
106 StContamPair *StMiniMcEvent::addContamPair(StContamPair* trk)
107 {
108  TClonesArray &tracks = *mContamPairs;
109  if (trk)
110  return new(tracks[mNContamPair++]) StContamPair(*trk);
111  else
112  return new(tracks[mNContamPair++]) StContamPair();
113 }
114 
115 //________________
116 
117 StMiniMcPair* StMiniMcEvent::addTrackPair(StMiniMcPair* pair,Category category)
118 {
119  TClonesArray *tracks;
120  Int_t *nPair;
121 
122  // special case for contamination pairs (make it a new function?)
123  // downcast..
124  //
125  switch(category){
126 
127  case MATCHED:
128  tracks = mMatchedPairs; nPair = &mNMatchedPair;
129  break;
130  case MERGED:
131  tracks = mMergedPairs; nPair = &mNMergedPair;
132  break;
133  case SPLIT:
134  tracks = mSplitPairs; nPair = &mNSplitPair;
135  break;
136  case GHOST:
137  tracks = mGhostPairs; nPair = &mNGhostPair;
138  break;
139  case MATGLOB:
140  tracks = mMatGlobPairs; nPair = &mNMatGlobPair;
141  break;
142  default:
143  Fatal("StMiniMcEvent", "WRONG CATEGORY IN StMiniMcEvent::addPair()");
144 // std::exit(-1);
145  break;
146  }
147 
148  if (pair)
149  return new((*tracks)[(*nPair)++]) StMiniMcPair(*pair);
150  else
151  return new((*tracks)[(*nPair)++]) StMiniMcPair();
152 }
153 
154 #if 0
155 TClonesArray*
156 StMiniMcEvent::tracks(Category category)
157 {
158  switch(category){
159  case MC:
160  return mMcTracks;
161  case MATCHED:
162  return mMatchedPairs;
163  case MERGED:
164  return mMergedPairs;
165  case SPLIT:
166  return mSplitPairs;
167  case GHOST:
168  return mGhostPairs;
169  case CONTAM:
170  return mContamPairs;
171  case MATGLOB:
172  return mMatGlobPairs;
173  default:
174  cout << "****WRONG CATEGORY****"<< endl
175  << "StMiniMcEvent::tracks()" << endl;
176  return 0;
177  }
178 
179 }
180 #endif
181 TClonesArray*
182 StMiniMcEvent::tracks(Category category) const
183 {
184  switch(category){
185  case MC:
186  return mMcTracks;
187  case MATCHED:
188  return mMatchedPairs;
189  case MERGED:
190  return mMergedPairs;
191  case SPLIT:
192  return mSplitPairs;
193  case GHOST:
194  return mGhostPairs;
195  case CONTAM:
196  return mContamPairs;
197  case MATGLOB:
198  return mMatGlobPairs;
199  default:
200  cout << "****WRONG CATEGORY****"<< endl
201  << "StMiniMcEvent::tracks()" << endl;
202  return 0;
203  }
204 
205 }
206 
207 //_________________
208 //
209 // clear all the track arrays for the next event
210 //
211 
212 void
213 StMiniMcEvent::Clear(Option_t *option)
214 {
215  mMcTracks->Clear();
216  mMatchedPairs->Clear();
217  mMergedPairs->Clear();
218  mSplitPairs->Clear();
219  mGhostPairs->Clear();
220  mContamPairs->Clear();
221  mMatGlobPairs->Clear();
222 
223  mNMcTrack = mNMatchedPair = mNMergedPair = mNSplitPair
224  = mNGhostPair = mNContamPair = mNMatGlobPair = 0;
225 
226 }
227 #define PrMinMc(A) cout << #A":" << m ## A << "\t"
228 //________________________________________________________________________________
229 void StMiniMcEvent::Print(Option_t *option) const {
230  cout << "StMiniMcEvent\t"; PrMinMc(RunId);PrMinMc(EventId);
231  PrMinMc(OriginMult); // StEvent::primaryVertex(0)->numberOfDaughters()
232  PrMinMc(CentralMult); // reco, primary trk, flag>0, |eta|<0.75
233  PrMinMc(Centrality); // centrality bin, Nch cuts, P02gd, 2k2
234  cout << endl;
235  PrMinMc(NUncorrectedNegativePrimaries); // from StuRefMult
236  PrMinMc(NUncorrectedPrimaries); // from StuRefMult
237  PrMinMc(NFtpcWUncorrectedPrimaries); // reco, primaries, flag>0, glTrk->helix->dist(vtx)<3, prim.pt<3, gl.fitPts>=5, 2.8 < eta < 3.8
238  PrMinMc(NFtpcEUncorrectedPrimaries); // reco, primaries, flag>0, glTrk->helix->dist(vtx)<3, prim.pt<3, gl.fitPts>=5,-2.8 > eta >-3.8
239  cout << endl;
240  PrMinMc(McMult); // embedding: n mc tracks; (StMcEvent::numberOfPrimaryTracks() simulation: same as mOriginMult
241  PrMinMc(NMcNch); // mc, primary, charge!=0, |eta|<0.5
242  PrMinMc(NMcFtpcWNch); // mc, primary, charge!=0, 2.8 < eta < 3.8
243  PrMinMc(NMcFtpcENch); // mc, primary, charge!=0,-2.8 > eta >-3.8
244  PrMinMc(NMcHminus); // mc, primary, charg <0, |eta|<0.5
245  cout << endl;
246  PrMinMc(NMcGlobal); // mc, primary, |eta|<4
247  PrMinMc(NMcGoodGlobal20); // mc, primary, |eta|<4, MC TPC hits >=20
248 
249  PrMinMc(NRcGlobal); // reco, primaries flag > 0
250  PrMinMc(NRcGoodGlobal20); // reco, primaries flag > 0, 20 fit hits
251  cout << endl;
252  PrMinMc(McMult); PrMinMc(NMcNch); PrMinMc(NMcFtpcWNch); PrMinMc(NMcFtpcENch); PrMinMc(NMcHminus); cout << endl;
253  PrMinMc(MagField);
254  cout << "Vertex X/Y/Z = " << mVertexX << "/" << mVertexY << "/" << mVertexZ
255  << "\tMc Vertex X/Y/Z = " << mMcVertexX << "/" <<mMcVertexY << "/" <<mMcVertexZ << endl;
256 
257  PrMinMc(CenterOfMassEnergy);
258  PrMinMc(BackgroundRate);
259  PrMinMc(BeamMassNumberEast);
260  PrMinMc(BeamMassNumberWest); cout << endl;
261 
262  PrMinMc(Ctb);
263  PrMinMc(ZdcE);
264  PrMinMc(ZdcW); cout << endl;
265  PrMinMc(NMcTrack);
266  PrMinMc(NMatchedPair);
267  PrMinMc(NMergedPair);
268  PrMinMc(NSplitPair);
269  PrMinMc(NGhostPair);
270  PrMinMc(NContamPair);
271  PrMinMc(NMatGlobPair); cout << endl;
272  StTinyMcTrack *mctrak = 0;
273  StMiniMcPair *mcpair = 0;
274  StTinyRcTrack *rctrak = 0;
275  Category Kase[] = {MC,MATCHED,MERGED,SPLIT,CONTAM,GHOST,MATGLOB};
276  for (Int_t K = MC; K <= MATGLOB; K++) {
277  TClonesArray* Tracks = ( TClonesArray* ) tracks(Kase[K]);
278  Int_t N = Tracks->GetEntriesFast();
279  for (int l = 0; l < N; l++) {
280  switch (K) {
281  case MC:
282  mctrak = (StTinyMcTrack *) Tracks->At(l);
283  if (! l) {
284  cout << "McTracks ====================================" << endl;
285  mctrak->Print("desc");
286  }
287  mctrak->Print();
288  break;
289  default:
290  mcpair = (StMiniMcPair *) Tracks->At(l);
291  mctrak = (StTinyMcTrack *) mcpair;
292  rctrak = (StTinyRcTrack *) mcpair;
293  if (! l) {
294  if (K == MATCHED) cout << "MATCHED ======================" << endl;
295  if (K == MERGED) cout << "MERGED ======================" << endl;
296  if (K == SPLIT) cout << "SPLIT ======================" << endl;
297  if (K == CONTAM) cout << "CONTAM ======================" << endl;
298  if (K == GHOST) cout << "GHOST ======================" << endl;
299  if (K == MATGLOB) cout << "MATGLOB ======================" << endl;
300  mctrak->Print("desc"); rctrak->Print("desc");
301  }
302  mctrak->Print(""); rctrak->Print();
303  break;
304  }
305  }
306  }
307 }
308 #undef PrMinMc
309 //__________________
310 //
311 // $Log $
312 //
313 
314 
Top level class for the MiniMcTree, containing event-wise information and the McTrack, and all TrackPair collections.
Definition of Pair for Contamination tracks (secondary tracks, weak decay tracks) ...