Jpp test-rotations-old
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"
13#include "JTools/JSpline.hh"
14#include "JTools/JQuantiles.hh"
16#include "Jeep/JPrint.hh"
17#include "Jeep/JParser.hh"
18#include "Jeep/JMessage.hh"
19
20
21/**
22 * Scaling of absorption and scattering length.
23 */
26
27inline double getAbsorptionLength(const double lambda)
28{
29 return absorptionLengthFactor * NAMESPACE::getAbsorptionLength(lambda);
30}
31
32
33inline double getScatteringLength(const double lambda)
34{
35 return scatteringLengthFactor * NAMESPACE::getScatteringLength(lambda);
36}
37
38
39/**
40 * \file
41 *
42 * Auxiliary program to draw PDF of Cherenkov light from bright point.
43 * \author mdejong
44 */
45int main(int argc, char **argv)
46{
47 using namespace std;
48 using namespace JPP;
49
51
52 string outputFile;
54 double epsilon;
55 double E;
56 double D;
57 double ct;
58 vector<int> function;
59 JHistogram_t histogram;
60 int debug;
61
62 try {
63
64 JParser<> zap("Auxiliary program to draw PDF of Cherenkov light from bright point.");
65
66 zap['o'] = make_field(outputFile) = "pd0.root";
67 zap['n'] = make_field(numberOfPoints, "points for integration") = 25;
68 zap['e'] = make_field(epsilon, "precision for integration") = 1.0e-10;
69 zap['A'] = make_field(absorptionLengthFactor, "scaling factor") = 1.0;
70 zap['S'] = make_field(scatteringLengthFactor, "scaling factor") = 1.0;
71 zap['E'] = make_field(E, "shower energy [GeV]");
72 zap['R'] = make_field(D, "distance [m]");
73 zap['c'] = make_field(ct, "cosine PMT angle");
74 zap['F'] = make_field(function, "PDF type");
75 zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
76 zap['d'] = make_field(debug) = 0;
77
78 zap(argc, argv);
79 }
80 catch(const exception &error) {
81 FATAL(error.what() << endl);
82 }
83
84
85 const JPDF_C
86 pdf(NAMESPACE::getPhotocathodeArea(),
87 NAMESPACE::getQE,
88 NAMESPACE::getAngularAcceptance,
91 NAMESPACE::getScatteringProbability,
92 NAMESPACE::getAmbientPressure(),
93 getMinimalWavelength(),
94 getMaximalWavelength(),
96 epsilon);
97
98
99 if (outputFile == "") {
100
101 for (double dt; cin >> dt; ) {
102
103 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
104
105 cout << setw(2) << *F << ' '
106 << SCIENTIFIC(7,1) << E << ' '
107 << FIXED(5,1) << D << ' '
108 << FIXED(5,2) << ct << ' '
109 << FIXED(5,1) << dt << ' '
110 << SCIENTIFIC(9,3) << pdf.getLightFromBrightPoint(*F, D, ct, dt) * E << endl;
111 }
112 }
113
114 return 0;
115 }
116
117
118 TFile out(outputFile.c_str(), "recreate");
119
120 //const double t0 = D * getIndexOfRefraction() / C; // time [ns]
121 const double t0 = 0.0; // time [ns]
122
123 if (!histogram.is_valid()) {
124
125 if (function.size() == 1 && function[0] == DIRECT_LIGHT_FROM_BRIGHT_POINT) {
126
127 histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
128
129 histogram.setBinWidth(0.1);
130
131 } else {
132
133 histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
134
135 histogram.setBinWidth(0.5);
136 }
137 }
138
139 TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
140
142
143 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
144
145 const double dt = h0.GetBinCenter(i) - t0;
146
147 double value = 0.0;
148
149 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
150 value += pdf.getLightFromBrightPoint(*F, D, ct, dt) * E;
151 }
152
153 h0.SetBinContent(i, value);
154
155 f1[dt] = value;
156 }
157
158 f1.compile();
159
160 try {
161
162 JQuantiles quantiles(f1);
163
164 DEBUG("int " << quantiles.getIntegral() << endl);
165 DEBUG("x " << quantiles.getX() << endl);
166 DEBUG("y " << quantiles.getY() << endl);
167 DEBUG("FWHM " << quantiles.getFWHM() << endl);
168 }
169 catch(const exception&) {}
170
171 out.Write();
172 out.Close();
173}
Properties of Antares PMT and deep-sea water.
string outputFile
int main(int argc, char **argv)
Definition JDrawPD0.cc:45
double getAbsorptionLength(const double lambda)
Definition JDrawPD0.cc:27
double getScatteringLength(const double lambda)
Definition JDrawPD0.cc:33
double absorptionLengthFactor
Scaling of absorption and scattering length.
Definition JDrawPD0.cc:24
double scatteringLengthFactor
Definition JDrawPD0.cc:25
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:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
int numberOfPoints
Definition JResultPDF.cc:22
Properties of KM3NeT PMT and deep-sea water.
Utility class to parse command line options.
Definition JParser.hh:1698
Probability Density Functions of the time response of a PMT with an implementation of the JAbstractPM...
Definition JPDF.hh:2185
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:1928
Quantile calculator for a given function.
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
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
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.
Type definition of a spline interpolation method based on a JCollection with double result type.
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488