Jpp test-rotations-old
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 "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TGraph.h"
#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/JPMTHVRunSettings.hh"
#include "JDB/JLocation_t.hh"
#include "JDB/JSupport.hh"
#include "JROOT/JGraph.hh"
#include "JROOT/JRootToolkit.hh"
#include "JROOT/JManager.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 JCheckHV.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 38 of file JCheckHV.cc.

39{
40 using namespace std;
41 using namespace JPP;
42
43 JServer server;
44 string usr;
45 string pwd;
46 string cookie;
47 string outputFile;
48 string detid;
49 vector<int> runs;
50 long long int numberOfRows;
51 double precision;
52 int debug;
53
54 try {
55
56 JParser<> zap("Auxiliary program to check HV.");
57
58 zap['s'] = make_field(server) = getServernames();
59 zap['u'] = make_field(usr) = "";
60 zap['!'] = make_field(pwd) = "";
61 zap['C'] = make_field(cookie) = "";
62 zap['o'] = make_field(outputFile) = "hv.root";
63 zap['D'] = make_field(detid, "Detector identifier");
64 zap['R'] = make_field(runs, "Run(s)");
65 zap['n'] = make_field(numberOfRows, "Maximal number of rows") = numeric_limits<long long int>::max();
66 zap['e'] = make_field(precision) = 0.5;
67 zap['d'] = make_field(debug) = 2;
68
69 zap(argc, argv);
70 }
71 catch(const exception &error) {
72 FATAL(error.what() << endl);
73 }
74
75
77 JManager<JLocation_t, TH1D> H1(new TH1D("HV[%]", NULL, 201, -1500.0, +1500.0));
78
79 map<JUPI_t, int> errors;
80
81 try {
82
83 JDB::reset(usr, pwd, cookie);
84
85 const int ID = getDetector<int> (detid);
86 detid = getDetector<string>(detid);
87
88 typedef map<JUPI_t, JLocation_t> detector_type;
89
90 detector_type detector;
91
92 {
93 ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(ID));
94
95 for (JDetectorIntegration parameters; rs >> parameters; ) {
96
97 if (parameters.PMTUPI.getPBS() == PBS::PMT) {
98 detector[parameters.PMTUPI] = JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS);
99 }
100 }
101
102 rs.Close();
103 }
104
105 for (const int run : runs) {
106
108
109 {
110 ResultSet& rs = getResultSet(getTable<JPMTHVRunSettings>(), getSelector<JPMTHVRunSettings>(detid, run));
111
112 for (JPMTHVRunSettings parameters; rs >> parameters; ) {
113
114 const JLocation_t location(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS);
115
116 if (parameters.CABLEPOS != parameters.PMTINTID) {
117 WARNING("PMT " << location << " position " << parameters.PMTINTID << endl);
118 }
119
120 HV[location] = parameters.HV_VALUE;
121 }
122
123 rs.Close();
124 }
125
126 if (debug >= debug_t) {
127
128 cout << "HV settings " << setw(8) << run << endl;
129
130 for (map<JLocation_t, double>::const_iterator i = HV.begin(); i != HV.end(); ++i) {
131 cout << i->first << ' ' << FIXED(6,1) << i->second << endl;
132 }
133 }
134
135 JSelector selection(&JDatalogNumbers::PARAMETER_NAME, "pmt_highvolt@");
136
137 selection += getSelector<JDatalogNumbers>(detid, run, run);
138
139 ResultSet& rs = getResultSet(getTable<JDatalogNumbers>(), selection);
140
141 long long int counter = 0;
142
143 for (JDatalogNumbers parameters; rs >> parameters && counter != numberOfRows; ++counter) {
144
145 STATUS(setw(10) << counter << '\r'); DEBUG(endl);
146
147 const JUPI_t upi = parameters.SOURCE_NAME;
148 const JLocation_t location = detector[upi];
149
150 DEBUG(location << ' ' << FIXED(7,1) << HV[location] << ' ' << FIXED(7,1) << parameters.DATA_VALUE << endl);
151
152 if (location.is_valid()) {
153
154 G1[location].put(parameters.getTime(), parameters.DATA_VALUE);
155
156 H1[location]->Fill(HV[location] - parameters.DATA_VALUE);
157
158 if (fabs(HV[location] - parameters.DATA_VALUE) > precision) {
159 ERROR("HV " << location << " set/read " << FIXED(7,1) << HV[location] << "/" << FIXED(7,1) << parameters.DATA_VALUE << endl);
160 }
161
162 } else {
163
164 errors[upi] += 1;
165 }
166
167 STATUS(endl);
168 }
169
170 rs.Close();
171 }
172 }
173 catch(const exception& error) {
174 FATAL(error.what() << endl);
175 }
176
177
178 for (map<JUPI_t, int>::const_iterator i = errors.begin(); i != errors.end(); ++i) {
179 ERROR("Alien UPI " << setw(24) << i->first << ' ' << i->second << endl);
180 }
181
182 TFile out(outputFile.c_str(), "recreate");
183
184 for (map<JLocation_t, JGraph_t>::const_iterator i = G1.begin(); i != G1.end(); ++i) {
185 out << JGraph(i->second, MAKE_CSTRING("G[" << i->first << "].hv"));
186 }
187
188 out << H1;
189
190 out.Write();
191 out.Close();
192}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define ERROR(A)
Definition JMessage.hh:66
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define WARNING(A)
Definition JMessage.hh:65
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
Double_t G1(const Double_t x)
Integral of method g1.
Definition JQuantiles.cc:37
Utility class to parse command line options.
Definition JParser.hh:1698
const char * map
Definition elog.cc:87
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:32
Template definition for getting table specific selector.
Auxiliary data structure to build TGraph.
Definition JGraph.hh:44