Skip to content

Commit 435dcbc

Browse files
committed
DPL: add support for lhcPeriod in DataTakingContext
1 parent 3a4f1fe commit 435dcbc

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

Framework/Core/include/Framework/DataTakingContext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ struct DataTakingContext {
3434
uint64_t orbitResetTime = INVALID_RESET_TIME;
3535
// What currently set the orbitResetTime value.
3636
OrbitResetTimeSource source = OrbitResetTimeSource::Default;
37+
/// The current lhc period
38+
std::string lhcPeriod = "unknown";
39+
/// The run type of the current run
40+
std::string runType = "unknown";
41+
/// The environment ID for the deployment
42+
std::string envId = "unknown";
43+
/// The list of detectors taking part in the run
44+
std::string detectors = "unknown";
3745
};
3846

3947
} // namespace o2::framework

Framework/Core/src/CommonServices.cxx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,29 @@ o2::framework::ServiceSpec CommonServices::datatakingContextSpec()
168168
if (extRunNumber != "unspecified" || context.runNumber == "0") {
169169
context.runNumber = extRunNumber;
170170
}
171+
auto extLHCPeriod = services.get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("lhc_period", "unspecified");
172+
if (extLHCPeriod != "unspecified") {
173+
context.lhcPeriod = extLHCPeriod;
174+
} else {
175+
static const char* months[12] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
176+
time_t now = time(nullptr);
177+
auto ltm = gmtime(&now);
178+
context.lhcPeriod = months[ltm->tm_mon];
179+
LOG(warning) << "LHCPeriod is not available, using current month " << context.lhcPeriod;
180+
}
181+
182+
auto extRunType = services.get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("run_type", "unspecified");
183+
if (extRunType != "unspecified") {
184+
context.runType = extRunType;
185+
}
186+
auto extEnvId = services.get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("environment_id", "unspecified");
187+
if (extEnvId != "unspecified") {
188+
context.runType = extEnvId;
189+
}
190+
auto extDetectors = services.get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("detectors", "unspecified");
191+
if (extDetectors != "unspecified") {
192+
context.detectors = extDetectors;
193+
}
171194
// FIXME: we actually need to get the orbit, not only to know where it is
172195
std::string orbitResetTimeUrl = services.get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("orbit-reset-time", "ccdb://CTP/Calib/OrbitResetTime");
173196
auto is_number = [](const std::string& s) -> bool {

0 commit comments

Comments
 (0)