Skip to content

Commit a3d5d3c

Browse files
committed
Fix initialisation order
1 parent 458f551 commit a3d5d3c

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Common/TableProducer/propagationServiceV2.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ struct propagationServiceV2 {
7272
o2::framework::Configurable<std::string> ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
7373
Service<o2::ccdb::BasicCCDBManager> ccdb;
7474

75-
// propagation stuff — ccdbLoader used only for lut + mMeanVtx (set from column) + runNumber
75+
// propagation stuff — ccdbLoader used only for lut + mMeanVtx + runNumber
7676
o2::common::StandardCCDBLoaderConfigurables standardCCDBLoaderConfigurables;
7777
o2::common::StandardCCDBLoader ccdbLoader;
78+
o2::dataformats::MeanVertexObject mMeanVtxValue; // owned copy; ccdbLoader.mMeanVtx points here
7879

7980
// boilerplate: strangeness builder stuff
8081
o2::pwglf::strangenessbuilder::products products;
@@ -109,26 +110,25 @@ struct propagationServiceV2 {
109110
strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, histos, initContext);
110111
}
111112

112-
// Load MatLUT once (needs rectifyPtrFromFile, kept manual), set B-field per run from
113-
// GRPMagField CCDB column, and refresh mMeanVtx pointer every call (pointer into current
114-
// BC table, valid only for the duration of this process() invocation).
113+
// Load MatLUT once (needs rectifyPtrFromFile, kept manual), set B-field and mean vertex
114+
// once per run from GRPMagField/MeanVertex CCDB columns.
115115
template <typename TBC>
116116
void initCCDB(TBC const& bc0)
117117
{
118+
if (ccdbLoader.runNumber != bc0.runNumber()) {
119+
const auto& grpmag = bc0.grpMagField();
120+
LOG(info) << "Setting B-field to current " << grpmag.getL3Current() << " A for run " << bc0.runNumber() << " from GRPMagField CCDB column";
121+
o2::base::Propagator::initFieldFromGRP(&grpmag);
122+
mMeanVtxValue = bc0.meanVertex(); // copy by value — message lifetime does not matter
123+
ccdbLoader.mMeanVtx = &mMeanVtxValue;
124+
ccdbLoader.runNumber = bc0.runNumber();
125+
}
118126
if (!ccdbLoader.lut) {
119127
LOG(info) << "Loading material look-up table for run: " << bc0.runNumber();
120128
ccdbLoader.lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(
121129
ccdb->template getForRun<o2::base::MatLayerCylSet>(standardCCDBLoaderConfigurables.lutPath.value, bc0.runNumber()));
122130
o2::base::Propagator::Instance()->setMatLUT(ccdbLoader.lut);
123131
}
124-
// Always refresh: pointer into current BC table, invalidated after process() returns
125-
ccdbLoader.mMeanVtx = &bc0.meanVertex();
126-
if (ccdbLoader.runNumber != bc0.runNumber()) {
127-
const auto& grpmag = bc0.grpMagField(); // from declarative CCDB column
128-
LOG(info) << "Setting B-field to current " << grpmag.getL3Current() << " A for run " << bc0.runNumber() << " from GRPMagField CCDB column";
129-
o2::base::Propagator::initFieldFromGRP(&grpmag);
130-
ccdbLoader.runNumber = bc0.runNumber();
131-
}
132132
}
133133

134134
void processRealData(soa::Join<aod::Collisions, aod::EvSels> const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtIU const& tracks, BCsWithCCDB const& bcs)

0 commit comments

Comments
 (0)