3333// / `DECLARE_SOA_TIMESTAMPED_TABLE` with the relevant subset of columns from
3434// / the `o2::aod::ccdbGlo` namespace rather than joining `aod::GloCCDBObjects`.
3535// /
36- // / Note: MatLayerCylSet is intentionally omitted — it requires
37- // / `MatLayerCylSet::rectifyPtrFromFile()` after deserialisation, which the
38- // / CCDB column mechanism does not perform.
36+ // / The material LUT lives in `aod::GeomCCDBObjects` rather than here: it belongs to
37+ // / the geometry/material family, whose validity is essentially static, and keeping it
38+ // / out means joining `aod::GloCCDBObjects` does not drag in a multi-hundred-MB object
39+ // / nobody asked for. Join whichever tables you need — the duplicated `aod::Timestamps`
40+ // / is deduplicated:
41+ // / \code
42+ // / using BCsWithLUT = soa::Join<aod::BCsWithTimestamps, aod::GeomCCDBObjects>;
43+ // / // rectifyPtrFromFile() is applied by the column's finaliser, so the object
44+ // / // handed back is ready to use. Installing it is a pointer store, so it costs
45+ // / // nothing to redo every timeframe — and doing so picks up a relocated column
46+ // / // buffer for free instead of dangling.
47+ // / o2::base::Propagator::Instance()->setMatLUT(&bcs.begin().matLUT());
48+ // / \endcode
3949
4050#ifndef COMMON_DATAMODEL_GLOCCDBOBJECTS_H_
4151#define COMMON_DATAMODEL_GLOCCDBOBJECTS_H_
4454#include < DataFormatsParameters/GRPECSObject.h>
4555#include < DataFormatsParameters/GRPLHCIFData.h>
4656#include < DataFormatsParameters/GRPMagField.h>
57+ #include < DetectorsBase/MatLayerCylSet.h>
4758#include < Framework/ASoA.h>
4859#include < Framework/AnalysisDataModel.h>
60+ #include < Framework/Logger.h>
61+
62+ #include < cstdint>
63+ #include < string>
64+ #include < string_view>
4965
5066namespace o2 ::aod
5167{
@@ -55,11 +71,62 @@ DECLARE_SOA_CCDB_COLUMN(GRPMagField, grpMagField, o2::parameters::GRPMagField, "
5571DECLARE_SOA_CCDB_COLUMN (MeanVertex, meanVertex, o2::dataformats::MeanVertexObject, " GLO/Calib/MeanVertex" ); // !
5672DECLARE_SOA_CCDB_COLUMN (GRPECSObject, grpECS, o2::parameters::GRPECSObject, " GLO/Config/GRPECS" ); // !
5773DECLARE_SOA_CCDB_COLUMN (GRPLHCIFData, grpLHCIF, o2::parameters::GRPLHCIFData, " GLO/Config/GRPLHCIF" ); // !
74+
75+ // / The material LUT is a FlatObject: straight out of the ROOT streamer its internal
76+ // / pointers are unfixed and its voxel lookup is unbuilt, so it is finalised with
77+ // / MatLayerCylSet::rectifyPtrFromFile() before ever being handed to a task.
78+ DECLARE_SOA_CCDB_COLUMN_FULL (MatLUT, " fMatLUT" , matLUT, o2::base::MatLayerCylSet, " GLO/Param/MatLUT" , 0 , // !
79+ [](o2::base::MatLayerCylSet* lut) { return o2::base::MatLayerCylSet::rectifyPtrFromFile (lut); });
80+
81+ // / Returns the GRPLHCIF object for this BC: straight from the aod::GrpLHCIFCCDBObjects
82+ // / column when the BC table carries it, else through a CCDB query at \p timestamp. Lets a
83+ // / shared module serve migrated and un-migrated tasks from a single code path — the
84+ // / discarded branch is not instantiated, so an un-migrated caller keeps its CCDB query and
85+ // / a migrated one never names the CCDB manager.
86+ template <typename TBC , typename TCCDB >
87+ inline o2::parameters::GRPLHCIFData* grpLHCIFFor (TBC const & bc, TCCDB & ccdb, std::string const & path, int64_t timestamp)
88+ {
89+ if constexpr (requires { bc.grpLHCIF (); }) {
90+ // The column is the single source of truth for the path; a caller that also configured
91+ // one is telling us two different things, and silently honouring one is how conditions
92+ // diverge unnoticed.
93+ if (path != std::string_view{GRPLHCIFData::query}) {
94+ LOGP (fatal, R"( A GRPLHCIF path "{}" is configured while the object is taken from the aod::GrpLHCIFCCDBObjects column, whose path is "{}". Set it through the "ccdb:{}" option instead.)" ,
95+ path, GRPLHCIFData::query, GRPLHCIFData::mLabel );
96+ }
97+ return &bc.grpLHCIF ();
98+ } else {
99+ return ccdb->template getForTimeStamp <o2::parameters::GRPLHCIFData>(path, timestamp);
100+ }
101+ }
58102} // namespace ccdbGlo
59103
60104// / Full table — join with aod::BCsWithTimestamps to obtain all four objects.
61105DECLARE_SOA_TIMESTAMPED_TABLE (GloCCDBObjects, aod::Timestamps, o2::aod::timestamp::Timestamp, 1 , " GLOCCDBOBJ" , // !
62106 ccdbGlo::GRPMagField, ccdbGlo::MeanVertex, ccdbGlo::GRPECSObject, ccdbGlo::GRPLHCIFData);
107+
108+ // / The LHC filling scheme and beam configuration on its own. Run-uniform: GRPLHCIF is set
109+ // / per fill and a run lies within a fill, so the fetcher resolves it once per run rather
110+ // / than once per BC. Kept apart from aod::GloCCDBObjects so that a task needing only this
111+ // / does not also fetch GRPMagField, MeanVertex and GRPECS — GRPLHCIF is the most widely
112+ // / used of the four (44 files reference the path) and is usually wanted alone.
113+ DECLARE_SOA_UNIFORM_TABLE (GrpLHCIFCCDBObjects, aod::Timestamps, o2::aod::timestamp::Timestamp,
114+ aod::BCs, o2::aod::bc::RunNumber, 1 , " GRPLHCIFCCDB" , // !
115+ ccdbGlo::GRPLHCIFData);
116+
117+ // / Geometry and material description: objects which describe where the detector material
118+ // / is, and which share an essentially static interval of validity. Kept apart from the GRP
119+ // / family above, which changes per run (and, for GRPMagField, per timeframe).
120+ // / The aligned/ideal geometry and the per-detector alignment objects belong here too when
121+ // / they get columns; see GRPGeomRequest in O2 (GLO/Config/GeometryAligned, GLO/Config/Geometry,
122+ // / <DET>/Calib/Align) for the family.
123+ // / Join it alongside aod::GloCCDBObjects when a task needs both — the duplicated
124+ // / aod::Timestamps is deduplicated when the joined table's originals are merged.
125+ // / Uniform in the run number: the geometry/material description does not change within a
126+ // / run, so the fetcher queries once per distinct run rather than once per BC.
127+ DECLARE_SOA_UNIFORM_TABLE (GeomCCDBObjects, aod::Timestamps, o2::aod::timestamp::Timestamp,
128+ aod::BCs, o2::aod::bc::RunNumber, 1 , " GEOMCCDBOBJ" , // !
129+ ccdbGlo::MatLUT);
63130} // namespace o2::aod
64131
65132#endif // COMMON_DATAMODEL_GLOCCDBOBJECTS_H_
0 commit comments