]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FEMTOSCOPY/AliFemto/AliFemtoEvent.cxx
AliCentrality for ESD and AOD analysis
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemto / AliFemtoEvent.cxx
1 ///////////////////////////////////////////////////////////////////////////
2 //                                                                       //
3 //  AliFemtoEvent: hold the information specific to the event and a      //
4 //  track list                                                           //
5 //  AliFemtoEvent is the "transient microDST"  Objects of this class are //
6 //   generated from the input data by a Reader, and then presented to    //
7 //   the Cuts of the various active Analyses.                            //
8 //                                                                       //
9 ///////////////////////////////////////////////////////////////////////////
10 #include "AliFemtoEvent.h"
11 #include "AliFemtoTrack.h"
12 #include "AliFemtoV0.h"
13 #include "AliFemtoXi.h"
14 #include "AliFemtoKink.h"
15 #include "AliFemtoTrackCut.h"
16 #include "AliFemtoV0Cut.h"
17 #include "AliFemtoXiCut.h"
18 #include "AliFemtoKinkCut.h"
19 #include "PhysicalConstants.h"
20 #include "SystemOfUnits.h"
21
22 // Mike removed all of the AliFemtoTTree stuff here 21apr2006 - it was not used for a long time.
23
24
25
26 //___________________
27 AliFemtoEvent::AliFemtoEvent():
28   fEventNumber(0),
29   fRunNumber(0),
30   fNumberOfTracks(0),
31   fNormalizedMult(-1),
32   fSPDMult(0),
33   fEstimateITSTPC(0),
34   fEstimateTracklets(0),
35   fEstimateITSPure(0),
36   fMagneticField(0),
37   fIsCollisionCandidate(kTRUE),
38   fPrimVertPos(0,0,0),
39   fPrimVertCov(),
40   fTrackCollection(0),
41   fV0Collection(0),
42   fXiCollection(0),
43   fKinkCollection(0),
44   fZDCN1Energy(0),   
45   fZDCP1Energy(0),   
46   fZDCN2Energy(0),   
47   fZDCP2Energy(0),   
48   fZDCEMEnergy(0),   
49   fZDCParticipants(0),
50   fTriggerMask(0),  
51   fTriggerCluster(0),
52   fReactionPlaneAngle(0)
53 {
54   // Default constructor
55   fPrimVertPos[0]=-999.0;
56   fPrimVertPos[1]=-999.0;
57   fPrimVertPos[2]=-999.0;
58   fPrimVertCov[0]=0.000000000001;
59   fPrimVertCov[1]=0.000000000001;
60   fPrimVertCov[2]=0.000000000001;
61   fPrimVertCov[3]=0.000000000001;
62   fPrimVertCov[4]=0.000000000001;
63   fPrimVertCov[5]=0.000000000001;
64   fTrackCollection = new AliFemtoTrackCollection;
65   fV0Collection = new AliFemtoV0Collection;
66   fXiCollection = new AliFemtoXiCollection;
67   fKinkCollection = new AliFemtoKinkCollection;
68   fMagneticField=0.0;
69 }
70 //___________________
71 AliFemtoEvent::AliFemtoEvent(const AliFemtoEvent& ev, AliFemtoTrackCut* tCut, AliFemtoV0Cut* vCut, AliFemtoXiCut* xCut, AliFemtoKinkCut* kCut):
72   fEventNumber(0),
73   fRunNumber(0),
74   fNumberOfTracks(0),
75   fNormalizedMult(-1),
76   fSPDMult(0),
77   fEstimateITSTPC(0),
78   fEstimateTracklets(0),
79   fEstimateITSPure(0),
80   fMagneticField(0),
81   fIsCollisionCandidate(kTRUE),
82   fPrimVertPos(0,0,0),
83   fPrimVertCov(),
84   fTrackCollection(0),
85   fV0Collection(0),
86   fXiCollection(0),
87   fKinkCollection(0),
88   fZDCN1Energy(0),   
89   fZDCP1Energy(0),   
90   fZDCN2Energy(0),   
91   fZDCP2Energy(0),   
92   fZDCEMEnergy(0),   
93   fZDCParticipants(0),
94   fTriggerMask(0),  
95   fTriggerCluster(0),
96   fReactionPlaneAngle(0)
97 { // copy constructor with track and v0 cuts
98   //cout << "AliFemtoEvent::AliFemtoEvent(const AliFemtoEvent& ev, AliFemtoTrackCut* tCut, AliFemtoV0Cut* vCut, AliFemtoV0Cut* kCut)" << endl;
99   fEventNumber = ev.fEventNumber;
100   fRunNumber = ev.fRunNumber;
101   
102   SetPrimVertCov(ev.PrimVertCov());
103
104   fZDCN1Energy=ev.fZDCN1Energy;     
105   fZDCP1Energy=ev.fZDCP1Energy;      
106   fZDCN2Energy=ev.fZDCN2Energy;      
107   fZDCP2Energy=ev.fZDCP2Energy;      
108   fZDCEMEnergy=ev.fZDCEMEnergy;
109   fZDCParticipants=ev.fZDCParticipants;
110   fNumberOfTracks = ev.fNumberOfTracks;
111   fNormalizedMult = ev.fNormalizedMult;
112   fEstimateITSTPC = ev.fEstimateITSTPC;
113   fEstimateTracklets = ev.fEstimateTracklets;
114   fEstimateITSPure = ev.fEstimateITSPure;
115   fMagneticField= ev.fMagneticField;
116   fIsCollisionCandidate = ev.fIsCollisionCandidate;
117
118   fTriggerMask=ev.fTriggerMask;     // Trigger Type (mask)
119   fTriggerCluster=ev.fTriggerCluster;
120   fReactionPlaneAngle=ev.fReactionPlaneAngle;
121
122   // create collections
123   fTrackCollection = new AliFemtoTrackCollection;
124   fV0Collection = new AliFemtoV0Collection;
125   fXiCollection = new AliFemtoXiCollection;
126   fKinkCollection = new AliFemtoKinkCollection;
127   // copy track collection  
128   for ( AliFemtoTrackIterator tIter=ev.fTrackCollection->begin(); tIter!=ev.fTrackCollection->end(); tIter++) {
129     if ( !tCut || tCut->Pass(*tIter) ) {
130       AliFemtoTrack* trackCopy = new AliFemtoTrack(**tIter);
131       fTrackCollection->push_back(trackCopy);
132     }
133   }
134   // copy v0 collection
135   for ( AliFemtoV0Iterator vIter=ev.fV0Collection->begin(); vIter!=ev.fV0Collection->end(); vIter++) {
136     if ( !vCut || vCut->Pass(*vIter) ) {
137       AliFemtoV0* v0Copy = new AliFemtoV0(**vIter);
138       fV0Collection->push_back(v0Copy);
139     }
140   }
141   // copy xi collection
142   for ( AliFemtoXiIterator xIter=ev.fXiCollection->begin(); xIter!=ev.fXiCollection->end(); xIter++) {
143     if ( !xCut || xCut->Pass(*xIter) ) {
144       AliFemtoXi* xiCopy = new AliFemtoXi(**xIter);
145       fXiCollection->push_back(xiCopy);
146     }
147   }
148   // copy kink collection  
149   for ( AliFemtoKinkIterator kIter=ev.fKinkCollection->begin(); kIter!=ev.fKinkCollection->end(); kIter++) {
150     if ( !kCut || kCut->Pass(*kIter) ) {
151       //cout << " kinkCut passed " << endl;
152       AliFemtoKink* kinkCopy = new AliFemtoKink(**kIter);
153       fKinkCollection->push_back(kinkCopy);
154     }
155   }
156 }
157 //___________________
158 AliFemtoEvent::AliFemtoEvent(const AliFemtoEvent& ev):
159   fEventNumber(0),
160   fRunNumber(0),
161   fNumberOfTracks(0),
162   fNormalizedMult(-1),
163   fSPDMult(0),
164   fEstimateITSTPC(0),
165   fEstimateTracklets(0),
166   fEstimateITSPure(0),
167   fMagneticField(0),
168   fIsCollisionCandidate(kTRUE),
169   fPrimVertPos(0,0,0),
170   fPrimVertCov(),
171   fTrackCollection(0),
172   fV0Collection(0),
173   fXiCollection(0),
174   fKinkCollection(0),
175   fZDCN1Energy(0),   
176   fZDCP1Energy(0),   
177   fZDCN2Energy(0),   
178   fZDCP2Energy(0),   
179   fZDCEMEnergy(0),   
180   fZDCParticipants(0),
181   fTriggerMask(0),  
182   fTriggerCluster(0),
183   fReactionPlaneAngle(0)
184
185   // copy constructor 
186   fEventNumber = ev.fEventNumber;
187   fRunNumber = ev.fRunNumber;
188   
189   SetPrimVertCov(ev.PrimVertCov());
190
191   fZDCN1Energy=ev.fZDCN1Energy;     
192   fZDCP1Energy=ev.fZDCP1Energy;      
193   fZDCN2Energy=ev.fZDCN2Energy;      
194   fZDCP2Energy=ev.fZDCP2Energy;      
195   fZDCEMEnergy=ev.fZDCEMEnergy;
196   fZDCParticipants=ev.fZDCParticipants;
197   fNumberOfTracks = ev.fNumberOfTracks;
198   fEstimateITSTPC = ev.fEstimateITSTPC;
199   fEstimateTracklets = ev.fEstimateTracklets;
200   fEstimateITSPure = ev.fEstimateITSPure;
201   fMagneticField= ev.fMagneticField;
202   fIsCollisionCandidate = ev.fIsCollisionCandidate;
203   fTriggerMask=ev.fTriggerMask;     // Trigger Type (mask)
204   fTriggerCluster=ev.fTriggerCluster;
205   fReactionPlaneAngle=ev.fReactionPlaneAngle;
206   // create collections
207   fTrackCollection = new AliFemtoTrackCollection;
208   fV0Collection = new AliFemtoV0Collection;
209   fXiCollection = new AliFemtoXiCollection;
210   fKinkCollection = new AliFemtoKinkCollection;
211   // copy track collection  
212   for ( AliFemtoTrackIterator tIter=ev.fTrackCollection->begin(); tIter!=ev.fTrackCollection->end(); tIter++) {
213     AliFemtoTrack* trackCopy = new AliFemtoTrack(**tIter);
214     fTrackCollection->push_back(trackCopy);
215   }
216   // copy v0 collection
217   for ( AliFemtoV0Iterator vIter=ev.fV0Collection->begin(); vIter!=ev.fV0Collection->end(); vIter++) {
218     AliFemtoV0* v0Copy = new AliFemtoV0(**vIter);
219     fV0Collection->push_back(v0Copy);
220   }
221   // copy xi collection
222   for ( AliFemtoXiIterator xIter=ev.fXiCollection->begin(); xIter!=ev.fXiCollection->end(); xIter++) {
223     AliFemtoXi* xiCopy = new AliFemtoXi(**xIter);
224     fXiCollection->push_back(xiCopy);
225   }
226   // copy kink collection  
227   for ( AliFemtoKinkIterator kIter=ev.fKinkCollection->begin(); kIter!=ev.fKinkCollection->end(); kIter++) {
228     //cout << " kinkCut passed " << endl;
229     AliFemtoKink* kinkCopy = new AliFemtoKink(**kIter);
230     fKinkCollection->push_back(kinkCopy);
231   }
232 }
233 //______________________________
234 AliFemtoEvent& AliFemtoEvent::operator=(const AliFemtoEvent& aEvent)
235 {
236   // assignment operator
237   if (this == &aEvent)
238     return *this;
239
240   fEventNumber = aEvent.fEventNumber;
241   fRunNumber = aEvent.fRunNumber;
242   
243   fZDCN1Energy=aEvent.fZDCN1Energy;     
244   fZDCP1Energy=aEvent.fZDCP1Energy;      
245   fZDCN2Energy=aEvent.fZDCN2Energy;      
246   fZDCP2Energy=aEvent.fZDCP2Energy;      
247   fZDCEMEnergy=aEvent.fZDCEMEnergy;
248   fZDCParticipants=aEvent.fZDCParticipants;
249   fNumberOfTracks = aEvent.fNumberOfTracks;
250   fEstimateITSTPC = aEvent.fEstimateITSTPC;
251   fEstimateTracklets = aEvent.fEstimateTracklets;
252   fEstimateITSPure = aEvent.fEstimateITSPure;
253   fNormalizedMult = aEvent.fNormalizedMult;
254   fEstimateITSTPC = aEvent.fEstimateITSTPC;
255   fEstimateTracklets = aEvent.fEstimateTracklets;
256   fEstimateITSPure = aEvent.fEstimateITSPure;
257   fMagneticField= aEvent.fMagneticField;
258   fIsCollisionCandidate = aEvent.fIsCollisionCandidate;
259
260   fTriggerMask=aEvent.fTriggerMask;     // Trigger Type (mask)
261   fTriggerCluster=aEvent.fTriggerCluster;
262   fReactionPlaneAngle=aEvent.fReactionPlaneAngle;
263   // create collections
264   fTrackCollection = new AliFemtoTrackCollection;
265   fV0Collection = new AliFemtoV0Collection;
266   fXiCollection = new AliFemtoXiCollection;
267   fKinkCollection = new AliFemtoKinkCollection;
268   // copy track collection  
269   for ( AliFemtoTrackIterator tIter=aEvent.fTrackCollection->begin(); tIter!=aEvent.fTrackCollection->end(); tIter++) {
270     AliFemtoTrack* trackCopy = new AliFemtoTrack(**tIter);
271     fTrackCollection->push_back(trackCopy);
272   }
273   // copy v0 collection
274   for ( AliFemtoV0Iterator vIter=aEvent.fV0Collection->begin(); vIter!=aEvent.fV0Collection->end(); vIter++) {
275     AliFemtoV0* v0Copy = new AliFemtoV0(**vIter);
276     fV0Collection->push_back(v0Copy);
277   }
278   // copy xi collection
279   for ( AliFemtoXiIterator xIter=aEvent.fXiCollection->begin(); xIter!=aEvent.fXiCollection->end(); xIter++) {
280     AliFemtoXi* xiCopy = new AliFemtoXi(**xIter);
281     fXiCollection->push_back(xiCopy);
282   }
283   // copy kink collection  
284   for ( AliFemtoKinkIterator kIter=aEvent.fKinkCollection->begin(); kIter!=aEvent.fKinkCollection->end(); kIter++) {
285     AliFemtoKink* kinkCopy = new AliFemtoKink(**kIter);
286     fKinkCollection->push_back(kinkCopy);
287   }
288
289   return *this;
290 }
291
292 //___________________
293 AliFemtoEvent::~AliFemtoEvent(){
294   // destructor
295 #ifdef STHBTDEBUG
296   cout << " AliFemtoEvent::~AliFemtoEvent() " << endl;
297 #endif
298   for (AliFemtoTrackIterator iter=fTrackCollection->begin();iter!=fTrackCollection->end();iter++){
299     delete *iter;
300   }
301   fTrackCollection->clear();
302   delete fTrackCollection;
303   //must do the same for the V0 collection
304   for (AliFemtoV0Iterator tV0iter=fV0Collection->begin();tV0iter!=fV0Collection->end();tV0iter++){
305     delete *tV0iter;
306   }//added by M Chojnacki To avodid memory leak 
307   fV0Collection->clear();
308   delete fV0Collection;
309   //must do the same for the Xi collection
310   for (AliFemtoXiIterator tXiIter=fXiCollection->begin();tXiIter!=fXiCollection->end();tXiIter++){
311     delete *tXiIter;
312   }
313   fXiCollection->clear();
314   delete fXiCollection;
315   //must do the same for the Kink collection
316   for (AliFemtoKinkIterator kinkIter=fKinkCollection->begin();kinkIter!=fKinkCollection->end();kinkIter++){
317     delete *kinkIter;
318   }
319   fKinkCollection->clear();
320   delete fKinkCollection;
321 }
322 //___________________
323
324
325
326 void AliFemtoEvent::SetEventNumber(const unsigned short& event){fEventNumber = event;}
327 void AliFemtoEvent::SetRunNumber(const int& runNum){fRunNumber = runNum;}
328
329
330 void AliFemtoEvent::SetZDCN1Energy(const float& aZDCN1Energy){fZDCN1Energy=aZDCN1Energy;}
331 void AliFemtoEvent::SetZDCP1Energy(const float& aZDCP1Energy){fZDCP1Energy=aZDCP1Energy;}      
332 void AliFemtoEvent::SetZDCN2Energy(const float& aZDCN2Energy){fZDCN2Energy=aZDCN2Energy;}      
333 void AliFemtoEvent::SetZDCP2Energy(const float& aZDCP2Energy){fZDCP2Energy=aZDCP2Energy;}      
334 void AliFemtoEvent::SetZDCEMEnergy(const float& aZDCEMEnergy){fZDCEMEnergy=aZDCEMEnergy;}    
335 void AliFemtoEvent::SetZDCParticipants(const unsigned int& aZDCParticipants){fZDCParticipants=aZDCParticipants;}
336
337 void AliFemtoEvent::SetNumberOfTracks(const unsigned short& tracks){fNumberOfTracks = tracks;}
338 void AliFemtoEvent::SetNormalizedMult(const int& i){fNormalizedMult = i;}
339 void AliFemtoEvent::SetSPDMult(const int& i){fSPDMult = i;}
340
341 void AliFemtoEvent::SetPrimVertPos(const AliFemtoThreeVector& vp){fPrimVertPos = vp;}
342 void AliFemtoEvent::SetPrimVertCov(const double* v){
343   fPrimVertCov[0] = v[0];
344   fPrimVertCov[1] = v[1];
345   fPrimVertCov[2] = v[2];
346   fPrimVertCov[3] = v[3];
347   fPrimVertCov[4] = v[4];
348   fPrimVertCov[5] = v[5];
349 }
350 void AliFemtoEvent::SetMagneticField(const double& magF){fMagneticField = magF;}
351 void AliFemtoEvent::SetIsCollisionCandidate(const bool& is){fIsCollisionCandidate = is;}
352
353 void AliFemtoEvent::SetTriggerMask(const unsigned long int& aTriggerMask) {fTriggerMask=aTriggerMask;}
354 void AliFemtoEvent::SetTriggerCluster(const unsigned char& aTriggerCluster) {fTriggerCluster=aTriggerCluster;}
355
356
357 unsigned short AliFemtoEvent::EventNumber() const {return fEventNumber;}
358 int            AliFemtoEvent::RunNumber() const {return fRunNumber;}
359
360
361
362 unsigned short AliFemtoEvent::NumberOfTracks() const {return fNumberOfTracks;}
363
364 AliFemtoV0Collection* AliFemtoEvent::V0Collection() const {return fV0Collection;}
365 AliFemtoXiCollection* AliFemtoEvent::XiCollection() const {return fXiCollection;}
366 AliFemtoKinkCollection* AliFemtoEvent::KinkCollection() const {return fKinkCollection;}
367 AliFemtoTrackCollection* AliFemtoEvent::TrackCollection() const {return fTrackCollection;}
368 AliFemtoThreeVector AliFemtoEvent::PrimVertPos() const {return fPrimVertPos;}
369 const double* AliFemtoEvent::PrimVertCov() const {return fPrimVertCov;}
370 double AliFemtoEvent::MagneticField() const {return fMagneticField;}
371 unsigned long int AliFemtoEvent::TriggerMask() const {return fTriggerMask;}
372 unsigned char AliFemtoEvent::TriggerCluster() const {return fTriggerCluster;}
373 bool AliFemtoEvent::IsCollisionCandidate() const {return fIsCollisionCandidate;}
374
375
376 float AliFemtoEvent::ZDCN1Energy() const {return fZDCN1Energy;}       
377 float AliFemtoEvent::ZDCP1Energy() const {return fZDCP1Energy;}       
378 float AliFemtoEvent::ZDCN2Energy() const {return fZDCN2Energy;}       
379 float AliFemtoEvent::ZDCP2Energy() const {return fZDCP2Energy;}       
380 float AliFemtoEvent::ZDCEMEnergy() const {return fZDCEMEnergy;}   
381 unsigned int  AliFemtoEvent::ZDCParticipants() const {return fZDCParticipants;}
382
383 void AliFemtoEvent::SetReactionPlaneAngle(const float& a) { fReactionPlaneAngle = a;}
384 float AliFemtoEvent::ReactionPlaneAngle() const { return fReactionPlaneAngle; }
385
386 //----------------------------- below here is only for star
387
388 double AliFemtoEvent::UncorrectedNumberOfNegativePrimaries() const
389 {
390   return NumberOfTracks()/2;
391 }
392
393 double AliFemtoEvent::SPDMultiplicity() const
394 {
395   return fSPDMult;
396 }
397
398 double AliFemtoEvent::UncorrectedNumberOfPrimaries() const
399 {
400   if (fNormalizedMult < 0) {
401     // Count number of normalized charged tracks 
402     Int_t tNormTrackCount = 0;
403     for (AliFemtoTrackIterator iter=fTrackCollection->begin();iter!=fTrackCollection->end();iter++){
404       if (!((*iter)->Flags()&(AliFemtoTrack::kTPCrefit))) continue;
405       if ((*iter)->TPCncls() < 50) continue;
406       if ((*iter)->TPCchi2()/(*iter)->TPCncls() > 60.0) continue;
407       if ((*iter)->ImpactD() > 6.0) continue;
408       if ((*iter)->ImpactZ() > 6.0) continue;
409       if (fabs((*iter)->P().PseudoRapidity()) > 0.9) continue;
410       
411       tNormTrackCount++;
412     }
413     return tNormTrackCount;
414   }
415
416   return fNormalizedMult;
417   //  return NumberOfTracks();
418 }
419
420 unsigned short AliFemtoEvent::MultiplicityEstimateITSTPC() const
421 {
422   return fEstimateITSTPC;
423 }
424
425 unsigned short AliFemtoEvent::MultiplicityEstimateTracklets() const
426 {
427   return fEstimateTracklets;
428 }
429
430 unsigned short AliFemtoEvent::MultiplicityEstimateITSPure() const
431 {
432   return fEstimateITSPure;
433 }
434
435 void AliFemtoEvent::SetMultiplicityEstimateITSTPC(const unsigned short &s)
436 {
437   fEstimateITSTPC = s;
438 }
439
440 void AliFemtoEvent::SetMultiplicityEstimateTracklets(const unsigned short &s)
441 {
442   fEstimateTracklets = s;
443 }
444
445 void AliFemtoEvent::SetMultiplicityEstimateITSPure(const unsigned short &s)
446 {
447   fEstimateITSPure = s;
448 }