Jpp  debug
the software that should make you happy
JCheckDetectorIntegration.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <map>
5 
6 #include "JDB/JDB.hh"
7 #include "JDB/JSelector.hh"
9 #include "JDB/JDBToolkit.hh"
12 #include "JDB/JProductRouter.hh"
13 #include "JDB/JLocation_t.hh"
14 
15 #include "Jeep/JPrint.hh"
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 
20 /**
21  * \file
22  *
23  * Auxiliary program to check detector integration.
24  * \author mdejong
25  */
26 int main(int argc, char **argv)
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  const int ID = getDetector<int> (detid);
62  detid = getDetector<string>(detid);
63 
64  typedef map<JUPI_t, JLocation_t> detector_type;
65 
66  detector_type detectorA;
67 
68  {
69  ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(ID));
70 
71  for (JDetectorIntegration parameters; rs >> parameters; ) {
72 
73  if (parameters.PMTUPI.getPBS() == PBS::PMT) {
74  detectorA[parameters.PMTUPI] = JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS);
75  }
76  }
77 
78  rs.Close();
79  }
80 
81 
82  JDetectorIntegration_t detectorB;
83 
84  {
85  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
86 
87  if (! (rs >> detectorB)) {
88  THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration_t>());
89  }
90  }
91 
92  detectorB.configure(detid);
93 
94  const JProductRouter router(detectorB, PBS::PMT_SEQUENCES);
95 
96 
97  for (detector_type::const_iterator i = detectorA.begin(); i != detectorA.end(); ++i) {
98 
99  const JLocation_t locationA = i->second;
100  const JLocation_t locationB = router.getLocation(i->first);
101 
102  cout << locationA << ' ' << locationB << ' ' << (locationA != locationB ? "*" : "") << endl;
103  }
104  }
105  catch(const exception& error) {
106  FATAL(error.what() << endl);
107  }
108 }
int main(int argc, char **argv)
JDAQPMTIdentifier PMT
Command line options.
string outputFile
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
I/O formatting auxiliaries.
Database exception.
Definition: JException.hh:684
Utility class to parse command line options.
Definition: JParser.hh:1714
static const JPBSSequences PMT_SEQUENCES
PBS sequences for PMT.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:436
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:106
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void reset(T &value)
Reset value.
Definition: JSTDTypes.hh:14
void configure(const std::string &detid, const bool option=false)
Configure detector integration for given detector identifier.
Auxiliary data structure for location of product in detector.
Definition: JLocation_t.hh:26
Auxiliary class to map UPI to location in detector.
JLocation_t getLocation(const JUPI_t &upi) const
Get location of product with given UPI.
Wrapper class for server name.
Definition: JDB.hh:52
Template definition for getting table specific selector.