Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JRuns.cc File Reference

Example program to print 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 data from data base.

Author
mdejong

Definition in file JRuns.cc.

Function Documentation

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  string usr;
35  string pwd;
36  string cookie;
37  string detid;
38  TRegexp regexp(".");
39  vector<string> format;
40  JSelector selection;
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Example program to print data from data base.");
46 
47  zap['u'] = make_field(usr) = "";
48  zap['!'] = make_field(pwd) = "";
49  zap['C'] = make_field(cookie) = "";
50  zap['D'] = make_field(detid);
51  zap['r'] = make_field(regexp, "TRegexp for selection of run setup names.") = JPARSER::initialised();
52  zap['F'] = make_field(format, "column names: " << JEEPZ() << getColumns<JRuns>()) = JPARSER::initialised();
53  zap['@'] = make_field(selection) = JPARSER::initialised();
54  zap['d'] = make_field(debug) = 2;
55 
56  zap(argc, argv);
57  }
58  catch(const exception &error) {
59  FATAL(error.what() << endl);
60  }
61 
62 
63  if (format.empty()) {
64  format = getColumns<JRuns>();
65  }
66 
67  try {
68 
69  JDB::reset(usr, pwd, cookie);
70 
71  int id;
72 
73  if (is_integer(detid))
74  id = to_value<int>(detid);
75  else
76  id = getDetector(detid);
77 
78  selection += getSelector<JRuns>(id);
79 
80  ResultSet& rs = getResultSet(getTable<JRuns>(), selection);
81 
82  for (JRuns parameters; rs >> parameters; ) {
83 
84  if (TString(parameters.RUNSETUPNAME.c_str()).Contains(regexp)) {
85 
86  for (vector<string>::const_iterator i = format.begin(); i != format.end(); ++i) {
87  JRootPrinter::print(cout, parameters, *i);
88  }
89 
90  cout << endl;
91  }
92  }
93  }
94  catch(const exception& error) {
95  FATAL(error.what() << endl);
96  }
97 }
Utility class to parse command line options.
Definition: JParser.hh:1500
*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
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
Definition: JDBToolkit.cc:5
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
bool is_integer(const std::string &buffer)
Check if string is an integer.
Definition: JLangToolkit.hh:58
int debug
debug level
Definition: JSirene.cc:63
Auxiliary data structure for streaming of STL containers.
Definition: JPrint.hh:65
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:269