Jpp 19.3.0-rc.5
the software that should make you happy
Loading...
Searching...
No Matches
JPlotK40.cc File Reference

Auxiliary plot fit function of JFitK40.cc. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDetector/JModule.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorSupportkit.hh"
#include "JCalibrate/JCalibrateK40.hh"
#include "JCalibrate/JFitK40.hh"
#include "Jeep/JProperties.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 plot fit function of JFitK40.cc.

Author
mdejong

Definition in file JPlotK40.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 31 of file JPlotK40.cc.

32{
33 using namespace std;
34 using namespace JPP;
35
36 JK40Parameters K40 = JK40Parameters::getInstance();
37
38 string detectorFile;
39 string outputFile;
40 int debug;
41
42 try {
43
44 JProperties properties;
45
46 properties.insert(gmake_property(K40.R));
47 properties.insert(gmake_property(K40.p1));
48 properties.insert(gmake_property(K40.p2));
49 properties.insert(gmake_property(K40.p3));
50 properties.insert(gmake_property(K40.p4));
51
52 JParser<> zap("Auxiliary plot fit function of JFitK40.cc.");
53
54 zap['@'] = make_field(properties) = JPARSER::initialised();
55 zap['a'] = make_field(detectorFile) = "";
56 zap['o'] = make_field(outputFile, "output file.") = "k40.root";
57 zap['d'] = make_field(debug, "debug.") = 1;
58
59 zap(argc, argv);
60 }
61 catch(const exception &error) {
62 FATAL(error.what() << endl);
63 }
64
65
66 JModule module;
67
68 if (detectorFile != "") {
69
71
72 try {
73 load(detectorFile, detector);
74 }
75 catch(const JException& error) {
76 FATAL(error);
77 }
78
79 module = detector[0];
80
81 } else {
82
83 module = getModule<JKM3NeT_t>(1001);
84 }
85
86 const JModel model(module, K40);
87
88 const int nx = model.getNumberOfPairs();
89 const double xmin = -0.5;
90 const double xmax = nx - 0.5;
91
92 if (debug >= debug_t) {
93 for (size_t i = 0; i != module.size(); ++i) {
94 DEBUG("PMT " << FILL(2,'0') << i << ' ' << module[i].getDirection() << endl);
95 }
96 }
97
98 TFile out(outputFile.c_str(), "recreate");
99
100 TH1D h1("h1", NULL, nx, xmin, xmax);
101
102 double R = 0.0;
103
104 for (int ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
105
106 const Double_t x = h1.GetXaxis()->GetBinCenter(ix);
107
108 const pair_type pair = model.getPair((int) x);
109 const double rate = model.getValue(pair);
110
111 R += rate;
112
113 DEBUG("bin " << setw(3) << ix << ' '
114 << "(" << FILL(2,'0') << pair.first << "," << FILL(2,'0') << pair.second << ")" << FILL() << ' '
115 << FIXED(6,3) << getDot(module[pair.first] .getDirection(),
116 module[pair.second].getDirection()) << ' '
117 << FIXED(6,3) << rate << endl);
118
119 h1.SetBinContent(ix, rate);
120 }
121
122 cout << "Total rate " << FIXED(7,3) << R << " [Hz]." << endl;
123
124 out.Write();
125 out.Close();
126}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#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 gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Detector data structure.
Definition JDetector.hh:96
Data structure for a composite optical module.
Definition JModule.hh:75
Utility class to parse parameter values.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
const double xmax
const double xmin
JDirection3D getDirection(const Vec &dir)
Get direction.
double getDot(const JNeutrinoDirection &first, const JNeutrinoDirection &second)
Dot product.
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
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Livetime of noise data.
Definition JHead.hh:1062
Detector file.
Definition JHead.hh:227
Model for fit to acoustics data.
Fit parameters for two-fold coincidence rate due to K40.
Definition JFitK40.hh:700
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Data structure for a pair of indices.