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

Example program for module identification. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JDetectorIntegration_t.hh"
#include "JDB/JProductRouter.hh"
#include "JDB/JCLBID.hh"
#include "JDB/JDBToolkit.hh"
#include "JLang/JComparator.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.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

Example program for module identification.

Author
mdejong

Definition in file JCLBID.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file JCLBID.cc.

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 
89 
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 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Database exception.
Definition: JException.hh:648
Detector data structure.
Definition: JDetector.hh:89
#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
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
Definition: JLocation_t.hh:106
map_type::const_iterator range_const_iterator
Detector file.
Definition: JHead.hh:196
Auxiliary data structure for location of product in detector.
Definition: JLocation_t.hh:24
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
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.
#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.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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
Wrapper class for server name.
Definition: JDB.hh:42
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
Definition: JLocation_t.hh:105