Jpp  debug
the software that should make you happy
JPMTHV.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <vector>
4 #include <map>
5 
6 #include "JDB/JDB.hh"
7 #include "JDB/JSelector.hh"
9 #include "JDB/JDBToolkit.hh"
11 #include "JDB/JPMTHVRunSettings.hh"
12 #include "JDB/JPMTHV.hh"
13 
15 
16 #include "Jeep/JPrint.hh"
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  * Utility program to print PMT HV settings.
24  * \author mdejong
25  */
26 int main(const int argc, const char * const argv[])
27 {
28  using namespace std;
29  using namespace JPP;
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("Utility program to print PMT HV settings.");
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  try {
59 
60  JDB::reset(usr, pwd, cookie);
61 
62  const int ID = getDetector<int> (detid);
63  detid = getDetector<string>(detid);
64 
65  typedef vector<JDetectorIntegration> detector_type;
66 
67  detector_type detector;
68 
69  {
70  DEBUG("Downloading detector integration data... " << flush);
71 
72  ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(ID));
73 
74  for (JDetectorIntegration parameters; rs >> parameters; ) {
75  detector.push_back(parameters);
76  }
77 
78  rs.Close();
79 
80  DEBUG("OK" << endl);
81  }
82 
84 
85  {
86  DEBUG("Downloading HV data... " << flush);
87 
88  ResultSet& rs = getResultSet(getTable<JPMTHVRunSettings>(), getSelector<JPMTHVRunSettings>(ID, run));
89 
90  for (JPMTHVRunSettings parameters; rs >> parameters; ) {
91  HV[parameters.DUID][parameters.FLOORID][parameters.CABLEPOS] = parameters;
92  }
93 
94  rs.Close();
95 
96  DEBUG("OK" << endl);
97  }
98 
99  const JPMTHV pmt_hv(ID, run);
100 
101  for (detector_type::const_iterator i = detector.begin(); i != detector.end(); ++i) {
102 
103  if (i->PMTUPI.getPBS() == PBS::PMT) {
104  {
105  cout << FILL(4,'0') << i->DUID << '.' << FILL(2,'0') << i->FLOORID << "[" << FILL(2,'0') << i->CABLEPOS << "] " << FILL()
106  << setw(4) << HV[i->DUID][i->FLOORID][i->CABLEPOS].HV_INDEX << ' '
107  << FIXED(7,1) << HV[i->DUID][i->FLOORID][i->CABLEPOS].HV_VALUE << ' ';
108  }
109  try {
110  cout << setw(4) << pmt_hv(i->PMTUPI).value << ' '
111  << pmt_hv(i->PMTUPI).is_default
112  << (pmt_hv(i->PMTUPI).value != HV[i->DUID][i->FLOORID][i->CABLEPOS].HV_INDEX ? "*" : "");
113  }
114  catch(const exception& error) {
115  cout << "****";
116  }
117 
118  cout << endl;
119  }
120  }
121  }
122  catch(const exception& error) {
123  FATAL(error.what() << endl);
124  }
125 }
JDAQPMTIdentifier PMT
Command line options.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
int main(const int argc, const char *const argv[])
Definition: JPMTHV.cc:26
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
I/O formatting auxiliaries.
Auxiliary class for PMT HVs.
Definition: JPMTHV.hh:20
Utility class to parse command line options.
Definition: JParser.hh:1714
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:436
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:106
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void reset(T &value)
Reset value.
Definition: JSTDTypes.hh:14
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:330
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Detector file.
Definition: JHead.hh:227
Wrapper class for server name.
Definition: JDB.hh:52
Template definition for getting table specific selector.