diff --git a/Detectors/MUON/MCH/Conditions/README.md b/Detectors/MUON/MCH/Conditions/README.md index d35fdcd0a0958..21892a7478d86 100644 --- a/Detectors/MUON/MCH/Conditions/README.md +++ b/Detectors/MUON/MCH/Conditions/README.md @@ -73,6 +73,8 @@ Usage: change HV thresholds -d [ --duration ] arg (=0) minimum duration (ms) of HV/LV issues to consider + -i [ --interval ] arg (=30) creation time interval (minutes) between + CCDB files -w [ --warning ] arg (=1) warning level (0, 1 or 2) -p [ --print ] arg (=1) print level (0, 1, 2 or 3) -o [ --output ] arg (=scan.root) output root file name diff --git a/Detectors/MUON/MCH/Conditions/src/scan-hvlv-ccdb.cxx b/Detectors/MUON/MCH/Conditions/src/scan-hvlv-ccdb.cxx index 32cd365916c63..307759c97a0c3 100644 --- a/Detectors/MUON/MCH/Conditions/src/scan-hvlv-ccdb.cxx +++ b/Detectors/MUON/MCH/Conditions/src/scan-hvlv-ccdb.cxx @@ -153,6 +153,20 @@ std::string getTime(uint64_t ts) return time; } +//---------------------------------------------------------------------------- +std::string getDuration(uint64_t tStart, uint64_t tStop) +{ + /// get the duration (dd hh:mm:ss) between the two time stamps (ms) + + auto dt = ms2s(tStop - tStart); + auto s = dt % 60; + auto m = (dt / 60) % 60; + auto h = (dt / 3600) % 24; + auto d = dt / 86400; + + return fmt::format("{:02}d {:02}:{:02}:{:02}", d, h, m, s); +} + //---------------------------------------------------------------------------- std::set getRuns(std::string runList) { @@ -283,15 +297,17 @@ void drawRunBoudaries(const RBMAP& runBoundaries, TCanvas* c) } //---------------------------------------------------------------------------- -DPBMAP getDPBoundaries(ccdb::CcdbApi const& api, std::string what, uint64_t tStart, uint64_t tStop) +DPBMAP getDPBoundaries(ccdb::CcdbApi const& api, std::string what, + uint64_t tStart, uint64_t tStop, uint64_t timeInterval) { /// get the time boundaries of every HV/LV files found in the time range - // add extra margin (ms) of ± 1 min to the creation time, which occurs every 30 min - static const uint64_t timeMarging[2] = {60000, 1860000}; + // add an extra margin (ms) of ± 1 min to the creation time, + // which corresponds to the end of the time interval covered by the file + static const uint64_t timeMarging = 60000; std::istringstream fileInfo(api.list(what.c_str(), false, "text/plain", - tStop + timeMarging[1], tStart - timeMarging[0])); + tStop + timeInterval + timeMarging, tStart - timeMarging)); DPBMAP dpBoundaries{}; std::string dummy{}; @@ -357,7 +373,7 @@ void checkDPBoundaries(const DPBMAP& dpBoundaries, bool scanHV, uint64_t tStart, } //---------------------------------------------------------------------------- -void printDPBoundaries(const DPBMAP& dpBoundaries, bool scanHV) +void printDPBoundaries(const DPBMAP& dpBoundaries, bool scanHV, uint64_t timeInterval) { /// print the time boundaries of every HV/LV files found in the full time range @@ -365,7 +381,13 @@ void printDPBoundaries(const DPBMAP& dpBoundaries, bool scanHV) printf("------------------------------------\n"); for (auto [tStart, tStop] : dpBoundaries) { - printf("%llu - %llu (%s - %s)\n", tStart, tStop, getTime(tStart).c_str(), getTime(tStop).c_str()); + printf("%llu - %llu (%s - %s)", tStart, tStop, getTime(tStart).c_str(), getTime(tStop).c_str()); + if (tStop - tStart < 60000 * (timeInterval - 1) || tStop - tStart > 60000 * (timeInterval + 1)) { + printf("\e[0;31m ! warning: validity range %s != %llu±1 min\e[0m\n", + getDuration(tStart, tStop).c_str(), timeInterval); + } else { + printf("\n"); + } } printf("------------------------------------\n"); @@ -400,20 +422,6 @@ void drawLimit(double limit, TCanvas* c) l->Draw(); } -//---------------------------------------------------------------------------- -std::string getDuration(uint64_t tStart, uint64_t tStop) -{ - /// get the duration (dd hh:mm:ss) between the two time stamps (ms) - - auto dt = ms2s(tStop - tStart); - auto s = dt % 60; - auto m = (dt / 60) % 60; - auto h = (dt / 3600) % 24; - auto d = dt / 86400; - - return fmt::format("{:02}d {:02}:{:02}:{:02}", d, h, m, s); -} - //---------------------------------------------------------------------------- double getValue(DPVAL dp) { @@ -943,6 +951,7 @@ int main(int argc, char** argv) std::string what = ""; std::string config = ""; uint64_t minDuration = 0; + uint64_t timeInterval = 30; int warningLevel = 1; int printLevel = 1; std::string outFileName = ""; @@ -955,6 +964,7 @@ int main(int argc, char** argv) ("channels,c",po::value(&what)->default_value(""),R"(channel(s) to scan ("HV" or "LV" or comma separated list of (part of) DCS aliases))") ("configKeyValues",po::value(&config)->default_value(""),"Semicolon separated key=value strings to change HV thresholds") ("duration,d",po::value(&minDuration)->default_value(0),"minimum duration (ms) of HV/LV issues to consider") + ("interval,i",po::value(&timeInterval)->default_value(30),"creation time interval (minutes) between CCDB files") ("warning,w",po::value(&warningLevel)->default_value(1),"warning level (0, 1 or 2)") ("print,p",po::value(&printLevel)->default_value(1),"print level (0, 1, 2 or 3)") ("output,o",po::value(&outFileName)->default_value("scan.root"),"output root file name") @@ -1021,9 +1031,9 @@ int main(int argc, char** argv) // extract the time boundaries for each HV/LV file in the full time range auto dpBoundaries = getDPBoundaries(api, path.c_str(), runBoundaries.begin()->second.first, - runBoundaries.rbegin()->second.second); + runBoundaries.rbegin()->second.second, timeInterval * 60000); if (printLevel > 0) { - printDPBoundaries(dpBoundaries, scanHV); + printDPBoundaries(dpBoundaries, scanHV, timeInterval); } checkDPBoundaries(dpBoundaries, scanHV, runBoundaries.begin()->second.first, runBoundaries.rbegin()->second.second);