Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JEMShower.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/KM3NeT.hh"
13
14#include "Jeep/JPrint.hh"
15#include "Jeep/JParser.hh"
16#include "Jeep/JMessage.hh"
17
18#include <cmath>
19
23
24namespace {
25
27
28 /**
29 * Auxiliary class for correction of number of photons from EM-shower.
30 */
31 class JEMShowerCorrection
32 {
33 public:
34 /**
35 * Default constructor.
36 */
37 JEMShowerCorrection()
38 {
39 using namespace JPP;
40
41 const double P_Atm = 240.0; // ambient pressure [Atm]
42 const double wmin = getMinimalWavelength(); // [nm]
43 const double wmax = getMaximalWavelength(); // [nm]
44
45 const JDispersion dispersion(P_Atm);
46
47 const double xmin = 1.0 / wmax;
48 const double xmax = 1.0 / wmin;
49 const int nx = 10000;
50
51 double value = 0.0;
52
53 for (double x = xmin, dx = (xmax - xmin) / (double) nx; x <= xmax; x += dx) {
54
55 const double w = 1.0 / x;
56 const double dw = dx * w*w;
57
58 const double n = dispersion.getIndexOfRefractionPhase(w);
59
60 value += cherenkov(w,n) * dw;
61 }
62
63 value *= geanc(); // number of photons per GeV
64
65
66 f1[MASS_ELECTRON] = 0.00;
67 f1[ 1.0e-3] = 90.96 / 1.0e-3; // number of photons per GeV
68 f1[ 2.0e-3] = 277.36 / 2.0e-3; // from Geant4 simulation by Daniel Lopez
69 f1[ 3.0e-3] = 485.82 / 3.0e-3;
70 f1[ 4.0e-3] = 692.83 / 4.0e-3;
71 f1[ 5.0e-3] = 890.01 / 5.0e-3;
72 f1[ 6.0e-3] = 1098.53 / 6.0e-3;
73 f1[ 7.0e-3] = 1285.47 / 7.0e-3;
74 f1[ 8.0e-3] = 1502.86 / 8.0e-3;
75 f1[ 9.0e-3] = 1687.15 / 9.0e-3;
76 f1[10.0e-3] = 1891.00 / 10.0e-3;
77
78 f1.div(value);
79 f1.compile();
80
81 f2[-2.0] = log(1.891e3 / 1.0e-2);
82 f2[-1.0] = log(1.905e4 / 1.0e-1);
83 f2[ 0.0] = log(1.889e5 / 1.0e+0);
84 f2[+1.0] = log(1.875e6 / 1.0e+1);
85 f2[+2.0] = log(1.881e7 / 1.0e+2);
86
87 f2.sub(log(value));
88 f2.compile();
89 }
90
91
92 /**
93 * Get correction of number of photons from EM-shower as a function of energy.
94 *
95 * \param E energy [GeV]
96 * \return correction
97 */
98 double operator()(const double E) const
99 {
100 if (E <= f1.getXmin()) {
101
102 return 0.0;
103
104 } else if (E <= f1.getXmax()) {
105
106 return f1(E);
107
108 } else {
109
110 const double x = log10(E);
111
112 if (x <= f2.getXmin()) {
113
114 return exp(f2.begin()->getY());
115
116 } else if (x <= f2.getXmax()) {
117
118 return exp(f2(x));
119
120 } else {
121
122 return exp(f2.rbegin()->getY());
123 }
124 }
125 }
126
127
128 private:
131 };
132
133
134 /**
135 * Function object for EM-shower correction
136 */
137 static const JEMShowerCorrection getEMShowerCorrection;
138}
139
140
141/**
142 * \file
143 *
144 * Auxiliary program to draw npe as a function of EM-energy.
145 * \author mdejong
146 */
147int main(int argc, char **argv)
148{
149 using namespace std;
150
151 string outputFile;
152 int numberOfPoints;
153 double epsilon;
154 int debug;
155
156 try {
157
158 JParser<> zap("Auxiliary program to draw npe as a function of EM-energy.");
159
160 zap['o'] = make_field(outputFile) = "geanc.root";
161 zap['n'] = make_field(numberOfPoints) = 25;
162 zap['e'] = make_field(epsilon) = 1.0e-10;
163 zap['d'] = make_field(debug) = 2;
164
165 zap(argc, argv);
166 }
167 catch(const exception &error) {
168 FATAL(error.what() << endl);
169 }
170
171
172 using namespace JPP;
173
174 const JPDF_C
175 pdf(NAMESPACE::getPhotocathodeArea(),
176 NAMESPACE::getQE,
177 NAMESPACE::getAngularAcceptance,
178 NAMESPACE::getAbsorptionLength,
179 NAMESPACE::getScatteringLength,
180 NAMESPACE::getScatteringProbability,
181 NAMESPACE::getAmbientPressure(),
182 getMinimalWavelength(),
183 getMaximalWavelength(),
185 epsilon);
186
187
188 double xmin = -4.0;
189 double xmax = 0.0;
190
191 const double precision = 1.0e-10;
192
193 while (fabs(xmax - xmin) > precision) {
194
195 const double x = 0.5 * (xmin + xmax);
196 const double E = pow(10.0, x);
197
198 const double y = getEMShowerCorrection(E);
199
200 if (y < 0.5)
201 xmin = x;
202 else
203 xmax = x;
204 }
205
206 const double EMIN = pow(10.0, 0.5*(xmax + xmin));
207
208 NOTICE("Threshold kinetic energy [GeV] " << sqrt((EMIN + MASS_ELECTRON) * (EMIN - MASS_ELECTRON)) << endl);
209
210
211 TFile out(outputFile.c_str(), "recreate");
212
213 TH1D h0("h0", NULL, 10000, -4.0, +4.0);
214 TH1D h1("h1", NULL, 10000, -4.0, +4.0);
215
216 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
217
218 const Double_t x = h0.GetBinCenter(i);
219 const Double_t E = pow(10.0, x);
220
221 h0.SetBinContent(i, E * geanc() * pdf.getNumberOfPhotons());
222 h1.SetBinContent(i, getEMShowerCorrection(E));
223 }
224
225 out.Write();
226 out.Close();
227}
string outputFile
int main(int argc, char **argv)
Definition JEMShower.cc:147
General purpose messaging.
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Auxiliary methods for PDF calculations.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Physics constants.
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
Implementation of dispersion for water in deep sea.
Probability Density Functions of the time response of a PMT with an implementation of the JAbstractPM...
Definition JPDF.hh:2185
double getNumberOfPhotons() const
Number of Cherenkov photons per unit track length.
Definition JPDF.hh:325
const JPolynome f1(1.0, 2.0, 3.0)
Function.
const double xmax
const double xmin
double cherenkov(const double lambda, const double n)
Number of Cherenkov photons per unit track length and per unit wavelength.
double getMinimalWavelength()
Get minimal wavelength for PDF evaluations.
double geanc()
Equivalent muon track length per unit shower energy.
Definition JGeane.hh:28
double getMaximalWavelength()
Get maximal wavelength for PDF evaluations.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition JPolint.hh:791
JF1_t & div(const double factor)
Scale function.
Definition JMathlib.hh:267
Type definition of a 1st degree polynomial interpolation with result type double.