Skip to content

Commit 81e6fd9

Browse files
committed
add separate method to extract run-duration from RCT info headers
1 parent c7b07de commit 81e6fd9

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class CCDBManagerInstance
194194
/// On error it fatals (if fatal == true) or else returns the pair -1, -1.
195195
std::pair<int64_t, int64_t> getRunDuration(int runnumber, bool fatal = true);
196196
static std::pair<int64_t, int64_t> getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal = true);
197-
197+
static std::pair<int64_t, int64_t> getRunDuration(const MD& headers);
198198
std::string getSummaryString() const;
199199

200200
size_t getFetchedSize() const { return mFetchedSize; }

CCDB/src/BasicCCDBManager.cxx

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,44 +32,47 @@ void CCDBManagerInstance::reportFatal(std::string_view err)
3232
LOG(fatal) << err;
3333
}
3434

35-
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal)
35+
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(const std::map<std::string, std::string>& headers)
3636
{
37-
auto response = api.retrieveHeaders("RCT/Info/RunInformation", std::map<std::string, std::string>(), runnumber);
38-
if (response.size() != 0) {
37+
if (headers.size() != 0) {
3938
std::string report{};
40-
auto strt = response.find("STF");
41-
auto stop = response.find("ETF");
42-
long valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
43-
long valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
39+
auto strt = headers.find("STF");
40+
auto stop = headers.find("ETF");
41+
long valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
42+
long valStop = (stop == headers.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
4443
if (valStrt < 0 || valStop < 0) {
4544
report += "Missing STF/EFT -> use SOX/EOX;";
46-
strt = response.find("SOX");
47-
valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
45+
strt = headers.find("SOX");
46+
valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
4847
if (valStrt < 1) {
4948
report += fmt::format(" Missing/invalid SOX -> use SOR");
50-
strt = response.find("SOR");
51-
valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
49+
strt = headers.find("SOR");
50+
valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
5251
}
53-
stop = response.find("EOX");
54-
valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
52+
stop = headers.find("EOX");
53+
valStop = (stop == headers.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
5554
if (valStop < 1) {
5655
report += fmt::format(" | Missing/invalid EOX -> use EOR");
57-
stop = response.find("EOR");
58-
valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
56+
stop = headers.find("EOR");
57+
valStop = (stop == headers.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
5958
}
6059
if (!report.empty()) {
6160
LOGP(warn, "{}", report);
6261
}
6362
}
64-
if (valStrt > 0 && valStop >= valStrt) {
65-
return std::make_pair(valStrt, valStop);
66-
}
63+
return std::make_pair(valStrt, valStop);
6764
}
68-
// failure
69-
if (fatal) {
65+
return std::make_pair(-1L, -1L);
66+
}
67+
68+
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal)
69+
{
70+
auto headers = api.retrieveHeaders("RCT/Info/RunInformation", std::map<std::string, std::string>(), runnumber);
71+
auto response = getRunDuration(headers);
72+
if ((response.first <= 0 || response.second < response.first) && fatal) {
7073
LOG(fatal) << "Empty, missing or invalid response from query to RCT/Info/RunInformation for run " << runnumber;
7174
}
72-
return std::make_pair(-1L, -1L);
75+
return response;
7376
}
7477

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

0 commit comments

Comments
 (0)