Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
getPMT.cc File Reference

Auxiliary program to print PMT data for a given PMT channel or identifier. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JPMTChannel.hh"
#include "JDetector/JPMTIdentifier.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 PMT data for a given PMT channel or identifier.

Author
mdejong

Definition in file getPMT.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file getPMT.cc.

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 
46  JDetector detector;
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:1514
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level