Jpp 19.3.0
the software that should make you happy
Loading...
Searching...
No Matches
software/JDB/JCheckHV.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <limits>
5#include <vector>
6#include <map>
7
8#include "JDB/JDB.hh"
9#include "JDB/JSelector.hh"
11#include "JDB/JDBToolkit.hh"
14#include "JDB/JPMTHV.hh"
15#include "JDB/JLocation_t.hh"
16#include "JDB/JSupport.hh"
17
18#include "Jeep/JPrint.hh"
19#include "Jeep/JParser.hh"
20#include "Jeep/JMessage.hh"
21
22
23/**
24 * \file
25 *
26 * Auxiliary program to check HV.
27 * \author mdejong
28 */
29int main(int argc, char **argv)
30{
31 using namespace std;
32 using namespace JPP;
33
34 JServer server;
35 string usr;
36 string pwd;
37 string cookie;
38 string detid;
39 int run;
40 long long int numberOfRows;
41 double precision;
42 int qaqc;
43 int debug;
44
45 try {
46
47 JParser<> zap("Auxiliary program to check HV."\
48 "\nFor detailed ROOT output, use corresponding example.");
49
50 zap['s'] = make_field(server) = getServernames();
51 zap['u'] = make_field(usr) = "";
52 zap['!'] = make_field(pwd) = "";
53 zap['C'] = make_field(cookie) = "";
54 zap['D'] = make_field(detid, "Detector identifier");
55 zap['R'] = make_field(run, "Run");
56 zap['n'] = make_field(numberOfRows, "Maximal number of rows") = numeric_limits<long long int>::max();
57 zap['e'] = make_field(precision) = 0.5;
58 zap['Q'] = make_field(qaqc) = 0;
59 zap['d'] = make_field(debug) = 2;
60
61 zap(argc, argv);
62 }
63 catch(const exception &error) {
64 FATAL(error.what() << endl);
65 }
66
67
70
71 try {
72
73 JDB::reset(usr, pwd, cookie);
74
75 const int ID = getDetector<int> (detid);
76 detid = getDetector<string>(detid);
77
79
80 {
81 ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(ID));
82
83 for (JDetectorIntegration parameters; rs >> parameters; ) {
84
85 if (parameters.PMTUPI.getPBS() == PBS::PMT) {
86 detector[parameters.PMTUPI] = JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS);
87 }
88 }
89
90 rs.Close();
91 }
92 {
93 const JPMTHV HV(ID, run);
94
95 JSelector selection(&JDatalogNumbers::PARAMETER_NAME, "pmt_highvolt");
96
97 selection += getSelector<JDatalogNumbers>(detid, run, run);
98
99 ResultSet& rs = getResultSet(getTable<JDatalogNumbers>(), selection);
100
101 long long int counter = 0;
102
103 for (JDatalogNumbers parameters; rs >> parameters && counter != numberOfRows; ++counter) {
104
105 STATUS(setw(10) << counter << '\r'); DEBUG(endl);
106
107 const JUPI_t upi = parameters.SOURCE_NAME;
108 const JLocation_t location = detector[upi];
109
110 DEBUG(location << ' ' << FIXED(7,1) << HV(upi) << ' ' << FIXED(7,1) << parameters.DATA_VALUE << endl);
111
112 if (location.is_valid()) {
113
114 if (fabs(HV(upi).value - parameters.DATA_VALUE) > precision) {
115
116 ERROR("HV " << location << " set/read " << FIXED(7,1) << HV(upi) << "/" << FIXED(7,1) << parameters.DATA_VALUE << endl);
117
118 errors[upi] += 1;
119 }
120
121 } else {
122
123 aliens[upi] += 1;
124 }
125
126 STATUS(endl);
127 }
128
129 rs.Close();
130 }
131
132 if (debug >= warning_t) {
133 for (map<JUPI_t, size_t>::const_iterator i = errors.begin(); i != errors.end(); ++i) {
134 cout << "Error HV " << setw(32) << left << i->first << right << ' ' << detector[i->first] << ' ' << setw(3) << i->second << endl;
135 }
136 for (map<JUPI_t, size_t>::const_iterator i = aliens.begin(); i != aliens.end(); ++i) {
137 cout << "Alien UPI " << setw(32) << left << i->first << right << ' ' << setw(3) << i->second << endl;
138 }
139 }
140 }
141 catch(const exception& error) {
142 FATAL(error.what() << endl);
143 }
144
145 QAQC(setw(4) << errors.size() << endl);
146
147 return 0;
148}
ROOT TTree parameter settings.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define QAQC(A)
QA/QC output macro.
Definition JMessage.hh:100
#define ERROR(A)
Definition JMessage.hh:66
int qaqc
QA/QC file descriptor.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
Auxiliary class for PMT HVs.
Definition JPMTHV.hh:20
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
int main(int argc, char **argv)
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Detector file.
Definition JHead.hh:227
Auxiliary data structure for location of product in detector.
bool is_valid() const
Check validity of location.
Wrapper class for server name.
Definition JDB.hh:54
Universal product identifier (UPI).
Definition JUPI_t.hh:33
Template definition for getting table specific selector.