Skip to content

Commit

Permalink
getRunDuration uses SOX/EOX, fallback to SOR/EOR and warn if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
shahor02 committed Mar 6, 2024
1 parent d417269 commit a70c90f
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions CCDB/src/BasicCCDBManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,34 @@ void CCDBManagerInstance::reportFatal(std::string_view err)
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal)
{
auto response = api.retrieveHeaders("RCT/Info/RunInformation", std::map<std::string, std::string>(), runnumber);
if (response.size() == 0 || response.find("SOR") == response.end() || response.find("EOR") == response.end()) {
if (fatal) {
LOG(fatal) << "Empty or missing response from query to RCT/Info/RunInformation for run " << runnumber;
} else {
return std::make_pair(-1L, -1L);
if (response.size() != 0) {
std::string report{};
auto strt = response.find("SOX");
long valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
if (valStrt < 1) {
report += fmt::format(" Missing/invalid SOX -> use SOR");
strt = response.find("SOR");
valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
}
auto stop = response.find("EOX");
long valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
if (valStop < 1) {
report += fmt::format(" | Missing/invalid EOX -> use EOR");
stop = response.find("EOR");
valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
}
if (!report.empty()) {
LOGP(warn, "{}", report);
}
if (valStrt > 0 && valStop >= valStrt) {
return std::make_pair(valStrt, valStop);
}
}
// failure
if (fatal) {
LOG(fatal) << "Empty, missing or invalid response from query to RCT/Info/RunInformation for run " << runnumber;
}
auto sor = boost::lexical_cast<int64_t>(response["SOR"]);
auto eor = boost::lexical_cast<int64_t>(response["EOR"]);
return std::make_pair(sor, eor);
return std::make_pair(-1L, -1L);
}

std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(int runnumber, bool fatal)
Expand Down

0 comments on commit a70c90f

Please sign in to comment.