Jpp
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"
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  JPMTParametersMap parameters;
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(parameters, "PMT calibration data (or corresponding file name)");
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  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  const JPMTParameters buffer = parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt));
90 
91  manager[MAKE_CSTRING(module->getID() << "." << "EFFICIENCY")]->Fill((Double_t) pmt, getSurvivalProbability(buffer) * buffer.QE);
92  }
93  }
94 
95  manager.Write(outputFile.c_str());
96 }
JPMTParametersMap.hh
JDAQ.hh
JManager::Write
void Write(TFile &out)
Write histograms to file.
Definition: JHistogramToolkit.hh:225
JManager< string, TH1D >
JMessage.hh
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
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
main
int main(int argc, char **argv)
Definition: JPlotPMTParameters.cc:27
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