Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getPMTStatus.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JDetector/JDetector.hh"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * \file
15  *
16  * Auxiliary program to print module location for a given module iddentifier.
17  * \author mdejong
18  */
19 int main(int argc, char **argv)
20 {
21  using namespace std;
22  using namespace JPP;
23 
24  string detectorFile;
25  JPMTIdentifier id;
26  int debug;
27 
28  try {
29 
30  JParser<> zap("Auxiliary program to print PMT status for a given PMT iddentifier."
31  "\nInteractive mode in absence of option -P <PMT>.");
32 
33  zap['a'] = make_field(detectorFile, "Detector file");
34  zap['P'] = make_field(id, "PMT identifier") = JPMTIdentifier();
35  zap['d'] = make_field(debug) = 1;
36 
37  zap(argc, argv);
38  }
39  catch(const exception &error) {
40  FATAL(error.what() << endl);
41  }
42 
43 
45 
46  try {
47  load(detectorFile, detector);
48  }
49  catch(const JException& error) {
50  FATAL(error);
51  }
52 
53  const JModuleRouter router(detector);
54 
55  if (id != JPMTIdentifier()) {
56 
57  if (router.hasModule(id.getModuleID())) {
58  router.getModule(id.getModuleID()).getPMT(id.getPMTAddress()).getStatus().print(cout);
59  }
60 
61  } else {
62 
63  while (cin >> id && id != JPMTIdentifier()) {
64 
65  if (router.hasModule(id.getModuleID())) {
66  router.getModule(id.getModuleID()).getPMT(id.getPMTAddress()).getStatus().print(cout);
67  }
68  }
69  }
70 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
const JStatus & getStatus() const
Get status.
Definition: JStatus.hh:68
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Detector data structure.
Definition: JDetector.hh:80
Router for direct addressing of module data in detector data structure.
Data structure for detector geometry and calibration.
Detector file.
Definition: JHead.hh:196
void print(std::ostream &out) const
Print status.
Definition: JStatus.hh:331
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:211
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
bool hasModule(const JObjectID &id) const
Has module.
do set_variable DETECTOR_TXT $WORKDIR detector
int main(int argc, char *argv[])
Definition: Main.cpp:15