Jpp  15.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPlotPMTParameters.cc File Reference

Auxiliary application to plot PMT parameters. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "km3net-dataformat/online/JDAQ.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JPMTParametersMap.hh"
#include "JDetector/JPMTParametersToolkit.hh"
#include "JDetector/JDetectorAddressMap.hh"
#include "JDetector/JDetectorAddressMapToolkit.hh"
#include "JROOT/JManager.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary application to plot PMT parameters.

Author
mdejong

Definition in file JPlotPMTParameters.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JPlotPMTParameters.cc.

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
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.
string outputFile
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
Detector file.
Definition: JHead.hh:196
#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.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
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
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
double QE
relative quantum efficiency