Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
examples/JDB/JPrintTriggerParameters.cc File Reference

Auxiliary program to print trigger parameters. More...

#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include "JTrigger/JTriggerParameters.hh"
#include "JDB/JDB.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JRuns.hh"
#include "JDB/JAllParams.hh"
#include "JDB/JRunsetupParams.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (const int argc, const char *const argv[])
 

Detailed Description

Auxiliary program to print trigger parameters.

Author
lnauta

Definition in file examples/JDB/JPrintTriggerParameters.cc.

Function Documentation

int main ( const int  argc,
const char *const  argv[] 
)

Definition at line 25 of file examples/JDB/JPrintTriggerParameters.cc.

26 {
27  using namespace std;
28  using namespace JPP;
29  using namespace KM3NETDAQ;
30 
31  JServer server;
32  string usr;
33  string pwd;
34  string cookie;
35  int detid;
36  int run;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Auxiliary program to print trigger parameters.");
42 
43  zap['s'] = make_field(server) = getServernames();
44  zap['u'] = make_field(usr) = "";
45  zap['!'] = make_field(pwd) = "";
46  zap['C'] = make_field(cookie) = "";
47  zap['D'] = make_field(detid);
48  zap['r'] = make_field(run);
49  zap['d'] = make_field(debug) = 1;
50 
51  zap(argc, argv);
52  }
53  catch(const exception& error) {
54  FATAL(error.what() << endl);
55  }
56 
57 
58  const double Dmax_m = 9999.0;
59 
61 
62  try {
63  JDB::reset(usr, pwd, cookie);
64  }
65  catch(const exception& error) {
66  FATAL(error.what() << endl);
67  }
68 
69  string rs_oid;
70 
71  try {
72 
73  JRuns buffer;
74 
75  ResultSet& rs = getResultSet(getTable<JRuns>(), getSelector<JRuns>(detid, run));
76 
77  if (rs >> buffer) {
78  rs_oid = buffer.RUNSETUPID;
79  }
80 
81  rs.Close();
82  }
83  catch(const exception& error) {
84  FATAL(error.what() << endl);
85  }
86 
87 
89 
90  try {
91 
92  JAllParams buffer;
93 
94  ResultSet& rs = getResultSet(getTable<JAllParams>(), getSelector<JAllParams>("DATAACQUISITION"));
95 
96  while (rs >> buffer) {
97 
98  string::size_type pos = buffer.NAME.find(PREFIX_DATAFILTER);
99 
100  if (pos != string::npos) {
101 
102  pos = buffer.NAME.find('=', pos + PREFIX_DATAFILTER.length());
103 
104  zmap[buffer.OID] = buffer.NAME.erase(0, pos + 1);
105  }
106  }
107 
108  rs.Close();
109  }
110  catch(const exception& error) {
111  FATAL(error.what() << endl);
112  }
113 
114 
115  stringstream data;
116 
117  try {
118 
119  JRunsetupParams buffer;
120 
121  ResultSet& rs = getResultSet(getTable<JRunsetupParams>(), getSelector<JRunsetupParams>(getDetector(detid), rs_oid));
122 
123  while (rs >> buffer) {
124 
125  map<string, string>::const_iterator i = zmap.find(buffer.PAR_OID);
126 
127  if (i != zmap.end()) {
128  data << i->second << "=" << buffer.VALUE << ";\n";
129  }
130  }
131 
132  rs.Close();
133  }
134  catch(const exception& error) {
135  FATAL(error.what() << endl);
136  }
137 
138  data >> parameters;
139 
140  parameters.set(Dmax_m);
141  parameters.actionAtFileRead();
142 
143  cout << parameters;
144 }
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
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:365
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:67
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
static const std::string PREFIX_DATAFILTER
This string is prepended to every parameter in the database output for the corresponding process...
Definition: JDB.hh:174
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:432
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:98
Wrapper class for server name.
Definition: JDB.hh:42
Template definition for getting table specific selector.
std::string RUNSETUPID
Definition: JRuns.hh:26