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

Auxiliary program to print module identifier for a given module location. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JSupport/JMeta.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorAddressMapToolkit.hh"
#include "dbclient/KM3NeTDBClient.h"
#include "JDB/JDB.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JDBincludes.hh"
#include "JDB/JProductRouter.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print module identifier for a given module location.

Author
bjung, mjg

Definition in file getModuleID.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file getModuleID.cc.

30 {
31  using namespace std;
32  using namespace JPP;
33 
34  string usr;
35  string pwd;
36  string cookie;
37  JLocation location;
38  int detid;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Auxiliary program to print module identifier for a given module location."
44  "\nInteractive mode in absence of option -L <location>.");
45 
46  zap['u'] = make_field(usr) = "";
47  zap['!'] = make_field(pwd) = "";
48  zap['C'] = make_field(cookie) = "";
49  zap['D'] = make_field(detid, "Detector identifier") = -1;
50  zap['L'] = make_field(location, "Module location") = JLocation();
51  zap['d'] = make_field(debug) = 1;
52 
53  zap(argc, argv);
54  }
55  catch(const exception &error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60  while (location == JLocation()) {
61  cin >> location;
62  }
63 
64 
65  if (hasDetectorAddressMap(detid)) {
66 
68 
69  try {
70 
71  JDB::reset(usr, pwd, cookie);
72 
73  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
74 
75  if (! (rs >> detector)) {
76  THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration_t>());
77  }
78 
79  } catch (const exception& error) {
80 
81  FATAL(error.what() << endl);
82  }
83 
84  detector.configure(getDetector(detid));
85 
86  const JProductRouter router(detector, PBS::CLB_SEQUENCES);
87 
88  for (map<JUPI_t, JLocation_t>::const_iterator CLB = router.cbegin(); CLB != router.cend(); ++CLB) {
89 
90  if (location.getString() == CLB->second.string &&
91  location.getFloor() == CLB->second.floor) {
92 
93  cout << getCLBID(CLB->first) << endl;
94  break;
95  }
96  }
97 
98  } else {
99 
100  ERROR("No detector found corresponding to user specifications.");
101  }
102 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Database exception.
Definition: JException.hh:648
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
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
Logical location of module.
Definition: JLocation.hh:37
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define ERROR(A)
Definition: JMessage.hh:66
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
void reset(T &value)
Reset value.
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
void configure(const std::string &detid)
Configure detector integration for given detector identifier.