Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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 string 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
60 JTriggerParameters parameters;
61
62 try {
63 JDB::reset(usr, pwd, cookie);
64 }
65 catch(const exception& error) {
66 FATAL(error.what() << endl);
67 }
68
69 const int ID = getDetector<int> (detid);
70 detid = getDetector<string>(detid);
71
72 string rs_oid;
73
74 try {
75
76 JRuns buffer;
77
78 ResultSet& rs = getResultSet(getTable<JRuns>(), getSelector<JRuns>(ID, run));
79
80 if (rs >> buffer) {
81 rs_oid = buffer.RUNSETUPID;
82 }
83
84 rs.Close();
85 }
86 catch(const exception& error) {
87 FATAL(error.what() << endl);
88 }
89
90
92
93 try {
94
95 JAllParams buffer;
96
97 ResultSet& rs = getResultSet(getTable<JAllParams>(), getSelector<JAllParams>("DATAACQUISITION"));
98
99 while (rs >> buffer) {
100
101 string::size_type pos = buffer.NAME.find(PREFIX_DATAFILTER);
102
103 if (pos != string::npos) {
104
105 pos = buffer.NAME.find('=', pos + PREFIX_DATAFILTER.length());
106
107 zmap[buffer.OID] = buffer.NAME.erase(0, pos + 1);
108 }
109 }
110
111 rs.Close();
112 }
113 catch(const exception& error) {
114 FATAL(error.what() << endl);
115 }
116
117
118 stringstream data;
119
120 try {
121
122 JRunsetupParams buffer;
123
125
126 while (rs >> buffer) {
127
128 map<string, string>::const_iterator i = zmap.find(buffer.PAR_OID);
129
130 if (i != zmap.end()) {
131 data << i->second << "=" << buffer.VALUE << ";\n";
132 }
133 }
134
135 rs.Close();
136 }
137 catch(const exception& error) {
138 FATAL(error.what() << endl);
139 }
140
141 data >> parameters;
142
143 parameters.set(Dmax_m);
144 parameters.actionAtFileRead();
145
146 cout << parameters;
147}
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition JDB.hh:438
const char * getTable()
Get table name.
Definition JDB.hh:373
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
static const std::string PREFIX_DATAFILTER
This string is prepended to every parameter in the database output for the corresponding process.
Definition JDB.hh:184
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition JDB.hh:108
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
std::string RUNSETUPID
Definition JRuns.hh:26
Wrapper class for server name.
Definition JDB.hh:54
Template definition for getting table specific selector.