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

Auxiliary program to print PMT status for a given PMT identifier. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JPMTStatus.hh"
#include "JLang/JVectorize.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 status for a given PMT identifier.

Author
mdejong

Definition in file getPMTStatus.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file getPMTStatus.cc.

23 {
24  using namespace std;
25  using namespace JPP;
26 
27  string detectorFile;
28  JPMTIdentifier id;
29  string key;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Auxiliary program to print PMT status for a given PMT identifier."
35  "\nInteractive mode in absence of option -P <PMT identifier>.");
36 
37  zap['a'] = make_field(detectorFile, "Detector file");
38  zap['P'] = make_field(id, "PMT identifier") = JPMTIdentifier();
39  zap['k'] = make_field(key, "key") = "", get_keys(getPMTStatusBit);
40  zap['d'] = make_field(debug) = 1;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48 
49  JDetector detector;
50 
51  try {
52  load(detectorFile, detector);
53  }
54  catch(const JException& error) {
55  FATAL(error);
56  }
57 
58  const JModuleRouter router(detector);
59 
60  if (id != JPMTIdentifier()) {
61 
62  if (router.hasModule(id.getModuleID())) {
63  if (key == "")
64  print(cout, router.getModule(id.getModuleID()).getPMT(id.getPMTAddress()).getStatus(), putPMTStatusBit);
65  else
66  cout << router.getModule(id.getModuleID()).getPMT(id.getPMTAddress()).has(getPMTStatusBit(key));
67  }
68 
69  } else {
70 
71  while (cin >> id && id != JPMTIdentifier()) {
72 
73  if (router.hasModule(id.getModuleID())) {
74  if (key == "")
75  print(cout, router.getModule(id.getModuleID()).getPMT(id.getPMTAddress()).getStatus(), putPMTStatusBit);
76  else
77  cout << router.getModule(id.getModuleID()).getPMT(id.getPMTAddress()).has(getPMTStatusBit(key));
78  }
79  }
80  }
81 }
Utility class to parse command line options.
Definition: JParser.hh:1514
static const JGetPMTStatusBit getPMTStatusBit
Function object to map key to PMT status bit.
Definition: JPMTStatus.hh:65
static const JPutPMTStatusBit putPMTStatusBit(getPMTStatusBit)
Function object to map PMT status bit to key.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
print
Definition: JConvertDusj.sh:44
#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
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
Definition: JVectorize.hh:139
int debug
debug level