Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JPlotPMTSystematics.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#include "TH2D.h"
9
11
14
15#include "JTools/JRange.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 convert PMT parameters text file to ROOT histograms.
25 * \author mkarel
26 */
27
28int main(int argc, char **argv)
29{
30 using namespace std;
31 using namespace JPP;
32
33 typedef JRange<double> JRange_t;
34 typedef multimap<string, JRange_t> map_type;
35
36 string detectorFile;
37 string inputFile;
38 string outputFile;
39 map_type parameters;
40 int debug;
41
42 try {
43
44 JParser<> zap;
45
46 zap['a'] = make_field(detectorFile);
47 zap['f'] = make_field(inputFile);
48 zap['o'] = make_field(outputFile) = "PMTsystematics.root";
49 zap['p'] = make_field(parameters);
50 zap['d'] = make_field(debug) = 1;
51
52 zap(argc, argv);
53 }
54 catch(const exception &error) {
55 FATAL(error.what() << endl);
56 }
57
58 using namespace KM3NETDAQ;
59
61
62 try {
63 load(detectorFile, detector);
64 }
65 catch(const JException& error) {
66 FATAL(error);
67 }
68
69 if (detector.empty()) {
70 FATAL("Empty detector." << endl);
71 }
72
73 const int number_of_strings = getNumberOfStrings(detector);
74 const int number_of_floors = getNumberOfFloors (detector);
75
76 const int ny = number_of_strings * number_of_floors;
77
78
79 TFile* in = TFile::Open(inputFile.c_str(), "read");
80
81 if (in == NULL) {
82 FATAL("No data in inputfile " << inputFile << endl);
83 }
84
85 TFile out(outputFile.c_str(),"recreate");
86
87 for (map_type::const_iterator i = parameters.begin(); i != parameters.end(); ++i) {
88
89 const string key = i->first;
90 const JRange_t range = i->second;
91
92 TH1D h1(MAKE_CSTRING(key << ".1D"),
93 NULL,
94 100, range.first, range.second);
95
96 TH2D h2(MAKE_CSTRING(key << ".2D"),
97 NULL,
98 NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5,
99 ny, -0.5, ny - 0.5);
100
101 // fill
102
103 for (size_t dom = 0; dom != detector.size(); ++dom) {
104
105 const JModule& module = detector.at(dom);
106
107 TH1D* p1 = (TH1D*) in->Get(MAKE_CSTRING(module.getID() << ".1" << key));
108
109 if (p1 == NULL) {
110 continue;
111 }
112
113 const int iy = (module.getString() - 1) * number_of_floors + module.getFloor();
114
115 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
116
117 const double value = p1->GetBinContent(pmt+1);
118
119 h1.Fill(value);
120
121 h2.SetBinContent(pmt+1, iy, value);
122 }
123 }
124
125 // axis labels
126
127 h1.GetXaxis()->SetTitle(key.c_str());
128 h1.GetYaxis()->SetTitle("PMTs");
129
130 h2.GetXaxis()->SetTitle("PMT DAQ index");
131
132 for (size_t dom = 0; dom != detector.size(); ++dom) {
133
134 const JModule& module = detector.at(dom);
135
136 h2.GetYaxis()->SetBinLabel(dom+1, MAKE_CSTRING(""
137 << setw(3) << setfill('0') << module.getString() << ' '
138 << setw(2) << setfill('0') << module.getFloor()));
139 }
140
141 h2.GetZaxis()->SetTitle(key.c_str());
142
143 // write
144 h2.Write();
145 h1.Write();
146 }
147
148 out.Close();
149}
string outputFile
KM3NeT DAQ constants, bit handling, etc.
Data structure for detector geometry and calibration.
TPaveText * p1
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
I/O formatting auxiliaries.
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
Auxiliary class to define a range between two values.
Detector data structure.
Definition JDetector.hh:96
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
Data structure for a composite optical module.
Definition JModule.hh:75
General exception.
Definition JException.hh:24
int getID() const
Get identifier.
Definition JObjectID.hh:50
Utility class to parse command line options.
Definition JParser.hh:1698
Range of values.
Definition JRange.hh:42
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Detector file.
Definition JHead.hh:227