Jpp
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"
15 #include "JGizmo/JManager.hh"
16 
17 #include "Jeep/JPrint.hh"
18 #include "Jeep/JParser.hh"
19 #include "Jeep/JMessage.hh"
20 
21 
22 /**
23  * \file
24  * Auxiliary application to plot PMT parameters.
25  * \author mdejong
26  */
27 
28 int main(int argc, char **argv)
29 {
30  using namespace std;
31  using namespace JPP;
32  using namespace KM3NETDAQ;
33 
34  string detectorFile;
35  vector<string> inputFile;
36  string outputFile;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Auxiliary application to plot PMT parameters.");
42 
43  zap['a'] = make_field(detectorFile, "detector file.");
44  zap['o'] = make_field(outputFile, "output file.") = "pmt_parameters.root";
45  zap['P'] = make_field(inputFile, "PMT calibration data file");
46  zap['d'] = make_field(debug, "debug") = 0;
47 
48  zap(argc, argv);
49  }
50  catch(const exception &error) {
51  FATAL(error.what() << endl);
52  }
53 
54  JDetector detector;
55 
56  try {
57  load(detectorFile, detector);
58  }
59  catch(const JException& error) {
60  FATAL(error);
61  }
62 
63  if (detector.empty()) {
64  FATAL("Empty detector." << endl);
65  }
66 
67  vector<JPMTParametersMap> parameters;
68 
69  for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
70  parameters.push_back(JPMTParametersMap(i->c_str()));
71  }
72 
73 
74  const int NUMBER_OF_FILES = parameters.size();
75 
76  JManager<string, TH2D> manager(new TH2D("%", NULL,
77  NUMBER_OF_FILES, -0.5, NUMBER_OF_FILES - 0.5,
78  NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5));
79 
80  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
81 
82  DEBUG("Module " << setw(10) << module->getID() << endl);
83 
84  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
85 
86  for (int i = 0; i != NUMBER_OF_FILES; ++i) {
87 
88  const JProperties properties = parameters[i].getPMTParameters(JPMTIdentifier(module->getID(), pmt)).getProperties();
89 
90  for (JProperties::const_iterator p = properties.begin(); p != properties.end(); ++p) {
91 
92  try {
93  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->Fill((Double_t) i, (Double_t) pmt, p->second.getValue<const double>());
94  }
95  catch(const exception& error) {}
96 
97  try {
98  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->Fill((Double_t) i, (Double_t) pmt, p->second.getValue<const bool>() ? 1.0 : 0.0);
99  }
100  catch(const exception& error) {}
101  }
102 
103  const JPMTParameters buffer = parameters[i].getPMTParameters(JPMTIdentifier(module->getID(), pmt));
104 
105  manager[MAKE_CSTRING(module->getID() << "." << "EFFICIENCY")]->Fill((Double_t) i, (Double_t) pmt, getSurvivalProbability(buffer) * buffer.QE);
106  }
107  }
108  }
109 
110  manager.Write(outputFile.c_str());
111 }
JPMTParametersMap.hh
JDAQ.hh
JManager::Write
void Write(TFile &out)
Write histograms to file.
Definition: JHistogramToolkit.hh:225
JManager< string, TH2D >
JMessage.hh
main
int main(int argc, char **argv)
Definition: JPlotPMTParameters2D.cc:28
JPrint.hh
JDETECTOR::getSurvivalProbability
double getSurvivalProbability(const JPMTParameters &parameters)
Get model dependent probability that a one photo-electron hit survives the simulation of the PMT assu...
Definition: JPMTParametersToolkit.hh:32
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:456
std::vector
Definition: JSTDTypes.hh:12
KM3NETDAQ::NUMBER_OF_PMTS
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JManager.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
MAKE_CSTRING
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:708
debug
int debug
debug level
Definition: JSirene.cc:59
JParser.hh
JDetectorToolkit.hh
JPMTParametersToolkit.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JEEP::JProperties
Utility class to parse parameter values.
Definition: JProperties.hh:496
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JDetector.hh
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37