d1bb9ff338bf08ab85daedf5df6415e946821d01
[u/mrichter/AliRoot.git] / STEER / AliAODHeader.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //     AOD event base class
20 //     Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
22
23 #include "AliAODHeader.h"
24 #include "AliCentrality.h"
25 #include "AliEventplane.h"
26 #include <TGeoMatrix.h>
27 #include <TObjString.h>
28
29 ClassImp(AliAODHeader)
30
31 //______________________________________________________________________________
32 AliAODHeader::AliAODHeader() : 
33   AliVHeader(),
34   fMagneticField(-999.),
35   fMuonMagFieldScale(-999.),
36   fCentrality(-999.),
37   fEventplane(-999.),
38   fZDCN1Energy(-999.),
39   fZDCP1Energy(-999.),
40   fZDCN2Energy(-999.),
41   fZDCP2Energy(-999.),
42   fNQTheta(0),
43   fQTheta(0x0),
44   fTriggerMask(0),
45   fFiredTriggers(),
46   fRunNumber(-999),  
47   fRefMult(-999),
48   fRefMultPos(-999),
49   fRefMultNeg(-999),
50   fNMuons(0),
51   fNDimuons(0),
52   fEventType(0),
53   fOrbitNumber(0),
54   fPeriodNumber(0),
55   fBunchCrossNumber(0),
56   fTriggerCluster(0), 
57   fDiamondZ(0.), 
58   fDiamondSig2Z(0.),
59   fOfflineTrigger(0),
60   fESDFileName(""),
61   fEventNumberESDFile(-1),
62   fL0TriggerInputs(0),
63   fL1TriggerInputs(0),
64   fL2TriggerInputs(0),
65   fCentralityP(0),
66   fEventplaneP(0)
67 {
68   // default constructor
69
70   SetName("header");
71   for(int j=0; j<2; j++) fZDCEMEnergy[j] = -999.;
72   for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
73   fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
74   fDiamondCovXY[1]=0.;
75   for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
76   for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
77 }
78
79 //______________________________________________________________________________
80 AliAODHeader::AliAODHeader(Int_t nRun, 
81                            UShort_t nBunchX,
82                            UInt_t nOrbit,
83                            UInt_t nPeriod,
84                            const Char_t *title) :
85   AliVHeader(),
86   fMagneticField(-999.),
87   fMuonMagFieldScale(-999.),
88   fCentrality(-999.),
89   fEventplane(-999.),
90   fZDCN1Energy(-999.),
91   fZDCP1Energy(-999.),
92   fZDCN2Energy(-999.),
93   fZDCP2Energy(-999.),
94   fNQTheta(0),
95   fQTheta(0x0),
96   fTriggerMask(0),
97   fFiredTriggers(),
98   fRunNumber(nRun),
99   fRefMult(-999),
100   fRefMultPos(-999),
101   fRefMultNeg(-999),
102   fNMuons(0),
103   fNDimuons(0),
104   fEventType(0),
105   fOrbitNumber(nOrbit),
106   fPeriodNumber(nPeriod),
107   fBunchCrossNumber(nBunchX),
108   fTriggerCluster(0), 
109   fDiamondZ(0.), 
110   fDiamondSig2Z(0.),
111   fOfflineTrigger(0),
112   fESDFileName(""),
113   fEventNumberESDFile(-1),
114   fL0TriggerInputs(0),
115   fL1TriggerInputs(0),
116   fL2TriggerInputs(0),
117   fCentralityP(0),
118   fEventplaneP(0)
119 {
120   // constructor
121
122   SetName("header");
123   SetTitle(title);
124   for(int j=0; j<2; j++) fZDCEMEnergy[j] = -999.;
125   for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
126   fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
127   fDiamondCovXY[1]=0.;
128   for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
129   for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
130 }
131
132 //______________________________________________________________________________
133 AliAODHeader::AliAODHeader(Int_t nRun, 
134                            UShort_t nBunchX,
135                            UInt_t nOrbit,
136                            UInt_t nPeriod,
137                            Int_t refMult,
138                            Int_t refMultPos,
139                            Int_t refMultNeg,
140                            Double_t magField,
141                            Double_t muonMagFieldScale,
142                            Double_t cent,
143                            Double_t eventplane,
144                            Double_t n1Energy,
145                            Double_t p1Energy,
146                            Double_t n2Energy,
147                            Double_t p2Energy,
148                            Double_t *emEnergy,
149                            ULong64_t trigMask,
150                            UChar_t trigClus,
151                            UInt_t evttype,
152                            const Char_t *title,
153                            Int_t nMuons,
154                            Int_t nDimuons) :
155   AliVHeader(),
156   fMagneticField(magField),
157   fMuonMagFieldScale(muonMagFieldScale),
158   fCentrality(cent),
159   fEventplane(eventplane),
160   fZDCN1Energy(n1Energy),
161   fZDCP1Energy(p1Energy),
162   fZDCN2Energy(n2Energy),
163   fZDCP2Energy(p2Energy),
164   fNQTheta(0),
165   fQTheta(0x0),
166   fTriggerMask(trigMask),
167   fFiredTriggers(),
168   fRunNumber(nRun),  
169   fRefMult(refMult),
170   fRefMultPos(refMultPos),
171   fRefMultNeg(refMultNeg),
172   fNMuons(nMuons),
173   fNDimuons(nDimuons),
174   fEventType(evttype),
175   fOrbitNumber(nOrbit),
176   fPeriodNumber(nPeriod),
177   fBunchCrossNumber(nBunchX),
178   fTriggerCluster(trigClus),
179   fDiamondZ(0.), 
180   fDiamondSig2Z(0.),
181   fOfflineTrigger(0),
182   fESDFileName(""),
183   fEventNumberESDFile(-1),
184   fL0TriggerInputs(0),
185   fL1TriggerInputs(0),
186   fL2TriggerInputs(0),
187   fCentralityP(0),
188   fEventplaneP(0)
189 {
190   // constructor
191
192   SetName("header");
193   SetTitle(title);
194   for(int j=0; j<2; j++) fZDCEMEnergy[j] = emEnergy[j];
195   for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
196   fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
197   fDiamondCovXY[1]=0.;
198   for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
199   for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
200 }
201
202 //______________________________________________________________________________
203 AliAODHeader::~AliAODHeader() 
204 {
205   // destructor
206   delete fCentralityP;
207   delete fEventplaneP;
208   RemoveQTheta();
209 }
210
211 //______________________________________________________________________________
212 AliAODHeader::AliAODHeader(const AliAODHeader& hdr) :
213   AliVHeader(hdr),
214   fMagneticField(hdr.fMagneticField),
215   fMuonMagFieldScale(hdr.fMuonMagFieldScale),
216   fCentrality(hdr.fCentrality),
217   fEventplane(hdr.fEventplane),
218   fZDCN1Energy(hdr.fZDCN1Energy),
219   fZDCP1Energy(hdr.fZDCP1Energy),
220   fZDCN2Energy(hdr.fZDCN2Energy),
221   fZDCP2Energy(hdr.fZDCP2Energy),
222   fNQTheta(0),
223   fQTheta(0x0),
224   fTriggerMask(hdr.fTriggerMask),
225   fFiredTriggers(hdr.fFiredTriggers),
226   fRunNumber(hdr.fRunNumber),  
227   fRefMult(hdr.fRefMult), 
228   fRefMultPos(hdr.fRefMultPos), 
229   fRefMultNeg(hdr.fRefMultNeg),
230   fNMuons(hdr.fNMuons),
231   fNDimuons(hdr.fNDimuons),
232   fEventType(hdr.fEventType),
233   fOrbitNumber(hdr.fOrbitNumber),
234   fPeriodNumber(hdr.fPeriodNumber),
235   fBunchCrossNumber(hdr.fBunchCrossNumber),
236   fTriggerCluster(hdr.fTriggerCluster), 
237   fDiamondZ(hdr.fDiamondZ), 
238   fDiamondSig2Z(hdr.fDiamondSig2Z),
239   fOfflineTrigger(hdr.fOfflineTrigger),
240   fESDFileName(hdr.fESDFileName),
241   fEventNumberESDFile(hdr.fEventNumberESDFile),
242   fL0TriggerInputs(hdr.fL0TriggerInputs),
243   fL1TriggerInputs(hdr.fL1TriggerInputs),
244   fL2TriggerInputs(hdr.fL2TriggerInputs),
245   fCentralityP(new AliCentrality(*hdr.fCentralityP)),
246   fEventplaneP(new AliEventplane(*hdr.fEventplaneP))
247 {
248   // Copy constructor.
249   
250   SetName(hdr.fName);
251   SetTitle(hdr.fTitle);
252   SetQTheta(hdr.fQTheta, hdr.fNQTheta);
253   SetZDCEMEnergy(hdr.fZDCEMEnergy[0], hdr.fZDCEMEnergy[1]);
254   for(Int_t i=0; i<2; i++) fDiamondXY[i]=hdr.fDiamondXY[i];
255   for(Int_t i=0; i<3; i++) fDiamondCovXY[i]=hdr.fDiamondCovXY[i];
256
257
258   for(Int_t m=0; m<kNPHOSMatrix; m++){
259       if(hdr.fPHOSMatrix[m])
260           fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
261       else
262           fPHOSMatrix[m]=0;
263   }
264   
265   for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
266       if(hdr.fEMCALMatrix[sm])
267           fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
268       else
269           fEMCALMatrix[sm]=0;
270   }
271
272 }
273
274 //______________________________________________________________________________
275 AliAODHeader& AliAODHeader::operator=(const AliAODHeader& hdr)
276 {
277   // Assignment operator
278   if(this!=&hdr) {
279     
280      AliVHeader::operator=(hdr);
281     
282     fMagneticField    = hdr.fMagneticField;
283     fMuonMagFieldScale= hdr.fMuonMagFieldScale;
284     fCentrality       = hdr.fCentrality;
285     fEventplane       = hdr.fEventplane;
286     fZDCN1Energy      = hdr.fZDCN1Energy;
287     fZDCP1Energy      = hdr.fZDCP1Energy;
288     fZDCN2Energy      = hdr.fZDCN2Energy;
289     fZDCP2Energy      = hdr.fZDCP2Energy;
290     fTriggerMask      = hdr.fTriggerMask;
291     fFiredTriggers    = hdr.fFiredTriggers;
292     fRunNumber        = hdr.fRunNumber;
293     fRefMult          = hdr.fRefMult;
294     fRefMultPos       = hdr.fRefMultPos;
295     fRefMultNeg       = hdr.fRefMultNeg;
296     fEventType        = hdr.fEventType;
297     fOrbitNumber      = hdr.fOrbitNumber;
298     fPeriodNumber     = hdr.fPeriodNumber;
299     fBunchCrossNumber = hdr.fBunchCrossNumber;
300     fTriggerCluster   = hdr.fTriggerCluster;
301     fNMuons           = hdr.fNMuons;
302     fNDimuons         = hdr.fNDimuons;
303     fDiamondZ         = hdr.fDiamondZ;
304     fDiamondSig2Z     = hdr.fDiamondSig2Z;
305     fOfflineTrigger   = hdr.fOfflineTrigger;
306     fESDFileName      = hdr.fESDFileName;
307     fEventNumberESDFile = hdr.fEventNumberESDFile;
308     fL0TriggerInputs    = hdr.fL0TriggerInputs;
309     fL1TriggerInputs    = hdr.fL1TriggerInputs;
310     fL2TriggerInputs    = hdr.fL2TriggerInputs;
311     fCentralityP        = new AliCentrality(*hdr.fCentralityP);
312     fEventplaneP        = new AliEventplane(*hdr.fEventplaneP);
313
314     SetName(hdr.fName);
315     SetTitle(hdr.fTitle);
316     SetQTheta(hdr.fQTheta, hdr.fNQTheta);
317     SetZDCEMEnergy(hdr.fZDCEMEnergy[0], hdr.fZDCEMEnergy[1]);
318     for(Int_t i=0; i<2; i++) fDiamondXY[i]=hdr.fDiamondXY[i];
319     for(Int_t i=0; i<3; i++) fDiamondCovXY[i]=hdr.fDiamondCovXY[i];
320
321     for(Int_t m=0; m<kNPHOSMatrix; m++){
322         if(hdr.fPHOSMatrix[m])
323             fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
324         else
325             fPHOSMatrix[m]=0;
326     }
327     
328     for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
329         if(hdr.fEMCALMatrix[sm])
330             fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
331         else
332             fEMCALMatrix[sm]=0;
333   }
334
335   }
336
337
338   return *this;
339 }
340
341 //______________________________________________________________________________
342 void AliAODHeader::SetQTheta(Double_t *QTheta, UInt_t size) 
343 {
344   if (QTheta && size>0) {
345     if (size != (UInt_t)fNQTheta) {
346       RemoveQTheta();
347       fNQTheta = size;
348       fQTheta = new Double_t[fNQTheta];
349     }
350     
351     for (Int_t i = 0; i < fNQTheta; i++) {
352       fQTheta[i] = QTheta[i];
353     }
354   } else {
355     RemoveQTheta();
356   }
357
358   return;
359 }
360
361 //______________________________________________________________________________
362 Double_t AliAODHeader::GetQTheta(UInt_t i) const
363 {
364   if (fQTheta && i < (UInt_t)fNQTheta) {
365     return fQTheta[i];
366   } else {
367     return -999.;
368   }
369 }
370
371 //______________________________________________________________________________
372 void AliAODHeader::RemoveQTheta()
373 {
374   delete[] fQTheta;
375   fQTheta = 0x0;
376   fNQTheta = 0;
377
378   return;
379 }
380
381 void AliAODHeader::Clear(Option_t* /*opt*/)
382 {
383 // Clear memory
384   RemoveQTheta();
385   if (fCentralityP){
386     delete fCentralityP;
387     fCentralityP = 0;
388     fCentrality = -999;
389   }
390   if (fEventplaneP){
391     delete fEventplaneP;
392     fEventplaneP = 0;
393     fEventplane = -999;
394   }
395   return;
396 }
397
398 //______________________________________________________________________________
399 void AliAODHeader::Print(Option_t* /*option*/) const 
400 {
401   // prints event information
402
403   printf("Run #                   : %d\n", fRunNumber);
404   printf("Bunch Crossing  #       : %d\n", fBunchCrossNumber);
405   printf("Orbit Number #          : %d\n", fOrbitNumber);
406   printf("Period Number #         : %d\n", fPeriodNumber);
407   printf("Trigger mask            : %lld\n", fTriggerMask);
408   printf("Trigger cluster         : %d\n", fTriggerCluster);
409   printf("Event Type              : %d\n", fEventType);
410   printf("Magnetic field          : %f\n", fMagneticField);
411   printf("Muon mag. field scale   : %f\n", fMuonMagFieldScale);
412   
413   printf("Centrality              : %f\n", fCentrality);
414   printf("Event plane             : %f\n", fEventplane);
415   printf("ZDC N1 Energy           : %f\n", fZDCN1Energy);
416   printf("ZDC P1 Energy           : %f\n", fZDCP1Energy);
417   printf("ZDC N2 Energy           : %f\n", fZDCN2Energy);
418   printf("ZDC P2 Energy           : %f\n", fZDCP2Energy);
419   printf("ZDC EM1 Energy          : %f\n", fZDCEMEnergy[0]);
420   printf("ZDC EM2 Energy          : %f\n", fZDCEMEnergy[1]);
421   printf("ref. Multiplicity       : %d\n", fRefMult);
422   printf("ref. Multiplicity (pos) : %d\n", fRefMultPos);
423   printf("ref. Multiplicity (neg) : %d\n", fRefMultNeg);
424   printf("number of muons         : %d\n", fNMuons);
425   printf("number of dimuons       : %d\n", fNDimuons);
426   printf("offline trigger         : %u\n", fOfflineTrigger);
427
428   if (fQTheta) {
429     for (UInt_t i = 0; i<(UInt_t)fNQTheta; i++) {
430       printf("QTheta[%d]              : %13.3e\n", i, GetQTheta(i));
431     }
432   }
433
434   return;
435 }