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