Jpp  16.0.0-rc.1
the software that should make you happy
 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 
10 #include "JDetector/JDetector.hh"
16 #include "JROOT/JManager.hh"
17 #include "JGizmo/JGizmoToolkit.hh"
18 
19 #include "Jeep/JPrint.hh"
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 
24 /**
25  * \file
26  * Auxiliary application to plot PMT parameters.
27  * \author mdejong
28  */
29 
30 int main(int argc, char **argv)
31 {
32  using namespace std;
33  using namespace JPP;
34  using namespace KM3NETDAQ;
35 
36  string detectorFile;
38  string outputFile;
39  bool showPMTAddress;
40  int debug;
41 
42  try {
43 
44  JParser<> zap("Auxiliary application to plot PMT parameters.");
45 
46  zap['a'] = make_field(detectorFile, "detector file.");
47  zap['o'] = make_field(outputFile, "output file.") = "pmt_parameters.root";
48  zap['P'] = make_field(parameters, "PMT calibration data (or corresponding file name)");
49  zap['A'] = make_field(showPMTAddress, "show PMT address on y-axis");
50  zap['d'] = make_field(debug, "debug") = 0;
51 
52  zap(argc, argv);
53  }
54  catch(const exception &error) {
55  FATAL(error.what() << endl);
56  }
57 
59 
60  try {
61  load(detectorFile, detector);
62  }
63  catch(const JException& error) {
64  FATAL(error);
65  }
66 
67  if (detector.empty()) {
68  FATAL("Empty detector." << endl);
69  }
70 
71  const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID());
72 
73  JManager<string, TH1D> manager(new TH1D("%", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5));
74 
75  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
76 
77  DEBUG("Module " << setw(10) << module->getID() << endl);
78 
79  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
80 
81  const JProperties properties = parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt)).getProperties();
82 
83  for (JProperties::const_iterator p = properties.begin(); p != properties.end(); ++p) {
84 
85  try {
86  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->SetBinContent(pmt + 1, p->second.getValue<const double>());
87  }
88  catch(const exception& error) {}
89 
90  try {
91  manager[MAKE_CSTRING(module->getID() << "." << p->first)]->SetBinContent(pmt + 1, p->second.getValue<const bool>() ? 1.0 : 0.0);
92  }
93  catch(const exception& error) {}
94  }
95 
96  const JPMTParameters buffer = parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt));
97 
98  manager[MAKE_CSTRING(module->getID() << "." << "EFFICIENCY")]->SetBinContent(pmt + 1, getSurvivalProbability(buffer) * buffer.QE);
99  }
100  }
101 
102  if (showPMTAddress){
103 
104  for (JManager<string, TH1D>::iterator i = manager.begin(); i != manager.end(); ++i) {
105 
106  int id;
107 
108  istringstream(i->first) >> id;
109 
110  setAxisLabels(*i->second, "X", demo.get(id));
111  }
112  }
113 
114  manager.Write(outputFile.c_str());
115 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
Detector data structure.
Definition: JDetector.hh:89
Utility class to parse parameter values.
Definition: JProperties.hh:496
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
Lookup table for PMT addresses in detector.
Dynamic ROOT object management.
string outputFile
Data structure for detector geometry and calibration.
Detector specific mapping between logical positions and readout channels of PMTs in optical modules...
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
I/O formatting auxiliaries.
Detector file.
Definition: JHead.hh:224
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void setAxisLabels(TAxis *axis, const JModuleAddressMap &memo)
Set axis with PMT address labels.
Auxiliary class for map of PMT parameters.
int debug
debug level
Definition: JSirene.cc:63
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
double getSurvivalProbability(const JPMTParameters &parameters)
Get model dependent probability that a one photo-electron hit survives the simulation of the PMT assu...
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
Data structure for PMT parameters.
do set_variable DETECTOR_TXT $WORKDIR detector
KM3NeT DAQ constants, bit handling, etc.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
double QE
relative quantum efficiency