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.),
57 fNGlobalMuons(0), // AU
58 fNGlobalDimuons(0), // AU
70 fEventNumberESDFile(-1),
78 fIRInt2InteractionsMap(0),
79 fIRInt1InteractionsMap(0)
81 // default constructor
84 for(int j=0; j<2; j++) fZDCEMEnergy[j] = -999.;
85 for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
86 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
88 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
89 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
90 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = 0;
91 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=-1;
92 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=0;
95 //______________________________________________________________________________
96 AliAODHeader::AliAODHeader(Int_t nRun,
100 const Char_t *title) :
102 fMagneticField(-999.),
103 fMuonMagFieldScale(-999.),
106 fEventplaneMag(-999.),
107 fEventplaneQx(-999.),
108 fEventplaneQy(-999.),
123 fNGlobalMuons(0), // AU
124 fNGlobalDimuons(0), // AU
126 fOrbitNumber(nOrbit),
127 fPeriodNumber(nPeriod),
128 fBunchCrossNumber(nBunchX),
129 fRefMultComb05(-999),
130 fRefMultComb08(-999),
136 fEventNumberESDFile(-1),
137 fNumberESDTracks(-1),
144 fIRInt2InteractionsMap(0),
145 fIRInt1InteractionsMap(0)
151 for(int j=0; j<2; j++) fZDCEMEnergy[j] = -999.;
152 for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
153 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
155 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
156 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
157 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=-1;
158 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=0;
161 //______________________________________________________________________________
162 AliAODHeader::AliAODHeader(Int_t nRun,
172 Double_t muonMagFieldScale,
183 const Float_t *vzeroEqFactors,
187 Int_t nGlobalMuons, // AU
188 Int_t nGlobalDimuons) : // AU
190 fMagneticField(magField),
191 fMuonMagFieldScale(muonMagFieldScale),
193 fEventplane(eventplane),
197 fZDCN1Energy(n1Energy),
198 fZDCP1Energy(p1Energy),
199 fZDCN2Energy(n2Energy),
200 fZDCP2Energy(p2Energy),
203 fTriggerMask(trigMask),
207 fRefMultPos(refMultPos),
208 fRefMultNeg(refMultNeg),
211 fNGlobalMuons(nGlobalMuons), // AU
212 fNGlobalDimuons(nGlobalDimuons), // AU
214 fOrbitNumber(nOrbit),
215 fPeriodNumber(nPeriod),
216 fBunchCrossNumber(nBunchX),
217 fRefMultComb05(refMultComb05),
218 fRefMultComb08(refMultComb08),
219 fTriggerCluster(trigClus),
224 fEventNumberESDFile(-1),
225 fNumberESDTracks(-1),
232 fIRInt2InteractionsMap(0),
233 fIRInt1InteractionsMap(0)
239 for(int j=0; j<2; j++) fZDCEMEnergy[j] = emEnergy[j];
240 for(Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
241 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
243 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
244 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
245 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = 0;
246 if (vzeroEqFactors) for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j] = vzeroEqFactors[j];
247 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=0;
250 //______________________________________________________________________________
251 AliAODHeader::~AliAODHeader()
259 //______________________________________________________________________________
260 AliAODHeader::AliAODHeader(const AliAODHeader& hdr) :
262 fMagneticField(hdr.fMagneticField),
263 fMuonMagFieldScale(hdr.fMuonMagFieldScale),
264 fCentrality(hdr.fCentrality),
265 fEventplane(hdr.fEventplane),
266 fEventplaneMag(hdr.fEventplaneMag),
267 fEventplaneQx(hdr.fEventplaneQx),
268 fEventplaneQy(hdr.fEventplaneQy),
269 fZDCN1Energy(hdr.fZDCN1Energy),
270 fZDCP1Energy(hdr.fZDCP1Energy),
271 fZDCN2Energy(hdr.fZDCN2Energy),
272 fZDCP2Energy(hdr.fZDCP2Energy),
275 fTriggerMask(hdr.fTriggerMask),
276 fFiredTriggers(hdr.fFiredTriggers),
277 fRunNumber(hdr.fRunNumber),
278 fRefMult(hdr.fRefMult),
279 fRefMultPos(hdr.fRefMultPos),
280 fRefMultNeg(hdr.fRefMultNeg),
281 fNMuons(hdr.fNMuons),
282 fNDimuons(hdr.fNDimuons),
283 fNGlobalMuons(hdr.fNGlobalMuons), // AU
284 fNGlobalDimuons(hdr.fNGlobalDimuons), // AU
285 fEventType(hdr.fEventType),
286 fOrbitNumber(hdr.fOrbitNumber),
287 fPeriodNumber(hdr.fPeriodNumber),
288 fBunchCrossNumber(hdr.fBunchCrossNumber),
289 fRefMultComb05(hdr.fRefMultComb05),
290 fRefMultComb08(hdr.fRefMultComb08),
291 fTriggerCluster(hdr.fTriggerCluster),
292 fDiamondZ(hdr.fDiamondZ),
293 fDiamondSig2Z(hdr.fDiamondSig2Z),
294 fOfflineTrigger(hdr.fOfflineTrigger),
295 fESDFileName(hdr.fESDFileName),
296 fEventNumberESDFile(hdr.fEventNumberESDFile),
297 fNumberESDTracks(hdr.fNumberESDTracks),
298 fL0TriggerInputs(hdr.fL0TriggerInputs),
299 fL1TriggerInputs(hdr.fL1TriggerInputs),
300 fL2TriggerInputs(hdr.fL2TriggerInputs),
301 fTPConlyRefMult(hdr.fTPConlyRefMult),
302 fCentralityP(new AliCentrality(*hdr.fCentralityP)),
303 fEventplaneP(new AliEventplane(*hdr.fEventplaneP)),
304 fIRInt2InteractionsMap(hdr.fIRInt2InteractionsMap),
305 fIRInt1InteractionsMap(hdr.fIRInt1InteractionsMap)
310 SetTitle(hdr.fTitle);
311 SetQTheta(hdr.fQTheta, hdr.fNQTheta);
312 SetZDCEMEnergy(hdr.fZDCEMEnergy[0], hdr.fZDCEMEnergy[1]);
313 for(Int_t i=0; i<2; i++) fDiamondXY[i]=hdr.fDiamondXY[i];
314 for(Int_t i=0; i<3; i++) fDiamondCovXY[i]=hdr.fDiamondCovXY[i];
317 for(Int_t m=0; m<kNPHOSMatrix; m++){
318 if(hdr.fPHOSMatrix[m])
319 fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
324 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
325 if(hdr.fEMCALMatrix[sm])
326 fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
330 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = hdr.fITSClusters[i];
331 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=hdr.fVZEROEqFactors[j];
332 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=hdr.fT0spread[i];
336 //______________________________________________________________________________
337 AliAODHeader& AliAODHeader::operator=(const AliAODHeader& hdr)
339 // Assignment operator
342 AliVHeader::operator=(hdr);
344 fMagneticField = hdr.fMagneticField;
345 fMuonMagFieldScale= hdr.fMuonMagFieldScale;
346 fCentrality = hdr.fCentrality;
347 fEventplane = hdr.fEventplane;
348 fEventplaneMag = hdr.fEventplaneMag;
349 fEventplaneQx = hdr.fEventplaneQx;
350 fEventplaneQy = hdr.fEventplaneQy;
351 fZDCN1Energy = hdr.fZDCN1Energy;
352 fZDCP1Energy = hdr.fZDCP1Energy;
353 fZDCN2Energy = hdr.fZDCN2Energy;
354 fZDCP2Energy = hdr.fZDCP2Energy;
355 fTriggerMask = hdr.fTriggerMask;
356 fFiredTriggers = hdr.fFiredTriggers;
357 fRunNumber = hdr.fRunNumber;
358 fRefMult = hdr.fRefMult;
359 fRefMultPos = hdr.fRefMultPos;
360 fRefMultNeg = hdr.fRefMultNeg;
361 fEventType = hdr.fEventType;
362 fOrbitNumber = hdr.fOrbitNumber;
363 fPeriodNumber = hdr.fPeriodNumber;
364 fBunchCrossNumber = hdr.fBunchCrossNumber;
365 fRefMultComb05 = hdr.fRefMultComb05;
366 fRefMultComb08 = hdr.fRefMultComb08;
368 fTriggerCluster = hdr.fTriggerCluster;
369 fNMuons = hdr.fNMuons;
370 fNDimuons = hdr.fNDimuons;
371 fNGlobalMuons = hdr.fNGlobalMuons; // AU
372 fNGlobalDimuons = hdr.fNGlobalDimuons; // AU
373 fDiamondZ = hdr.fDiamondZ;
374 fDiamondSig2Z = hdr.fDiamondSig2Z;
375 fOfflineTrigger = hdr.fOfflineTrigger;
376 fESDFileName = hdr.fESDFileName;
377 fEventNumberESDFile = hdr.fEventNumberESDFile;
378 fNumberESDTracks = hdr.fNumberESDTracks;
379 fL0TriggerInputs = hdr.fL0TriggerInputs;
380 fL1TriggerInputs = hdr.fL1TriggerInputs;
381 fL2TriggerInputs = hdr.fL2TriggerInputs;
382 fTPConlyRefMult = hdr.fTPConlyRefMult;
384 fIRInt2InteractionsMap = hdr.fIRInt2InteractionsMap;
385 fIRInt1InteractionsMap = hdr.fIRInt1InteractionsMap;
387 if(hdr.fEventplaneP){
388 if(fEventplaneP)*fEventplaneP = *hdr.fEventplaneP;
389 else fEventplaneP = new AliEventplane(*hdr.fEventplaneP);
392 if(hdr.fCentralityP){
393 if(fCentralityP)*fCentralityP = *hdr.fCentralityP;
394 else fCentralityP = new AliCentrality(*hdr.fCentralityP);
398 SetTitle(hdr.fTitle);
399 SetQTheta(hdr.fQTheta, hdr.fNQTheta);
400 SetZDCEMEnergy(hdr.fZDCEMEnergy[0], hdr.fZDCEMEnergy[1]);
401 for(Int_t i=0; i<2; i++) fDiamondXY[i]=hdr.fDiamondXY[i];
402 for(Int_t i=0; i<3; i++) fDiamondCovXY[i]=hdr.fDiamondCovXY[i];
404 for(Int_t m=0; m<kNPHOSMatrix; m++){
405 if(hdr.fPHOSMatrix[m]){
406 if(fPHOSMatrix[m])delete fPHOSMatrix[m];
407 fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
413 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
414 if(hdr.fEMCALMatrix[sm]){
415 if(fEMCALMatrix[sm])delete fEMCALMatrix[sm];
416 fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
424 for (Int_t i = 0; i < 6; i++) fITSClusters[i] = hdr.fITSClusters[i];
425 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j] = hdr.fVZEROEqFactors[j];
426 for (Int_t i=0; i<kT0SpreadSize;i++) fT0spread[i]=hdr.fT0spread[i];
431 //______________________________________________________________________________
432 void AliAODHeader::SetQTheta(Double_t *QTheta, UInt_t size)
434 if (QTheta && size>0) {
435 if (size != (UInt_t)fNQTheta) {
438 fQTheta = new Double_t[fNQTheta];
441 for (Int_t i = 0; i < fNQTheta; i++) {
442 fQTheta[i] = QTheta[i];
451 //______________________________________________________________________________
452 Double_t AliAODHeader::GetQTheta(UInt_t i) const
454 if (fQTheta && i < (UInt_t)fNQTheta) {
461 //______________________________________________________________________________
462 void AliAODHeader::RemoveQTheta()
471 void AliAODHeader::Clear(Option_t* /*opt*/)
484 fEventplaneMag = -999.;
485 fEventplaneQx = -999.;
486 fEventplaneQy = -999.;
491 //______________________________________________________________________________
492 void AliAODHeader::Print(Option_t* /*option*/) const
494 // prints event information
496 printf("Run # : %d\n", fRunNumber);
497 printf("Bunch Crossing # : %d\n", fBunchCrossNumber);
498 printf("Orbit Number # : %d\n", fOrbitNumber);
499 printf("Period Number # : %d\n", fPeriodNumber);
500 printf("Trigger mask : %lld\n", fTriggerMask);
501 printf("Trigger cluster : %d\n", fTriggerCluster);
502 printf("Event Type : %d\n", fEventType);
503 printf("Magnetic field : %f\n", fMagneticField);
504 printf("Muon mag. field scale : %f\n", fMuonMagFieldScale);
506 printf("Centrality : %f\n", fCentrality);
507 printf("Event plane Ang : %f\n", fEventplane);
508 printf("Event plane Mag : %f\n", fEventplaneMag);
509 printf("Event plane Qx : %f\n", fEventplaneQx);
510 printf("Event plane Qy : %f\n", fEventplaneQy);
511 printf("ZDC N1 Energy : %f\n", fZDCN1Energy);
512 printf("ZDC P1 Energy : %f\n", fZDCP1Energy);
513 printf("ZDC N2 Energy : %f\n", fZDCN2Energy);
514 printf("ZDC P2 Energy : %f\n", fZDCP2Energy);
515 printf("ZDC EM1 Energy : %f\n", fZDCEMEnergy[0]);
516 printf("ZDC EM2 Energy : %f\n", fZDCEMEnergy[1]);
517 printf("ref. Multiplicity : %d\n", fRefMult);
518 printf("ref. Multiplicity (pos) : %d\n", fRefMultPos);
519 printf("ref. Multiplicity (neg) : %d\n", fRefMultNeg);
520 printf("ref. Mult.Comb |eta|<.5 : %d\n", fRefMultComb05);
521 printf("ref. Mult.Comb |eta|<.8 : %d\n", fRefMultComb08);
522 printf("number of muons : %d\n", fNMuons);
523 printf("number of dimuons : %d\n", fNDimuons);
524 printf("offline trigger : %u\n", fOfflineTrigger);
527 for (UInt_t i = 0; i<(UInt_t)fNQTheta; i++) {
528 printf("QTheta[%d] : %13.3e\n", i, GetQTheta(i));
531 printf("V0 Eq factors: ");
532 for (Int_t j=0; j<64; ++j) printf(" %.3f",fVZEROEqFactors[j]);
538 //__________________________________________________________________________
539 Int_t AliAODHeader::FindIRIntInteractionsBXMap(Int_t difference) const
542 // The mapping is of 181 bits, from -90 to +90
546 if(difference<-90 || difference>90) return bin;
547 else { bin = 90 + difference; }
552 //__________________________________________________________________________
553 Int_t AliAODHeader::GetIRInt2ClosestInteractionMap() const
556 // Calculation of the closest interaction
558 Int_t firstNegative=100;
559 for(Int_t item=-1; item>=-90; item--) {
560 Int_t bin = FindIRIntInteractionsBXMap(item);
561 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
563 firstNegative = item;
567 Int_t firstPositive=100;
568 for(Int_t item=1; item<=90; item++) {
569 Int_t bin = FindIRIntInteractionsBXMap(item);
570 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
572 firstPositive = item;
577 Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative);
578 if(firstPositive==100 && firstNegative==100) closest=0;
582 //__________________________________________________________________________
583 Int_t AliAODHeader::GetIRInt1ClosestInteractionMap(Int_t gap) const
586 // Calculation of the closest interaction
587 // In case of VZERO (Int1) one has to introduce a gap
588 // in order to avoid false positivies from after-pulses
590 Int_t firstNegative=100;
591 for(Int_t item=-1; item>=-90; item--) {
592 Int_t bin = FindIRIntInteractionsBXMap(item);
593 Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin);
595 firstNegative = item;
599 Int_t firstPositive=100;
600 for(Int_t item=1+gap; item<=90; item++) {
601 Int_t bin = FindIRIntInteractionsBXMap(item);
602 Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin);
604 firstPositive = item;
609 Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative);
610 if(firstPositive==100 && firstNegative==100) closest=0;
614 //__________________________________________________________________________
615 Int_t AliAODHeader::GetIRInt2LastInteractionMap() const
618 // Calculation of the last interaction
620 Int_t lastNegative=0;
621 for(Int_t item=-90; item<=-1; item++) {
622 Int_t bin = FindIRIntInteractionsBXMap(item);
623 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
629 Int_t lastPositive=0;
630 for(Int_t item=90; item>=1; item--) {
631 Int_t bin = FindIRIntInteractionsBXMap(item);
632 Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin);
639 Int_t last = lastPositive > TMath::Abs(lastNegative) ? lastPositive : TMath::Abs(lastNegative);
643 //__________________________________________________________________________
644 Bool_t AliAODHeader::InitMagneticField() const
646 // Create mag field from stored information
648 const double def5kg = 5.00667905807495117e+00;
649 const double def2kg = 2.04487347602844238e+00;
651 AliMagF* fld = (AliMagF*) TGeoGlobalMagField::Instance()->GetField();
653 if (TGeoGlobalMagField::Instance()->IsLocked()) {
654 if (fld->TestBit(AliMagF::kOverrideGRP)) {
655 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
656 AliInfo("ExpertMode!!! Running with the externally locked B field !");
660 AliInfo("Destroying existing B field instance!");
661 delete TGeoGlobalMagField::Instance();
664 double fc5 = fMagneticField/def5kg;
665 double fc2 = fMagneticField/def2kg;
666 Bool_t use5 = TMath::Abs(TMath::Abs(fc5)-1.) < TMath::Abs(TMath::Abs(fc2)-1.);
668 fld = new AliMagF("mag","mag",use5 ? fc5 : fc2, fMuonMagFieldScale, use5 ? AliMagF::k5kG : AliMagF::k2kG);
671 TGeoGlobalMagField::Instance()->SetField( fld );
672 TGeoGlobalMagField::Instance()->Lock();
673 AliInfo("Running with the B field constructed out of the AOD Header !");
677 AliError("Failed to create a B field map !");