Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPlotPMTParameters2D.cc File Reference

Auxiliary application to plot PMT parameters. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "JDAQ/JDAQ.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JPMTParametersMap.hh"
#include "JGizmo/JManager.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 JPlotPMTParameters2D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file JPlotPMTParameters2D.cc.

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
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Definition: JScale.hh:47
Utility class to parse parameter values.
Definition: JProperties.hh:484
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:611
string outputFile
#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
#define FATAL(A)
Definition: JMessage.hh:65
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