Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JCLBID.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
5#include "JDB/JDB.hh"
6#include "JDB/JSelector.hh"
10#include "JDB/JCLBID.hh"
11#include "JDB/JDBToolkit.hh"
12#include "JLang/JComparator.hh"
13
16
17#include "Jeep/JParser.hh"
18#include "Jeep/JMessage.hh"
19
20
21/**
22 * \file
23 *
24 * Example program for module identification.
25 * \author mdejong
26 */
27int main(int argc, char **argv)
28{
29 using namespace std;
30 using namespace JPP;
31
32 JServer server;
33 string usr;
34 string pwd;
35 string cookie;
36 string detectorFile;
37 int debug;
38
39 try {
40
41 JParser<> zap("Example program for module identification.");
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['a'] = make_field(detectorFile);
48 zap['d'] = make_field(debug) = 3;
49
50 zap(argc, argv);
51 }
52 catch(const exception &error) {
53 FATAL(error.what() << endl);
54 }
55
56
58
59 DEBUG("Reading database table " << getTable<JDetectorIntegration_t>() << endl);
60
61 try {
62
63 JDB::reset(usr, pwd, cookie);
64
65 ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
66
67 if (! (rs >> detector)) {
68 THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration_t>());
69 }
70 }
71 catch(const exception& error) {
72 FATAL(error.what() << endl);
73 }
74
75
76 JDetector detx;
77
78 try {
79 load(detectorFile, detx);
80 }
81 catch(const JException& error) {
82 FATAL(error);
83 }
84
85
86 detector.configure(getDetector(detx.getID()));
87
88 const JProductRouter router(detector, PBS::CLB_SEQUENCES);
89
90 const JDetectorIntegration_t::range_type range = detector.find(PBS::CLB);
91
92 for (JDetectorIntegration_t::range_const_iterator i = range.first; i != range.second; ++i) {
93
94 const JUPI_t upi = detector[i->second].content.getUPI();
95 const JLocation_t location = router.getLocation(upi);
96
97 cout << setw(24) << left << upi << right << ' '
98 << setw(4) << location.string << ' '
99 << setw(2) << location.floor << ' '
100 << setw(10) << getCLBID(upi) << ' ';
101
102 for (JDetector::const_iterator module = detx.begin(); module != detx.end(); ++module) {
103
104 if (module->getString() == location.string &&
105 module->getFloor() == location.floor) {
106
107 cout << setw(10) << module->getID();
108
109 break;
110 }
111 }
112
113 cout << endl;
114 }
115
116 return 0;
117}
int main(int argc, char **argv)
Definition JCLBID.cc:27
Data structure for detector geometry and calibration.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Detector data structure.
Definition JDetector.hh:96
Database exception.
General exception.
Definition JException.hh:24
int getID() const
Get identifier.
Definition JObjectID.hh:50
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227
map_type::const_iterator range_const_iterator
Auxiliary data structure for location of product in detector.
int string
position in detector
int floor
position in string
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:54
Universal product identifier (UPI).
Definition JUPI_t.hh:32