diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx index aa10200a8a5..d938fa3ba35 100644 --- a/Common/TableProducer/trackPropagation.cxx +++ b/Common/TableProducer/trackPropagation.cxx @@ -25,6 +25,7 @@ #include "CommonUtils/NameConf.h" #include "CCDB/CcdbApi.h" #include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" @@ -61,13 +62,16 @@ struct TrackPropagation { const o2::dataformats::MeanVertexObject* mVtx = nullptr; o2::parameters::GRPObject* grpo = nullptr; + o2::parameters::GRPMagField* grpmag = nullptr; o2::base::MatLayerCylSet* lut = nullptr; Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + Configurable checkGRPObject{"checkGRPObject", false, "Flag to check the CCDB for GRPObject before asking for the GRPMagField"}; void init(o2::framework::InitContext& initContext) { @@ -93,6 +97,9 @@ struct TrackPropagation { if (!o2::base::GeometryManager::isGeometryLoaded()) { ccdb->get(geoPath); } + if (checkGRPObject) { + ccdb->setFatalWhenNull(false); + } } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -100,9 +107,24 @@ struct TrackPropagation { if (runNumber == bc.runNumber()) { return; } - grpo = ccdb->getForTimeStamp(grpPath, bc.timestamp()); - LOGF(info, "Setting magnetic field to %d kG for run %d from its GRP CCDB object", grpo->getNominalL3Field(), bc.runNumber()); - o2::base::Propagator::initFieldFromGRP(grpo); + if (checkGRPObject) { + grpo = ccdb->getForTimeStamp(grpPath, bc.timestamp()); + if (!grpo) { + grpmag = ccdb->getForTimeStamp(grpmagPath, bc.timestamp()); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << bc.timestamp(); + } + LOGF(info, "Setting magnetic field to current %d A for run %d from its GRPMagField CCDB object", grpmag->getL3Current(), bc.runNumber()); + o2::base::Propagator::initFieldFromGRP(grpmag); + } else { + LOGF(info, "Setting magnetic field to %d kG for run %d from its GRP CCDB object", grpo->getNominalL3Field(), bc.runNumber()); + o2::base::Propagator::initFieldFromGRP(grpo); + } + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, bc.timestamp()); + LOG(info) << "Setting magnetic field to current " << grpmag->getL3Current() << " A for run " << bc.runNumber() << " from its GRPMagField CCDB object"; + o2::base::Propagator::initFieldFromGRP(grpmag); + } o2::base::Propagator::Instance()->setMatLUT(lut); mVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); runNumber = bc.runNumber();