diff --git a/Common/Field/CMakeLists.txt b/Common/Field/CMakeLists.txt index b39c6e0083ce7..e8714d613dc68 100644 --- a/Common/Field/CMakeLists.txt +++ b/Common/Field/CMakeLists.txt @@ -4,12 +4,14 @@ O2_SETUP(NAME ${MODULE_NAME}) set(SRCS src/MagneticWrapperChebyshev.cxx + src/MagFieldParam.cxx src/MagneticField.cxx ) set(HEADERS include/${MODULE_NAME}/MagneticWrapperChebyshev.h include/${MODULE_NAME}/MagneticField.h + include/${MODULE_NAME}/MagFieldParam.h ) set(LINKDEF src/FieldLinkDef.h) set(LIBRARY_NAME ${MODULE_NAME}) diff --git a/Common/Field/include/Field/MagFieldParam.h b/Common/Field/include/Field/MagFieldParam.h new file mode 100644 index 0000000000000..b0d3dc4e98d86 --- /dev/null +++ b/Common/Field/include/Field/MagFieldParam.h @@ -0,0 +1,62 @@ +/// \file MagFieldParam.h +/// \brief Definition of the MagFieldParam: container for ALICE mag. field parameters +/// \author ruben.shahoyan@cern.ch + +#ifndef ALICEO2_FIELD_MAGFIELDPARAM_H_ +#define ALICEO2_FIELD_MAGFIELDPARAM_H_ + +#include "FairParGenericSet.h" +#include + +class FairParamList; + + +namespace AliceO2 { + namespace Field { + +class MagneticField; + +class MagFieldParam : public FairParGenericSet +{ + public: + enum BMap_t + { + k2kG, k5kG, k5kGUniform + }; + enum BeamType_t + { + kNoBeamField, kBeamTypepp, kBeamTypeAA, kBeamTypepA, kBeamTypeAp + }; + + MagFieldParam(const char* name="", const char* title="", const char* context=""); + + void SetParam(const MagneticField* field); + + BMap_t GetMapType() const {return mMapType;} + BeamType_t GetBeamType() const {return mBeamType;} + Int_t GetDefInt() const {return mDefaultIntegration;} + Double_t GetFactorSol() const {return mFactorSol;} + Double_t GetFactorDip() const {return mFactorDip;} + Double_t GetBeamEnergy() const {return mBeamEnergy;} + Double_t GetMaxField() const {return mMaxField;} + const char* GetMapPath() const {return mMapPath.Data();} + + virtual void putParams(FairParamList* list); + virtual Bool_t getParams(FairParamList* list); + + protected: + BMap_t mMapType; ///< map type ID + BeamType_t mBeamType; ///< beam type ID + Int_t mDefaultIntegration; ///< field integration type for MC + Double_t mFactorSol; ///< solenoid current factor + Double_t mFactorDip; ///< dipole current factor + Double_t mBeamEnergy; ///< beam energy + Double_t mMaxField; ///< max field for geant + TString mMapPath; ///< path to map file + + ClassDef(MagFieldParam,1) +}; +} +} + +#endif diff --git a/Common/Field/include/Field/MagneticField.h b/Common/Field/include/Field/MagneticField.h index 6302699157550..e9729ddacfd73 100644 --- a/Common/Field/include/Field/MagneticField.h +++ b/Common/Field/include/Field/MagneticField.h @@ -5,33 +5,30 @@ #ifndef ALICEO2_FIELD_MAGNETICFIELD_H_ #define ALICEO2_FIELD_MAGNETICFIELD_H_ -#include // for TVirtualMagField +#include "FairField.h" // for FairField +#include "Field/MagFieldParam.h" +#include "Field/MagneticWrapperChebyshev.h" // for MagneticWrapperChebyshev #include "TSystem.h" #include "Rtypes.h" // for Double_t, Char_t, Int_t, Float_t, etc #include "TNamed.h" // for TNamed +#include // for str::unique_ptr class FairLogger; // lines 14-14 +class FairParamList; + namespace AliceO2 { namespace Field { class MagneticWrapperChebyshev; }} // lines 19-19 namespace AliceO2 { namespace Field { class MagneticWrapperChebyshev; - + /// Interface between the TVirtualMagField and MagneticWrapperChebyshev: wrapper to the set of magnetic field data + /// Tosca /// parametrization by Chebyshev polynomials -class MagneticField : public TVirtualMagField +class MagneticField : public FairField { public: - enum BMap_t - { - k2kG, k5kG, k5kGUniform - }; - enum BeamType_t - { - kNoBeamField, kBeamTypepp, kBeamTypeAA, kBeamTypepA, kBeamTypeAp - }; enum PolarityConvention_t { kConvLHC, kConvDCS2008, kConvMap2005 @@ -48,21 +45,55 @@ class MagneticField : public TVirtualMagField /// Impose scaling of parameterized L3 field by factorSol and of dipole by factorDip. /// The "be" is the energy of the beam in GeV/nucleon MagneticField(const char *name, const char *title, Double_t factorSol = 1., Double_t factorDip = 1., - BMap_t maptype = k5kG, BeamType_t btype = kBeamTypepp, Double_t benergy = -1, Int_t integ = 2, + MagFieldParam::BMap_t maptype = MagFieldParam::k5kG, + MagFieldParam::BeamType_t btype = MagFieldParam::kBeamTypepp, + Double_t benergy = -1, Int_t integ = 2, Double_t fmax = 15, const std::string path = std::string(gSystem->Getenv("VMCWORKDIR")) + std::string("/Common/maps/mfchebKGI_sym.root") ); - MagneticField(const MagneticField &src); + + MagneticField(const MagFieldParam& param); MagneticField &operator=(const MagneticField &src); /// Default destructor - virtual ~MagneticField(); + virtual ~MagneticField() {} + + /// real field creation is here + void CreateField(); + + /// Virtual methods from FairField + + /// X component, avoid using since slow + virtual Double_t GetBx(Double_t x, Double_t y, Double_t z) { + double xyz[3]={x,y,z},b[3]; + GetFieldValue(xyz,b); + return b[0]; + } + + /// Y component, avoid using since slow + virtual Double_t GetBy(Double_t x, Double_t y, Double_t z) { + double xyz[3]={x,y,z},b[3]; + GetFieldValue(xyz,b); + return b[1]; + } + + /// Z component + virtual Double_t GetBz(Double_t x, Double_t y, Double_t z) { + double xyz[3]={x,y,z}; + return getBz(xyz); + } /// Method to calculate the field at point xyz - virtual void Field(const Double_t *x, Double_t *b); + virtual void GetFieldValue(const Double_t point[3], Double_t* bField); + + /// 3d field query alias for Alias Method to calculate the field at point xyz + virtual void GetBxyz(const Double_t p[3], Double_t* b) {Field(p,b);} + /// Fill Paramater + virtual void FillParContainer(); + /// Method to calculate the integral_0^z of br,bt,bz void getTPCIntegral(const Double_t *xyz, Double_t *b) const; @@ -79,10 +110,7 @@ class MagneticField : public TVirtualMagField /// Method to calculate the field at point xyz Double_t getBz(const Double_t *xyz) const; - MagneticWrapperChebyshev *getMeasuredMap() const - { - return mMeasuredMap; - } + MagneticWrapperChebyshev *getMeasuredMap() const { return mMeasuredMap.get();} // Former MagF methods or their aliases @@ -105,7 +133,7 @@ class MagneticField : public TVirtualMagField Double_t getCurrentSolenoid() const { - return getFactorSolenoid() * (mMapType == k2kG ? 12000 : 30000); + return getFactorSolenoid() * (mMapType == MagFieldParam::k2kG ? 12000 : 30000); } Double_t getCurrentDipole() const @@ -115,17 +143,17 @@ class MagneticField : public TVirtualMagField Bool_t IsUniform() const { - return mMapType == k5kGUniform; + return mMapType == MagFieldParam::k5kGUniform; } void MachineField(const Double_t *x, Double_t *b) const; - BMap_t getMapType() const + MagFieldParam::BMap_t getMapType() const { return mMapType; } - BeamType_t getBeamType() const + MagFieldParam::BeamType_t getBeamType() const { return mBeamType; } @@ -202,9 +230,9 @@ class MagneticField : public TVirtualMagField protected: // not supposed to be changed during the run, set only at the initialization via constructor - void initializeMachineField(BeamType_t btype, Double_t benergy); + void initializeMachineField(MagFieldParam::BeamType_t btype, Double_t benergy); - void setBeamType(BeamType_t type) + void setBeamType(MagFieldParam::BeamType_t type) { mBeamType = type; } @@ -215,10 +243,10 @@ class MagneticField : public TVirtualMagField } protected: - MagneticWrapperChebyshev *mMeasuredMap; //! Measured part of the field map - BMap_t mMapType; ///< field map type + std::unique_ptr mMeasuredMap; //! Measured part of the field map + MagFieldParam::BMap_t mMapType; ///< field map type Double_t mSolenoid; ///< Solenoid field setting - BeamType_t mBeamType; ///< Beam type: A-A (mBeamType=0) or p-p (mBeamType=1) + MagFieldParam::BeamType_t mBeamType; ///< Beam type: A-A (mBeamType=0) or p-p (mBeamType=1) Double_t mBeamEnergy; ///< Beam energy in GeV Int_t mDefaultIntegration; ///< Default integration method as indicated in Geant @@ -234,15 +262,20 @@ class MagneticField : public TVirtualMagField Double_t mCompensatorField1A; ///< Side A 1st compensator field Double_t mCompensatorField2A; ///< Side A 2nd compensator field - TNamed mParameterNames; ///< file and parameterization loadad + TNamed mParameterNames; ///< file and parameterization loaded static const Double_t sSolenoidToDipoleZ; ///< conventional Z of transition from L3 to Dipole field static const UShort_t sPolarityConvention; ///< convention for the mapping of the curr.sign on main component sign FairLogger *mLogger; + private: + MagneticField(const MagneticField &src); + + + ClassDef(AliceO2::Field::MagneticField, - 2) // Class for all Alice MagField wrapper for measured data + Tosca parameterization + 3) // Class for all Alice MagField wrapper for measured data + Tosca parameterization }; } } diff --git a/Common/Field/src/FieldLinkDef.h b/Common/Field/src/FieldLinkDef.h index 403a8481c2518..cf97195ebc19c 100644 --- a/Common/Field/src/FieldLinkDef.h +++ b/Common/Field/src/FieldLinkDef.h @@ -6,5 +6,6 @@ #pragma link C++ class AliceO2::Field::MagneticField+; #pragma link C++ class AliceO2::Field::MagneticWrapperChebyshev+; +#pragma link C++ class AliceO2::Field::MagFieldParam+; #endif diff --git a/Common/Field/src/MagFieldParam.cxx b/Common/Field/src/MagFieldParam.cxx new file mode 100644 index 0000000000000..7d7394c0a08f9 --- /dev/null +++ b/Common/Field/src/MagFieldParam.cxx @@ -0,0 +1,86 @@ +/// \file MagFieldParam.cxx +/// \brief Implementation of the MagFieldParam class +/// \author ruben.shahoyan@cern.ch + +#include "Field/MagFieldParam.h" +#include "Field/MagneticField.h" +#include "FairParamList.h" +#include "FairRun.h" +#include "FairRuntimeDb.h" + +using namespace AliceO2::Field; + + +//======================================== +ClassImp(MagFieldParam); + +MagFieldParam::MagFieldParam(const char* name, const char* title, const char* context) + :FairParGenericSet(name, title, context) + ,mMapType(k5kG) + ,mBeamType(kNoBeamField) + ,mDefaultIntegration(0) + ,mFactorSol(0.) + ,mFactorDip(0.) + ,mBeamEnergy(0.) + ,mMaxField(0.) + ,mMapPath() +{ + /// create param for alice mag. field +} + +void MagFieldParam::SetParam(const MagneticField* field) +{ + /// fill parameters from the initialized field + // SetName(field->GetName()); ? is this needed + // SetTitle(field->GetTitle()); + mMapType = field->getMapType(); + mBeamType = field->getBeamType(); + mDefaultIntegration = field->Integral(); + mFactorSol = field->getFactorSolenoid(); + mFactorDip = field->getFactorDipole(); + mBeamEnergy = field->getBeamEnergy(); + mMaxField = field->Max(); + mMapPath = field->getDataFileName(); + // +} + +void MagFieldParam::putParams(FairParamList* list) +{ + /// store parameters in the list + if (!list) return; + list->add("Map Type ID", int(mMapType)); + list->add("Beam Type ID", int(mBeamType)); + list->add("Integral Type", mDefaultIntegration); + list->add("Fact.Solenoid", mFactorSol); + list->add("Fact.Dipole ", mFactorDip); + list->add("Beam Energy ", mBeamEnergy); + list->add("Max. Field ", mMaxField); + list->add("Path to map ", mMapPath.Data()); + // +} + +Bool_t MagFieldParam::getParams(FairParamList* list) +{ + /// retried parameters + int int2enum=0; + if (!list->fill("Map Type ID", &int2enum)) return kFALSE; + mMapType = static_cast(int2enum); + if (!list->fill("Beam Type ID", &int2enum)) return kFALSE; + mBeamType = static_cast(int2enum); + // + if (!list->fill("Integral Type", &mDefaultIntegration)) return kFALSE; + if (!list->fill("Fact.Solenoid", &mFactorSol)) return kFALSE; + if (!list->fill("Fact.Dipole ", &mFactorDip)) return kFALSE; + if (!list->fill("Beam Energy ", &mBeamEnergy)) return kFALSE; + if (!list->fill("Max. Field ", &mMaxField)) return kFALSE; + FairParamObj* parpath = list->find("Path to map "); + if (!parpath) return kFALSE; + int lgt = parpath->getLength(); + // RS: is there a bug in FairParamList::fill(const Text_t* name,Text_t* value,const Int_t length)? + // I think the "if (lfill("Path to map ", cbuff, lgt+2)) return kFALSE; + mMapPath = cbuff; + return kTRUE; +} diff --git a/Common/Field/src/MagneticField.cxx b/Common/Field/src/MagneticField.cxx index a9b959b60b99b..b6ce37e8c80b4 100644 --- a/Common/Field/src/MagneticField.cxx +++ b/Common/Field/src/MagneticField.cxx @@ -3,11 +3,13 @@ /// \author ruben.shahoyan@cern.ch #include "Field/MagneticField.h" -#include "Field/MagneticWrapperChebyshev.h" // for MagneticWrapperChebyshev #include // for TFile #include // for TPRegexp #include // for TSystem, gSystem #include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN +#include "FairParamList.h" +#include "FairRun.h" +#include "FairRuntimeDb.h" using namespace AliceO2::Field; @@ -51,11 +53,11 @@ Double_t MagneticField::sSolenoidToDipoleZ = -700.; const UShort_t MagneticField::sPolarityConvention = MagneticField::kConvLHC; MagneticField::MagneticField() - : TVirtualMagField(), - mMeasuredMap(0), - mMapType(k5kG), + : FairField(), + mMeasuredMap(nullptr), + mMapType(MagFieldParam::k5kG), mSolenoid(0), - mBeamType(kNoBeamField), + mBeamType(MagFieldParam::kNoBeamField), mBeamEnergy(0), mDefaultIntegration(0), mPrecisionInteg(0), @@ -71,21 +73,22 @@ MagneticField::MagneticField() mParameterNames("", ""), mLogger(FairLogger::GetLogger()) { + fType = 2; // flag non-constant field } MagneticField::MagneticField(const char *name, const char *title, Double_t factorSol, Double_t factorDip, - BMap_t maptype, BeamType_t bt, Double_t be, Int_t integ, Double_t fmax, - const std::string path) - : TVirtualMagField(name), - mMeasuredMap(0), + MagFieldParam::BMap_t maptype, MagFieldParam::BeamType_t bt, + Double_t be, Int_t integ, Double_t fmax,const std::string path) + : FairField(name,title), + mMeasuredMap(nullptr), mMapType(maptype), mSolenoid(0), mBeamType(bt), mBeamEnergy(be), mDefaultIntegration(integ), mPrecisionInteg(1), - mMultipicativeFactorSolenoid(1.), - mMultipicativeFactorDipole(1.), + mMultipicativeFactorSolenoid(factorSol), + mMultipicativeFactorDipole(factorDip), mMaxField(fmax), mDipoleOnOffFlag(factorDip == 0.), mQuadrupoleGradient(0), @@ -96,55 +99,85 @@ MagneticField::MagneticField(const char *name, const char *title, Double_t facto mParameterNames("", ""), mLogger(FairLogger::GetLogger()) { - SetTitle(title); - if (integ < 0 || integ > 2) { - mLogger->Warning(MESSAGE_ORIGIN, "Invalid magnetic field flag: %5d; Helix tracking chosen instead", integ); + setDataFileName(path.c_str()); + CreateField(); +} + +MagneticField::MagneticField(const MagFieldParam& param) + : FairField(param.GetName(),param.GetTitle()), + mMeasuredMap(nullptr), + mMapType(param.GetMapType()), + mSolenoid(0), + mBeamType(param.GetBeamType()), + mBeamEnergy(param.GetBeamEnergy()), + mDefaultIntegration(param.GetDefInt()), + mPrecisionInteg(1), + mMultipicativeFactorSolenoid(param.GetFactorSol()), // temporary + mMultipicativeFactorDipole(param.GetFactorDip()), // temporary + mMaxField(param.GetMaxField()), + mDipoleOnOffFlag(param.GetFactorDip() == 0.), + mQuadrupoleGradient(0), + mDipoleField(0), + mCompensatorField2C(0), + mCompensatorField1A(0), + mCompensatorField2A(0), + mParameterNames("", ""), + mLogger(FairLogger::GetLogger()) +{ + setDataFileName(param.GetMapPath()); + CreateField(); +} + +void MagneticField::CreateField() +{ + fType = 2; // flag non-constant field + + // does real creation of the field + if (mDefaultIntegration < 0 || mDefaultIntegration > 2) { + mLogger->Warning(MESSAGE_ORIGIN, "Invalid magnetic field flag: %5d; Helix tracking chosen instead", + mDefaultIntegration); mDefaultIntegration = 2; } - if (mDefaultIntegration == 0) { - mPrecisionInteg = 0; - } + if (mDefaultIntegration == 0) mPrecisionInteg = 0; - if (mBeamEnergy <= 0 && mBeamType != kNoBeamField) { - if (mBeamType == kBeamTypepp) { - mBeamEnergy = 7000.; // max proton energy - } - else if (mBeamType == kBeamTypeAA) { - mBeamEnergy = 2760; // max PbPb energy - } - else if (mBeamType == kBeamTypepA || mBeamType == kBeamTypeAp) { + if (mBeamEnergy <= 0 && mBeamType != MagFieldParam::kNoBeamField) { + if (mBeamType == MagFieldParam::kBeamTypepp) mBeamEnergy = 7000.; // max proton energy + else if (mBeamType == MagFieldParam::kBeamTypeAA) mBeamEnergy = 2760; // max PbPb energy + else if (mBeamType == MagFieldParam::kBeamTypepA || mBeamType == MagFieldParam::kBeamTypeAp) mBeamEnergy = 2760; // same rigitiy max PbPb energy - } + // FairLogger::GetLogger()->Info(MESSAGE_ORIGIN, "Maximim possible beam energy for requested beam is assumed"); } const char *parname = 0; - if (mMapType == k2kG) { + if (mMapType == MagFieldParam::k2kG) { parname = mDipoleOnOffFlag ? "Sol12_Dip0_Hole" : "Sol12_Dip6_Hole"; - } else if (mMapType == k5kG) { + } else if (mMapType == MagFieldParam::k5kG) { parname = mDipoleOnOffFlag ? "Sol30_Dip0_Hole" : "Sol30_Dip6_Hole"; - } else if (mMapType == k5kGUniform) { + } else if (mMapType == MagFieldParam::k5kGUniform) { parname = "Sol30_Dip6_Uniform"; } else { mLogger->Fatal(MESSAGE_ORIGIN, "Unknown field identifier %d is requested\n", mMapType); } - setDataFileName(path.c_str()); setParameterName(parname); loadParameterization(); initializeMachineField(mBeamType, mBeamEnergy); + setFactorSolenoid(mMultipicativeFactorSolenoid); + setFactorDipole(mMultipicativeFactorDipole); double xyz[3] = {0., 0., 0.}; mSolenoid = getBz(xyz); - setFactorSolenoid(factorSol); - setFactorDipole(factorDip); Print("a"); + // } +/* + RS: not needed, FairField has no copy c-tor implemented MagneticField::MagneticField(const MagneticField &src) - : TVirtualMagField(src), - mMeasuredMap(0), + : FairField(src), + mMeasuredMap(nullptr), mMapType(src.mMapType), mSolenoid(src.mSolenoid), mBeamType(src.mBeamType), @@ -164,14 +197,11 @@ MagneticField::MagneticField(const MagneticField &src) mLogger(FairLogger::GetLogger()) { if (src.mMeasuredMap) { - mMeasuredMap = new MagneticWrapperChebyshev(*src.mMeasuredMap); + mMeasuredMap(new MagneticWrapperChebyshev(*src.mMeasuredMap)); } } +*/ -MagneticField::~MagneticField() -{ - delete mMeasuredMap; -} Bool_t MagneticField::loadParameterization() { @@ -185,7 +215,8 @@ Bool_t MagneticField::loadParameterization() mLogger->Fatal(MESSAGE_ORIGIN, "Failed to open magnetic field data file %s\n", fname); } - mMeasuredMap = dynamic_cast(file->Get(getParameterName())); + mMeasuredMap = std::unique_ptr + (dynamic_cast(file->Get(getParameterName()))); if (!mMeasuredMap) { mLogger->Fatal(MESSAGE_ORIGIN, "Did not find field %s in %s\n", getParameterName(), fname); } @@ -194,7 +225,7 @@ Bool_t MagneticField::loadParameterization() return kTRUE; } -void MagneticField::Field(const Double_t *xyz, Double_t *b) +void MagneticField::GetFieldValue(const Double_t *xyz, Double_t *b) { // b[0]=b[1]=b[2]=0.0; if (mMeasuredMap && xyz[2] > mMeasuredMap->getMinZ() && xyz[2] < mMeasuredMap->getMaxZ()) { @@ -228,10 +259,7 @@ MagneticField &MagneticField::operator=(const MagneticField &src) { if (this != &src) { if (src.mMeasuredMap) { - if (mMeasuredMap) { - delete mMeasuredMap; - } - mMeasuredMap = new MagneticWrapperChebyshev(*src.mMeasuredMap); + mMeasuredMap.reset(new MagneticWrapperChebyshev(*src.getMeasuredMap())); } SetName(src.GetName()); mSolenoid = src.mSolenoid; @@ -248,16 +276,16 @@ MagneticField &MagneticField::operator=(const MagneticField &src) return *this; } -void MagneticField::initializeMachineField(BeamType_t btype, Double_t benergy) +void MagneticField::initializeMachineField(MagFieldParam::BeamType_t btype, Double_t benergy) { - if (btype == kNoBeamField) { + if (btype == MagFieldParam::kNoBeamField) { mQuadrupoleGradient = mDipoleField = mCompensatorField2C = mCompensatorField1A = mCompensatorField2A = 0.; return; } double rigScale = benergy / 7000.; // scale according to ratio of E/Enominal // for ions assume PbPb (with energy provided per nucleon) and account for A/Z - if (btype == kBeamTypeAA /* || btype==kBeamTypepA || btype==kBeamTypeAp */) { + if (btype == MagFieldParam::kBeamTypeAA /* || btype==kBeamTypepA || btype==kBeamTypeAp */) { rigScale *= 208. / 82.; } // Attention: in p-Pb the energy recorded in the GRP is the PROTON energy, no rigidity @@ -455,7 +483,7 @@ MagneticField *MagneticField::createFieldMap(Float_t l3Cur, Float_t diCur, Int_t const Float_t tolerance = 0.03; // relative current tolerance const Float_t zero = 77.f; // "zero" current (A) - BMap_t map = k5kG; + MagFieldParam::BMap_t map = MagFieldParam::k5kG; double sclL3, sclDip; Float_t l3Pol = l3Cur > 0 ? 1 : -1; @@ -475,23 +503,23 @@ MagneticField *MagneticField::createFieldMap(Float_t l3Cur, Float_t diCur, Int_t 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; + map = MagFieldParam::k5kGUniform; sclL3 = l3Cur / l3NominalCurrent1; } else { if (TMath::Abs((sclL3 = l3Cur / l3NominalCurrent1) - 1.) < tolerance) { - map = k5kG; + map = MagFieldParam::k5kG; } else if (TMath::Abs((sclL3 = l3Cur / l3NominalCurrent2) - 1.) < tolerance) { - map = k2kG; + map = MagFieldParam::k2kG; } else if (l3Cur <= zero && diCur <= zero) { sclL3 = 0; sclDip = 0; - map = k5kGUniform; + map = MagFieldParam::k5kGUniform; } else { FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, "Wrong L3 current (%f A)!", l3Cur); } } - if (sclDip != 0 && map != k5kGUniform) { + if (sclDip != 0 && map != MagFieldParam::k5kGUniform) { if ((l3Cur <= zero) || ((convention == kConvLHC && l3Pol != diPol) || (convention == kConvDCS2008 && l3Pol == diPol))) { FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, @@ -507,7 +535,7 @@ MagneticField *MagneticField::createFieldMap(Float_t l3Cur, Float_t diCur, Int_t sclDip = -sclDip; } - BeamType_t btype = kNoBeamField; + MagFieldParam::BeamType_t btype = MagFieldParam::kNoBeamField; TString btypestr = beamtype; btypestr.ToLower(); TPRegexp protonBeam("(proton|p)\\s*-?\\s*\\1"); @@ -515,13 +543,13 @@ MagneticField *MagneticField::createFieldMap(Float_t l3Cur, Float_t diCur, Int_t TPRegexp protonionBeam("(proton|p)\\s*-?\\s*(lead|pb|ion|a|A)"); TPRegexp ionprotonBeam("(lead|pb|ion|a|A)\\s*-?\\s*(proton|p)"); if (btypestr.Contains(ionBeam)) { - btype = kBeamTypeAA; + btype = MagFieldParam::kBeamTypeAA; } else if (btypestr.Contains(protonBeam)) { - btype = kBeamTypepp; + btype = MagFieldParam::kBeamTypepp; } else if (btypestr.Contains(protonionBeam)) { - btype = kBeamTypepA; + btype = MagFieldParam::kBeamTypepA; } else if (btypestr.Contains(ionprotonBeam)) { - btype = kBeamTypeAp; + btype = MagFieldParam::kBeamTypeAp; } else { FairLogger::GetLogger()->Info(MESSAGE_ORIGIN, "Assume no LHC magnet field for the beam type %s,", beamtype); } @@ -545,15 +573,15 @@ const char *MagneticField::getBeamTypeText() const const char *beamPPb = "p-A"; const char *beamPbP = "A-p"; switch (mBeamType) { - case kBeamTypepp: + case MagFieldParam::kBeamTypepp: return beamPP; - case kBeamTypeAA: + case MagFieldParam::kBeamTypeAA: return beamPbPb; - case kBeamTypepA: + case MagFieldParam::kBeamTypepA: return beamPPb; - case kBeamTypeAp: + case MagFieldParam::kBeamTypeAp: return beamPbP; - case kNoBeamField: + case MagFieldParam::kNoBeamField: default: return beamNA; } @@ -565,11 +593,23 @@ void MagneticField::Print(Option_t *opt) const opts.ToLower(); mLogger->Info(MESSAGE_ORIGIN, "%s:%s", GetName(), GetTitle()); mLogger->Info(MESSAGE_ORIGIN, "Solenoid (%+.2f*)%.0f kG, Dipole %s (%+.2f) %s", getFactorSolenoid(), - (mMapType == k5kG || mMapType == k5kGUniform) ? 5. : 2., mDipoleOnOffFlag ? "OFF" : "ON", - getFactorDipole(), mMapType == k5kGUniform ? " |Constant Field!" : ""); + (mMapType == MagFieldParam::k5kG || mMapType == MagFieldParam::k5kGUniform) ? 5. : 2., + mDipoleOnOffFlag ? "OFF" : "ON", + getFactorDipole(), mMapType == MagFieldParam::k5kGUniform ? " |Constant Field!" : ""); if (opts.Contains("a")) { mLogger->Info(MESSAGE_ORIGIN, "Machine B fields for %s beam (%.0f GeV): QGrad: %.4f Dipole: %.4f", getBeamTypeText(), mBeamEnergy, mQuadrupoleGradient, mDipoleField); mLogger->Info(MESSAGE_ORIGIN, "Uses %s of %s", getParameterName(), getDataFileName()); } } + +void MagneticField::FillParContainer() +{ + // fill field parameters + FairRun* fRun = FairRun::Instance(); + FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + MagFieldParam* par = static_cast(rtdb->getContainer("MagFieldParam")); + par->SetParam(this); + par->setChanged(); +} + diff --git a/cmake/O2Dependencies.cmake b/cmake/O2Dependencies.cmake index 273f17314cc44..13946f2f6d4a6 100644 --- a/cmake/O2Dependencies.cmake +++ b/cmake/O2Dependencies.cmake @@ -1,4 +1,5 @@ + ########## DEPENDENCIES lookup ############ find_package(ROOT 6.06.00 REQUIRED) @@ -186,9 +187,11 @@ o2_define_bucket( common_field_bucket DEPENDENCIES - Core RIO MathUtils Geom + fairroot_base_bucket + Base ParBase Core RIO MathUtils Geom INCLUDE_DIRECTORIES + ${FAIRROOT_INCLUDE_DIR} ${ROOT_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/Common/MathUtils/include )