Skip to content

Commit

Permalink
AggregatedRunInfo can be requested via GRPGeomHelper
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shahor02 committed Oct 11, 2024
1 parent d40dbaa commit 9679546
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
12 changes: 9 additions & 3 deletions Detectors/Base/include/DetectorsBase/GRPGeomHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "DataFormatsParameters/GRPLHCIFData.h"
#include "DataFormatsParameters/GRPECSObject.h"
#include "DataFormatsParameters/GRPMagField.h"
#include "DataFormatsParameters/AggregatedRunInfo.h"

namespace o2::framework
{
Expand Down Expand Up @@ -92,6 +93,7 @@ struct GRPGeomRequest {
Ideal,
Alignments };

bool askAggregateRunInfo = false;
bool askGRPECS = false;
bool askGRPLHCIF = false;
bool askGRPMagField = false;
Expand All @@ -105,6 +107,7 @@ struct GRPGeomRequest {

GRPGeomRequest() = delete;
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");
void requireAggregateRunInfo(std::vector<o2::framework::InputSpec>& inputs);
void addInput(const o2::framework::InputSpec&& isp, std::vector<o2::framework::InputSpec>& inputs);
};

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

auto getAlignment(o2::detectors::DetID det) const { return mAlignments[det]; }
auto getMatLUT() const { return mMatLUT; }
auto getGRPECS() const { return mGRPECS; }
auto getGRPLHCIF() const { return mGRPLHCIF; }
auto getGRPMagField() const { return mGRPMagField; }
auto getOrbitResetTimeMS() const { return mOrbitResetTimeMS; }
auto getOrbitResetTimeMS() const { return mOrbitResetTimeMUS / 1000; }
auto getOrbitResetTimeMUS() const { return mOrbitResetTimeMUS; }
const o2::parameters::AggregatedRunInfo& getAggregatedRunInfo() const { return mAggregatedRunInfo; }
static int getNHBFPerTF();

private:
Expand All @@ -141,7 +146,8 @@ class GRPGeomHelper
const o2::parameters::GRPECSObject* mGRPECS = nullptr;
const o2::parameters::GRPLHCIFData* mGRPLHCIF = nullptr;
const o2::parameters::GRPMagField* mGRPMagField = nullptr;
long mOrbitResetTimeMS = 0; // orbit reset time in milliseconds
o2::parameters::AggregatedRunInfo mAggregatedRunInfo{};
long mOrbitResetTimeMUS = 0; // orbit reset time in microseconds
};

} // namespace base
Expand Down
32 changes: 28 additions & 4 deletions Detectors/Base/src/GRPGeomHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ GRPGeomRequest::GRPGeomRequest(bool orbitResetTime, bool GRPECS, bool GRPLHCIF,
addInput({"orbitReset", "CTP", "ORBITRESET", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/OrbitReset")}, inputs);
}
if (askGRPECS) {
addInput({"grpecs", "GLO", "GRPECS", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPECS", true)}, inputs); // Run dependent !!!
addInput({"grpecs", "GLO", "GRPECS", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPECS", 1)}, inputs); // Run dependent !!!
}
if (askGRPLHCIF) {
addInput({"grplhcif", "GLO", "GRPLHCIF", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPLHCIF")}, inputs);
Expand All @@ -73,6 +73,22 @@ GRPGeomRequest::GRPGeomRequest(bool orbitResetTime, bool GRPECS, bool GRPLHCIF,
}
}

void GRPGeomRequest::requireAggregateRunInfo(std::vector<o2::framework::InputSpec>& inputs)
{
askAggregateRunInfo = true;
// require dependencies
if (!askGRPECS) {
askGRPECS = true;
addInput({"grpecs", "GLO", "GRPECS", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/GRPECS", 1)}, inputs);
}
if (!askTime) {
askTime = true;
addInput({"orbitReset", "CTP", "ORBITRESET", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/OrbitReset")}, inputs);
}
addInput({"RCTRunInfo", "RCT", "RunInfo", 0, Lifetime::Condition, ccdbParamSpec("RCT/Info/RunInformation", 2)}, inputs);
addInput({"CTPRunOrbit", "CTP", "RunOrbit", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/FirstRunOrbit")}, inputs); // TODO: should become run-depenendent (1) object
}

void GRPGeomRequest::addInput(const o2::framework::InputSpec&& isp, std::vector<o2::framework::InputSpec>& inputs)
{
if (std::find(inputs.begin(), inputs.end(), isp) == inputs.end()) {
Expand Down Expand Up @@ -124,8 +140,8 @@ bool GRPGeomHelper::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
return true;
}
if (mRequest->askTime && matcher == ConcreteDataMatcher("CTP", "ORBITRESET", 0)) {
mOrbitResetTimeMS = (*(std::vector<Long64_t>*)obj)[0] / 1000;
LOG(info) << "orbit reset time updated to " << mOrbitResetTimeMS;
mOrbitResetTimeMUS = (*(std::vector<Long64_t>*)obj)[0];
LOG(info) << "orbit reset time updated to " << mOrbitResetTimeMUS;
return true;
}
if (mRequest->askMatLUT && matcher == ConcreteDataMatcher("GLO", "MATLUT", 0)) {
Expand Down Expand Up @@ -159,7 +175,7 @@ bool GRPGeomHelper::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
return false;
}

void GRPGeomHelper::checkUpdates(ProcessingContext& pc) const
void GRPGeomHelper::checkUpdates(ProcessingContext& pc)
{
// request input just to trigger finaliseCCDB if there was an update

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

Expand Down

0 comments on commit 9679546

Please sign in to comment.