134    JParser<> zap(
"Example program to plot quality data from data base or input file.");
 
  136    zap[
's'] = 
make_field(server)        = getServernames();
 
  140    zap[
'f'] = 
make_field(inputFile,  
"Optional input file instead of database.")       = 
"";
 
  141    zap[
'o'] = 
make_field(
outputFile, 
"ROOT file with histograms and n-tuple or ASCII file with QA/QC data.") = 
"monitor.root";
 
  142    zap[
'D'] = 
make_field(detid,      
"detector identifier");
 
  143    zap[
'S'] = 
make_field(source,     
"GIT versions")               = getGITTags(TRegexp(
"v[0-9]*\\.[0-9]*\\.[0-9]*$"), JGITTags_t::key_type(
"2019-04-12"));
 
  145    zap[
'T'] = 
make_field(Tmin_s,     
"minimal run duration [s]")   = 60;
 
  150  catch(
const exception &error) {
 
  151    FATAL(error.what() << endl);
 
  160    JDB::reset(usr, pwd, cookie);
 
  162    const int ID = getDetector<int   >(detid);
 
  163    detid        = getDetector<string>(detid);
 
  167    NOTICE(
"Extracting run information from database... " << flush);
 
  171    for (
JRuns parameters; rs >> parameters; ) {
 
  173      parameters.DETID = 
ID;
 
  175      if (UTC(parameters.getRunStartTime())) {
 
  176        runs.insert(parameters);
 
  185      FATAL(
"No runs for detector " << detid << endl);
 
  188    NOTICE(
"Run range " << runs.begin()->RUN << 
' ' << runs.rbegin()->RUN << endl);
 
  190    if (inputFile == 
"") {                    
 
  194      for (vector<string>::const_iterator git = source.begin(); git != source.end(); ++git) {
 
  203        selector.add(&JRunSummaryNumbers::SOURCE_NAME, *git);
 
  207          NOTICE(
"Extracting run summmary information with source " << *git << 
" from database... " << flush);
 
  209          ResultSet& rs  = getResultSet(getTable<JRunSummaryNumbers>(), selector);
 
  212            zmap[parameters.RUN].insert(make_pair(parameters.PARAMETER_NAME, parameters.DATA_VALUE));
 
  219        catch(
const exception& error) { 
NOTICE(endl); }
 
  221        for (map_type::const_iterator run = zmap.begin(); run != zmap.end(); ++run) {
 
  227          quality.
run      = run->first;
 
  229          for (data_type::const_iterator p = run->second.begin(); p != run->second.end(); ++p) {
 
  230            quality.
put(p->first, p->second);
 
  233          if (UTC(TTimeStamp(quality.
UTCMin_s, 0)) &&
 
  234              UTC(TTimeStamp(quality.
UTCMax_s, 0))) {
 
  235            buffer.insert(quality);
 
  249        if (UTC(TTimeStamp(quality.UTCMin_s, 0)) &&
 
  250            UTC(TTimeStamp(quality.UTCMax_s, 0))) {
 
  251          buffer.insert(quality);
 
  258  catch(
const exception& error) {
 
  259    FATAL(error.what() << endl);
 
  263  if (getFilenameExtension(
outputFile) == ROOT_FILE_FORMAT) {
 
  269    X.push_back(runs. begin()->getRunStartTime());    
 
  272      X.push_back(quality->UTCMin_s);
 
  273      X.push_back(quality->UTCMax_s);
 
  276    X.push_back(runs.rbegin()->getRunStartTime());    
 
  278    sort(X.begin(), X.end());
 
  285      bool operator()(
const double x1, 
const double x2) 
 
  287        return x2 - x1 <= xmin;
 
  293    X.erase(unique(X.begin(), X.end(), Xmin(Tmin_s)), X.end());
 
  295    TH1D h0(
"livetime_s", NULL, X.size() - 1, X.data());
 
  296    TH1D h1(
"QAQC",       NULL, X.size() - 1, X.data());
 
  302      if (
debug >= debug_t) {
 
  305             << setw(8) << i->RUN                                        << 
' '  
  306             << TTimeStamp((time_t) i->UNIXSTARTTIME/1000).AsString(
"c") << 
' ';
 
  308        if (quality != buffer.end())
 
  309          cout << 
"[" << TTimeStamp((time_t) quality->UTCMin_s).AsString(
"c") << 
"," << TTimeStamp((time_t) quality->UTCMax_s).AsString(
"c") << 
"]";
 
  311          cout << 
"missing QA/QC data";
 
  316      h1.Fill(i->getRunStartTime() + Tmin_s, (quality != buffer.end() ? 1.0 : -1.0));
 
  319    JManager<string, TH1D> H1(
new TH1D(
"H[%]", NULL, X.size() - 1, X.data()));  
 
  320    JManager<string, TH1D> 
R1(
new TH1D(
"R[%]", NULL, X.size() - 1, X.data()));  
 
  324      const double x = 0.5 * (quality->UTCMin_s + quality->UTCMax_s);
 
  326      h0.Fill(x, 100.0 * quality->livetime_s / (quality->UTCMax_s - quality->UTCMin_s));
 
  328      H1[
"JDAQEvent"]        -> Fill(x, quality->JDAQEvent);
 
  329      H1[
"JTrigger3DShower"] -> Fill(x, quality->JTrigger3DShower);
 
  330      H1[
"JTrigger3DMuon"]   -> Fill(x, quality->JTrigger3DMuon);
 
  331      H1[
"JTriggerMXShower"] -> Fill(x, quality->JTriggerMXShower);
 
  333      if (quality->livetime_s > 0.0) {
 
  334        R1[
"JDAQEvent"]        -> Fill(x, quality->JDAQEvent        / quality->livetime_s);
 
  335        R1[
"JTrigger3DShower"] -> Fill(x, quality->JTrigger3DShower / quality->livetime_s);
 
  336        R1[
"JTrigger3DMuon"]   -> Fill(x, quality->JTrigger3DMuon   / quality->livetime_s);
 
  337        R1[
"JTriggerMXShower"] -> Fill(x, quality->JTriggerMXShower / quality->livetime_s);
 
  342    Double_t W[2] = { 0.0 };
 
  344    W[0] = *X.rbegin() - *X.begin();
 
  347      W[1] += quality->livetime_s;
 
  350    NOTICE(
"Average data taking efficiency  " << 
FIXED(5,1) << 100.0*W[1]/W[0] << 
" %." << endl);
 
  353    for (TH1* p : { &h0, &h1 }) {
 
  354      p->GetXaxis()->SetTimeDisplay(1);
 
  355      p->GetXaxis()->SetTimeFormat(TIMESTAMP);
 
  359    for (JManager<string, TH1D>::iterator p = H1.begin(); p != H1.end(); ++p) {
 
  363      for (Int_t i = 1; i <= p->second->GetXaxis()->GetNbins(); ++i) {
 
  364        p->second->SetBinContent(i, (W += p->second->GetBinContent(i)));
 
  367      p->second->GetXaxis()->SetTimeDisplay(1);
 
  368      p->second->GetXaxis()->SetTimeFormat(TIMESTAMP);
 
  369      p->second->Sumw2(
false);
 
  372    for (JManager<string, TH1D>::iterator p = 
R1.begin(); p != 
R1.end(); ++p) {
 
  374      p->second->GetXaxis()->SetTimeDisplay(1);
 
  375      p->second->GetXaxis()->SetTimeFormat(TIMESTAMP);
 
  376      p->second->Sumw2(
false);
 
  381    out << h0 << h1 << H1 << 
R1;
 
  388  if (getFilenameExtension(
outputFile) == ASCII_FILE_FORMAT) {
 
  394    out.setf(ios::fixed);