13 #include "TTimeStamp.h" 
   46 inline std::istream& 
operator>>(std::istream& 
in, TTimeStamp& 
object)
 
   61     is.str(
replace(buffer, 
'-', 
' '));
 
   63     if (is >> year >> month >> day) {
 
   72         is.str(
replace(buffer, 
':', 
' '));
 
   74         if (is >> hour >> min >> sec) {
 
   76           object = TTimeStamp(year, month, day, hour, min, sec);
 
   84   in.setstate(ios::failbit);
 
   97 inline std::ostream& 
operator>>(std::ostream& out, 
const TTimeStamp& 
object)
 
   99   return out << 
object.AsString();
 
  109 int main(
int argc, 
char **argv)
 
  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.*\\..*\\..*"), 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);
 
  162       ID = to_value<int>(detid);
 
  170       ResultSet& rs  = 
getResultSet(getTable<JRuns>(), getSelector<JRuns>(ID));
 
  174         parameters.DETID = 
ID;
 
  176         if (UTC(parameters.getRunStartTime())) {
 
  177           data.push_back(parameters);
 
  183     catch(
const exception& error) {}
 
  198       JSelector selector = getSelector<JRunSummaryNumbers>(detid, runs.getLowerLimit(), runs.getUpperLimit());
 
  200       selector.add(&JRunSummaryNumbers::SOURCE_NAME, *i);
 
  204         ResultSet& rs  = 
getResultSet(getTable<JRunSummaryNumbers>(), selector);
 
  207           zmap[parameters.RUN].insert(make_pair(parameters.PARAMETER_NAME, parameters.DATA_VALUE));
 
  212       catch(
const exception& error) {}
 
  214       for (map_type::const_iterator run = zmap.begin(); run != zmap.end(); ++run) {
 
  219         quality.detector = 
ID;
 
  220         quality.run      = run->first;
 
  222         for (data_type::const_iterator p = run->second.begin(); p != run->second.end(); ++p) {
 
  223           quality.put(p->first, p->second);
 
  226         qaqc.insert(JRun_t(ID, quality.run));
 
  228         if (UTC(TTimeStamp(quality.UTCMin_s, 0)) &&
 
  229             UTC(TTimeStamp(quality.UTCMax_s, 0))) {
 
  233           if (p == buffer.end() || p->run != quality.run) {
 
  234             buffer.insert(p, quality);
 
  240   catch(
const exception& error) {
 
  241     FATAL(error.what() << endl);
 
  244   if (buffer.empty()) {
 
  245     FATAL(
"No valid QA/QC data for detector " << detid << endl);
 
  254     X.push_back(quality->UTCMin_s);
 
  255     X.push_back(quality->UTCMax_s);
 
  258   sort(
X.begin(), 
X.end());
 
  265     bool operator()(
const double x1, 
const double x2) 
 
  267       return x2 - x1 <= xmin;
 
  273   X.push_back(data.rbegin()->getRunStartTime());    
 
  275   X.erase(unique(
X.begin(), 
X.end(), Xmin(Tmin_s)), 
X.end());
 
  277   TH1D h0(
"livetime_s", NULL, 
X.size() - 1, 
X.data());
 
  278   TH1D 
h1(
"QAQC",       NULL, 
X.size() - 1, 
X.data());
 
  282     const JRun_t run(i->DETID,i->RUN);
 
  287            << setw(8) << i->RUN                                        << 
' '  
  288            << TTimeStamp((time_t) i->UNIXSTARTTIME/1000).AsString(
"c") << 
' ';
 
  292       if (quality != buffer.end() && quality->run == i->RUN) {
 
  293         cout << 
"[" << TTimeStamp((time_t) quality->UTCMin_s).AsString(
"c") << 
"," << TTimeStamp((time_t) quality->UTCMax_s).AsString(
"c") << 
"]";
 
  295         cout << (
qaqc.count(run) == 0 ? 
"missing" : 
"invalid") << 
" QA/QC data";
 
  303     if (! binary_search(buffer.begin(), buffer.end(), run)) {
 
  304       W = (
qaqc.count(run) == 0 ? -1.0 : 0.0);
 
  307     h1.Fill(i->getRunStartTime() + Tmin_s, W);
 
  310   JManager<string, TH1D> 
H1(
new TH1D(
"H[%]", NULL, 
X.size() - 1, 
X.data()));  
 
  311   JManager<string, TH1D> 
R1(
new TH1D(
"R[%]", NULL, 
X.size() - 1, 
X.data()));  
 
  315     const double x = 0.5 * (quality->UTCMin_s + quality->UTCMax_s);
 
  317     h0.Fill(x, 100.0 * quality->livetime_s / (quality->UTCMax_s - quality->UTCMin_s));
 
  319     H1[
"JDAQEvent"]        -> Fill(x, quality->JDAQEvent);
 
  320     H1[
"JTrigger3DShower"] -> Fill(x, quality->JTrigger3DShower);
 
  321     H1[
"JTrigger3DMuon"]   -> Fill(x, quality->JTrigger3DMuon);
 
  322     H1[
"JTriggerMXShower"] -> Fill(x, quality->JTriggerMXShower);
 
  324     if (quality->livetime_s > 0.0) {
 
  325       R1[
"JDAQEvent"]        -> Fill(x, quality->JDAQEvent        / quality->livetime_s);
 
  326       R1[
"JTrigger3DShower"] -> Fill(x, quality->JTrigger3DShower / quality->livetime_s);
 
  327       R1[
"JTrigger3DMuon"]   -> Fill(x, quality->JTrigger3DMuon   / quality->livetime_s);
 
  328       R1[
"JTriggerMXShower"] -> Fill(x, quality->JTriggerMXShower / quality->livetime_s);
 
  333   Double_t W[2] = { 0.0 };
 
  335   W[0] = *
X.rbegin() - *
X.begin();
 
  338     W[1] += quality->livetime_s;
 
  341   NOTICE(
"Average data taking efficiency  " << 
FIXED(5,1) << 100.0*W[1]/W[0] << 
" %." << endl);
 
  344   for (TH1* p : { &h0, &
h1 }) {
 
  345     p->GetXaxis()->SetTimeDisplay(1);
 
  350   for (JManager<string, TH1D>::iterator p = H1.begin(); p != H1.end(); ++p) {
 
  354     for (Int_t i = 1; i <= p->second->GetXaxis()->GetNbins(); ++i) {
 
  355       p->second->SetBinContent(i, (W += p->second->GetBinContent(i)));
 
  358     p->second->GetXaxis()->SetTimeDisplay(1);
 
  359     p->second->GetXaxis()->SetTimeFormat(
TIMESTAMP);
 
  360     p->second->Sumw2(
false);
 
  363   for (JManager<string, TH1D>::iterator p = R1.begin(); p != R1.end(); ++p) {
 
  365     p->second->GetXaxis()->SetTimeDisplay(1);
 
  366     p->second->GetXaxis()->SetTimeFormat(
TIMESTAMP);
 
  367     p->second->Sumw2(
false);
 
  372   out << h0 << 
h1 << H1 << 
R1;
 
Utility class to parse command line options. 
 
int main(int argc, char *argv[])
 
TString replace(const TString &target, const TRegexp ®exp, const T &replacement)
Replace regular expression in input by given replacement. 
 
std::vector< std::string > getGITTags(const TRegexp regexp, const JGITTags_t::key_type date)
Get selection of GIT tags. 
 
Print objects in ASCII format using ROOT dictionary. 
 
*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
 
Dynamic ROOT object management. 
 
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 
 
then break fi done getCenter read X Y Z let X
 
bool is_integer(const std::string &buffer)
Check if string is an integer. 
 
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
 
General purpose messaging. 
 
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input. 
 
Auxiliary class to define a range between two values. 
 
Utility class to parse command line options. 
 
ResultSet & getResultSet(const std::string &query)
Get result set. 
 
std::vector< JServer > getServernames()
Get list of names of available database servers. 
 
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
 
static const char *const TIMESTAMP
Time stamp of earliest UTC time. 
 
int qaqc
QA/QC file descriptor.