Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JCheckHV.cc File Reference

Auxiliary program to check HV. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JDetectorIntegration.hh"
#include "JDB/JDatalogNumbers.hh"
#include "JDB/JPMTHV.hh"
#include "JDB/JLocation_t.hh"
#include "JDB/JSupport.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

Auxiliary program to check HV.

Author
mdejong

Definition in file software/JDB/JCheckHV.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 29 of file software/JDB/JCheckHV.cc.

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
71
72 try {
73
74 JDB::reset(usr, pwd, cookie);
75
76 const int ID = getDetector<int> (detid);
77 detid = getDetector<string>(detid);
78
80
81 {
82 ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(ID));
83
84 for (JDetectorIntegration parameters; rs >> parameters; ) {
85
86 if (parameters.PMTUPI.getPBS() == PBS::PMT) {
87 detector[parameters.PMTUPI] = JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS);
88 }
89 }
90
91 rs.Close();
92 }
93 {
94 const JPMTHV HV(ID, run);
95
96 JSelector selection(&JDatalogNumbers::PARAMETER_NAME, "pmt_highvolt");
97
98 selection += getSelector<JDatalogNumbers>(detid, run, run);
99
100 ResultSet& rs = getResultSet(getTable<JDatalogNumbers>(), selection);
101
102 long long int counter = 0;
103
104 for (JDatalogNumbers parameters; rs >> parameters && counter != numberOfRows; ++counter) {
105
106 STATUS(setw(10) << counter << '\r'); DEBUG(endl);
107
108 const JUPI_t upi = parameters.SOURCE_NAME;
109 const JLocation_t location = detector[upi];
110
111 DEBUG(location << ' ' << FIXED(7,1) << HV(upi) << ' ' << FIXED(7,1) << parameters.DATA_VALUE << endl);
112
113 if (location.is_valid()) {
114
115 counts[upi] += 1;
116
117 if (fabs(HV(upi).value - parameters.DATA_VALUE) > precision) {
118
119 ERROR("HV " << setw(10) << parameters.UNIXTIME << ' ' << location << " set/read " << FIXED(7,1) << HV(upi) << "/" << FIXED(7,1) << parameters.DATA_VALUE << endl);
120
121 errors[upi] += 1;
122 }
123
124 } else {
125
126 aliens[upi] += 1;
127 }
128
129 STATUS(endl);
130 }
131
132 rs.Close();
133 }
134
135 if (debug >= warning_t) {
136 for (map<JUPI_t, size_t>::const_iterator i = errors.begin(); i != errors.end(); ++i) {
137 cout << "Error HV " << setw(32) << left << i->first << right << ' ' << detector[i->first] << ' ' << setw(3) << i->second << '/' << setw(3) << counts[i->first] << endl;
138 }
139 for (map<JUPI_t, size_t>::const_iterator i = aliens.begin(); i != aliens.end(); ++i) {
140 cout << "Alien UPI " << setw(32) << left << i->first << right << ' ' << setw(3) << i->second << endl;
141 }
142 }
143 }
144 catch(const exception& error) {
145 FATAL(error.what() << endl);
146 }
147
148 QAQC(setw(4) << errors.size() << endl);
149
150 return 0;
151}
#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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Auxiliary class for PMT HVs.
Definition JPMTHV.hh:20
Utility class to parse command line options.
Definition JParser.hh:1698
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition JDB.hh:438
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).
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.