From 127be20802b22a9e071a12b35d4336fd2ac1d876 Mon Sep 17 00:00:00 2001 From: shahoian Date: Wed, 27 Nov 2013 13:16:37 +0000 Subject: [PATCH] Made InitMagneticField a virtual method of the AliVEvent Added implementation for the AliAOD --- STEER/AOD/AliAODEvent.h | 2 ++ STEER/AOD/AliAODHeader.cxx | 42 +++++++++++++++++++++++++++++++++++++ STEER/AOD/AliAODHeader.h | 1 + STEER/ESD/AliESDEvent.h | 2 +- STEER/ESD/AliESDRun.cxx | 23 ++++++++++---------- STEER/STEERBase/AliVEvent.h | 3 +++ 6 files changed, 61 insertions(+), 12 deletions(-) diff --git a/STEER/AOD/AliAODEvent.h b/STEER/AOD/AliAODEvent.h index 1a867abb1bc..b061631adc0 100644 --- a/STEER/AOD/AliAODEvent.h +++ b/STEER/AOD/AliAODEvent.h @@ -96,6 +96,8 @@ class AliAODEvent : public AliVEvent { (fAODObjects->FirstLink())->SetObject(fHeader); } + virtual Bool_t InitMagneticField() const {return fHeader ? fHeader->InitMagneticField() : kFALSE;} + // setters and getters for header information void SetRunNumber(Int_t n) {if (fHeader) fHeader->SetRunNumber(n);} void SetPeriodNumber(UInt_t n){if (fHeader) fHeader->SetPeriodNumber(n);} diff --git a/STEER/AOD/AliAODHeader.cxx b/STEER/AOD/AliAODHeader.cxx index a87dad69b2b..46edc3c40a2 100644 --- a/STEER/AOD/AliAODHeader.cxx +++ b/STEER/AOD/AliAODHeader.cxx @@ -23,6 +23,8 @@ #include "AliAODHeader.h" #include "AliCentrality.h" #include "AliEventplane.h" +#include "AliMagF.h" +#include #include #include @@ -625,3 +627,43 @@ Int_t AliAODHeader::GetIRInt2LastInteractionMap() const Int_t last = lastPositive > TMath::Abs(lastNegative) ? lastPositive : TMath::Abs(lastNegative); return last; } + +//__________________________________________________________________________ +Bool_t AliAODHeader::InitMagneticField() const +{ + // Create mag field from stored information + // + const double def5kg = 5.00667905807495117e+00; + const double def2kg = 2.04487347602844238e+00; + // + AliMagF* fld = (AliMagF*) TGeoGlobalMagField::Instance()->GetField(); + if (fld) { + if (TGeoGlobalMagField::Instance()->IsLocked()) { + if (fld->TestBit(AliMagF::kOverrideGRP)) { + AliInfo("ExpertMode!!! Information on magnet currents will be ignored !"); + AliInfo("ExpertMode!!! Running with the externally locked B field !"); + return kTRUE; + } + } + AliInfo("Destroying existing B field instance!"); + delete TGeoGlobalMagField::Instance(); + } + // + double fc5 = fMagneticField/def5kg; + double fc2 = fMagneticField/def2kg; + Bool_t use5 = TMath::Abs(TMath::Abs(fc5)-1.) < TMath::Abs(TMath::Abs(fc2)-1.); + // + fld = new AliMagF("mag","mag",use5 ? fc5 : fc2, fMuonMagFieldScale, use5 ? AliMagF::k5kG : AliMagF::k2kG); + // + if (fld) { + TGeoGlobalMagField::Instance()->SetField( fld ); + TGeoGlobalMagField::Instance()->Lock(); + AliInfo("Running with the B field constructed out of the AOD Header !"); + return kTRUE; + } + else { + AliError("Failed to create a B field map !"); + return kFALSE; + } + // +} diff --git a/STEER/AOD/AliAODHeader.h b/STEER/AOD/AliAODHeader.h index f5f54a7aba7..73b1fa2d6dc 100644 --- a/STEER/AOD/AliAODHeader.h +++ b/STEER/AOD/AliAODHeader.h @@ -58,6 +58,7 @@ class AliAODHeader : public AliVHeader { virtual ~AliAODHeader(); AliAODHeader(const AliAODHeader& evt); AliAODHeader& operator=(const AliAODHeader& evt); + Bool_t InitMagneticField() const; Int_t GetRunNumber() const { return fRunNumber;} Int_t GetEventNumberESDFile() const { return fEventNumberESDFile;} diff --git a/STEER/ESD/AliESDEvent.h b/STEER/ESD/AliESDEvent.h index 60b0f54ecc3..d17c8b4cbac 100644 --- a/STEER/ESD/AliESDEvent.h +++ b/STEER/ESD/AliESDEvent.h @@ -170,7 +170,7 @@ public: Int_t GetBeamParticleZ(Int_t ibeam) const {return fESDRun?fESDRun->GetBeamParticleZ(ibeam):0;} Bool_t IsUniformBMap() const {return fESDRun?fESDRun->TestBit(AliESDRun::kUniformBMap):kFALSE;} // - Bool_t InitMagneticField() const {return fESDRun?fESDRun->InitMagneticField():kFALSE;} + virtual Bool_t InitMagneticField() const {return fESDRun?fESDRun->InitMagneticField():kFALSE;} void SetT0spread(Float_t *t) const {if(fESDRun) fESDRun->SetT0spread(t);} Float_t GetT0spread(Int_t i) const {return fESDRun?fESDRun->GetT0spread(i):0;} virtual void SetVZEROEqFactors(Float_t factors[64]) const {if(fESDRun) fESDRun->SetVZEROEqFactors(factors);} diff --git a/STEER/ESD/AliESDRun.cxx b/STEER/ESD/AliESDRun.cxx index ddf7cc3ba5f..d4e658e12e6 100644 --- a/STEER/ESD/AliESDRun.cxx +++ b/STEER/ESD/AliESDRun.cxx @@ -348,20 +348,21 @@ Bool_t AliESDRun::InitMagneticField() const return kFALSE; } // - if ( TGeoGlobalMagField::Instance()->IsLocked() ) { - if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) { - AliInfo("ExpertMode!!! Information on magnet currents will be ignored !"); - AliInfo("ExpertMode!!! Running with the externally locked B field !"); - return kTRUE; - } - else { - AliInfo("Destroying existing B field instance!"); - delete TGeoGlobalMagField::Instance(); + AliMagF* fld = (AliMagF*) TGeoGlobalMagField::Instance()->GetField(); + if (fld) { + if (TGeoGlobalMagField::Instance()->IsLocked()) { + if (fld->TestBit(AliMagF::kOverrideGRP)) { + AliInfo("ExpertMode!!! Information on magnet currents will be ignored !"); + AliInfo("ExpertMode!!! Running with the externally locked B field !"); + return kTRUE; + } } + AliInfo("Destroying existing B field instance!"); + delete TGeoGlobalMagField::Instance(); } // - AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC, - TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType()); + fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC, + TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType()); if (fld) { TGeoGlobalMagField::Instance()->SetField( fld ); TGeoGlobalMagField::Instance()->Lock(); diff --git a/STEER/STEERBase/AliVEvent.h b/STEER/STEERBase/AliVEvent.h index 0cfe3fc215a..91fbca05c2a 100644 --- a/STEER/STEERBase/AliVEvent.h +++ b/STEER/STEERBase/AliVEvent.h @@ -102,6 +102,9 @@ public: // Header virtual AliVHeader* GetHeader() const = 0; + // + // field initialization + virtual Bool_t InitMagneticField() const {return kFALSE;} // Delegated methods for fESDRun or AODHeader -- 2.43.0