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