Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JDrawPDF.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/JElement.hh"
15#include "JTools/JQuantiles.hh"
18#include "Jeep/JProperties.hh"
19#include "Jeep/JPrint.hh"
20#include "Jeep/JParser.hh"
21#include "Jeep/JMessage.hh"
22#include "JPhysics/JGeane.hh"
23
24
25/**
26 * Scaling of absorption and scattering length.
27 */
30
31inline double getAbsorptionLength(const double lambda)
32{
33 return absorptionLengthFactor * NAMESPACE::getAbsorptionLength(lambda);
34}
35
36
37inline double getScatteringLength(const double lambda)
38{
39 return scatteringLengthFactor * NAMESPACE::getScatteringLength(lambda);
40}
41
42
43/**
44 * \file
45 *
46 * Auxiliary program to draw PDF of Cherenkov light from muon.
47 * \author mdejong, bofearraigh
48 */
49int main(int argc, char **argv)
50{
51 using namespace std;
52 using namespace JPP;
53
55
56 string outputFile;
58 double epsilon;
59 double E;
60 double R;
61 double z;
62 JAngle3D dir;
63 vector<int> function;
64 JHistogram_t histogram;
65 int debug;
66
67 try {
68
69 JProperties properties;
70
71 properties.insert(gmake_property(JPHYSICS::MODULE_RADIUS_M));
72
73 JParser<> zap("Auxiliary program to draw PDF of Cherenkov light from muon.");
74
75 zap['@'] = make_field(properties) = JPARSER::initialised();
76 zap['o'] = make_field(outputFile) = "";
77 zap['n'] = make_field(numberOfPoints, "points for integration") = 25;
78 zap['e'] = make_field(epsilon, "precision for integration") = 1.0e-10;
79 zap['A'] = make_field(absorptionLengthFactor, "scaling factor") = 1.0;
80 zap['S'] = make_field(scatteringLengthFactor, "scaling factor") = 1.0;
81 zap['E'] = make_field(E, "muon energy at vertex [GeV]")= 1.0;
82 zap['R'] = make_field(R, "distance of approach [m]");
83 zap['z'] = make_field(z, "PMT z-position [m]");
84 zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
85 zap['F'] = make_field(function, "PDF type");
86 zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
87 zap['d'] = make_field(debug) = 0;
88
89 zap(argc, argv);
90 }
91 catch(const exception &error) {
92 FATAL(error.what() << endl);
93 }
94
95
96 const JPDF_C
97 pdf(NAMESPACE::getPhotocathodeArea(),
98 NAMESPACE::getQE,
99 NAMESPACE::getAngularAcceptance,
102 NAMESPACE::getScatteringProbability,
103 NAMESPACE::getAmbientPressure(),
104 getMinimalWavelength(),
105 getMaximalWavelength(),
107 epsilon);
108
109 const double z_emission = z - R/getTanThetaC(); // emission point z-position
110 const double E_emission = gWater.getE(E, z_emission ); // Get energy of muon at emission point
111
112 if (outputFile == "") {
113
114 cout << "enter time (^C to exit) > " << flush;
115
116 for (double dt; cin >> dt; ) {
117
118 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
119
120 cout << setw(2) << *F << ' '
121 << SCIENTIFIC(7,1) << E << ' '
122 << FIXED(5,1) << R << ' '
123 << FIXED(5,1) << z << ' '
124 << FIXED(5,2) << dir.getTheta() << ' '
125 << FIXED(5,2) << dir.getPhi() << ' '
126 << FIXED(5,1) << dt << ' '
127 << SCIENTIFIC(9,3) << pdf.getLightFromMuon(*F, E_emission, R, dir.getTheta(), dir.getPhi(), dt) * E_emission << endl;
128 }
129 }
130
131 return 0;
132 }
133
134
135 TFile out(outputFile.c_str(), "recreate");
136
137 const double t0 = 0.0; // time [ns]
138
139 if (!histogram.is_valid()) {
140
141 if (function.size() == 1 && function[0] == DIRECT_LIGHT_FROM_MUON) {
142
143 histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
144
145 histogram.setBinWidth(0.1);
146
147 } else {
148
149 histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
150
151 histogram.setBinWidth(0.5);
152 }
153 }
154
155 TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
156
158
159 if ( E_emission >= MASS_MUON* (1/SIN_THETA_C_WATER ) ) { // muon emission energy has to be above Cherenkov threshold
160
161 if (z_emission >= 0 && z_emission <= gWater(E)) { // emission point is between start and end point of muon
162 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
163
164 const double dt = h0.GetBinCenter(i) - t0;
165
166 double value = 0.0;
167
168 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
169 value += pdf.getLightFromMuon(*F, E_emission, R, dir.getTheta(), dir.getPhi(), dt);
170 }
171
172 h0.SetBinContent(i, value);
173
174 f1[dt] = value;
175 }
176 }
177 }
178
179 f1.setExceptionHandler(new JSplineFunction1S_t::JDefaultResult(JMATH::zero));
180 f1.compile();
181
182 try {
183
184 const double T_ns = 5; // [ns]
185
186 JQuantiles quantiles(f1);
187
188 const double t1 = quantiles.getX();
189 const double y = f1(t1 + T_ns).v - f1(t1 - T_ns).v;
190
191 DEBUG("E " << E << endl);
192 DEBUG("E_emission" << E_emission << endl);
193 DEBUG("R " << R << endl);
194 DEBUG("z " << z << endl);
195 DEBUG("theta " << dir.getTheta() << endl);
196 DEBUG("phi " << dir.getPhi() << endl);
197 DEBUG("int " << quantiles.getIntegral() << endl);
198 DEBUG("t1 " << t1 << endl);
199 DEBUG("max " << quantiles.getY() << endl);
200 DEBUG("FWHM " << quantiles.getFWHM() << endl);
201 DEBUG("int[] " << y << endl);
202 }
203 catch(const exception&) {}
204
205 out.Write();
206 out.Close();
207}
Properties of Antares PMT and deep-sea water.
string outputFile
int main(int argc, char **argv)
Definition JDrawPDF.cc:49
double getAbsorptionLength(const double lambda)
Definition JDrawPDF.cc:31
double getScatteringLength(const double lambda)
Definition JDrawPDF.cc:37
double absorptionLengthFactor
Scaling of absorption and scattering length.
Definition JDrawPDF.cc:28
double scatteringLengthFactor
Definition JDrawPDF.cc:29
The elements in a collection are sorted according to their abscissa values and a given distance opera...
Energy loss of muon.
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.
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
int numberOfPoints
Definition JResultPDF.cc:22
Properties of KM3NeT PMT and deep-sea water.
Utility class to parse parameter values.
Data structure for angles in three dimensions.
Definition JAngle3D.hh:35
double getTheta() const
Get theta angle.
Definition JAngle3D.hh:86
double getPhi() const
Get phi angle.
Definition JAngle3D.hh:97
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:2186
double getLightFromMuon(const int type, const double E_GeV, const double R_m, const double theta, const double phi, const double t_ns) const
Probability density function for light from muon.
Definition JPDF.hh:1752
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
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
static double MODULE_RADIUS_M
Radius of optical module [m].
Definition JPDF.hh:41
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:68
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.
void setExceptionHandler(const JSupervisor &supervisor)
Set the supervisor for handling of exceptions.
Type definition of a spline interpolation method based on a JCollection with JResultPDF result type.
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488