Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Functions
JPlotPMTSystematics.cc File Reference

Auxiliary application to convert PMT parameters text file to ROOT histograms. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "km3net-dataformat/online/JDAQ.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JTools/JRange.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 convert PMT parameters text file to ROOT histograms.

Author
mkarel

Definition in file JPlotPMTSystematics.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JPlotPMTSystematics.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32 
33  typedef JRange<double> JRange_t;
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
TPaveText * p1
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:72
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
JKey_t first
Definition: JPair.hh:128
JValue_t second
Definition: JPair.hh:129
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
std::map< int, range_type > map_type
Definition: JSTDTypes.hh:14
Type definition of range.
Definition: JHead.hh:43
Detector file.
Definition: JHead.hh:227