Jpp  19.1.0-rc.1
the software that should make you happy
JDrawLED.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 "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 #include "JPhysics/JLED.hh"
13 #include "JPhysics/JPDFToolkit.hh"
14 #include "JPhysics/Antares.hh"
15 #include "JPhysics/KM3NeT.hh"
16 
17 #include "JTools/JSpline.hh"
18 #include "JTools/JQuantiles.hh"
19 #include "JTools/JToolsToolkit.hh"
20 
21 
23 
24 std::istream& operator>>(std::istream& in, orientation& x) { return in >> x.first >> x.second; }
25 std::ostream& operator<<(std::ostream& out, const orientation& x) { return out << x.first << ' ' << x.second; }
26 
27 
28 /**
29  * Light yield from %LED (number of p.e. per unit solid angle per unit time).
30  */
31 class LED : public JPHYSICS::JAbstractLED {
32 public:
33  /**
34  * Constructor.
35  */
36  LED()
37  {}
38 
39  /**
40  * Light yield from %LED (number of p.e. per unit solid angle per unit time).
41  *
42  * \param ct zenith angle of emission
43  * \param phi azimuth angle of emission
44  * \param dt time of emission [ns]
45  * \return d^2P / dOmega dt [npe/ns/sr]
46  */
47  double getLightFromLED(const double ct,
48  const double phi,
49  const double dt) const
50  {
51  using namespace JPP;
52 
53  static const double sigma = 2.0;
54 
55  const double x = dt / sigma;
56 
57  return exp(-0.5*x*x) / (sigma*sqrt(2*PI)) / (4*PI);
58  }
59 };
60 
61 
62 /**
63  * Angular acceptence of PMT
64  *
65  * \param x cosine of angle of incidence
66  * \return probability
67  */
68 inline double getAngularAcceptance(const double x)
69 {
71 }
72 
73 
74 /**
75  * \file
76  *
77  * Example program to draw PDF from %LED beacon.
78  * \author mdejong
79  */
80 int main(int argc, char **argv)
81 {
82  using namespace std;
83 
84  string outputFile;
85  int numberOfPoints;
86  int number_of_points;
87  double epsilon;
88  double D;
89  double ct;
90  orientation dir;
91  double wavelength;
92  double absorptionLength;
93  double scatteringLength;
94  int debug;
95 
96  try {
97 
98  JParser<> zap("Example program to draw PDF from LED beacon.");
99 
100  zap['o'] = make_field(outputFile) = "led.root";
101  zap['n'] = make_field(numberOfPoints) = 25;
102  zap['N'] = make_field(number_of_points) = 25;
103  zap['e'] = make_field(epsilon) = 1.0e-10;
104  zap['A'] = make_field(absorptionLength) = 50.0;
105  zap['S'] = make_field(scatteringLength) = 50.0;
106  zap['R'] = make_field(D);
107  zap['c'] = make_field(ct);
108  zap['D'] = make_field(dir);
109  zap['w'] = make_field(wavelength) = 470;
110  zap['d'] = make_field(debug) = 2;
111 
112  zap(argc, argv);
113  }
114  catch(const exception &error) {
115  FATAL(error.what() << endl);
116  }
117 
118 
119  const double theta = dir.first;
120  const double phi = dir.second;
121 
122  using namespace JPP;
123 
124  // set global parameters
125 
126  const double P_atm = 240.0; // ambient pressure [Atm]
127  const double tmin = -10.0; // minimal time of emission [ns]
128  const double tmax = +10.0; // maximal time of emission [ns]
129  const double A = 440e-4; // ANTARES photo-cathode area [m2]
130  const double R_Hz = 0.0e3; // singles rate [Hz]
131 
132  const JDispersion dispersion(P_atm);
133 
134  //const double ng = dispersion.getIndexOfRefractionGroup(wavelength);
135  const double lm = scatteringLength / 0.83;
136  const double lr = scatteringLength / 0.17;
137 
138  const double cs = 0.83 * 0.92; // average cosine scattering angle
139 
140  const double l_abs = absorptionLength;
141  const double ls = scatteringLength;
142  const double l_att = l_abs * lr / (l_abs + lr);
143 
144 
145  LED* led = new LED();
146 
147  cout << "Rayleigh scattering length " << lr << " m" << endl;
148  cout << "Mie scattering length " << lm << " m" << endl;
149  cout << "Absorption length " << l_abs << " m" << endl;
150 
151  const JLED_C
152  pdfMie(A,
153  led,
156  l_abs,
157  lm,
159  P_atm,
160  wavelength,
161  tmin,
162  tmax,
163  JCotangent(number_of_points),
165  epsilon);
166 
167 
168  const JLED_C
169  pdfRayleigh(A,
170  led,
173  l_att,
174  lr,
175  rayleigh,
176  P_atm,
177  wavelength,
178  tmin,
179  tmax,
180  JCotangent(number_of_points),
182  epsilon);
183 
184 
185  TFile out(outputFile.c_str(), "recreate");
186 
187  TH1D h0("h0", NULL, 430, -15.0, +200.0);
188  TH1D h1("h1", NULL, 430, -15.0, +200.0);
189  TH1D h2("h2", NULL, 430, -15.0, +200.0);
190  TH1D h3("h3", NULL, 430, -15.0, +200.0);
191  TH1D ha("ha", NULL, 430, -15.0, +200.0);
192 
193  JSplineFunction1S_t f[4];
195 
196 
197  for (int i = 1; i <= h1.GetNbinsX(); ++i) {
198 
199  const double t1 = h1.GetBinCenter(i);
200 
201  const double F1 = pdfMie .getDirectLightFromLED (D, ct, theta, phi, t1);
202  const double F2 = pdfMie .getScatteredLightFromLED(D, ct, theta, phi, t1);
203  const double F3 = pdfRayleigh.getScatteredLightFromLED(D, ct, theta, phi, t1);
204 
205 
206  h0.SetBinContent(i, F1 + F2 + F3);
207  h1.SetBinContent(i, F1);
208  h2.SetBinContent(i, F2);
209  h3.SetBinContent(i, F3);
210 
211  f[0][t1] = F1;
212  f[1][t1] = F2;
213  f[2][t1] = F3;
214  f[3][t1] = F1 + F2 + F3;
215 
216  f1[t1] = F1 + F2 + F3;
217  }
218 
219  f1.compile();
220 
221  for (int i = 3; i != sizeof(f)/sizeof(f[0]); ++i) {
222 
223  f[i].compile();
224 
225  JQuantiles quantiles(f[i]);
226 
227 
228  const double lz = l_abs * ls / (l_abs*(1.0-cs) + ls);
229 
230  NOTICE("int " << quantiles.getIntegral() * D*D * exp(D/lz) << endl);
231 
232  DEBUG("D " << D << endl);
233  DEBUG("ct " << ct << endl);
234  DEBUG("theta " << theta << endl);
235  DEBUG("phi " << phi << endl);
236  DEBUG("int " << quantiles.getIntegral() << endl);
237  DEBUG("t1 " << quantiles.getX() << endl);
238  DEBUG("max " << quantiles.getY() << endl);
239  DEBUG("FWHM " << quantiles.getFWHM() << endl);
240  }
241 
242 
243  const double Tmin = ha.GetXaxis()->GetXmin();
244  const double Tmax = ha.GetXaxis()->GetXmax();
245 
246  const double V = f1.rbegin()->getIntegral() + R_Hz * 1e-9 * (Tmax - Tmin); // integral [Tmin,Tmax]
247 
248  for (int i = 1; i <= ha.GetNbinsX(); ++i) {
249 
250  const double t1 = ha.GetBinCenter(i);
251 
252  JSplineFunction1S_t::result_type p = f1(t1);
253 
254  double v = p.v + R_Hz * 1e-9 * (t1 - Tmin);
255  double y = p.f + R_Hz * 1e-9; // function value
256 
257  const double W = exp(-v) * y / (1.0 - exp(-V));
258 
259  ha.SetBinContent(i,W);
260  }
261 
262  delete led;
263 
264  out.Write();
265  out.Close();
266 }
Properties of Antares PMT and deep-sea water.
string outputFile
std::pair< double, double > orientation
Definition: JDrawLED.cc:22
int main(int argc, char **argv)
Definition: JDrawLED.cc:80
std::istream & operator>>(std::istream &in, orientation &x)
Definition: JDrawLED.cc:24
double getAngularAcceptance(const double x)
Angular acceptence of PMT.
Definition: JDrawLED.cc:68
std::ostream & operator<<(std::ostream &out, const orientation &x)
Definition: JDrawLED.cc:25
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
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:2158
int numberOfPoints
Definition: JResultPDF.cc:22
This include file contains various recursive methods to operate on multi-dimensional collections.
Properties of KM3NeT PMT and deep-sea water.
Utility class to parse command line options.
Definition: JParser.hh:1714
Interface for emission profile from LED.
Definition: JLED.hh:34
Implementation of dispersion for water in deep sea.
Definition: JDispersion.hh:28
Probability Density Functions of the time response of a PMT (C-like interface)
Definition: JLED.hh:278
double getDirectLightFromLED(const double D_m, const double cd, const double theta, const double phi, const double t_ns) const
Probability density function for direct light from LED.
Definition: JLED.hh:108
double getScatteredLightFromLED(const double D_m, const double cd, const double theta, const double phi, const double t_ns) const
Probability density function for scattered light from LED.
Definition: JLED.hh:147
Numerical integrator for .
Definition: JQuadrature.hh:484
Quantile calculator for a given function.
Definition: JQuantiles.hh:108
double getIntegral() const
Get integral of function.
Definition: JQuantiles.hh:346
double getY() const
Get value of maximum.
Definition: JQuantiles.hh:324
double getX() const
Get position of maximum.
Definition: JQuantiles.hh:313
double getFWHM() const
Get Full Width at Half Maximum.
Definition: JQuantiles.hh:335
Light yield from LED (number of p.e.
Definition: JDrawLED.cc:31
double getLightFromLED(const double ct, const double phi, const double dt) const
Light yield from LED (number of p.e.
Definition: JDrawLED.cc:47
LED()
Constructor.
Definition: JDrawLED.cc:36
double getAngularAcceptance(const double x)
Get angular acceptance of PMT.
Definition: Antares.hh:281
double getQE(const double lambda, const bool option)
Get quantum efficiency of PMT.
Definition: Antares.hh:294
const double sigma[]
Definition: JQuadrature.cc:74
const JPolynome F1
Integral.
Definition: JQuadrature.cc:34
const JPolynome f1(1.0, 2.0, 3.0)
Function.
const double epsilon
Definition: JQuadrature.cc:21
static const double PI
Mathematical constants.
double henyey_greenstein(const double g, const double x)
Auxiliary method to describe light scattering in water (Henyey-Greenstein).
double rayleigh(const double a, const double x)
Auxiliary method to describe light scattering in water (Rayleigh).
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
data_type v[N+1][M+1]
Definition: JPolint.hh:866
Definition: JSTDTypes.hh:14
double getIntegral(const double x) const
Integral value.
Definition: JPolynome.hh:276
Auxiliary data structure to list files in directory.
Definition: JFilesystem.hh:20
Type definition of a spline interpolation method based on a JCollection with JResultPDF result type.