Jpp
Functions
JRuns.cc File Reference
#include <iostream>
#include <iomanip>
#include <vector>
#include "TTimeStamp.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 "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 data from data base.

Author
mdejong

Definition in file JRuns.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JRuns.cc.

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 }
JLANG::is_integer
bool is_integer(const std::string &buffer)
Check if string is an integer.
Definition: JLangToolkit.hh:58
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
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
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
std
Definition: jaanetDictionary.h:36
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