114   typedef JRange<int>  JRange_t;
 
  123   JRange<TTimeStamp> UTC;
 
  129     JParser<> zap(
"Example program to plot quality data from data base.");
 
  135     zap[
'D'] = 
make_field(detid,      
"detector identifier");
 
  136     zap[
'R'] = 
make_field(runs,       
"run range")                  = JRange_t(1, JRange_t::getMaximum());
 
  137     zap[
'S'] = 
make_field(source,     
"GIT versions")               = 
getGITTags(TRegexp(
"v.*\\..*\\..*"), JGITTags_t::key_type(
"2019-04-12"));
 
  138     zap[
'U'] = 
make_field(UTC,        
"UTC time range" )            = JRange<TTimeStamp>();
 
  139     zap[
'T'] = 
make_field(Tmin_s,     
"minimal run duration [s]")   = 60;
 
  144   catch(
const exception &error) {
 
  145     FATAL(error.what() << endl);
 
  160       ID = to_value<int>(detid);
 
  168       ResultSet& rs  = 
getResultSet(getTable<JRuns>(), getSelector<JRuns>(ID));
 
  172         parameters.DETID = 
ID;
 
  174         if (UTC(parameters.getRunStartTime())) {
 
  175           data.push_back(parameters);
 
  181     catch(
const exception& error) {}
 
  196       JSelector selector = getSelector<JRunSummaryNumbers>(detid, runs.getLowerLimit(), runs.getUpperLimit());
 
  198       selector.add(&JRunSummaryNumbers::SOURCE_NAME, *i);
 
  202         ResultSet& rs  = 
getResultSet(getTable<JRunSummaryNumbers>(), selector);
 
  204         for (JRunSummaryNumbers parameters; rs >> 
parameters; ) {
 
  205           zmap[parameters.RUN].insert(make_pair(parameters.PARAMETER_NAME, parameters.DATA_VALUE));
 
  208       catch(
const exception& error) {}
 
  210       for (map_type::const_iterator run = zmap.begin(); run != zmap.end(); ++run) {
 
  215         quality.detector = 
ID;
 
  216         quality.run      = run->first;
 
  218         for (data_type::const_iterator p = run->second.begin(); p != run->second.end(); ++p) {
 
  219           quality.put(p->first, p->second);
 
  222         qaqc.insert(JRun_t(ID, quality.run));
 
  224         if (UTC(TTimeStamp(quality.UTCMin_s, 0)) &&
 
  225             UTC(TTimeStamp(quality.UTCMax_s, 0))) {
 
  229           if (p == buffer.end() || p->run != quality.run) {
 
  230             buffer.insert(p, quality);
 
  236   catch(
const exception& error) {
 
  237     FATAL(error.what() << endl);
 
  240   if (buffer.empty()) {
 
  241     FATAL(
"No valid QA/QC data for detector " << detid << endl);
 
  250     X.push_back(quality->UTCMin_s);
 
  251     X.push_back(quality->UTCMax_s);
 
  254   sort(X.begin(), X.end());
 
  261     bool operator()(
const double x1, 
const double x2) 
 
  263       return x2 - x1 <= xmin;
 
  269   X.push_back(data.rbegin()->getRunStartTime());    
 
  271   X.erase(unique(X.begin(), X.end(), Xmin(Tmin_s)), X.end());
 
  273   TH1D h0(
"livetime_s", NULL, X.size() - 1, X.data());
 
  274   TH1D 
h1(
"QAQC",       NULL, X.size() - 1, X.data());
 
  278     const JRun_t run(i->DETID,i->RUN);
 
  283            << setw(8) << i->RUN                                        << 
' '  
  284            << TTimeStamp((time_t) i->UNIXSTARTTIME/1000).AsString(
"c") << 
' ';
 
  288       if (quality != buffer.end() && quality->run == i->RUN) {
 
  289         cout << 
"[" << TTimeStamp((time_t) quality->UTCMin_s).AsString(
"c") << 
"," << TTimeStamp((time_t) quality->UTCMax_s).AsString(
"c") << 
"]";
 
  291         cout << (
qaqc.count(run) == 0 ? 
"missing" : 
"invalid") << 
" QA/QC data";
 
  299     if (! binary_search(buffer.begin(), buffer.end(), run)) {
 
  300       W = (
qaqc.count(run) == 0 ? -1.0 : 0.0);
 
  303     h1.Fill(i->getRunStartTime() + Tmin_s, W);
 
  306   JManager<string, TH1D> 
H1(
new TH1D(
"%", NULL, X.size() - 1, X.data()));  
 
  310     const double x = 0.5 * (quality->UTCMin_s + quality->UTCMax_s);
 
  312     h0.Fill(x, 100.0 * quality->livetime_s / (quality->UTCMax_s - quality->UTCMin_s));
 
  314     H1[
"JDAQEvent"]        -> Fill(x, quality->JDAQEvent);
 
  315     H1[
"JTrigger3DShower"] -> Fill(x, quality->JTrigger3DShower);
 
  316     H1[
"JTrigger3DMuon"]   -> Fill(x, quality->JTrigger3DMuon);
 
  317     H1[
"JTriggerMXShower"] -> Fill(x, quality->JTriggerMXShower);
 
  321   Double_t W[2] = { 0.0 };
 
  323   W[0] = *X.rbegin() - *X.begin();
 
  326     W[1] += quality->livetime_s;
 
  329   NOTICE(
"Average data taking efficiency  " << 
FIXED(5,1) << 100.0*W[1]/W[0] << 
" %." << endl);
 
  332   for (TH1* p : { &h0, &
h1 }) {
 
  333     p->GetXaxis()->SetTimeDisplay(1);
 
  338   for (JManager<string, TH1D>::iterator p = 
H1.begin(); p != 
H1.end(); ++p) {
 
  342     for (Int_t i = 1; i <= p->second->GetXaxis()->GetNbins(); ++i) {
 
  343       p->second->SetBinContent(i, (W += p->second->GetBinContent(i)));
 
  346     p->second->GetXaxis()->SetTimeDisplay(1);
 
  347     p->second->GetXaxis()->SetTimeFormat(
TIMESTAMP);
 
  348     p->second->Sumw2(
false);
 
  353   out << h0 << 
h1 << 
H1;
 
Utility class to parse command line options. 
 
std::vector< std::string > getGITTags(const TRegexp regexp, const JGITTags_t::key_type date)
Get selection of GIT tags. 
 
*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
Function object for mapping serial number to object identifier of detector and vice versa...
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
bool is_integer(const std::string &buffer)
Check if string is an integer. 
 
ResultSet & getResultSet(const std::string &query)
Get result set. 
 
static const char *const TIMESTAMP
Time stamp of earliest UTC time. 
 
int qaqc
QA/QC file descriptor.