Jpp
JRuns.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <vector>
4 
5 #include "TTimeStamp.h"
6 
7 #include "JDB/JDB.hh"
8 #include "JDB/JSelector.hh"
10 #include "JDB/JRuns.hh"
11 #include "JDB/JDBToolkit.hh"
12 
13 #include "JLang/JLangToolkit.hh"
14 #include "JROOT/JRootPrinter.hh"
15 
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 
20 /**
21  * \file
22  *
23  * Example program to print data from data base.
24  * \author mdejong
25  */
26 int main(int argc, char **argv)
27 {
28  using namespace std;
29  using namespace JPP;
30 
31  string usr;
32  string pwd;
33  string cookie;
34  string detid;
35  string setup;
36  int debug;
37 
38  try {
39 
40  JParser<> zap("Example program to print data from data base.");
41 
42  zap['u'] = make_field(usr) = "";
43  zap['!'] = make_field(pwd) = "";
44  zap['C'] = make_field(cookie) = "";
45  zap['D'] = make_field(detid);
46  zap['S'] = make_field(setup) = "";
47  zap['d'] = make_field(debug) = 1;
48 
49  zap(argc, argv);
50  }
51  catch(const exception &error) {
52  FATAL(error.what() << endl);
53  }
54 
55 
56  try {
57 
58  JDB::reset(usr, pwd, cookie);
59 
60  int id;
61 
62  if (is_integer(detid))
63  id = to_value<int>(detid);
64  else
65  id = getDetector(detid);
66 
67  JSelector selector = getSelector<JRuns>(id);
68 
69  if (setup != "") {
70  selector.add(&JRuns::RUNSETUPNAME, setup);
71  }
72 
73  ResultSet& rs = getResultSet(getTable<JRuns>(), selector);
74 
75  for (JRuns parameters; rs >> parameters; ) {
76 
77  if (debug >= debug_t)
78  JRootPrinter::print(cout, parameters);
79  else if (setup == "")
80  cout << setw(8) << parameters.RUN << ' ' << parameters.RUNSETUPNAME << ' ' << TTimeStamp((time_t) parameters.UNIXSTARTTIME/1000).AsString("c") << endl;
81  else
82  cout << setw(8) << parameters.RUN << endl;
83  }
84  }
85  catch(const exception& error) {
86  FATAL(error.what() << endl);
87  }
88 }
JRootPrinter.hh
JMessage.hh
JLANG::is_integer
bool is_integer(const std::string &buffer)
Check if string is an integer.
Definition: JLangToolkit.hh:58
JSelector.hh
JDBToolkit.hh
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JDATABASE::getDetector
static const JDetectorsHelper & getDetector
Function object for mapping serial number and object identifier of detectors.
Definition: JDBToolkit.hh:131
JDATABASE::getResultSet
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:403
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JDB.hh
debug
int debug
debug level
Definition: JSirene.cc:59
JDETECTOR::reset
void reset(JCLBInput &data, size_t size)
Reset CLB buffers.
Definition: JCLBSimulator.hh:41
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
std
Definition: jaanetDictionary.h:36
JRuns.hh
main
int main(int argc, char **argv)
Definition: JRuns.cc:26
print
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
Definition: JTriggerMonitor.cc:38
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
JEEP::debug_t
debug
Definition: JMessage.hh:29
JSelectorSupportkit.hh
JLangToolkit.hh