Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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;
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 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
TPaveText * p1
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
Data structure for a composite optical module.
Definition: JModule.hh:68
Detector data structure.
Definition: JDetector.hh:89
*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
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
string outputFile
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int getID() const
Get identifier.
Definition: JObjectID.hh:50
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
int debug
debug level
Definition: JSirene.cc:63
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
int getString() const
Get string number.
Definition: JLocation.hh:134
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
do set_variable DETECTOR_TXT $WORKDIR detector
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41