@@ -153,6 +153,20 @@ std::string getTime(uint64_t ts)
153153 return time;
154154}
155155
156+ // ----------------------------------------------------------------------------
157+ std::string getDuration (uint64_t tStart, uint64_t tStop)
158+ {
159+ // / get the duration (dd hh:mm:ss) between the two time stamps (ms)
160+
161+ auto dt = ms2s (tStop - tStart);
162+ auto s = dt % 60 ;
163+ auto m = (dt / 60 ) % 60 ;
164+ auto h = (dt / 3600 ) % 24 ;
165+ auto d = dt / 86400 ;
166+
167+ return fmt::format (" {:02}d {:02}:{:02}:{:02}" , d, h, m, s);
168+ }
169+
156170// ----------------------------------------------------------------------------
157171std::set<int > getRuns (std::string runList)
158172{
@@ -283,15 +297,17 @@ void drawRunBoudaries(const RBMAP& runBoundaries, TCanvas* c)
283297}
284298
285299// ----------------------------------------------------------------------------
286- DPBMAP getDPBoundaries (ccdb::CcdbApi const & api, std::string what, uint64_t tStart, uint64_t tStop)
300+ DPBMAP getDPBoundaries (ccdb::CcdbApi const & api, std::string what,
301+ uint64_t tStart, uint64_t tStop, uint64_t timeInterval)
287302{
288303 // / get the time boundaries of every HV/LV files found in the time range
289304
290- // add extra margin (ms) of ± 1 min to the creation time, which occurs every 30 min
291- static const uint64_t timeMarging[2 ] = {60000 , 1860000 };
305+ // add an extra margin (ms) of ± 1 min to the creation time,
306+ // which corresponds to the end of the time interval covered by the file
307+ static const uint64_t timeMarging = 60000 ;
292308
293309 std::istringstream fileInfo (api.list (what.c_str (), false , " text/plain" ,
294- tStop + timeMarging[ 1 ] , tStart - timeMarging[ 0 ] ));
310+ tStop + timeInterval + timeMarging, tStart - timeMarging));
295311
296312 DPBMAP dpBoundaries{};
297313 std::string dummy{};
@@ -357,15 +373,21 @@ void checkDPBoundaries(const DPBMAP& dpBoundaries, bool scanHV, uint64_t tStart,
357373}
358374
359375// ----------------------------------------------------------------------------
360- void printDPBoundaries (const DPBMAP& dpBoundaries, bool scanHV)
376+ void printDPBoundaries (const DPBMAP& dpBoundaries, bool scanHV, uint64_t timeInterval )
361377{
362378 // / print the time boundaries of every HV/LV files found in the full time range
363379
364380 printf (" \n list of %s file time boundaries:\n " , scanHV ? " HV" : " LV" );
365381 printf (" ------------------------------------\n " );
366382
367383 for (auto [tStart, tStop] : dpBoundaries) {
368- printf (" %llu - %llu (%s - %s)\n " , tStart, tStop, getTime (tStart).c_str (), getTime (tStop).c_str ());
384+ printf (" %llu - %llu (%s - %s)" , tStart, tStop, getTime (tStart).c_str (), getTime (tStop).c_str ());
385+ if (tStop - tStart < 60000 * (timeInterval - 1 ) || tStop - tStart > 60000 * (timeInterval + 1 )) {
386+ printf (" \e[0;31m ! warning: validity range %s != %llu±1 min\e[0m\n " ,
387+ getDuration (tStart, tStop).c_str (), timeInterval);
388+ } else {
389+ printf (" \n " );
390+ }
369391 }
370392
371393 printf (" ------------------------------------\n " );
@@ -400,20 +422,6 @@ void drawLimit(double limit, TCanvas* c)
400422 l->Draw ();
401423}
402424
403- // ----------------------------------------------------------------------------
404- std::string getDuration (uint64_t tStart, uint64_t tStop)
405- {
406- // / get the duration (dd hh:mm:ss) between the two time stamps (ms)
407-
408- auto dt = ms2s (tStop - tStart);
409- auto s = dt % 60 ;
410- auto m = (dt / 60 ) % 60 ;
411- auto h = (dt / 3600 ) % 24 ;
412- auto d = dt / 86400 ;
413-
414- return fmt::format (" {:02}d {:02}:{:02}:{:02}" , d, h, m, s);
415- }
416-
417425// ----------------------------------------------------------------------------
418426double getValue (DPVAL dp)
419427{
@@ -943,6 +951,7 @@ int main(int argc, char** argv)
943951 std::string what = " " ;
944952 std::string config = " " ;
945953 uint64_t minDuration = 0 ;
954+ uint64_t timeInterval = 30 ;
946955 int warningLevel = 1 ;
947956 int printLevel = 1 ;
948957 std::string outFileName = " " ;
@@ -955,6 +964,7 @@ int main(int argc, char** argv)
955964 (" 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))" )
956965 (" configKeyValues" ,po::value<std::string>(&config)->default_value (" " )," Semicolon separated key=value strings to change HV thresholds" )
957966 (" duration,d" ,po::value<uint64_t >(&minDuration)->default_value (0 )," minimum duration (ms) of HV/LV issues to consider" )
967+ (" interval,i" ,po::value<uint64_t >(&timeInterval)->default_value (30 )," creation time interval (minutes) between CCDB files" )
958968 (" warning,w" ,po::value<int >(&warningLevel)->default_value (1 )," warning level (0, 1 or 2)" )
959969 (" print,p" ,po::value<int >(&printLevel)->default_value (1 )," print level (0, 1, 2 or 3)" )
960970 (" output,o" ,po::value<std::string>(&outFileName)->default_value (" scan.root" )," output root file name" )
@@ -1021,9 +1031,9 @@ int main(int argc, char** argv)
10211031
10221032 // extract the time boundaries for each HV/LV file in the full time range
10231033 auto dpBoundaries = getDPBoundaries (api, path.c_str (), runBoundaries.begin ()->second .first ,
1024- runBoundaries.rbegin ()->second .second );
1034+ runBoundaries.rbegin ()->second .second , timeInterval * 60000 );
10251035 if (printLevel > 0 ) {
1026- printDPBoundaries (dpBoundaries, scanHV);
1036+ printDPBoundaries (dpBoundaries, scanHV, timeInterval );
10271037 }
10281038 checkDPBoundaries (dpBoundaries, scanHV, runBoundaries.begin ()->second .first ,
10291039 runBoundaries.rbegin ()->second .second );
0 commit comments