114   typedef JRange<int>  JRange_t;
 
  124   JRange<TTimeStamp> UTC;
 
  130     JParser<> zap(
"Example program to plot quality data from data base.");
 
  137     zap[
'D'] = 
make_field(detid,      
"detector identifier");
 
  138     zap[
'R'] = 
make_field(runs,       
"run range")                  = JRange_t(1, JRange_t::getMaximum());
 
  139     zap[
'S'] = 
make_field(source,     
"GIT versions")               = 
getGITTags(TRegexp(
"v[0-9]*\\.[0-9]*\\.[0-9]*$"), JGITTags_t::key_type(
"2019-04-12"));
 
  140     zap[
'U'] = 
make_field(UTC,        
"UTC time range" )            = JRange<TTimeStamp>();
 
  141     zap[
'T'] = 
make_field(Tmin_s,     
"minimal run duration [s]")   = 60;
 
  146   catch(
const exception &error) {
 
  147     FATAL(error.what() << endl);
 
  159     const int ID = getDetector<int>(detid);
 
  165       NOTICE(
"Extracting run information from database... " << flush);
 
  167       ResultSet& rs  = 
getResultSet(getTable<JRuns>(), getSelector<JRuns>(ID));
 
  171         parameters.DETID = 
ID;
 
  173         if (UTC(parameters.getRunStartTime())) {
 
  174           data.push_back(parameters);
 
  182     catch(
const exception& error) {}
 
  197       JSelector selector = getSelector<JRunSummaryNumbers>(detid, runs.getLowerLimit(), runs.getUpperLimit());
 
  199       selector.add(&JRunSummaryNumbers::SOURCE_NAME, *git);
 
  203         NOTICE(
"Extracting run summmary information with source " << *git << 
" from database... " << flush);
 
  205         ResultSet& rs  = 
getResultSet(getTable<JRunSummaryNumbers>(), selector);
 
  207         for (JRunSummaryNumbers parameters; rs >> 
parameters; ) {
 
  208           zmap[parameters.RUN].insert(make_pair(parameters.PARAMETER_NAME, parameters.DATA_VALUE));
 
  215       catch(
const exception& error) { 
NOTICE(endl); }
 
  217       for (map_type::const_iterator run = zmap.begin(); run != zmap.end(); ++run) {
 
  222         quality.detector = 
ID;
 
  223         quality.run      = run->first;
 
  225         for (data_type::const_iterator p = run->second.begin(); p != run->second.end(); ++p) {
 
  226           quality.put(p->first, p->second);
 
  229         qaqc.insert(JRun_t(ID, quality.run));
 
  231         if (UTC(TTimeStamp(quality.UTCMin_s, 0)) &&
 
  232             UTC(TTimeStamp(quality.UTCMax_s, 0))) {
 
  236           if (p == buffer.end() || p->run != quality.run) {
 
  237             buffer.insert(p, quality);
 
  243   catch(
const exception& error) {
 
  244     FATAL(error.what() << endl);
 
  247   if (buffer.empty()) {
 
  248     FATAL(
"No valid QA/QC data for detector " << detid << endl);
 
  257     X.push_back(quality->UTCMin_s);
 
  258     X.push_back(quality->UTCMax_s);
 
  261   sort(
X.begin(), 
X.end());
 
  268     bool operator()(
const double x1, 
const double x2) 
 
  270       return x2 - x1 <= xmin;
 
  276   X.push_back(data.rbegin()->getRunStartTime());    
 
  278   X.erase(unique(
X.begin(), 
X.end(), Xmin(Tmin_s)), 
X.end());
 
  280   TH1D h0(
"livetime_s", NULL, 
X.size() - 1, 
X.data());
 
  281   TH1D 
h1(
"QAQC",       NULL, 
X.size() - 1, 
X.data());
 
  285     const JRun_t run(i->DETID,i->RUN);
 
  290            << setw(8) << i->RUN                                        << 
' '  
  291            << TTimeStamp((time_t) i->UNIXSTARTTIME/1000).AsString(
"c") << 
' ';
 
  295       if (quality != buffer.end() && quality->run == i->RUN) {
 
  296         cout << 
"[" << TTimeStamp((time_t) quality->UTCMin_s).AsString(
"c") << 
"," << TTimeStamp((time_t) quality->UTCMax_s).AsString(
"c") << 
"]";
 
  298         cout << (
qaqc.count(run) == 0 ? 
"missing" : 
"invalid") << 
" QA/QC data";
 
  306     if (! binary_search(buffer.begin(), buffer.end(), run)) {
 
  307       W = (
qaqc.count(run) == 0 ? -1.0 : 0.0);
 
  310     h1.Fill(i->getRunStartTime() + Tmin_s, W);
 
  313   JManager<string, TH1D> H1(
new TH1D(
"H[%]", NULL, 
X.size() - 1, 
X.data()));  
 
  314   JManager<string, TH1D> 
R1(
new TH1D(
"R[%]", NULL, 
X.size() - 1, 
X.data()));  
 
  318     const double x = 0.5 * (quality->UTCMin_s + quality->UTCMax_s);
 
  320     h0.Fill(x, 100.0 * quality->livetime_s / (quality->UTCMax_s - quality->UTCMin_s));
 
  322     H1[
"JDAQEvent"]        -> Fill(x, quality->JDAQEvent);
 
  323     H1[
"JTrigger3DShower"] -> Fill(x, quality->JTrigger3DShower);
 
  324     H1[
"JTrigger3DMuon"]   -> Fill(x, quality->JTrigger3DMuon);
 
  325     H1[
"JTriggerMXShower"] -> Fill(x, quality->JTriggerMXShower);
 
  327     if (quality->livetime_s > 0.0) {
 
  328       R1[
"JDAQEvent"]        -> Fill(x, quality->JDAQEvent        / quality->livetime_s);
 
  329       R1[
"JTrigger3DShower"] -> Fill(x, quality->JTrigger3DShower / quality->livetime_s);
 
  330       R1[
"JTrigger3DMuon"]   -> Fill(x, quality->JTrigger3DMuon   / quality->livetime_s);
 
  331       R1[
"JTriggerMXShower"] -> Fill(x, quality->JTriggerMXShower / quality->livetime_s);
 
  336   Double_t W[2] = { 0.0 };
 
  338   W[0] = *
X.rbegin() - *
X.begin();
 
  341     W[1] += quality->livetime_s;
 
  344   NOTICE(
"Average data taking efficiency  " << 
FIXED(5,1) << 100.0*W[1]/W[0] << 
" %." << endl);
 
  347   for (TH1* p : { &h0, &
h1 }) {
 
  348     p->GetXaxis()->SetTimeDisplay(1);
 
  353   for (JManager<string, TH1D>::iterator p = H1.begin(); p != H1.end(); ++p) {
 
  357     for (Int_t i = 1; i <= p->second->GetXaxis()->GetNbins(); ++i) {
 
  358       p->second->SetBinContent(i, (W += p->second->GetBinContent(i)));
 
  361     p->second->GetXaxis()->SetTimeDisplay(1);
 
  362     p->second->GetXaxis()->SetTimeFormat(
TIMESTAMP);
 
  363     p->second->Sumw2(
false);
 
  366   for (JManager<string, TH1D>::iterator p = 
R1.begin(); p != 
R1.end(); ++p) {
 
  368     p->second->GetXaxis()->SetTimeDisplay(1);
 
  369     p->second->GetXaxis()->SetTimeFormat(
TIMESTAMP);
 
  370     p->second->Sumw2(
false);
 
  375   out << h0 << 
h1 << H1 << 
R1;
 
Utility class to parse command line options. 
 
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
 
then for HISTOGRAM in h0 h1
 
Auxiliary data structure for floating point format specification. 
 
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation. 
 
std::vector< std::string > getGITTags(const TRegexp ®exp, const JGITTags_t::key_type &date)
Get selection of GIT tags. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
then break fi done getCenter read X Y Z let X
 
bool is_integer(const std::string &buffer)
Check if string is an integer. 
 
ResultSet & getResultSet(const std::string &query)
Get result set. 
 
std::vector< JServer > getServernames()
Get list of names of available database servers. 
 
static const char *const TIMESTAMP
Time stamp of earliest UTC time. 
 
int qaqc
QA/QC file descriptor.