Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
9 #include "JDB/JProductRouter.hh"
10 #include "JDB/JCLBID.hh"
11 #include "JDB/JDBToolkit.hh"
12 #include "JLang/JComparator.hh"
13 
14 #include "JDetector/JDetector.hh"
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  */
27 int main(int argc, char **argv)
28 {
29  using namespace std;
30  using namespace JPP;
31 
32  string usr;
33  string pwd;
34  string cookie;
35  string detectorFile;
36  int debug;
37 
38  try {
39 
40  JParser<> zap("Example program for module identification.");
41 
42  zap['u'] = make_field(usr) = "";
43  zap['!'] = make_field(pwd) = "";
44  zap['C'] = make_field(cookie) = "";
45  zap['a'] = make_field(detectorFile);
46  zap['d'] = make_field(debug) = 3;
47 
48  zap(argc, argv);
49  }
50  catch(const exception &error) {
51  FATAL(error.what() << endl);
52  }
53 
54 
56 
57  DEBUG("Reading database table " << getTable<JDetectorIntegration_t>() << endl);
58 
59  try {
60 
61  JDB::reset(usr, pwd, cookie);
62 
63  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
64 
65  if (! (rs >> detector)) {
66  THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration_t>());
67  }
68  }
69  catch(const exception& error) {
70  FATAL(error.what() << endl);
71  }
72 
73 
74  JDetector detx;
75 
76  try {
77  load(detectorFile, detx);
78  }
79  catch(const JException& error) {
80  FATAL(error);
81  }
82 
83 
84  detector.configure(getDetector(detx.getID()));
85 
87 
89 
90  for (JDetectorIntegration_t::range_const_iterator i = range.first; i != range.second; ++i) {
91 
92  const JUPI_t upi = detector[i->second].content.getUPI();
93  const JLocation_t location = router.getLocation(upi);
94 
95  cout << setw(24) << left << upi << right << ' '
96  << setw(4) << location.string << ' '
97  << setw(2) << location.floor << ' '
98  << setw(10) << getCLBID(upi) << ' ';
99 
100  for (JDetector::const_iterator module = detx.begin(); module != detx.end(); ++module) {
101 
102  if (module->getString() == location.string &&
103  module->getFloor() == location.floor) {
104 
105  cout << setw(10) << module->getID();
106 
107  break;
108  }
109  }
110 
111  cout << endl;
112  }
113 
114  return 0;
115 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
Database exception.
Definition: JException.hh:648
Detector data structure.
Definition: JDetector.hh:80
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
Universal product identifier (UPI).
Definition: JUPI_t.hh:29
Data structure for detector geometry and calibration.
static const JPBS_t CLB(3, 4, 3, 2)
PBS of central-logic board
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
Definition: JDBToolkit.cc:5
int floor
position in string
map_type::const_iterator range_const_iterator
Detector file.
Definition: JHead.hh:196
Auxiliary data structure for location of product in detector.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
JLocation_t getLocation(const JUPI_t &upi) const
Get location of product with given UPI.
int debug
debug level
Definition: JSirene.cc:63
static const JPBSSequences CLB_SEQUENCES
PBS sequences for central-logic board.
Auxiliary class to map UPI to location in detector.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
void reset(T &value)
Reset value.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:269
JCLBIDHelper getCLBID
Function object for mapping UPI of central-logic board to module identifier.
Definition: JDBToolkit.cc:6
do set_variable DETECTOR_TXT $WORKDIR detector
int string
position in detector
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62