Jpp  18.2.1-ARCA-DF-PATCH
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 "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "dbclient/KM3NeTDBClient.h"
#include "JDB/JDB.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JDetectorIntegration_t.hh"
#include "JDB/JProductRouter.hh"
#include "Jeep/JPrint.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

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 26 of file getModuleID.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  JServer server;
32  string usr;
33  string pwd;
34  string cookie;
35  JLocation location;
36  int detid;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Auxiliary program to print module identifier for a given module location.");
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['D'] = make_field(detid, "Detector identifier");
48  zap['L'] = make_field(location, "Module location");
49  zap['d'] = make_field(debug) = 1;
50 
51  zap(argc, argv);
52  }
53  catch(const exception &error) {
54  FATAL(error.what() << endl);
55  }
56 
57 
58  while (location == JLocation()) {
59  cin >> location;
60  }
61 
62 
63  JDetectorIntegration_t detector;
64 
65  try {
66 
67  JDB::reset(usr, pwd, cookie);
68 
69  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
70 
71  if (! (rs >> detector)) {
72  THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration_t>());
73  }
74 
75  } catch (const exception& error) {
76 
77  FATAL(error.what() << endl);
78  }
79 
80  detector.configure(getDetector(detid));
81 
82  const JProductRouter router(detector, PBS::CLB_SEQUENCES);
83 
84  for (map<JUPI_t, JLocation_t>::const_iterator CLB = router.cbegin(); CLB != router.cend(); ++CLB) {
85 
86  if (location.getString() == CLB->second.string &&
87  location.getFloor() == CLB->second.floor) {
88 
89  cout << getCLBID(CLB->first) << endl;
90  break;
91  }
92  }
93 }
Utility class to parse command line options.
Definition: JParser.hh:1514
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
static const JPBS_t CLB(3, 4, 3, 2)
PBS of central-logic board
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
JCLBIDHelper & getCLBID()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:426
static const JPBSSequences CLB_SEQUENCES
PBS sequences for central-logic board.
#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:436
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:106
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level