Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
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

◆ main()

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 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Detector data structure.
Definition: JDetector.hh:96
Database exception.
Definition: JException.hh:684
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
static const JPBS_t CLB(3, 4, 3, 2)
PBS of central-logic board
static const JPBSSequences CLB_SEQUENCES
PBS sequences for central-logic board.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:437
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
JCLBIDHelper & getCLBID()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:426
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:107
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void reset(T &value)
Reset value.
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227
map_type::const_iterator range_const_iterator
Auxiliary data structure for location of product in detector.
Definition: JLocation_t.hh:26
int string
position in detector
Definition: JLocation_t.hh:105
int floor
position in string
Definition: JLocation_t.hh:106
Auxiliary class to map UPI to location in detector.
Wrapper class for server name.
Definition: JDB.hh:53
Universal product identifier (UPI).
Definition: JUPI_t.hh:32