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