Jpp
Functions
JCheckHV.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JDetectorIntegration.hh"
#include "JDB/JProductRouter.hh"
#include "JDB/JAllParams.hh"
#include "JDB/JDatalogNumbers.hh"
#include "JDB/JPMTHVRunSettings.hh"
#include "JDB/JSupport.hh"
#include "JGizmo/JManager.hh"
#include "JLang/JLangToolkit.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 36 of file JCheckHV.cc.

37 {
38  using namespace std;
39  using namespace JPP;
40 
41  string usr;
42  string pwd;
43  string cookie;
44  string outputFile;
45  string detid;
46  int run;
47  long long int numberOfRows;
48  double precision;
49  int debug;
50 
51  try {
52 
53  JParser<> zap("Auxiliary program to check HV.");
54 
55  zap['u'] = make_field(usr) = "";
56  zap['!'] = make_field(pwd) = "";
57  zap['C'] = make_field(cookie) = "";
58  zap['o'] = make_field(outputFile) = "hv.root";
59  zap['D'] = make_field(detid, "Detector identifier");
60  zap['R'] = make_field(run, "Run");
61  zap['n'] = make_field(numberOfRows, "Maximal number of rows") = numeric_limits<long long int>::max();
62  zap['p'] = make_field(precision) = 0.5;
63  zap['d'] = make_field(debug) = 2;
64 
65  zap(argc, argv);
66  }
67  catch(const exception &error) {
68  FATAL(error.what() << endl);
69  }
70 
71 
72  JManager<JLocation_t, TH1D> manager(new TH1D("HV[%]", NULL, 200, -1500.0, +1500.0));
73 
74  try {
75 
76  JDB::reset(usr, pwd, cookie);
77 
78  if (is_integer(detid)) {
79  detid = getDetector(to_value<int>(detid));
80  }
81 
82  JDetectorIntegration detector;
83 
84  {
85  DEBUG("Reading database table " << getTable<JDetectorIntegration>() << endl);
86 
87  ResultSet& rs = getResultSet(getTable<JDetectorIntegration>());
88 
89  if (! (rs >> detector)) {
90  THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration>());
91  }
92  }
93 
94  DEBUG("Number of integrated products (before) " << right << detector.size() << endl);
95 
96  detector.configure(detid);
97 
98  DEBUG("Number of integrated products (after) " << right << detector.size() << endl);
99 
100  const JProductRouter router(detector);
101 
103 
104  {
105  ResultSet& rs = getResultSet(getTable<JPMTHVRunSettings>(), getSelector<JPMTHVRunSettings>(detid, run));
106 
107  for (JPMTHVRunSettings parameters; rs >> parameters; ) {
108 
109  const JLocation_t location(parameters.DUID, parameters.FLOORID, parameters.PMTINTID);
110 
111  HV[location] = parameters.HV_VALUE;
112  }
113 
114  rs.Close();
115  }
116 
117  if (debug >= debug_t) {
118 
119  cout << "HV settings:" << endl;
120 
121  for (map<JLocation_t, double>::const_iterator i = HV.begin(); i != HV.end(); ++i) {
122  cout << i->first << ' ' << FIXED(6,1) << i->second << endl;
123  }
124  }
125 
126  JSelector selection(&JDatalogNumbers::PARAMETER_NAME, "pmt_highvolt@");
127 
128  selection += getSelector<JDatalogNumbers>(detid, run, run);
129 
130  ResultSet& rs = getResultSet(getTable<JDatalogNumbers>(), selection);
131 
132  long long int counter = 0;
133 
134  for (JDatalogNumbers parameters; rs >> parameters && counter != numberOfRows; ++counter) {
135 
136  STATUS(setw(10) << counter << '\r'); DEBUG(endl);
137 
138  const JUPI upi = parameters.SOURCE_NAME;
139  const JLocation_t& location = router.getLocation(upi);
140 
141  DEBUG(location << ' ' << FIXED(6,1) << HV[location] << ' ' << FIXED(6,1) << parameters.DATA_VALUE << endl);
142 
143  if (location != JLocation_t()) {
144 
145  const double hv = HV[location] - parameters.DATA_VALUE ;
146 
147  manager[location]->Fill(hv);
148 
149  if (fabs(hv) > precision) {
150  WARNING("HV " << location << " set/read " << FIXED(6,1) << HV[location] << "/" << FIXED(6,1) << parameters.DATA_VALUE << endl);
151  }
152  }
153  STATUS(endl);
154  }
155  }
156  catch(const exception& error) {
157  FATAL(error.what() << endl);
158  }
159 
160 
161  TFile out(outputFile.c_str(), "recreate");
162 
163  out << manager;
164 
165  out.Write();
166  out.Close();
167 }
JManager
Auxiliary class to manage set of histograms.
Definition: JHistogramToolkit.hh:160
FIXED
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
JLANG::is_integer
bool is_integer(const std::string &buffer)
Check if string is an integer.
Definition: JLangToolkit.hh:58
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JDATABASE::getDetector
static const JDetectorsHelper & getDetector
Function object for mapping serial number and object identifier of detectors.
Definition: JDBToolkit.hh:131
JDATABASE::getResultSet
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:403
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
WARNING
#define WARNING(A)
Definition: JMessage.hh:65
debug
int debug
debug level
Definition: JSirene.cc:59
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
std::map
Definition: JSTDTypes.hh:16
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JDETECTOR::reset
void reset(JCLBInput &data, size_t size)
Reset CLB buffers.
Definition: JCLBSimulator.hh:41
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JEEP::debug_t
debug
Definition: JMessage.hh:29