1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // AOD event base class
20 // Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
23 #include "AliAODHeader.h"
24 #include "AliCentrality.h"
25 #include "AliEventplane.h"
27 #include <TGeoGlobalMagField.h>
28 #include <TGeoMatrix.h>
29 #include <TObjString.h>
31 ClassImp(AliAODHeader)
33 //______________________________________________________________________________
34 AliAODHeader::AliAODHeader() :
36 fMagneticField(-999.),
37 fMuonMagFieldScale(-999.),
40 fEventplaneMag(-999.),
68 fEventNumberESDFile(-1),
76 fIRInt2InteractionsMap(0),
77 fIRInt1InteractionsMap(0)
79 // default constructor
82 for(int j=0; j<2; j++) fZDCEMEnergy[j] = -999.;
83 for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
84 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
86 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
87 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
88 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = 0;
89 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=-1;
90 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=0;
93 //______________________________________________________________________________
94 AliAODHeader::AliAODHeader(Int_t nRun,
98 const Char_t *title) :
100 fMagneticField(-999.),
101 fMuonMagFieldScale(-999.),
104 fEventplaneMag(-999.),
105 fEventplaneQx(-999.),
106 fEventplaneQy(-999.),
122 fOrbitNumber(nOrbit),
123 fPeriodNumber(nPeriod),
124 fBunchCrossNumber(nBunchX),
125 fRefMultComb05(-999),
126 fRefMultComb08(-999),
132 fEventNumberESDFile(-1),
133 fNumberESDTracks(-1),
140 fIRInt2InteractionsMap(0),
141 fIRInt1InteractionsMap(0)
147 for(int j=0; j<2; j++) fZDCEMEnergy[j] = -999.;
148 for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
149 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
151 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
152 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
153 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=-1;
154 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=0;
157 //______________________________________________________________________________
158 AliAODHeader::AliAODHeader(Int_t nRun,
168 Double_t muonMagFieldScale,
179 const Float_t *vzeroEqFactors,
184 fMagneticField(magField),
185 fMuonMagFieldScale(muonMagFieldScale),
187 fEventplane(eventplane),
191 fZDCN1Energy(n1Energy),
192 fZDCP1Energy(p1Energy),
193 fZDCN2Energy(n2Energy),
194 fZDCP2Energy(p2Energy),
197 fTriggerMask(trigMask),
201 fRefMultPos(refMultPos),
202 fRefMultNeg(refMultNeg),
206 fOrbitNumber(nOrbit),
207 fPeriodNumber(nPeriod),
208 fBunchCrossNumber(nBunchX),
209 fRefMultComb05(refMultComb05),
210 fRefMultComb08(refMultComb08),
211 fTriggerCluster(trigClus),
216 fEventNumberESDFile(-1),
217 fNumberESDTracks(-1),
224 fIRInt2InteractionsMap(0),
225 fIRInt1InteractionsMap(0)
231 for(int j=0; j<2; j++) fZDCEMEnergy[j] = emEnergy[j];
232 for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
233 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
235 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
236 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
237 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = 0;
238 if (vzeroEqFactors) for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j] = vzeroEqFactors[j];
239 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=0;
242 //______________________________________________________________________________
243 AliAODHeader::~AliAODHeader()
251 //______________________________________________________________________________
252 AliAODHeader::AliAODHeader(const AliAODHeader& hdr) :
254 fMagneticField(hdr.fMagneticField),
255 fMuonMagFieldScale(hdr.fMuonMagFieldScale),
256 fCentrality(hdr.fCentrality),
257 fEventplane(hdr.fEventplane),
258 fEventplaneMag(hdr.fEventplaneMag),
259 fEventplaneQx(hdr.fEventplaneQx),
260 fEventplaneQy(hdr.fEventplaneQy),
261 fZDCN1Energy(hdr.fZDCN1Energy),
262 fZDCP1Energy(hdr.fZDCP1Energy),
263 fZDCN2Energy(hdr.fZDCN2Energy),
264 fZDCP2Energy(hdr.fZDCP2Energy),
267 fTriggerMask(hdr.fTriggerMask),
268 fFiredTriggers(hdr.fFiredTriggers),
269 fRunNumber(hdr.fRunNumber),
270 fRefMult(hdr.fRefMult),
271 fRefMultPos(hdr.fRefMultPos),
272 fRefMultNeg(hdr.fRefMultNeg),
273 fNMuons(hdr.fNMuons),
274 fNDimuons(hdr.fNDimuons),
275 fEventType(hdr.fEventType),
276 fOrbitNumber(hdr.fOrbitNumber),
277 fPeriodNumber(hdr.fPeriodNumber),
278 fBunchCrossNumber(hdr.fBunchCrossNumber),
279 fRefMultComb05(hdr.fRefMultComb05),
280 fRefMultComb08(hdr.fRefMultComb08),
281 fTriggerCluster(hdr.fTriggerCluster),
282 fDiamondZ(hdr.fDiamondZ),
283 fDiamondSig2Z(hdr.fDiamondSig2Z),
284 fOfflineTrigger(hdr.fOfflineTrigger),
285 fESDFileName(hdr.fESDFileName),
286 fEventNumberESDFile(hdr.fEventNumberESDFile),
287 fNumberESDTracks(hdr.fNumberESDTracks),
288 fL0TriggerInputs(hdr.fL0TriggerInputs),
289 fL1TriggerInputs(hdr.fL1TriggerInputs),
290 fL2TriggerInputs(hdr.fL2TriggerInputs),
291 fTPConlyRefMult(hdr.fTPConlyRefMult),
292 fCentralityP(new AliCentrality(*hdr.fCentralityP)),
293 fEventplaneP(new AliEventplane(*hdr.fEventplaneP)),
294 fIRInt2InteractionsMap(hdr.fIRInt2InteractionsMap),
295 fIRInt1InteractionsMap(hdr.fIRInt1InteractionsMap)
300 SetTitle(hdr.fTitle);
301 SetQTheta(hdr.fQTheta, hdr.fNQTheta);
302 SetZDCEMEnergy(hdr.fZDCEMEnergy[0], hdr.fZDCEMEnergy[1]);
303 for(Int_t i=0; i<2; i++) fDiamondXY[i]=hdr.fDiamondXY[i];
304 for(Int_t i=0; i<3; i++) fDiamondCovXY[i]=hdr.fDiamondCovXY[i];
307 for(Int_t m=0; m<kNPHOSMatrix; m++){
308 if(hdr.fPHOSMatrix[m])
309 fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
314 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
315 if(hdr.fEMCALMatrix[sm])
316 fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
320 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = hdr.fITSClusters[i];
321 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=hdr.fVZEROEqFactors[j];
322 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=hdr.fT0spread[i];
326 //______________________________________________________________________________
327 AliAODHeader& AliAODHeader::operator=(const AliAODHeader& hdr)
329 // Assignment operator
332 AliVHeader::operator=(hdr);
334 fMagneticField = hdr.fMagneticField;
335 fMuonMagFieldScale= hdr.fMuonMagFieldScale;
336 fCentrality = hdr.fCentrality;
337 fEventplane = hdr.fEventplane;
338 fEventplaneMag = hdr.fEventplaneMag;
339 fEventplaneQx = hdr.fEventplaneQx;
340 fEventplaneQy = hdr.fEventplaneQy;
341 fZDCN1Energy = hdr.fZDCN1Energy;
342 fZDCP1Energy = hdr.fZDCP1Energy;
343 fZDCN2Energy = hdr.fZDCN2Energy;
344 fZDCP2Energy = hdr.fZDCP2Energy;
345 fTriggerMask = hdr.fTriggerMask;
346 fFiredTriggers = hdr.fFiredTriggers;
347 fRunNumber = hdr.fRunNumber;
348 fRefMult = hdr.fRefMult;
349 fRefMultPos = hdr.fRefMultPos;
350 fRefMultNeg = hdr.fRefMultNeg;
351 fEventType = hdr.fEventType;
352 fOrbitNumber = hdr.fOrbitNumber;
353 fPeriodNumber = hdr.fPeriodNumber;
354 fBunchCrossNumber = hdr.fBunchCrossNumber;
355 fRefMultComb05 = hdr.fRefMultComb05;
356 fRefMultComb08 = hdr.fRefMultComb08;
358 fTriggerCluster = hdr.fTriggerCluster;
359 fNMuons = hdr.fNMuons;
360 fNDimuons = hdr.fNDimuons;
361 fDiamondZ = hdr.fDiamondZ;
362 fDiamondSig2Z = hdr.fDiamondSig2Z;
363 fOfflineTrigger = hdr.fOfflineTrigger;
364 fESDFileName = hdr.fESDFileName;
365 fEventNumberESDFile = hdr.fEventNumberESDFile;
366 fNumberESDTracks = hdr.fNumberESDTracks;
367 fL0TriggerInputs = hdr.fL0TriggerInputs;
368 fL1TriggerInputs = hdr.fL1TriggerInputs;
369 fL2TriggerInputs = hdr.fL2TriggerInputs;
370 fTPConlyRefMult = hdr.fTPConlyRefMult;
372 fIRInt2InteractionsMap = hdr.fIRInt2InteractionsMap;
373 fIRInt1InteractionsMap = hdr.fIRInt1InteractionsMap;
375 if(hdr.fEventplaneP){
376 if(fEventplaneP)*fEventplaneP = *hdr.fEventplaneP;
377 else fEventplaneP = new AliEventplane(*hdr.fEventplaneP);
380 if(hdr.fCentralityP){
381 if(fCentralityP)*fCentralityP = *hdr.fCentralityP;
382 else fCentralityP = new AliCentrality(*hdr.fCentralityP);
386 SetTitle(hdr.fTitle);
387 SetQTheta(hdr.fQTheta, hdr.fNQTheta);
388 SetZDCEMEnergy(hdr.fZDCEMEnergy[0], hdr.fZDCEMEnergy[1]);
389 for(Int_t i=0; i<2; i++) fDiamondXY[i]=hdr.fDiamondXY[i];
390 for(Int_t i=0; i<3; i++) fDiamondCovXY[i]=hdr.fDiamondCovXY[i];
392 for(Int_t m=0; m<kNPHOSMatrix; m++){
393 if(hdr.fPHOSMatrix[m]){
394 if(fPHOSMatrix[m])delete fPHOSMatrix[m];
395 fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
401 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
402 if(hdr.fEMCALMatrix[sm]){
403 if(fEMCALMatrix[sm])delete fEMCALMatrix[sm];
404 fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
412 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = hdr.fITSClusters[i];
413 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j] = hdr.fVZEROEqFactors[j];
414 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=hdr.fT0spread[i];
419 //______________________________________________________________________________
420 void AliAODHeader::SetQTheta(Double_t *QTheta, UInt_t size)
422 if (QTheta && size>0) {
423 if (size != (UInt_t)fNQTheta) {
426 fQTheta = new Double_t[fNQTheta];
429 for (Int_t i = 0; i < fNQTheta; i++) {
430 fQTheta[i] = QTheta[i];
439 //______________________________________________________________________________
440 Double_t AliAODHeader::GetQTheta(UInt_t i) const
442 if (fQTheta && i < (UInt_t)fNQTheta) {
449 //______________________________________________________________________________
450 void AliAODHeader::RemoveQTheta()
459 void AliAODHeader::Clear(Option_t* /*opt*/)
472 fEventplaneMag = -999.;
473 fEventplaneQx = -999.;
474 fEventplaneQy = -999.;
479 //______________________________________________________________________________
480 void AliAODHeader::Print(Option_t* /*option*/) const
482 // prints event information
484 printf("Run # : %d\n", fRunNumber);
485 printf("Bunch Crossing # : %d\n", fBunchCrossNumber);
486 printf("Orbit Number # : %d\n", fOrbitNumber);
487 printf("Period Number # : %d\n", fPeriodNumber);
488 printf("Trigger mask : %lld\n", fTriggerMask);
489 printf("Trigger cluster : %d\n", fTriggerCluster);
490 printf("Event Type : %d\n", fEventType);
491 printf("Magnetic field : %f\n", fMagneticField);
492 printf("Muon mag. field scale : %f\n", fMuonMagFieldScale);
494 printf("Centrality : %f\n", fCentrality);
495 printf("Event plane Ang : %f\n", fEventplane);
496 printf("Event plane Mag : %f\n", fEventplaneMag);
497 printf("Event plane Qx : %f\n", fEventplaneQx);
498 printf("Event plane Qy : %f\n", fEventplaneQy);
499 printf("ZDC N1 Energy : %f\n", fZDCN1Energy);
500 printf("ZDC P1 Energy : %f\n", fZDCP1Energy);
501 printf("ZDC N2 Energy : %f\n", fZDCN2Energy);
502 printf("ZDC P2 Energy : %f\n", fZDCP2Energy);
503 printf("ZDC EM1 Energy : %f\n", fZDCEMEnergy[0]);
504 printf("ZDC EM2 Energy : %f\n", fZDCEMEnergy[1]);
505 printf("ref. Multiplicity : %d\n", fRefMult);
506 printf("ref. Multiplicity (pos) : %d\n", fRefMultPos);
507 printf("ref. Multiplicity (neg) : %d\n", fRefMultNeg);
508 printf("ref. Mult.Comb |eta|<.5 : %d\n", fRefMultComb05);
509 printf("ref. Mult.Comb |eta|<.8 : %d\n", fRefMultComb08);
510 printf("number of muons : %d\n", fNMuons);
511 printf("number of dimuons : %d\n", fNDimuons);
512 printf("offline trigger : %u\n", fOfflineTrigger);
515 for (UInt_t i = 0; i<(UInt_t)fNQTheta; i++) {
516 printf("QTheta[%d] : %13.3e\n", i, GetQTheta(i));
519 printf("V0 Eq factors: ");
520 for (Int_t j=0; j<64; ++j) printf(" %.3f",fVZEROEqFactors[j]);
526 //__________________________________________________________________________
527 Int_t AliAODHeader::FindIRIntInteractionsBXMap(Int_t difference) const
530 // The mapping is of 181 bits, from -90 to +90
534 if(difference<-90 || difference>90) return bin;
535 else { bin = 90 + difference; }
540 //__________________________________________________________________________
541 Int_t AliAODHeader::GetIRInt2ClosestInteractionMap() const
544 // Calculation of the closest interaction
546 Int_t firstNegative=100;
547 for(Int_t item=-1; item>=-90; item--) {
548 Int_t bin = FindIRIntInteractionsBXMap(item);
549 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
551 firstNegative = item;
555 Int_t firstPositive=100;
556 for(Int_t item=1; item<=90; item++) {
557 Int_t bin = FindIRIntInteractionsBXMap(item);
558 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
560 firstPositive = item;
565 Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative);
566 if(firstPositive==100 && firstNegative==100) closest=0;
570 //__________________________________________________________________________
571 Int_t AliAODHeader::GetIRInt1ClosestInteractionMap(Int_t gap) const
574 // Calculation of the closest interaction
575 // In case of VZERO (Int1) one has to introduce a gap
576 // in order to avoid false positivies from after-pulses
578 Int_t firstNegative=100;
579 for(Int_t item=-1; item>=-90; item--) {
580 Int_t bin = FindIRIntInteractionsBXMap(item);
581 Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin);
583 firstNegative = item;
587 Int_t firstPositive=100;
588 for(Int_t item=1+gap; item<=90; item++) {
589 Int_t bin = FindIRIntInteractionsBXMap(item);
590 Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin);
592 firstPositive = item;
597 Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative);
598 if(firstPositive==100 && firstNegative==100) closest=0;
602 //__________________________________________________________________________
603 Int_t AliAODHeader::GetIRInt2LastInteractionMap() const
606 // Calculation of the last interaction
608 Int_t lastNegative=0;
609 for(Int_t item=-90; item<=-1; item++) {
610 Int_t bin = FindIRIntInteractionsBXMap(item);
611 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
617 Int_t lastPositive=0;
618 for(Int_t item=90; item>=1; item--) {
619 Int_t bin = FindIRIntInteractionsBXMap(item);
620 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
627 Int_t last = lastPositive > TMath::Abs(lastNegative) ? lastPositive : TMath::Abs(lastNegative);
631 //__________________________________________________________________________
632 Bool_t AliAODHeader::InitMagneticField() const
634 // Create mag field from stored information
636 const double def5kg = 5.00667905807495117e+00;
637 const double def2kg = 2.04487347602844238e+00;
639 AliMagF* fld = (AliMagF*) TGeoGlobalMagField::Instance()->GetField();
641 if (TGeoGlobalMagField::Instance()->IsLocked()) {
642 if (fld->TestBit(AliMagF::kOverrideGRP)) {
643 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
644 AliInfo("ExpertMode!!! Running with the externally locked B field !");
648 AliInfo("Destroying existing B field instance!");
649 delete TGeoGlobalMagField::Instance();
652 double fc5 = fMagneticField/def5kg;
653 double fc2 = fMagneticField/def2kg;
654 Bool_t use5 = TMath::Abs(TMath::Abs(fc5)-1.) < TMath::Abs(TMath::Abs(fc2)-1.);
656 fld = new AliMagF("mag","mag",use5 ? fc5 : fc2, fMuonMagFieldScale, use5 ? AliMagF::k5kG : AliMagF::k2kG);
659 TGeoGlobalMagField::Instance()->SetField( fld );
660 TGeoGlobalMagField::Instance()->Lock();
661 AliInfo("Running with the B field constructed out of the AOD Header !");
665 AliError("Failed to create a B field map !");