Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Detectors/MUON/MCH/Conditions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 32 additions & 22 deletions Detectors/MUON/MCH/Conditions/src/scan-hvlv-ccdb.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> getRuns(std::string runList)
{
Expand Down Expand Up @@ -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{};
Expand Down Expand Up @@ -357,15 +373,21 @@ 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

printf("\nlist of %s file time boundaries:\n", scanHV ? "HV" : "LV");
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");
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 = "";
Expand All @@ -955,6 +964,7 @@ int main(int argc, char** argv)
("channels,c",po::value<std::string>(&what)->default_value(""),R"(channel(s) to scan ("HV" or "LV" or comma separated list of (part of) DCS aliases))")
("configKeyValues",po::value<std::string>(&config)->default_value(""),"Semicolon separated key=value strings to change HV thresholds")
("duration,d",po::value<uint64_t>(&minDuration)->default_value(0),"minimum duration (ms) of HV/LV issues to consider")
("interval,i",po::value<uint64_t>(&timeInterval)->default_value(30),"creation time interval (minutes) between CCDB files")
("warning,w",po::value<int>(&warningLevel)->default_value(1),"warning level (0, 1 or 2)")
("print,p",po::value<int>(&printLevel)->default_value(1),"print level (0, 1, 2 or 3)")
("output,o",po::value<std::string>(&outFileName)->default_value("scan.root"),"output root file name")
Expand Down Expand Up @@ -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);
Expand Down