Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPlotPMTParameters.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "TROOT.h"
6 #include "TFile.h"
7 #include "TH1D.h"
8 
9 #include "JDAQ/JDAQ.hh"
10 #include "JDetector/JDetector.hh"
13 #include "JGizmo/JManager.hh"
14 
15 #include "Jeep/JPrint.hh"
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 
20 /**
21  * \file
22  * Auxiliary application to plot PMT parameters.
23  * \author mdejong
24  */
25 
26 int main(int argc, char **argv)
27 {
28  using namespace std;
29  using namespace JPP;
30  using namespace KM3NETDAQ;
31 
32  string detectorFile;
33  JPMTParametersMap parameters;
34  string outputFile;
35  int debug;
36 
37  try {
38 
39  JParser<> zap("Auxiliary application to plot PMT parameters.");
40 
41  zap['a'] = make_field(detectorFile, "detector file.");
42  zap['o'] = make_field(outputFile, "output file.") = "pmt_parameters.root";
43  zap['P'] = make_field(parameters, "PMT calibration data (or corresponding file name)");
44  zap['d'] = make_field(debug, "debug") = 0;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
52  JDetector detector;
53 
54  try {
55  load(detectorFile, detector);
56  }
57  catch(const JException& error) {
58  FATAL(error);
59  }
60 
61  if (detector.empty()) {
62  FATAL("Empty detector." << endl);
63  }
64 
65 
66  JManager<string, TH1D> manager(new TH1D("%", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5));
67 
68  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
69 
70  DEBUG("Module " << setw(10) << module->getID() << endl);
71 
72  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
73 
74  const JProperties properties = parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt)).getProperties();
75 
76  for (JProperties::const_iterator p = properties.begin(); p != properties.end(); ++p) {
77 
78  try {
79  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->Fill((Double_t) pmt, p->second.getValue<const double>());
80  }
81  catch(const exception& error) {}
82 
83  try {
84  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->Fill((Double_t) pmt, p->second.getValue<const bool>() ? 1.0 : 0.0);
85  }
86  catch(const exception& error) {}
87  }
88  }
89  }
90 
91  manager.Write(outputFile.c_str());
92 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Utility class to parse parameter values.
Definition: JProperties.hh:484
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:611
Dynamic ROOT object management.
string outputFile
Data structure for detector geometry and calibration.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Utility class to parse command line options.
void Write(TFile &out)
Write histograms to file.
KM3NeT DAQ constants, bit handling, etc.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
int main(int argc, char *argv[])
Definition: Main.cpp:15