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

Auxiliary program to check detector integration. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JDetectorIntegration.hh"
#include "JDB/JDetectorIntegration_t.hh"
#include "JDB/JProductRouter.hh"
#include "JDB/JLocation_t.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 detector integration.

Author
mdejong

Definition in file JCheckDetectorIntegration.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JCheckDetectorIntegration.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 outputFile;
36  string detid;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Auxiliary program to check detector integration.");
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, "Detector identifier");
48  zap['d'] = make_field(debug) = 1;
49 
50  zap(argc, argv);
51  }
52  catch(const exception &error) {
53  FATAL(error.what() << endl);
54  }
55 
56 
57  try {
58 
59  JDB::reset(usr, pwd, cookie);
60 
61  int ID = -1;
62 
63  if (is_integer(detid)) {
64  ID = to_value<int>(detid);
65  detid = getDetector(ID);
66  } else {
67  ID = getDetector(detid);
68  }
69 
70 
71  typedef map<JUPI_t, JLocation_t> detector_type;
72 
73  detector_type detectorA;
74 
75  {
76  ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(ID));
77 
78  for (JDetectorIntegration parameters; rs >> parameters; ) {
79 
80  if (parameters.PMTUPI.getPBS() == PBS::PMT) {
81  detectorA[parameters.PMTUPI] = JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS);
82  }
83  }
84 
85  rs.Close();
86  }
87 
88 
89  JDetectorIntegration_t detectorB;
90 
91  {
92  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
93 
94  if (! (rs >> detectorB)) {
95  THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration_t>());
96  }
97  }
98 
99  detectorB.configure(detid);
100 
101  const JProductRouter router(detectorB, PBS::PMT_SEQUENCES);
102 
103 
104  for (detector_type::const_iterator i = detectorA.begin(); i != detectorA.end(); ++i) {
105 
106  const JLocation_t locationA = i->second;
107  const JLocation_t locationB = router.getLocation(i->first);
108 
109  cout << locationA << ' ' << locationB << ' ' << (locationA != locationB ? "*" : "") << endl;
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)
static const JPBSSequences PMT_SEQUENCES
PBS sequences for PMT.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
*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
string outputFile
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
#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