From b5c44bc2d3d16136bc6bebb9a3ad62af962f8199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 12 Jul 2022 12:06:21 +0200 Subject: [PATCH 1/4] Add compatibility with new GRP scheme --- Common/TableProducer/trackPropagation.cxx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx index aa10200a8a5..2dce29f5ade 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) { @@ -100,9 +104,21 @@ 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()); + 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()); + 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); + } o2::base::Propagator::Instance()->setMatLUT(lut); mVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); runNumber = bc.runNumber(); From cb8739e1e019a182fdd663341b36cd4122be9033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 12 Jul 2022 12:20:17 +0200 Subject: [PATCH 2/4] Avoid fatal on non existing ccdb --- Common/TableProducer/trackPropagation.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx index 2dce29f5ade..b54d0af880c 100644 --- a/Common/TableProducer/trackPropagation.cxx +++ b/Common/TableProducer/trackPropagation.cxx @@ -97,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) @@ -108,6 +111,9 @@ struct TrackPropagation { 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 " << 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 { From dd8887d78276fa4efb7fdcc82336c04f89d3734d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 12 Jul 2022 14:06:28 +0200 Subject: [PATCH 3/4] Fix --- Common/TableProducer/trackPropagation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx index b54d0af880c..486994425c2 100644 --- a/Common/TableProducer/trackPropagation.cxx +++ b/Common/TableProducer/trackPropagation.cxx @@ -112,7 +112,7 @@ struct TrackPropagation { 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 " << timestamp; + 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); From b327d3c3c8b8e0ac447b3ab5656b6cc695297b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 12 Jul 2022 16:34:10 +0200 Subject: [PATCH 4/4] Fix error `invalid type specifier` - This is nasty because it was hiding in the LOGF(info, ..) function --- Common/TableProducer/trackPropagation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx index 486994425c2..d938fa3ba35 100644 --- a/Common/TableProducer/trackPropagation.cxx +++ b/Common/TableProducer/trackPropagation.cxx @@ -122,7 +122,7 @@ struct TrackPropagation { } } else { grpmag = ccdb->getForTimeStamp(grpmagPath, bc.timestamp()); - LOGF(info, "Setting magnetic field to current %d A for run %d from its GRPMagField CCDB object", grpmag->getL3Current(), bc.runNumber()); + 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);