Skip to content

Commit b4ffc31

Browse files
committed
AggregatedRunInfo can be requested via GRPGeomHelper
To do this, request it after creating auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(...) as ggRequest->requireAggregateRunInfo(inputs); Then, in the task, once the GRPGeomHelper::checkUpdates was called, one can access AggregatedRunInfo as const auto& rInfo = GGCCDBRequest.getAggregatedRunInfo() TODO: filling of AggregatedRunInfo requires CTP/Calib/FirstRunOrbit which is populated only starting from 15 Aug 2023. Need to retrofit it for all runs and also for special non-anchored MC range.
1 parent 0b6360d commit b4ffc31

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

Detectors/Base/include/DetectorsBase/GRPGeomHelper.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "DataFormatsParameters/GRPLHCIFData.h"
2323
#include "DataFormatsParameters/GRPECSObject.h"
2424
#include "DataFormatsParameters/GRPMagField.h"
25+
#include "DataFormatsParameters/AggregatedRunInfo.h"
2526

2627
namespace o2::framework
2728
{
@@ -92,6 +93,7 @@ struct GRPGeomRequest {
9293
Ideal,
9394
Alignments };
9495

96+
bool askAggregateRunInfo = false;
9597
bool askGRPECS = false;
9698
bool askGRPLHCIF = false;
9799
bool askGRPMagField = false;
@@ -105,6 +107,7 @@ struct GRPGeomRequest {
105107

106108
GRPGeomRequest() = delete;
107109
GRPGeomRequest(bool orbitResetTime, bool GRPECS, bool GRPLHCIF, bool GRPMagField, bool askMatLUT, GeomRequest geom, std::vector<o2::framework::InputSpec>& inputs, bool askOnce = false, bool needPropD = false, std::string detMaskString = "all");
110+
void requireAggregateRunInfo(std::vector<o2::framework::InputSpec>& inputs);
108111
void addInput(const o2::framework::InputSpec&& isp, std::vector<o2::framework::InputSpec>& inputs);
109112
};
110113

@@ -121,14 +124,16 @@ class GRPGeomHelper
121124
}
122125
void setRequest(std::shared_ptr<GRPGeomRequest> req);
123126
bool finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj);
124-
void checkUpdates(o2::framework::ProcessingContext& pc) const;
127+
void checkUpdates(o2::framework::ProcessingContext& pc);
125128

126129
auto getAlignment(o2::detectors::DetID det) const { return mAlignments[det]; }
127130
auto getMatLUT() const { return mMatLUT; }
128131
auto getGRPECS() const { return mGRPECS; }
129132
auto getGRPLHCIF() const { return mGRPLHCIF; }
130133
auto getGRPMagField() const { return mGRPMagField; }
131-
auto getOrbitResetTimeMS() const { return mOrbitResetTimeMS; }
134+
auto getOrbitResetTimeMS() const { return mOrbitResetTimeMUS / 1000; }
135+
auto getOrbitResetTimeMUS() const { return mOrbitResetTimeMUS; }
136+
const o2::parameters::AggregatedRunInfo& getAggregatedRunInfo() const { return mAggregatedRunInfo; }
132137
static int getNHBFPerTF();
133138

134139
private:
@@ -141,7 +146,8 @@ class GRPGeomHelper
141146
const o2::parameters::GRPECSObject* mGRPECS = nullptr;
142147
const o2::parameters::GRPLHCIFData* mGRPLHCIF = nullptr;
143148
const o2::parameters::GRPMagField* mGRPMagField = nullptr;
144-
long mOrbitResetTimeMS = 0; // orbit reset time in milliseconds
149+
o2::parameters::AggregatedRunInfo mAggregatedRunInfo{};
150+
long mOrbitResetTimeMUS = 0; // orbit reset time in microseconds
145151
};
146152

147153
} // namespace base

Detectors/Base/src/GRPGeomHelper.cxx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ GRPGeomRequest::GRPGeomRequest(bool orbitResetTime, bool GRPECS, bool GRPLHCIF,
6363
addInput({"orbitReset", "CTP", "ORBITRESET", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/OrbitReset")}, inputs);
6464
}
6565
if (askGRPECS) {
66-
addInput({"grpecs", "GLO", "GRPECS", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPECS", true)}, inputs); // Run dependent !!!
66+
addInput({"grpecs", "GLO", "GRPECS", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPECS", 1)}, inputs); // Run dependent !!!
6767
}
6868
if (askGRPLHCIF) {
6969
addInput({"grplhcif", "GLO", "GRPLHCIF", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPLHCIF")}, inputs);
@@ -73,6 +73,22 @@ GRPGeomRequest::GRPGeomRequest(bool orbitResetTime, bool GRPECS, bool GRPLHCIF,
7373
}
7474
}
7575

76+
void GRPGeomRequest::requireAggregateRunInfo(std::vector<o2::framework::InputSpec>& inputs)
77+
{
78+
askAggregateRunInfo = true;
79+
// require dependencies
80+
if (!askGRPECS) {
81+
askGRPECS = true;
82+
addInput({"grpecs", "GLO", "GRPECS", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPECS", 1)}, inputs);
83+
}
84+
if (!askTime) {
85+
askTime = true;
86+
addInput({"orbitReset", "CTP", "ORBITRESET", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/OrbitReset")}, inputs);
87+
}
88+
addInput({"RCTRunInfo", "RCT", "RunInfo", 0, Lifetime::Condition, ccdbParamSpec("RCT/Info/RunInformation", 2)}, inputs);
89+
addInput({"CTPRunOrbit", "CTP", "RunOrbit", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/FirstRunOrbit")}, inputs); // TODO: should become run-depenendent (1) object
90+
}
91+
7692
void GRPGeomRequest::addInput(const o2::framework::InputSpec&& isp, std::vector<o2::framework::InputSpec>& inputs)
7793
{
7894
if (std::find(inputs.begin(), inputs.end(), isp) == inputs.end()) {
@@ -124,8 +140,8 @@ bool GRPGeomHelper::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
124140
return true;
125141
}
126142
if (mRequest->askTime && matcher == ConcreteDataMatcher("CTP", "ORBITRESET", 0)) {
127-
mOrbitResetTimeMS = (*(std::vector<Long64_t>*)obj)[0] / 1000;
128-
LOG(info) << "orbit reset time updated to " << mOrbitResetTimeMS;
143+
mOrbitResetTimeMUS = (*(std::vector<Long64_t>*)obj)[0];
144+
LOG(info) << "orbit reset time updated to " << mOrbitResetTimeMUS;
129145
return true;
130146
}
131147
if (mRequest->askMatLUT && matcher == ConcreteDataMatcher("GLO", "MATLUT", 0)) {
@@ -159,7 +175,7 @@ bool GRPGeomHelper::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
159175
return false;
160176
}
161177

162-
void GRPGeomHelper::checkUpdates(ProcessingContext& pc) const
178+
void GRPGeomHelper::checkUpdates(ProcessingContext& pc)
163179
{
164180
// request input just to trigger finaliseCCDB if there was an update
165181

@@ -225,6 +241,14 @@ void GRPGeomHelper::checkUpdates(ProcessingContext& pc) const
225241
}
226242
}
227243
}
244+
if (mRequest->askAggregateRunInfo) {
245+
const auto hmap = pc.inputs().get<o2::framework::CCDBMetadataExtractor>("RCTRunInfo"); // metadata only!
246+
auto rl = o2::ccdb::BasicCCDBManager::getRunDuration(hmap);
247+
auto ctfFirstRunOrbitVec = pc.inputs().get<std::vector<Long64_t>*>("CTPRunOrbit");
248+
mAggregatedRunInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(pc.services().get<o2::framework::TimingInfo>().runNumber, rl.first, rl.second, mOrbitResetTimeMUS, mGRPECS, ctfFirstRunOrbitVec.get());
249+
LOGP(debug, "Extracted AggregateRunInfo: runNumber:{}, sor:{}, eor:{}, orbitsPerTF:{}, orbitReset:{}, orbitSOR:{}, orbitEOR:{}",
250+
mAggregatedRunInfo.runNumber, mAggregatedRunInfo.sor, mAggregatedRunInfo.eor, mAggregatedRunInfo.orbitsPerTF, mAggregatedRunInfo.orbitReset, mAggregatedRunInfo.orbitSOR, mAggregatedRunInfo.orbitEOR);
251+
}
228252
}
229253
}
230254

0 commit comments

Comments
 (0)