diff --git a/CCDB/include/CCDB/BasicCCDBManager.h b/CCDB/include/CCDB/BasicCCDBManager.h index 69d9150abcf62..678bedf24e551 100644 --- a/CCDB/include/CCDB/BasicCCDBManager.h +++ b/CCDB/include/CCDB/BasicCCDBManager.h @@ -194,7 +194,7 @@ class CCDBManagerInstance /// On error it fatals (if fatal == true) or else returns the pair -1, -1. std::pair getRunDuration(int runnumber, bool fatal = true); static std::pair getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal = true); - + static std::pair getRunDuration(const MD& headers); std::string getSummaryString() const; size_t getFetchedSize() const { return mFetchedSize; } diff --git a/CCDB/src/BasicCCDBManager.cxx b/CCDB/src/BasicCCDBManager.cxx index 0fe72c88fcb46..bcf88554578c1 100644 --- a/CCDB/src/BasicCCDBManager.cxx +++ b/CCDB/src/BasicCCDBManager.cxx @@ -32,44 +32,47 @@ void CCDBManagerInstance::reportFatal(std::string_view err) LOG(fatal) << err; } -std::pair CCDBManagerInstance::getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal) +std::pair CCDBManagerInstance::getRunDuration(const std::map& headers) { - auto response = api.retrieveHeaders("RCT/Info/RunInformation", std::map(), runnumber); - if (response.size() != 0) { + if (headers.size() != 0) { std::string report{}; - auto strt = response.find("STF"); - auto stop = response.find("ETF"); - long valStrt = (strt == response.end()) ? -1L : boost::lexical_cast(strt->second); - long valStop = (stop == response.end()) ? -1L : boost::lexical_cast(stop->second); + auto strt = headers.find("STF"); + auto stop = headers.find("ETF"); + long valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast(strt->second); + long valStop = (stop == headers.end()) ? -1L : boost::lexical_cast(stop->second); if (valStrt < 0 || valStop < 0) { report += "Missing STF/EFT -> use SOX/EOX;"; - strt = response.find("SOX"); - valStrt = (strt == response.end()) ? -1L : boost::lexical_cast(strt->second); + strt = headers.find("SOX"); + valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast(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(strt->second); + strt = headers.find("SOR"); + valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast(strt->second); } - stop = response.find("EOX"); - valStop = (stop == response.end()) ? -1L : boost::lexical_cast(stop->second); + stop = headers.find("EOX"); + valStop = (stop == headers.end()) ? -1L : boost::lexical_cast(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(stop->second); + stop = headers.find("EOR"); + valStop = (stop == headers.end()) ? -1L : boost::lexical_cast(stop->second); } if (!report.empty()) { LOGP(warn, "{}", report); } } - if (valStrt > 0 && valStop >= valStrt) { - return std::make_pair(valStrt, valStop); - } + return std::make_pair(valStrt, valStop); } - // failure - if (fatal) { + return std::make_pair(-1L, -1L); +} + +std::pair CCDBManagerInstance::getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal) +{ + auto headers = api.retrieveHeaders("RCT/Info/RunInformation", std::map(), runnumber); + auto response = getRunDuration(headers); + if ((response.first <= 0 || response.second < response.first) && fatal) { LOG(fatal) << "Empty, missing or invalid response from query to RCT/Info/RunInformation for run " << runnumber; } - return std::make_pair(-1L, -1L); + return response; } std::pair CCDBManagerInstance::getRunDuration(int runnumber, bool fatal)