Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
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 }
Data structure for detector geometry and calibration.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Data structure to uniquely identify PMT readout channel.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Detector data structure.
Definition: JDetector.hh:96
const JLocation & getLocation() const
Get location.
Definition: JLocation.hh:70
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:35
General exception.
Definition: JException.hh:24
Auxiliary class for object identification.
Definition: JObjectID.hh:25
Utility class to parse command line options.
Definition: JParser.hh:1698
int main(int argc, char **argv)
Definition: getPMT.cc:20
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227