Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
Functions
JCombinatoricsK40.cc File Reference

Auxiliary program to project single PMT data from 2D histogram. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "JCalibrate/JCalibrateK40.hh"
#include "JROOT/JRootToolkit.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 program to project single PMT data from 2D histogram.

Author
mdejong

Definition in file JCombinatoricsK40.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 29 of file JCombinatoricsK40.cc.

30{
31 using namespace std;
32 using namespace JPP;
33
34 string detectorFile;
35 string inputFile;
36 string outputFile;
38 string extension;
39 int debug;
40
41 try {
42
43 JParser<> zap("Auxiliary program to project single PMT data from 2D histogram.");
44
45 zap['a'] = make_field(detectorFile, "detector file.");
46 zap['f'] = make_field(inputFile, "input file.");
47 zap['o'] = make_field(outputFile, "output file.") = "k40.root";
48 zap['P'] = make_field(pmt, "PMT identifier");
49 zap['e'] = make_field(extension, "histogram name extension") = _2R, _2S, _2F;
50 zap['d'] = make_field(debug, "debug flag.") = 1;
51
52 zap(argc, argv);
53 }
54 catch(const exception &error) {
55 FATAL(error.what() << endl);
56 }
57
58
60
61
63
64 try {
66 }
67 catch(const JException& error) {
68 FATAL(error);
69 }
70
71 const JModuleRouter router(detector);
72
73 const JModule& module = router.getModule(pmt.getModuleID());
74
76
77 combinatorics.configure(module.size());
78
80
81 if (debug >= debug_t) {
82
83 for (size_t i = 0; i != combinatorics.getNumberOfPairs(); ++i) {
84
86
87 cout << setw(3) << i << " -> (" << FILL(2,'0') << pair.first << "," << FILL(2,'0') << pair.second << FILL() << ")" << endl;
88 }
89 }
90
91 TFile in(inputFile.c_str(), "read");
92
93 TH2D* h2 = (TH2D*) in.Get(MAKE_CSTRING(pmt.getModuleID() << extension));
94
95 if (h2 == NULL) {
96 FATAL("Missing histogram for module " << pmt.getModuleID() << endl);
97 }
98
99 TH1D ha(MAKE_CSTRING(pmt.getModuleID() << '.' << FILL(2,'0') << pmt.getTDC() << ".1D"), NULL,
100 h2->GetYaxis()->GetNbins(), h2->GetYaxis()->GetXmin(), h2->GetYaxis()->GetXmax());
101
102 TH2D hb(MAKE_CSTRING(pmt.getModuleID() << '.' << FILL(2,'0') << pmt.getTDC() << ".2D"), NULL,
103 module.size(), -0.5, module.size() - 0.5,
104 h2->GetYaxis()->GetNbins(), h2->GetYaxis()->GetXmin(), h2->GetYaxis()->GetXmax());
105
106 for (int i = 0; i != (int) module.size(); ++i) {
107
108 if (i != pmt.getTDC()) {
109
110 const Int_t ix = combinatorics.getIndex(pmt.getTDC(), i) + 1;
111
112 for (Int_t iy = 1; iy <= h2->GetYaxis()->GetNbins(); ++iy) {
113
114 ha.SetBinContent(iy, ha.GetBinContent(iy) + h2->GetBinContent(ix,iy));
115 ha.SetBinError (iy, hypot(ha.GetBinError (iy), h2->GetBinError (ix,iy)));
116
117 hb.SetBinContent(i + 1, iy, h2->GetBinContent(ix,iy));
118 hb.SetBinError (i + 1, iy, h2->GetBinError (ix,iy));
119 }
120 }
121 }
122
123 TFile out(outputFile.c_str(), "recreate");
124
125 out << ha << hb;
126
127 out.Write();
128 out.Close();
129}
string outputFile
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#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
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Definition JModule.hh:76
int getModuleID() const
Get module identifier.
General exception.
Definition JException.hh:24
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to convert pair of indices to unique index and back.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Detector file.
Definition JHead.hh:227
Auxiliary class to sort pairs of PMT addresses within optical module.
Data structure for a pair of indices.