Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JDrawPDG.cc File Reference

Auxiliary program to draw PDF of Cherenkov light from EM-shower. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JPhysics/JPDF.hh"
#include "JPhysics/Antares.hh"
#include "JPhysics/KM3NeT.hh"
#include "JPhysics/JPDFSupportkit.hh"
#include "JTools/JFunction1D_t.hh"
#include "JTools/JQuantiles.hh"
#include "JTools/JAbstractHistogram.hh"
#include "JGeometry3D/JAngle3D.hh"
#include "Jeep/JProperties.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to draw PDF of Cherenkov light from EM-shower.

Author
mdejong

Definition in file JDrawPDG.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 30 of file JDrawPDG.cc.

31{
32 using namespace std;
33 using namespace JPP;
34
36
37 string outputFile;
39 double epsilon;
40 JAbsorptionLength absorptionLength;
41 JScatteringLength scatteringLength;
42 JScatteringProbability scatteringProbability;
43 double E;
44 double D;
45 double cd;
46 JAngle3D dir;
47 vector<int> function;
48 JHistogram_t histogram;
49 int debug;
50
51 try {
52
53 JProperties properties;
54
55 properties.insert(gmake_property(absorptionLength));
56 properties.insert(gmake_property(scatteringLength));
57 properties.insert(gmake_property(scatteringProbability));
58
59 JParser<> zap("Auxiliary program to draw PDF of Cherenkov light from EM-shower.");
60
61 zap['@'] = make_field(properties, endl
62 << "possible options absorptionLength: " << get_keys(absorptionLength) << endl
63 << "possible options scatteringLength: " << get_keys(scatteringLength) << endl
64 << "possible options scatteringProbability: " << get_keys(scatteringProbability) << endl) = JPARSER::initialised();
65 zap['o'] = make_field(outputFile) = "";
66 zap['n'] = make_field(numberOfPoints, "points for integration") = 25;
67 zap['e'] = make_field(epsilon, "precision for integration") = 1.0e-10;
68 zap['E'] = make_field(E, "shower energy [GeV]") = 1.0;
69 zap['R'] = make_field(D, "distance [m]");
70 zap['c'] = make_field(cd, "cosine emission angle");
71 zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
72 zap['F'] = make_field(function, "PDF type");
73 zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
74 zap['d'] = make_field(debug) = 0;
75
76 zap(argc, argv);
77 }
78 catch(const exception &error) {
79 FATAL(error.what() << endl);
80 }
81
82
83 const JPDF_C
84 pdf(NAMESPACE::getPhotocathodeArea(),
85 NAMESPACE::getQE,
86 NAMESPACE::getAngularAcceptance,
87 JAbsorptionLength::getAbsorptionLength,
88 JScatteringLength::getScatteringLength,
89 JScatteringProbability::getScatteringProbability,
90 NAMESPACE::getAmbientPressure(),
94 epsilon);
95
96
97 if (outputFile == "") {
98
99 cout << "enter time (^C to exit) > " << flush;
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) << cd << ' '
109 << FIXED(5,2) << dir.getTheta() << ' '
110 << FIXED(5,2) << dir.getPhi() << ' '
111 << FIXED(5,1) << dt << ' '
112 << SCIENTIFIC(9,3) << pdf.getLightFromEMshower(*F, E, D, cd, dir.getTheta(), dir.getPhi(), dt) << endl;
113 }
114 }
115
116 return 0;
117 }
118
119
120 TFile out(outputFile.c_str(), "recreate");
121
122 //const double t0 = D * getIndexOfRefraction() / C; // time [ns]
123 const double t0 = 0.0; // time [ns]
124
125 if (!histogram.is_valid()) {
126
127 if (function.size() == 1 && function[0] == DIRECT_LIGHT_FROM_MUON) {
128
129 histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
130
131 histogram.setBinWidth(0.1);
132
133 } else {
134
135 histogram = JHistogram_t(t0 - 20.0, t0 + 1000.0);
136
137 histogram.setBinWidth(0.5);
138 }
139 }
140
141 TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
142
144
145 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
146
147 const double dt = h0.GetBinCenter(i) - t0;
148
149 double value = 0.0;
150
151 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
152 if (*F == SCATTERED_LIGHT_FROM_MUON_5D)
153 value += pdf.getScatteredLightFromMuon(D, cd, dir.getTheta(), dir.getPhi(), dt);
154 else
155 value += pdf.getLightFromEMshower(*F, D, cd, dir.getTheta(), dir.getPhi(), dt) * E;
156 }
157
158 h0.SetBinContent(i, value);
159
160 f1[dt] = value;
161 }
162
163 f1.setExceptionHandler(new JSplineFunction1S_t::JDefaultResult(JMATH::zero));
164 f1.compile();
165
166 try {
167
168 JQuantiles quantiles(f1);
169
170 DEBUG("int " << quantiles.getIntegral() << endl);
171 DEBUG("x " << quantiles.getX() << endl);
172 DEBUG("y " << quantiles.getY() << endl);
173 DEBUG("FWHM " << quantiles.getFWHM() << endl);
174 }
175 catch(const exception&) {}
176
177 out.Write();
178 out.Close();
179}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
int numberOfPoints
Definition JResultPDF.cc:22
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
Quantile calculator for a given interpolating function.
Definition JQuantiles.hh:34
T getLowerLimit() const
Get lower limit.
Definition JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
double getMinimalWavelength()
Get minimal wavelength for PDF evaluations.
double getMaximalWavelength()
Get maximal wavelength for PDF evaluations.
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
Auxiliary data structure to customize absorption length.
Auxiliary data structure to customize scattering length.
Auxiliary data structure to customize scattering probability.
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