Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPMTHV.cc File Reference

Utility program to test PMT HV settings. More...

#include <string>
#include <iostream>
#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/JPMTHVRunSettings.hh"
#include "JDB/JPMTHV.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (const int argc, const char *const argv[])
 

Detailed Description

Utility program to test PMT HV settings.

Author
mdejong

Definition in file JPMTHV.cc.

Function Documentation

int main ( const int  argc,
const char *const  argv[] 
)

Definition at line 26 of file JPMTHV.cc.

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 test 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  int ID = -1;
63 
64  if (is_integer(detid)) {
65  ID = to_value<int>(detid);
66  detid = getDetector(ID);
67  } else {
68  ID = getDetector(detid);
69  }
70 
71  typedef vector<JDetectorIntegration> detector_type;
72 
73  detector_type detector;
74 
75  {
76  ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(ID));
77 
78  for (JDetectorIntegration parameters; rs >> parameters; ) {
79  detector.push_back(parameters);
80  }
81 
82  rs.Close();
83  }
84 
86 
87  {
88  ResultSet& rs = getResultSet(getTable<JPMTHVRunSettings>(), getSelector<JPMTHVRunSettings>(detid, run));
89 
90  for (JPMTHVRunSettings parameters; rs >> parameters; ) {
91  HV[parameters.DUID][parameters.FLOORID][parameters.CABLEPOS] = parameters;
92  }
93 
94  rs.Close();
95  }
96 
97  const JPMTHV pmt_hv(ID, run);
98 
99  for (detector_type::const_iterator i = detector.begin(); i != detector.end(); ++i) {
100 
101  if (i->PMTUPI.getPBS() == PBS::PMT) {
102 
103  cout << FILL(4,'0') << i->DUID << '.' << FILL(2,'0') << i->FLOORID << "[" << FILL(2,'0') << i->CABLEPOS << "] " << FILL()
104  << setw(4) << pmt_hv(i->PMTUPI).value << ' '
105  << setw(4) << HV[i->DUID][i->FLOORID][i->CABLEPOS].HV_INDEX << ' '
106  << FIXED(7,1) << HV[i->DUID][i->FLOORID][i->CABLEPOS].HV_VALUE << ' '
107  << pmt_hv(i->PMTUPI).is_default
108  << (pmt_hv(i->PMTUPI).value != HV[i->DUID][i->FLOORID][i->CABLEPOS].HV_INDEX ? "*" : "") << endl;
109  }
110  }
111  }
112  catch(const exception& error) {
113  FATAL(error.what() << endl);
114  }
115 }
Utility class to parse command line options.
Definition: JParser.hh:1500
static const JPBS_t PMT(3, 4, 2, 3)
PBS of photo-multiplier tube (PMT)
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
Definition: JDBToolkit.cc:5
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
bool is_integer(const std::string &buffer)
Check if string is an integer.
Definition: JLangToolkit.hh:58
int debug
debug level
Definition: JSirene.cc:63
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:432
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:98
do set_variable DETECTOR_TXT $WORKDIR detector