Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPlotPMTParameters2D.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <vector>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 #include "TH2D.h"
9 
10 #include "JDAQ/JDAQ.hh"
11 #include "JDetector/JDetector.hh"
14 #include "JGizmo/JManager.hh"
15 
16 #include "Jeep/JPrint.hh"
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  * Auxiliary application to plot PMT parameters.
24  * \author mdejong
25  */
26 
27 int main(int argc, char **argv)
28 {
29  using namespace std;
30  using namespace JPP;
31  using namespace KM3NETDAQ;
32 
33  string detectorFile;
34  vector<string> inputFile;
35  string outputFile;
36  int debug;
37 
38  try {
39 
40  JParser<> zap("Auxiliary application to plot PMT parameters.");
41 
42  zap['a'] = make_field(detectorFile, "detector file.");
43  zap['o'] = make_field(outputFile, "output file.") = "pmt_parameters.root";
44  zap['P'] = make_field(inputFile, "PMT calibration data file");
45  zap['d'] = make_field(debug, "debug") = 0;
46 
47  zap(argc, argv);
48  }
49  catch(const exception &error) {
50  FATAL(error.what() << endl);
51  }
52 
53  JDetector detector;
54 
55  try {
56  load(detectorFile, detector);
57  }
58  catch(const JException& error) {
59  FATAL(error);
60  }
61 
62  if (detector.empty()) {
63  FATAL("Empty detector." << endl);
64  }
65 
66  vector<JPMTParametersMap> parameters;
67 
68  for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
69  parameters.push_back(JPMTParametersMap(i->c_str()));
70  }
71 
72 
73  const int NUMBER_OF_FILES = parameters.size();
74 
75  JManager<string, TH2D> manager(new TH2D("%", NULL,
76  NUMBER_OF_FILES, -0.5, NUMBER_OF_FILES - 0.5,
77  NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5));
78 
79  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
80 
81  DEBUG("Module " << setw(10) << module->getID() << endl);
82 
83  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
84 
85  for (int i = 0; i != NUMBER_OF_FILES; ++i) {
86 
87  const JProperties properties = parameters[i].getPMTParameters(JPMTIdentifier(module->getID(), pmt)).getProperties();
88 
89  for (JProperties::const_iterator p = properties.begin(); p != properties.end(); ++p) {
90 
91  try {
92  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->Fill((Double_t) i, (Double_t) pmt, p->second.getValue<const double>());
93  }
94  catch(const exception& error) {}
95 
96  try {
97  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->Fill((Double_t) i, (Double_t) pmt, p->second.getValue<const bool>() ? 1.0 : 0.0);
98  }
99  catch(const exception& error) {}
100  }
101  }
102  }
103  }
104 
105  manager.Write(outputFile.c_str());
106 }
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