Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getPMT.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JDetector/JDetector.hh"
9 
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 
14 /**
15  * \file
16  *
17  * Auxiliary program to print PMT data for a given PMT channel or identifier.
18  * \author mdejong
19  */
20 int main(int argc, char **argv)
21 {
22  using namespace std;
23  using namespace JPP;
24 
25  string detectorFile;
26  JPMTChannel channel;
27  JObjectID id;
28  int debug;
29 
30  try {
31 
32  JParser<> zap("Auxiliary program to print PMT data for a given PMT channel.");
33 
34  zap['a'] = make_field(detectorFile);
35  zap['P'] = make_field(channel, "PMT channel: <string> <floor> <TDC>") = JPMTChannel();
36  zap['p'] = make_field(id, "PMT identifier") = JObjectID();
37  zap['d'] = make_field(debug) = 1;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
47 
48  try {
49  load(detectorFile, detector);
50  }
51  catch(const JException& error) {
52  FATAL(error);
53  }
54 
55  if (channel != JPMTChannel()) {
56 
57  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
58 
59  if (module->getLocation() == channel.getLocation()) {
60 
61  cout << module->getPMT(channel.getTDC()) << endl;
62 
63  break;
64  }
65  }
66 
67  } else if (id != JObjectID()) {
68 
69  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
70  for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
71  if (pmt->getID() == id.getID()) {
72 
73  cout << *pmt << endl;
74 
75  break;
76  }
77  }
78  }
79 
80  } else {
81 
82  while (cin >> channel && channel != JPMTChannel()) {
83 
84  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
85 
86  if (module->getLocation() == channel.getLocation()) {
87 
88  cout << module->getPMT(channel.getTDC()) << endl;
89 
90  break;
91  }
92  }
93  }
94  }
95 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:30
int main(int argc, char *argv[])
Definition: Main.cc:15
Data structure to uniquely identify PMT readout channel.
Detector data structure.
Definition: JDetector.hh:89
Data structure for detector geometry and calibration.
Detector file.
Definition: JHead.hh:224
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:66
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
Auxiliary class for object identification.
Definition: JObjectID.hh:22
do set_variable DETECTOR_TXT $WORKDIR detector