Jpp  master_rocky
the software that should make you happy
Functions
JRuns.cc File Reference

Example program to print run related data from data base. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include "TTimeStamp.h"
#include "TRegexp.h"
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JRuns.hh"
#include "JDB/JDBToolkit.hh"
#include "JLang/JLangToolkit.hh"
#include "JROOT/JRootPrinter.hh"
#include "JROOT/JRootToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to print run related data from data base.

Author
mdejong

Definition in file JRuns.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file JRuns.cc.

30 {
31  using namespace std;
32  using namespace JPP;
33 
34  JServer server;
35  string usr;
36  string pwd;
37  string cookie;
38  string detid;
39  TRegexp regexp(".");
40  vector<string> format;
41  JSelector selection;
42  string option;
43  int debug;
44 
45  try {
46 
47  JParser<> zap("Example program to print run related data from data base.");
48 
49  zap['s'] = make_field(server) = getServernames();
50  zap['u'] = make_field(usr) = "";
51  zap['!'] = make_field(pwd) = "";
52  zap['C'] = make_field(cookie) = "";
53  zap['D'] = make_field(detid);
54  zap['r'] = make_field(regexp, "TRegexp for selection of run setup names.") = JPARSER::initialised();
55  zap['F'] = make_field(format, "column names: " << JEEPZ() << getColumns<JRuns>()) = JPARSER::initialised();
56  zap['@'] = make_field(selection) = JPARSER::initialised();
57  zap['O'] = make_field(option, "print UNIX time as TTimeStamp::AsString(<option>)") = "";
58  zap['d'] = make_field(debug) = 2;
59 
60  zap(argc, argv);
61  }
62  catch(const exception &error) {
63  FATAL(error.what() << endl);
64  }
65 
66 
67  if (format.empty()) {
68  format = getColumns<JRuns>();
69  }
70 
71  try {
72 
73  JDB::reset(usr, pwd, cookie);
74 
75  const int id = getDetector<int>(detid);
76 
77  selection += getSelector<JRuns>(id);
78 
79  ResultSet& rs = getResultSet(getTable<JRuns>(), selection);
80 
81  for (JRuns parameters; selection >> parameters && rs >> parameters; ) {
82 
83  if (TString(parameters.RUNSETUPNAME.c_str()).Contains(regexp)) {
84 
85  for (vector<string>::const_iterator i = format.begin(); i != format.end(); ++i) {
86 
87  if (option != "" && *i == "UNIXJOBSTART")
88  cout << ' ' << TTimeStamp((time_t) (parameters.UNIXJOBSTART /1000)).AsString(option.c_str());
89  else if (option != "" && *i == "UNIXJOBEND")
90  cout << ' ' << TTimeStamp((time_t) (parameters.UNIXJOBEND /1000)).AsString(option.c_str());
91  else
92  JRootPrinter::print(cout, parameters, *i);
93  }
94 
95  cout << endl;
96  }
97  }
98  }
99  catch(const exception& error) {
100  FATAL(error.what() << endl);
101  }
102 }
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Auxiliary class for specifying selection of database data.
Utility class to parse command line options.
Definition: JParser.hh:1698
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:437
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:107
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void reset(T &value)
Reset value.
Definition: JSTDTypes.hh:14
Wrapper class for server name.
Definition: JDB.hh:53
Template definition for getting table specific selector.
Auxiliary data structure for streaming of STL containers.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:68