]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
ESD can init the Bfield via AliESDRun::InitMagneticField()
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 7 Oct 2009 13:47:12 +0000 (13:47 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 7 Oct 2009 13:47:12 +0000 (13:47 +0000)
1) Added currents/beam info to AliESDRun and the method
to AliESDRun::InitMagneticField() (+ alias AliESDEvent::InitMagneticField())
2) AliReconstruction will fill needed Bfield info in AliESDRun
3) AliMagF got a "static CreateFieldMap" to create a map from the
currents. All classes which create the field (AliGRPManager,
AliReconstruction, AliESDRun) will use this method

STEER/AliAODEvent.h
STEER/AliESDEvent.h
STEER/AliESDRun.cxx
STEER/AliESDRun.h
STEER/AliGRPManager.cxx
STEER/AliGRPManager.h
STEER/AliMagF.cxx
STEER/AliMagF.h
STEER/AliReconstruction.cxx
STEER/AliReconstruction.h

index 56ae6a27134b67fb40ecdd52068317e0f20f101b..161eaa1bac56dee02cf0567641cf95abfdd1b671 100644 (file)
@@ -76,6 +76,7 @@ class AliAODEvent : public AliVEvent {
   void     SetOrbitNumber(UInt_t n) {if (fHeader) fHeader->SetOrbitNumber(n);}
   void     SetBunchCrossNumber(UShort_t n) {if (fHeader) fHeader->SetBunchCrossNumber(n);}
   void     SetMagneticField(Double_t mf){if (fHeader) fHeader->SetMagneticField(mf);}
+  void     SetMuonMagFieldScale(Double_t mf){if (fHeader) fHeader->SetMuonMagFieldScale(mf);}
   void     SetDiamond(Float_t xy[2],Float_t cov[3]){if (fHeader) fHeader->SetDiamond(xy,cov);}
 
   Int_t    GetRunNumber() const {return fHeader ? fHeader->GetRunNumber() : -999;}
@@ -83,6 +84,7 @@ class AliAODEvent : public AliVEvent {
   UInt_t   GetOrbitNumber() const {return fHeader ? fHeader->GetOrbitNumber() : 0;}
   UShort_t GetBunchCrossNumber() const {return fHeader ? fHeader->GetBunchCrossNumber() : 0;}
   Double_t GetMagneticField() const {return fHeader ? fHeader->GetMagneticField() : -999.;}
+  Double_t GetMuonMagFieldScale() const {return fHeader ? fHeader->GetMuonMagFieldScale() : -999.;}
   Double_t GetDiamondX() const {return fHeader ? fHeader->GetDiamondX() : -999.;}
   Double_t GetDiamondY() const {return fHeader ? fHeader->GetDiamondY() : -999.;}
   void     GetDiamondCovXY(Float_t cov[3]) const {cov[0]=-999.; if(fHeader) fHeader->GetDiamondCovXY(cov);}
index b3a483092e43f1fa7bec5c927dc032d649d1c680..bb9fe4a98987c09d42382397b381512c16ae4733 100644 (file)
@@ -117,7 +117,21 @@ public:
   const TGeoHMatrix* GetPHOSMatrix(Int_t i) const {return fESDRun->GetPHOSMatrix(i);}
   void     SetEMCALMatrix(TGeoHMatrix*matrix, Int_t i) {fESDRun->SetEMCALMatrix(matrix,i);}
   const TGeoHMatrix* GetEMCALMatrix(Int_t i) const {return fESDRun->GetEMCALMatrix(i);}
-
+  //
+  void        SetCurrentL3(Float_t cur)           const  {fESDRun->SetCurrentL3(cur);}
+  void        SetCurrentDip(Float_t cur)          const  {fESDRun->SetCurrentDip(cur);}
+  void        SetBeamEnergy(Float_t be)           const  {fESDRun->SetBeamEnergy(be);}
+  void        SetBeamType(const char* bt)         const  {fESDRun->SetBeamType(bt);}
+  void        SetUniformBMap(Bool_t val=kTRUE)    const  {fESDRun->SetBit(AliESDRun::kUniformBMap,val);}
+  void        SetBInfoStored(Bool_t val=kTRUE)    const  {fESDRun->SetBit(AliESDRun::kBInfoStored,val);}
+  //
+  Float_t     GetCurrentL3()                      const  {return fESDRun->GetCurrentL3();}
+  Float_t     GetCurrentDip()                     const  {return fESDRun->GetCurrentDip();}
+  Float_t     SetBeamEnergy()                     const  {return fESDRun->GetBeamEnergy();}
+  const char* GetBeamType()                       const  {return fESDRun->GetBeamType();}
+  Bool_t      IsUniformBMap()                     const  {return fESDRun->TestBit(AliESDRun::kUniformBMap);}
+  //
+  Bool_t      InitMagneticField()                 const  {return fESDRun->InitMagneticField();} 
   // HEADER
   AliESDHeader* GetHeader() const {return fHeader;}
 
index 1225428b108b0839c7010c027a9bb0346addf6a6..61e86e870d2ab9fdd7825877e4f1596ec3275964 100644 (file)
  **************************************************************************/
 #include <TNamed.h>
 #include <TGeoMatrix.h>
+#include <TGeoGlobalMagField.h>
 
 #include "AliESDRun.h"
 #include "AliESDVertex.h"
 #include "AliLog.h"
+#include "AliMagF.h"
 
 //-------------------------------------------------------------------------
 //                     Implementation Class AliESDRun
@@ -31,10 +33,14 @@ ClassImp(AliESDRun)
 //______________________________________________________________________________
 AliESDRun::AliESDRun() :
   TObject(),
+  fCurrentL3(0),
+  fCurrentDip(0),
+  fBeamEnergy(0),
   fMagneticField(0),
   fPeriodNumber(0),
   fRunNumber(0),
   fRecoVersion(0),
+  fBeamType(""),
   fTriggerClasses(kNTriggerClasses)
 {
   for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
@@ -48,10 +54,14 @@ AliESDRun::AliESDRun() :
 //______________________________________________________________________________
 AliESDRun::AliESDRun(const AliESDRun &esd) :
   TObject(esd),
+  fCurrentL3(0),
+  fCurrentDip(0),
+  fBeamEnergy(0),
   fMagneticField(esd.fMagneticField),
   fPeriodNumber(esd.fPeriodNumber),
   fRunNumber(esd.fRunNumber),
   fRecoVersion(esd.fRecoVersion),
+  fBeamType(""),
   fTriggerClasses(TObjArray(kNTriggerClasses))
 { 
   // Copy constructor
@@ -88,6 +98,10 @@ AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
     fPeriodNumber=esd.fPeriodNumber;
     fRecoVersion=esd.fRecoVersion;
     fMagneticField=esd.fMagneticField;
+    fBeamType = esd.fBeamType;
+    fCurrentL3  = esd.fCurrentL3;
+    fCurrentDip = esd.fCurrentDip;
+    fBeamEnergy = esd.fBeamEnergy;
     for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
     for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
     fTriggerClasses.Clear();
@@ -159,8 +173,9 @@ void AliESDRun::Print(const Option_t *) const
   // Print some data members
   printf("Mean vertex in RUN %d: X=%.4f Y=%.4f cm\n",
         GetRunNumber(),GetDiamondX(),GetDiamondY());
-  printf("Magnetic field = %f T\n",
-        GetMagneticField());
+  printf("Beam Type: %s, Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":fBeamType.Data(),fBeamEnergy);
+  printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
+        GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
   printf("Event from reconstruction version %d \n",fRecoVersion);
   
   printf("List of active trigger classes: ");
@@ -268,3 +283,40 @@ Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
   else
     return kFALSE;
 }
+
+//_____________________________________________________________________________
+Bool_t AliESDRun::InitMagneticField() const
+{
+  // Create mag field from stored information
+  //
+  if (!TestBit(kBInfoStored)) {
+    AliError("No information on currents, cannot create field from run header");
+    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::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
+                                        TestBit(kUniformBMap),fBeamEnergy,fBeamType.Data());
+  if (fld) {
+    TGeoGlobalMagField::Instance()->SetField( fld );
+    TGeoGlobalMagField::Instance()->Lock();
+    AliInfo("Running with the B field constructed out of the Run Header !");
+    return kTRUE;
+  }
+  else {
+    AliError("Failed to create a B field map !");
+    return kFALSE;
+  }
+  //
+}
index e69d3d362e926c10d27921f1a2373681c013b530..026bc46bbb27b9adceb57ba6c7b0b7cbc84e16b4 100644 (file)
@@ -21,12 +21,15 @@ class AliESDVertex;
 class AliESDRun: public TObject {
 public:
 
+  enum StatusBits {kBInfoStored = BIT(14), kUniformBMap = BIT(15)};
+
   AliESDRun();
   AliESDRun(const AliESDRun& esd);
   AliESDRun& operator=(const AliESDRun& esd);
   virtual void Copy(TObject &obj) const; // Interface for using TOBject::Copy()
   virtual ~AliESDRun();
 
+  Bool_t  InitMagneticField() const;
   Int_t   GetRunNumber() const {return fRunNumber;}
   void    SetRunNumber(Int_t n) {fRunNumber=n;}
   void    SetMagneticField(Float_t mf){fMagneticField = mf;}
@@ -35,9 +38,13 @@ public:
   void    SetPeriodNumber(Int_t n) {fPeriodNumber=n;}
   void    Reset();
   void    Print(const Option_t *opt=0) const;
-  void SetDiamond(const AliESDVertex *vertex);
+  void    SetDiamond(const AliESDVertex *vertex);
   void    SetTriggerClass(const char*name, Int_t index);
-
+  void    SetCurrentL3(Float_t cur)    {fCurrentL3 = cur;}
+  void    SetCurrentDip(Float_t cur)   {fCurrentDip = cur;}
+  void    SetBeamEnergy(Float_t be)    {fBeamEnergy = be;}
+  void    SetBeamType(const char* bt)  {fBeamType = bt;}
+  
   Double_t GetDiamondX() const {return fDiamondXY[0];}
   Double_t GetDiamondY() const {return fDiamondXY[1];}
   Double_t GetSigma2DiamondX() const {return fDiamondCovXY[0];}
@@ -49,6 +56,10 @@ public:
   TString     GetActiveTriggerClasses() const;
   TString     GetFiredTriggerClasses(ULong64_t mask) const;
   Bool_t      IsTriggerClassFired(ULong64_t mask, const char *name) const;
+  Float_t     GetCurrentL3()               const {return fCurrentL3;}
+  Float_t     GetCurrentDip()              const {return fCurrentDip;}
+  Float_t     GetBeamEnergy()              const {return fBeamEnergy;}
+  const char* GetBeamType()                const {return fBeamType.Data();}
 
   void    SetPHOSMatrix(TGeoHMatrix*matrix, Int_t i) {
     if ((i >= 0) && (i < kNPHOSMatrix)) fPHOSMatrix[i] = matrix;
@@ -69,17 +80,21 @@ public:
   enum {kNEMCALMatrix = 12};
 
 private:
+  Float_t         fCurrentL3;       // signed current in the L3     (LHC convention: +current -> +Bz)
+  Float_t         fCurrentDip;      // signed current in the Dipole (LHC convention: +current -> -Bx)
+  Float_t         fBeamEnergy;      // beamEnergy entry from GRP
   Double32_t      fMagneticField;   // Solenoid Magnetic Field in kG : for compatibility with AliMagF
   Double32_t      fDiamondXY[2];    // Interaction diamond (x,y) in RUN
   Double32_t      fDiamondCovXY[3]; // Interaction diamond covariance (x,y) in RUN
   UInt_t          fPeriodNumber;    // PeriodNumber
   Int_t           fRunNumber;       // Run Number
-  Int_t           fRecoVersion;     // Version of reconstruction 
+  Int_t           fRecoVersion;     // Version of reconstruction
+  TString         fBeamType;        // beam type from GRP
   TObjArray       fTriggerClasses;  // array of TNamed containing the names of the active trigger classes
   TGeoHMatrix*    fPHOSMatrix[kNPHOSMatrix]; //PHOS module position and orientation matrices
   TGeoHMatrix*    fEMCALMatrix[kNEMCALMatrix]; //EMCAL supermodule position and orientation matrices
 
-  ClassDef(AliESDRun,5)
+  ClassDef(AliESDRun,6)
 };
 
 #endif 
index 5d1d26e4632456fe2ab1710d6d07119c2c48e407..dfaaff0ed595c27b532fc23a09c8e16465c8d010 100644 (file)
@@ -34,7 +34,6 @@
 ////////////////////////////////////////////////////////////////////////////
 
 #include <TGeoGlobalMagField.h>
-#include <TPRegexp.h>
 
 #include "AliGRPManager.h"
 #include "AliLog.h"
@@ -167,12 +166,18 @@ Bool_t AliGRPManager::SetMagField()
   Bool_t uniformB = fGRPData->IsUniformBMap();
   
   if (ok) { 
-    if ( !SetFieldMap(l3Current, diCurrent, l3Polarity ? -1:1, diPolarity ? -1:1, 
-                     polConvention,uniformB,beamEnergy, beamType.Data())) {
+    AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1), 
+                                          TMath::Abs(diCurrent) * (diPolarity ? -1:1), 
+                                          polConvention,uniformB,beamEnergy, beamType.Data());
+    if (fld) {
+      TGeoGlobalMagField::Instance()->SetField( fld );
+      TGeoGlobalMagField::Instance()->Lock();
+      AliInfo("Running with the B field constructed out of GRP !");
+    }
+    else {
       AliError("Failed to create a B field map !");
       ok = kFALSE;
     }
-    else AliInfo("Running with the B field constructed out of GRP !");
   }
   else {
     AliError("B field is neither set nor constructed from GRP ! Exitig...");
@@ -222,86 +227,3 @@ AliRunInfo* AliGRPManager::GetRunInfo()
 
   return new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
 }
-
-//_____________________________________________________________________________
-Bool_t AliGRPManager::SetFieldMap(Float_t l3Cur, Float_t diCur, Float_t l3Pol, 
-                                 Float_t diPol, Int_t convention, Bool_t uniform,
-                                 Float_t beamenergy, const Char_t *beamtype, const Char_t *path) 
-{
-  //------------------------------------------------
-  // The magnetic field map, defined externally...
-  // L3 current 30000 A  -> 0.5 T
-  // L3 current 12000 A  -> 0.2 T
-  // dipole current 6000 A
-  // The polarities must match the convention (LHC or DCS2008) 
-  // unless the special uniform map was used for MC
-  //------------------------------------------------
-  const Float_t l3NominalCurrent1=30000.; // (A)
-  const Float_t l3NominalCurrent2=12000.; // (A)
-  const Float_t diNominalCurrent =6000. ; // (A)
-
-  const Float_t tolerance=0.03; // relative current tolerance
-  const Float_t zero=77.;       // "zero" current (A)
-  //
-  AliMagF::BMap_t map;
-  double sclL3,sclDip;
-  //
-  l3Cur = TMath::Abs(l3Cur);
-  diCur = TMath::Abs(diCur);
-  //
-  if (TMath::Abs((sclDip=diCur/diNominalCurrent)-1.) > tolerance && !uniform) {
-    if (diCur <= zero) sclDip = 0.; // some small current.. -> Dipole OFF
-    else {
-      AliError(Form("Wrong dipole current (%f A)!",diCur));
-      return kFALSE;
-    }
-  }
-  //
-  if (uniform) { 
-    // special treatment of special MC with uniform mag field (normalized to 0.5 T)
-    // no check for scaling/polarities are done
-    map   = AliMagF::k5kGUniform;
-    sclL3 = l3Cur/l3NominalCurrent1; 
-  }
-  else {
-    if      (TMath::Abs((sclL3=l3Cur/l3NominalCurrent1)-1.) < tolerance) map  = AliMagF::k5kG;
-    else if (TMath::Abs((sclL3=l3Cur/l3NominalCurrent2)-1.) < tolerance) map  = AliMagF::k2kG;
-    else if (l3Cur <= zero)                                { sclL3 = 0;  map  = AliMagF::k5kGUniform;}
-    else {
-      AliError(Form("Wrong L3 current (%f A)!",l3Cur));
-      return kFALSE;
-    }
-  }
-  //
-  if (sclDip!=0 && (map==AliMagF::k5kG || map==AliMagF::k2kG) &&
-      ((convention==AliMagF::kConvLHC     && l3Pol!=diPol) ||
-       (convention==AliMagF::kConvDCS2008 && l3Pol==diPol)) ) { 
-    AliError(Form("Wrong combination for L3/Dipole polarities (%c/%c) for convention %d",
-                 l3Pol>0?'+':'-',diPol>0?'+':'-',AliMagF::GetPolarityConvention()));
-    return kFALSE;
-  }
-  //
-  if (l3Pol<0) sclL3  = -sclL3;
-  if (diPol<0) sclDip = -sclDip;
-  //
-  AliMagF::BeamType_t btype = AliMagF::kNoBeamField;
-  TString btypestr = beamtype;
-  btypestr.ToLower();
-  TPRegexp protonBeam("(proton|p)\\s*-?\\s*\\1");
-  TPRegexp ionBeam("(lead|pb|ion|a)\\s*-?\\s*\\1");
-  if (btypestr.Contains(ionBeam)) btype = AliMagF::kBeamTypeAA;
-  else if (btypestr.Contains(protonBeam)) btype = AliMagF::kBeamTypepp;
-  else AliInfo(Form("Assume no LHC magnet field for the beam type %s, ",beamtype));
-  char ttl[80];
-  sprintf(ttl,"L3: %+5d Dip: %+4d kA; %s | Polarities in %s convention",(int)TMath::Sign(l3Cur,float(sclL3)),
-         (int)TMath::Sign(diCur,float(sclDip)),uniform ? " Constant":"",
-         convention==AliMagF::kConvLHC ? "LHC":"DCS2008");
-  // LHC and DCS08 conventions have opposite dipole polarities
-  if ( AliMagF::GetPolarityConvention() != convention) sclDip = -sclDip;
-  AliMagF* fld = new AliMagF("MagneticFieldMap", ttl, 2, sclL3, sclDip, 10., map, path, 
-                            btype,beamenergy);
-  TGeoGlobalMagField::Instance()->SetField( fld );
-  TGeoGlobalMagField::Instance()->Lock();
-  //
-  return kTRUE;
-}
index 66aa653d9469f8382f0c309e06bc4d6c4c823737..5450f2e7adf36a1bfe489e335ccf26c9b58269da 100644 (file)
@@ -32,11 +32,6 @@ public:
   AliRunInfo* GetRunInfo();
 
 private:
-  Bool_t SetFieldMap(Float_t l3Current=30000., Float_t diCurrent=6000., 
-                    Float_t l3Pol=-1., Float_t dipPol=-1.,
-                    Int_t convention=0, Bool_t uniform = kFALSE, 
-                    Float_t benergy=7000., const Char_t* btype="pp",
-                    const Char_t* path="$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
   
   AliGRPObject*  fGRPData;        // Data from the GRP/GRP/Data CDB folder
 
index 8697aad1cf5b2165989756abbb9dc2f5b5c9d2f5..c32309ee256209ab5f9617ce3688a2fd6403481a 100644 (file)
@@ -17,6 +17,7 @@
 #include <TClass.h>
 #include <TFile.h>
 #include <TSystem.h>
+#include <TPRegexp.h>
 
 #include "AliMagF.h"
 #include "AliMagWrapCheb.h"
@@ -416,3 +417,100 @@ Double_t AliMagF::GetFactorDip() const
   default          : return  fFactorDip;       //  case kConvMap2005: return  fFactorDip;
   }
 }
+
+//_____________________________________________________________________________
+AliMagF* AliMagF::CreateFieldMap(Float_t l3Cur, Float_t diCur, Int_t convention, Bool_t uniform,
+                                Float_t beamenergy, const Char_t *beamtype, const Char_t *path) 
+{
+  //------------------------------------------------
+  // The magnetic field map, defined externally...
+  // L3 current 30000 A  -> 0.5 T
+  // L3 current 12000 A  -> 0.2 T
+  // dipole current 6000 A
+  // The polarities must match the convention (LHC or DCS2008) 
+  // unless the special uniform map was used for MC
+  //------------------------------------------------
+  const Float_t l3NominalCurrent1=30000.; // (A)
+  const Float_t l3NominalCurrent2=12000.; // (A)
+  const Float_t diNominalCurrent =6000. ; // (A)
+
+  const Float_t tolerance=0.03; // relative current tolerance
+  const Float_t zero=77.;       // "zero" current (A)
+  //
+  BMap_t map;
+  double sclL3,sclDip;
+  //
+  Float_t l3Pol = l3Cur > 0 ? 1:-1;
+  Float_t diPol = diCur > 0 ? 1:-1;
+  l3Cur = TMath::Abs(l3Cur);
+  diCur = TMath::Abs(diCur);
+  //
+  if (TMath::Abs((sclDip=diCur/diNominalCurrent)-1.) > tolerance && !uniform) {
+    if (diCur <= zero) sclDip = 0.; // some small current.. -> Dipole OFF
+    else {
+      AliErrorGeneral("AliMagF",Form("Wrong dipole current (%f A)!",diCur));
+      return 0;
+    }
+  }
+  //
+  if (uniform) { 
+    // special treatment of special MC with uniform mag field (normalized to 0.5 T)
+    // no check for scaling/polarities are done
+    map   = k5kGUniform;
+    sclL3 = l3Cur/l3NominalCurrent1; 
+  }
+  else {
+    if      (TMath::Abs((sclL3=l3Cur/l3NominalCurrent1)-1.) < tolerance) map  = k5kG;
+    else if (TMath::Abs((sclL3=l3Cur/l3NominalCurrent2)-1.) < tolerance) map  = k2kG;
+    else if (l3Cur <= zero)                                { sclL3 = 0;  map  = k5kGUniform;}
+    else {
+      AliErrorGeneral("AliMagF",Form("Wrong L3 current (%f A)!",l3Cur));
+      return 0;
+    }
+  }
+  //
+  if (sclDip!=0 && (map==k5kG || map==k2kG) &&
+      ((convention==kConvLHC     && l3Pol!=diPol) ||
+       (convention==kConvDCS2008 && l3Pol==diPol)) ) { 
+    AliErrorGeneral("AliMagF",Form("Wrong combination for L3/Dipole polarities (%c/%c) for convention %d",
+                                  l3Pol>0?'+':'-',diPol>0?'+':'-',GetPolarityConvention()));
+    return 0;
+  }
+  //
+  if (l3Pol<0) sclL3  = -sclL3;
+  if (diPol<0) sclDip = -sclDip;
+  //
+  BeamType_t btype = kNoBeamField;
+  TString btypestr = beamtype;
+  btypestr.ToLower();
+  TPRegexp protonBeam("(proton|p)\\s*-?\\s*\\1");
+  TPRegexp ionBeam("(lead|pb|ion|a)\\s*-?\\s*\\1");
+  if (btypestr.Contains(ionBeam)) btype = kBeamTypeAA;
+  else if (btypestr.Contains(protonBeam)) btype = kBeamTypepp;
+  else AliInfoGeneral("AliMagF",Form("Assume no LHC magnet field for the beam type %s, ",beamtype));
+  char ttl[80];
+  sprintf(ttl,"L3: %+5d Dip: %+4d kA; %s | Polarities in %s convention",(int)TMath::Sign(l3Cur,float(sclL3)),
+         (int)TMath::Sign(diCur,float(sclDip)),uniform ? " Constant":"",
+         convention==kConvLHC ? "LHC":"DCS2008");
+  // LHC and DCS08 conventions have opposite dipole polarities
+  if ( GetPolarityConvention() != convention) sclDip = -sclDip;
+  //
+  return new AliMagF("MagneticFieldMap", ttl, 2, sclL3, sclDip, 10., map, path,btype,beamenergy);
+  //
+}
+
+//_____________________________________________________________________________
+const char*  AliMagF::GetBeamTypeText() const
+{
+  const char *beamNA  = "No Beam";
+  const char *beamPP  = "p-p";
+  const char *beamPbPb= "Pb-Pb";
+  switch ( fBeamType ) {
+  case kBeamTypepp : return beamPP;
+  case kBeamTypeAA : return beamPbPb;
+  case kNoBeamField: 
+  default:           return beamNA;
+  }
+}
+
index ecea50f5e20cfd3ab8869547db7e1758d1a3385f..834c24b59f2d9047ab32c67c67eb75b535fdb79c 100644 (file)
@@ -19,7 +19,7 @@ class AliMagF : public TVirtualMagField
 {
  public:
   enum BMap_t      {k2kG, k5kG, k5kGUniform};
-  enum BeamType_t  {kBeamTypeAA, kBeamTypepp, kNoBeamField};
+  enum BeamType_t  {kNoBeamField, kBeamTypepp, kBeamTypeAA};
   enum PolarityConvention_t {kConvLHC,kConvDCS2008,kConvMap2005};
   enum             {kOverrideGRP=BIT(14)}; // don't recreate from GRP if set
   //
@@ -46,11 +46,14 @@ class AliMagF : public TVirtualMagField
   Double_t     GetFactorSol()                                   const;
   Double_t     GetFactorDip()                                   const;
   Double_t     Factor()                                         const {return GetFactorSol();}
+  Double_t     GetCurrentSol()                                  const {return GetFactorSol()*(fMapType==k2kG ? 12000:30000);}
+  Double_t     GetCurrentDip()                                  const {return GetFactorDip()*6000;}
   Bool_t       IsUniform()                                      const {return fMapType == k5kGUniform;}
   //
   void         MachineField(const Double_t  *x, Double_t *b)    const;
   BMap_t       GetMapType()                                     const {return fMapType;}
   BeamType_t   GetBeamType()                                    const {return fBeamType;}
+  const char*  GetBeamTypeText()                                const;
   Double_t     GetBeamEnergy()                                  const {return fBeamEnergy;}
   Double_t     Max()                                            const {return fMax;}
   Int_t        Integ()                                          const {return fInteg;}
@@ -64,6 +67,10 @@ class AliMagF : public TVirtualMagField
   //
   Bool_t       LoadParameterization();
   static Int_t GetPolarityConvention()                                {return Int_t(fgkPolarityConvention);}
+  static AliMagF* CreateFieldMap(Float_t l3Current=-30000., Float_t diCurrent=-6000., 
+                                Int_t convention=0, Bool_t uniform = kFALSE, 
+                                Float_t benergy=7000., const Char_t* btype="pp",
+                                const Char_t* path="$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
   //
  protected:
   // not supposed to be changed during the run, set only at the initialization via constructor
index 24027ce72e7d564a6b8d161b6f5a5d1c31e9f0cf..2620a40aaa3ed82db08bdce65d9b8d11a0c53768 100644 (file)
@@ -920,90 +920,6 @@ void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam
 }
 
 //_____________________________________________________________________________
-Bool_t AliReconstruction::SetFieldMap(Float_t l3Cur, Float_t diCur, Float_t l3Pol, 
-                                 Float_t diPol, Int_t convention, Bool_t uniform,
-                                 Float_t beamenergy, const Char_t *beamtype, const Char_t *path) 
-{
-  //------------------------------------------------
-  // The magnetic field map, defined externally...
-  // L3 current 30000 A  -> 0.5 T
-  // L3 current 12000 A  -> 0.2 T
-  // dipole current 6000 A
-  // The polarities must match the convention (LHC or DCS2008) 
-  // unless the special uniform map was used for MC
-  //------------------------------------------------
-  const Float_t l3NominalCurrent1=30000.; // (A)
-  const Float_t l3NominalCurrent2=12000.; // (A)
-  const Float_t diNominalCurrent =6000. ; // (A)
-
-  const Float_t tolerance=0.03; // relative current tolerance
-  const Float_t zero=77.;       // "zero" current (A)
-  //
-  AliMagF::BMap_t map;
-  double sclL3,sclDip;
-  //
-  l3Cur = TMath::Abs(l3Cur);
-  diCur = TMath::Abs(diCur);
-  //
-  if (TMath::Abs((sclDip=diCur/diNominalCurrent)-1.) > tolerance && !uniform) {
-    if (diCur <= zero) sclDip = 0.; // some small current.. -> Dipole OFF
-    else {
-      AliError(Form("Wrong dipole current (%f A)!",diCur));
-      return kFALSE;
-    }
-  }
-  //
-  if (uniform) { 
-    // special treatment of special MC with uniform mag field (normalized to 0.5 T)
-    // no check for scaling/polarities are done
-    map   = AliMagF::k5kGUniform;
-    sclL3 = l3Cur/l3NominalCurrent1; 
-  }
-  else {
-    if      (TMath::Abs((sclL3=l3Cur/l3NominalCurrent1)-1.) < tolerance) map  = AliMagF::k5kG;
-    else if (TMath::Abs((sclL3=l3Cur/l3NominalCurrent2)-1.) < tolerance) map  = AliMagF::k2kG;
-    else if (l3Cur <= zero)                                { sclL3 = 0;  map  = AliMagF::k5kGUniform;}
-    else {
-      AliError(Form("Wrong L3 current (%f A)!",l3Cur));
-      return kFALSE;
-    }
-  }
-  //
-  if (sclDip!=0 && (map==AliMagF::k5kG || map==AliMagF::k2kG) &&
-      ((convention==AliMagF::kConvLHC     && l3Pol!=diPol) ||
-       (convention==AliMagF::kConvDCS2008 && l3Pol==diPol)) ) { 
-    AliError(Form("Wrong combination for L3/Dipole polarities (%c/%c) in %s convention",
-                 l3Pol>0?'+':'-',diPol>0?'+':'-',convention==AliMagF::kConvDCS2008?"DCS2008":"LHC"));
-    return kFALSE;
-  }
-  //
-  if (l3Pol<0) sclL3  = -sclL3;
-  if (diPol<0) sclDip = -sclDip;
-  //
-  AliMagF::BeamType_t btype = AliMagF::kNoBeamField;
-  TString btypestr = beamtype;
-  btypestr.ToLower();
-  TPRegexp protonBeam("(proton|p)\\s*-?\\s*\\1");
-  TPRegexp ionBeam("(lead|pb|ion|a)\\s*-?\\s*\\1");
-  if (btypestr.Contains(ionBeam)) btype = AliMagF::kBeamTypeAA;
-  else if (btypestr.Contains(protonBeam)) btype = AliMagF::kBeamTypepp;
-  else AliInfo(Form("Assume no LHC magnet field for the beam type %s, ",beamtype));
-  //
-  char ttl[80];
-  sprintf(ttl,"L3: %+5d Dip: %+4d kA; %s | Polarities in %s convention",(int)TMath::Sign(l3Cur,float(sclL3)),
-         (int)TMath::Sign(diCur,float(sclDip)),uniform ? " Constant":"",
-         convention==AliMagF::kConvLHC ? "LHC":"DCS2008");
-  // LHC and DCS08 conventions have opposite dipole polarities
-  if ( AliMagF::GetPolarityConvention() != convention) sclDip = -sclDip;
-  //
-  AliMagF* fld = new AliMagF("MagneticFieldMap", ttl, 2, sclL3, sclDip, 10., map, path, 
-                            btype,beamenergy);
-  TGeoGlobalMagField::Instance()->SetField( fld );
-  TGeoGlobalMagField::Instance()->Lock();
-  //
-  return kTRUE;
-}
-
 Bool_t AliReconstruction::InitGRP() {
   //------------------------------------
   // Initialization of the GRP entry 
@@ -1155,10 +1071,15 @@ Bool_t AliReconstruction::InitGRP() {
     Bool_t uniformB = fGRPData->IsUniformBMap();
 
     if (ok) { 
-      if ( !SetFieldMap(l3Current, diCurrent, l3Polarity ? -1:1, diPolarity ? -1:1, 
-                       polConvention,uniformB,beamEnergy, beamType.Data()))
-       AliFatal("Failed to creat a B field map ! Exiting...");
-      AliInfo("Running with the B field constructed out of GRP !");
+      AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1), 
+                                            TMath::Abs(diCurrent) * (diPolarity ? -1:1), 
+                                            polConvention,uniformB,beamEnergy, beamType.Data());
+      if (fld) {
+       TGeoGlobalMagField::Instance()->SetField( fld );
+       TGeoGlobalMagField::Instance()->Lock();
+       AliInfo("Running with the B field constructed out of GRP !");
+      }
+      else AliFatal("Failed to create a B field map !");
     }
     else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
   }
@@ -1696,7 +1617,24 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     // Set magnetic field from the tracker
     fesd->SetMagneticField(AliTracker::GetBz());
     fhltesd->SetMagneticField(AliTracker::GetBz());
-
+    //
+    AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+    if (fld) { // set info needed for field initialization
+      fesd->SetCurrentL3(fld->GetCurrentSol());
+      fesd->SetCurrentDip(fld->GetCurrentDip());
+      fesd->SetBeamEnergy(fld->GetBeamEnergy());
+      fesd->SetBeamType(fld->GetBeamTypeText());
+      fesd->SetUniformBMap(fld->IsUniform());
+      fesd->SetBInfoStored();
+      //
+      fhltesd->SetCurrentL3(fld->GetCurrentSol());
+      fhltesd->SetCurrentDip(fld->GetCurrentDip());
+      fhltesd->SetBeamEnergy(fld->GetBeamEnergy());
+      fhltesd->SetBeamType(fld->GetBeamTypeText());
+      fhltesd->SetUniformBMap(fld->IsUniform());
+      fhltesd->SetBInfoStored();
+    }
+    //
     // Set most probable pt, for B=0 tracking
     // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
     const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
index c8715878e44e8d5b784b68f79a9172ff61e3e46c..157a954d2bf8a318dbc3b27ed1fdfa7d9ada6503 100644 (file)
@@ -81,13 +81,6 @@ public:
   void           SetLoadAlignData(const char* detectors) 
     {fLoadAlignData = detectors;};
 
-  //*** Magnetic field setters
-  Bool_t SetFieldMap(Float_t l3Current=30000., Float_t diCurrent=6000., 
-                    Float_t l3Pol=-1., Float_t dipPol=-1.,
-                    Int_t convention=0, Bool_t uniform = kFALSE, 
-                    Float_t benergy=7000., const Char_t* btype="pp",
-                    const Char_t* path="$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
-
   //*** Global reconstruction flag setters
   void SetRunVertexFinder(Bool_t flag=kTRUE) {fRunVertexFinder=flag;};
   void SetRunVertexFinderTracks(Bool_t flag=kTRUE) {fRunVertexFinderTracks=flag;};