Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JDrawPD0.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TH1D.h"
9
10#include "JPhysics/JPDF.hh"
11#include "JPhysics/Antares.hh"
12#include "JPhysics/KM3NeT.hh"
15#include "JTools/JQuantiles.hh"
17#include "Jeep/JProperties.hh"
18#include "Jeep/JPrint.hh"
19#include "Jeep/JParser.hh"
20#include "Jeep/JMessage.hh"
21
22
23/**
24 * \file
25 *
26 * Auxiliary program to draw PDF of Cherenkov light from bright point.
27 * \author mdejong
28 */
29int main(int argc, char **argv)
30{
31 using namespace std;
32 using namespace JPP;
33
35
36 string outputFile;
38 double epsilon;
39 PDF::configuration_type configuration;
40 double E;
41 double D;
42 double ct;
43 vector<int> function;
44 JHistogram_t histogram;
45 int debug;
46
47 try {
48
49 JProperties properties = configuration.getProperties();
50
51 JParser<> zap("Auxiliary program to draw PDF of Cherenkov light from bright point.");
52
53 zap['@'] = make_field(properties, PDF::help() << configuration) = JPARSER::initialised();
54 zap['o'] = make_field(outputFile) = "";
55 zap['n'] = make_field(numberOfPoints, "points for integration") = 25;
56 zap['e'] = make_field(epsilon, "precision for integration") = 1.0e-10;
57 zap['E'] = make_field(E, "shower energy [GeV]");
58 zap['R'] = make_field(D, "distance [m]");
59 zap['c'] = make_field(ct, "cosine PMT angle");
60 zap['F'] = make_field(function, "PDF type");
61 zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
62 zap['d'] = make_field(debug) = 0;
63
64 zap(argc, argv);
65 }
66 catch(const exception &error) {
67 FATAL(error.what() << endl);
68 }
69
70
71 const JPDF_C
72 pdf(NAMESPACE::getPhotocathodeArea(),
73 PDF::getQE,
74 PDF::getAngularAcceptance,
75 PDF::getAbsorptionLength,
76 PDF::getScatteringLength,
77 PDF::getScatteringProbability,
78 NAMESPACE::getAmbientPressure(),
79 getMinimalWavelength(),
80 getMaximalWavelength(),
82 epsilon);
83
84
85 if (outputFile == "") {
86
87 cout << "enter time (^C to exit) > " << flush;
88
89 for (double dt; cin >> dt; ) {
90
91 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
92
93 cout << setw(2) << *F << ' '
94 << SCIENTIFIC(7,1) << E << ' '
95 << FIXED(5,1) << D << ' '
96 << FIXED(5,2) << ct << ' '
97 << FIXED(5,1) << dt << ' '
98 << SCIENTIFIC(9,3) << pdf.getLightFromBrightPoint(*F, D, ct, dt) * E << endl;
99 }
100 }
101
102 return 0;
103 }
104
105
106 TFile out(outputFile.c_str(), "recreate");
107
108 //const double t0 = D * getIndexOfRefraction() / C; // time [ns]
109 const double t0 = 0.0; // time [ns]
110
111 if (!histogram.is_valid()) {
112
113 if (function.size() == 1 && function[0] == DIRECT_LIGHT_FROM_BRIGHT_POINT) {
114
115 histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
116
117 histogram.setBinWidth(0.1);
118
119 } else {
120
121 histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
122
123 histogram.setBinWidth(0.5);
124 }
125 }
126
127 TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
128
130
131 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
132
133 const double dt = h0.GetBinCenter(i) - t0;
134
135 double value = 0.0;
136
137 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
138 value += pdf.getLightFromBrightPoint(*F, D, ct, dt) * E;
139 }
140
141 h0.SetBinContent(i, value);
142
143 f1[dt] = value;
144 }
145
146 f1.compile();
147
148 try {
149
150 JQuantiles quantiles(f1);
151
152 DEBUG("int " << quantiles.getIntegral() << endl);
153 DEBUG("x " << quantiles.getX() << endl);
154 DEBUG("y " << quantiles.getY() << endl);
155 DEBUG("FWHM " << quantiles.getFWHM() << endl);
156 }
157 catch(const exception&) {}
158
159 out.Write();
160 out.Close();
161}
Properties of Antares PMT and deep-sea water.
string outputFile
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2107
I/O formatting auxiliaries.
Utility class to parse parameter values.
int numberOfPoints
Definition JResultPDF.cc:22
Properties of KM3NeT PMT and deep-sea water.
Utility class to parse parameter values.
Utility class to parse command line options.
Definition JParser.hh:1664
Probability Density Functions of the time response of a PMT with an implementation of the JAbstractPM...
Definition JPDF.hh:2188
double getLightFromBrightPoint(const int type, const double D_m, const double ct, const double t_ns) const
Probability density function for direct light from isotropic light source.
Definition JPDF.hh:1929
Quantile calculator for a given interpolating function.
Definition JQuantiles.hh:34
double getIntegral() const
Get integral of function.
double getY() const
Get value of maximum.
double getX() const
Get position of maximum.
double getFWHM() const
Get Full Width at Half Maximum.
T getLowerLimit() const
Get lower limit.
Definition JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
Template class for spline interpolation in 1D.
Definition JSpline.hh:734
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:66
Auxiliary data structure for complete configuration.
JProperties getProperties()
Get properties.
Manipulator for help output.
Simple data structure for histogram binning.
void setBinWidth(const abscissa_type dx, int option=0)
Set bin width.
bool is_valid() const
Check validity of histogram binning.
int getNumberOfBins() const
Get number of bins.
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488