]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/Chaoticity/AliChaoticityEventCollection.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / Chaoticity / AliChaoticityEventCollection.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 //  This class provides storage for event and track information which 
4 //  are used for same-event as well as mixed-event analyses in AliChaoticity 
5 //
6 //  authors: Dhevan Gangadharan (dhevan.raja.gangadharan@cern.ch)
7 //
8 ////////////////////////////////////////////////////////////////////////////////
9
10 #include "AliChaoticityEventCollection.h"
11
12 AliChaoticityTrackStruct::AliChaoticityTrackStruct():
13   fStatus(0),
14   fFiltermap(0),
15   fId(0),
16   fPhi(0),
17   fPt(0),
18   fMom(0),
19   fP(),
20   fCharge(0),
21   fEta(0),
22   fMass(0),
23   fDCAXY(0),
24   fDCAZ(0),
25   fDCA(0),
26   fEaccepted(0),
27   fKey(0),
28   fClusterMap(0),
29   fSharedMap(0),
30   fX(),
31   fTOFhit(0),
32   fElectron(0),
33   fMuon(0),
34   fPion(0),
35   fKaon(0),
36   fProton(0),
37   fLabel(0)// MC
38 {
39   //Default constructor
40 }
41 AliChaoticityTrackStruct::AliChaoticityTrackStruct(const AliChaoticityTrackStruct &obj)
42   : fStatus(obj.fStatus),
43     fFiltermap(obj.fFiltermap),
44     fId(obj.fId),
45     fPhi(obj.fPhi),
46     fPt(obj.fPt),
47     fMom(obj.fMom),
48     fP(),
49     fCharge(obj.fCharge),
50     fEta(obj.fEta),
51     fMass(obj.fMass),
52     fDCAXY(obj.fDCAXY),
53     fDCAZ(obj.fDCAZ),
54     fDCA(obj.fDCA),
55     fEaccepted(obj.fEaccepted),
56     fKey(obj.fKey),
57     fClusterMap(obj.fClusterMap),
58     fSharedMap(obj.fSharedMap),
59     fX(),
60     fTOFhit(obj.fTOFhit),
61     fElectron(obj.fElectron),
62     fMuon(obj.fMuon),
63     fPion(obj.fPion),
64     fKaon(obj.fKaon),
65     fProton(obj.fProton),
66     fLabel(obj.fLabel)// MC
67 {
68   // copy constructor
69 }
70 AliChaoticityTrackStruct &AliChaoticityTrackStruct::operator=(const AliChaoticityTrackStruct &obj) 
71 {
72   // Assignment operator  
73   if (this == &obj)
74     return *this;
75
76   fStatus = obj.fStatus;
77   fFiltermap = obj.fFiltermap;
78   fId = obj.fId;
79   fPhi = obj.fPhi;
80   fPt = obj.fPt;
81   fMom = obj.fMom;
82   fP[0] = obj.fP[0];
83   fP[1] = obj.fP[1];
84   fP[2] = obj.fP[2];
85   fCharge = obj.fCharge;
86   fEta = obj.fEta;
87   fMass = obj.fMass;
88   fDCAXY = obj.fDCAXY;
89   fDCAZ = obj.fDCAZ;
90   fDCA = obj.fDCA;
91   fEaccepted = obj.fEaccepted;
92   fKey = obj.fKey;
93   fClusterMap = obj.fClusterMap;
94   fSharedMap = obj.fSharedMap;
95   fX[0] = obj.fX[0];
96   fX[1] = obj.fX[1];
97   fX[2] = obj.fX[2];
98   fTOFhit = obj.fTOFhit;
99   fElectron = obj.fElectron;
100   fMuon = obj.fMuon;
101   fPion = obj.fPion;
102   fKaon = obj.fKaon;
103   fProton = obj.fProton;
104   fLabel = obj.fLabel;// MC
105
106   return (*this);
107 }
108 AliChaoticityTrackStruct::~AliChaoticityTrackStruct()
109 {
110   // Destructor
111 }
112
113 //_____________________________________________________________________________
114 AliChaoticityPairStruct::AliChaoticityPairStruct():
115   fP1(),
116   fP2(),
117   fE1(0),
118   fE2(0),
119   fCharge1(0),
120   fCharge2(0),
121   fIndex1(0),
122   fIndex2(0),
123   fQinv(0),
124   fKey1(0),
125   fKey2(0),
126   fLabel1(0),
127   fLabel2(0),
128   fP1MC(),
129   fP2MC()
130 {
131   //Default constructor
132 }
133 AliChaoticityPairStruct::AliChaoticityPairStruct(const AliChaoticityPairStruct &obj)
134   : fP1(),
135     fP2(),
136     fE1(obj.fE1),
137     fE2(obj.fE2),
138     fCharge1(obj.fCharge1),
139     fCharge2(obj.fCharge2),
140     fIndex1(obj.fIndex1),
141     fIndex2(obj.fIndex2),
142     fQinv(obj.fQinv),
143     fKey1(obj.fKey1),
144     fKey2(obj.fKey2),
145     fLabel1(obj.fLabel1),
146     fLabel2(obj.fLabel2),
147     fP1MC(),
148     fP2MC()
149 {
150   // copy constructor
151 }
152 AliChaoticityPairStruct &AliChaoticityPairStruct::operator=(const AliChaoticityPairStruct &obj) 
153 {
154   // Assignment operator  
155   if (this == &obj)
156     return *this;
157
158   fP1[0] = obj.fP1[0];
159   fP1[1] = obj.fP1[1];
160   fP1[2] = obj.fP1[2];
161   fP2[0] = obj.fP2[0];
162   fP2[1] = obj.fP2[1];
163   fP2[2] = obj.fP2[2];
164   fE1 = obj.fE1;
165   fE2 = obj.fE2;
166   fCharge1 = obj.fCharge1;
167   fCharge2 = obj.fCharge2;
168   fIndex1 = obj.fIndex1;
169   fIndex2 = obj.fIndex2;
170   fQinv = obj.fQinv;
171   fKey1 = obj.fKey1;
172   fKey2 = obj.fKey2;
173   fLabel1 = obj.fLabel1;
174   fLabel2 = obj.fLabel2;
175   fP1MC[0] = obj.fP1MC[0];
176   fP1MC[1] = obj.fP1MC[1];
177   fP1MC[2] = obj.fP1MC[2];
178   fP2MC[0] = obj.fP2MC[0];
179   fP2MC[1] = obj.fP2MC[1];
180   fP2MC[2] = obj.fP2MC[2];
181   
182   return (*this);
183 }
184 AliChaoticityPairStruct::~AliChaoticityPairStruct()
185 {
186   // Destructor
187 }
188
189 //_____________________________________________________________________________
190 AliChaoticityNormPairStruct::AliChaoticityNormPairStruct():
191   fCharge1(0),
192   fCharge2(0),
193   fIndex1(0),
194   fIndex2(0),
195   fKey1(0),
196   fKey2(0)
197 {
198   //Default constructor
199 }
200 AliChaoticityNormPairStruct::AliChaoticityNormPairStruct(const AliChaoticityNormPairStruct &obj)
201   : fCharge1(obj.fCharge1),
202     fCharge2(obj.fCharge2),
203     fIndex1(obj.fIndex1),
204     fIndex2(obj.fIndex2),
205     fKey1(obj.fKey1),
206     fKey2(obj.fKey2)
207 {
208   // copy constructor
209 }
210 AliChaoticityNormPairStruct &AliChaoticityNormPairStruct::operator=(const AliChaoticityNormPairStruct &obj) 
211 {
212   // Assignment operator  
213   if (this == &obj)
214     return *this;
215
216   fCharge1 = obj.fCharge1;
217   fCharge2 = obj.fCharge2;
218   fIndex1 = obj.fIndex1;
219   fIndex2 = obj.fIndex2;
220   fKey1 = obj.fKey1;
221   fKey2 = obj.fKey2;
222
223   return (*this);
224 }
225 AliChaoticityNormPairStruct::~AliChaoticityNormPairStruct()
226 {
227   // Destructor
228 }
229
230 //_____________________________________________________________________________
231 AliChaoticityMCStruct::AliChaoticityMCStruct():
232   fPx(0),
233   fPy(0),
234   fPz(0),
235   fPtot(0)
236 {
237   // Default constructor
238 }
239 AliChaoticityMCStruct::AliChaoticityMCStruct(const AliChaoticityMCStruct &obj)
240   : fPx(obj.fPx),
241     fPy(obj.fPy),
242     fPz(obj.fPz),
243     fPtot(obj.fPtot)
244 {
245   // copy constructor
246 }
247 AliChaoticityMCStruct &AliChaoticityMCStruct::operator=(const AliChaoticityMCStruct &obj) 
248 {
249   // Assignment operator  
250   if (this == &obj)
251     return *this;
252
253   fPx = obj.fPx;
254   fPy = obj.fPy;
255   fPz = obj.fPz;
256   fPtot = obj.fPtot;
257   
258   return (*this);
259 }
260 AliChaoticityMCStruct::~AliChaoticityMCStruct()
261 {
262   // Destructor
263 }
264
265 //_____________________________________________________________________________
266 AliChaoticityEventStruct::AliChaoticityEventStruct():
267   fFillStatus(0),
268   fNtracks(0),
269   fNpairsSE(0),
270   fNpairsME(0),
271   fMCarraySize(0),
272   fTracks(0),
273   fPairsSE(0),
274   fPairsME(0),
275   fMCtracks(0)
276 {
277   // Default constructor
278 }
279 AliChaoticityEventStruct::AliChaoticityEventStruct(const AliChaoticityEventStruct &obj)
280   : fFillStatus(obj.fFillStatus),
281     fNtracks(obj.fNtracks),
282     fNpairsSE(obj.fNpairsSE),
283     fNpairsME(obj.fNpairsME),
284     fMCarraySize(obj.fMCarraySize),
285     fTracks(obj.fTracks),
286     fPairsSE(obj.fPairsSE),
287     fPairsME(obj.fPairsME),
288     fMCtracks(obj.fMCtracks)
289 {
290   // copy constructor
291 }
292 AliChaoticityEventStruct &AliChaoticityEventStruct::operator=(const AliChaoticityEventStruct &obj) 
293 {
294   // Assignment operator  
295   if (this == &obj)
296     return *this;
297
298   fFillStatus = obj.fFillStatus;
299   fNtracks = obj.fNtracks;
300   fNpairsSE = obj.fNpairsSE;
301   fNpairsME = obj.fNpairsME;
302   fMCarraySize = obj.fMCarraySize;
303   fTracks = obj.fTracks;
304   fPairsSE = obj.fPairsSE;
305   fPairsME = obj.fPairsME;
306   fMCtracks = obj.fMCtracks;
307   
308   return (*this);
309 }
310 AliChaoticityEventStruct::~AliChaoticityEventStruct()
311 {
312   // Destructor
313   if(fTracks) delete fTracks;
314   if(fPairsSE) delete fPairsSE;
315   if(fPairsME) delete fPairsME;
316   if(fMCtracks) delete fMCtracks;
317 }
318
319 //_____________________________________________________________________________
320 AliChaoticityEventCollection::AliChaoticityEventCollection():
321   fFIFO(0),
322   fLimit(0),
323   fPairLimit(0),
324   fMCLimit(0),
325   fEvtStr(0)
326 {
327   // Default constructor
328 }
329 AliChaoticityEventCollection::AliChaoticityEventCollection(Short_t a, Int_t lim, Int_t plimit, Int_t mcarraylimit, Bool_t MCcase):
330   fFIFO(0),
331   fLimit(0),
332   fPairLimit(0),
333   fMCLimit(0),
334   fEvtStr(0)
335 {
336   
337   // Main constructor
338   SetBuffSize(a);
339   
340   fEvtStr = new AliChaoticityEventStruct[fFIFO];  //allocate pointer array of type particle_event
341   fLimit = lim;
342   fPairLimit = plimit;
343   fMCLimit = mcarraylimit;
344
345   for(Int_t ii = 0; ii < fFIFO; ii++){   //Initialize particle table pointers to NULL
346     (fEvtStr + ii)->fNtracks = 0;
347     (fEvtStr + ii)->fNpairsSE = 0;
348     (fEvtStr + ii)->fNpairsME = 0;
349     (fEvtStr + ii)->fFillStatus = 0;
350     (fEvtStr + ii)->fMCarraySize = 0;
351     //
352     (fEvtStr + ii)->fTracks = NULL;
353     (fEvtStr + ii)->fTracks = new AliChaoticityTrackStruct[fLimit];
354     (fEvtStr + ii)->fPairsSE = NULL;
355     (fEvtStr + ii)->fPairsSE = new AliChaoticityPairStruct[fPairLimit];
356     (fEvtStr + ii)->fPairsME = NULL;
357     (fEvtStr + ii)->fPairsME = new AliChaoticityPairStruct[Int_t(2*fPairLimit)];
358     if(MCcase) (fEvtStr + ii)->fMCtracks = new AliChaoticityMCStruct[fMCLimit];
359     
360   }
361 }
362 AliChaoticityEventCollection::AliChaoticityEventCollection(const AliChaoticityEventCollection &obj)
363   : fFIFO(obj.fFIFO),
364     fLimit(obj.fLimit),
365     fPairLimit(obj.fPairLimit),
366     fMCLimit(obj.fMCLimit),
367     fEvtStr(obj.fEvtStr)
368 {
369   // copy constructor
370 }
371 AliChaoticityEventCollection &AliChaoticityEventCollection::operator=(const AliChaoticityEventCollection &obj) 
372 {
373   // Assignment operator  
374   if (this == &obj)
375     return *this;
376
377   fFIFO = obj.fFIFO;
378   fLimit = obj.fLimit;
379   fPairLimit = obj.fPairLimit;
380   fMCLimit = obj.fMCLimit;
381   fEvtStr = obj.fEvtStr;
382   
383   return (*this);
384 }
385 AliChaoticityEventCollection::~AliChaoticityEventCollection(){
386
387     for(Int_t i = 0; i < fFIFO; i++){
388
389         if((fEvtStr + i)->fTracks != NULL){
390           delete [] (fEvtStr + i)->fTracks;
391           delete [] (fEvtStr + i)->fPairsSE;
392           delete [] (fEvtStr + i)->fPairsME;
393           delete [] (fEvtStr + i)->fMCtracks;
394         }       
395         
396     }
397     
398     delete [] fEvtStr;
399     //remove histos from heap
400
401 }
402
403
404 //_____________________________________________________________________________
405 void AliChaoticityEventCollection::FIFOShift(){ //Shift elements in FIFO by one and clear last element in FIFO 
406   
407   
408   for(UShort_t i=fFIFO-1 ; i > 0; i--){
409     for(Int_t j=0; j<(fEvtStr + i-1)->fNtracks; j++) (fEvtStr + i)->fTracks[j] = (fEvtStr + i-1)->fTracks[j];
410     for(Int_t j=0; j<(fEvtStr + i-1)->fNpairsSE; j++) (fEvtStr + i)->fPairsSE[j] = (fEvtStr + i-1)->fPairsSE[j];
411     for(Int_t j=0; j<(fEvtStr + i-1)->fMCarraySize; j++) (fEvtStr + i)->fMCtracks[j] = (fEvtStr + i-1)->fMCtracks[j];
412
413     (fEvtStr + i)->fFillStatus = (fEvtStr + i-1)->fFillStatus;
414     (fEvtStr + i)->fNtracks = (fEvtStr + i-1)->fNtracks;
415     (fEvtStr + i)->fNpairsSE = (fEvtStr + i-1)->fNpairsSE;
416     (fEvtStr + i)->fNpairsME = 0;
417     (fEvtStr + i)->fMCarraySize = (fEvtStr + i-1)->fMCarraySize;
418     
419   }// fifo loop
420
421
422   (fEvtStr)->fNtracks=0;
423   (fEvtStr)->fNpairsSE=0;
424   (fEvtStr)->fNpairsME=0;
425   (fEvtStr)->fFillStatus=0;
426   (fEvtStr)->fMCarraySize=0;
427 }