Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JShowerEnergyRegressor.hh
Go to the documentation of this file.
1#ifndef __JFIT__JSHOWERENERGYREGRESSOR__
2#define __JFIT__JSHOWERENERGYREGRESSOR__
3
8
10#include "JTools/JResult.hh"
11
13#include "JMath/JZero.hh"
14
16
17#include "JFit/JEnergy.hh"
18#include "JFit/JSimplex.hh"
19#include "JFit/JMEstimator.hh"
20#include "JFit/JRegressor.hh"
21#include "JFit/JFitToolkit.hh"
22#include "JFit/JShowerNPE.hh"
23#include "JFit/JShowerNPEHit.hh"
24#include "JFit/JTimeRange.hh"
25
26#include "Jeep/JMessage.hh"
27
28/**
29 * \file
30 * Data regression method for JFIT::JShower3EZ only focused on the energy estimation from
31 * a bright point emission PDF and considering the hit/non hit information for each PMT.
32 *
33 * \author adomi
34 */
35
36namespace JFIT {}
37namespace JPP { using namespace JFIT; }
38
39namespace JFIT {
40
46
47 /**
48 * Regressor function object for JShower3EZ fit using JSimplex minimiser.
49 */
50 template<>
52 public JAbstractRegressor<JEnergy, JSimplex>
53 {
54 using JAbstractRegressor<JEnergy, JSimplex>::operator();
55
60
62
63 /**
64 * Parameterized constructor
65 *
66 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
67 * will be replaced by the corresponding PDF types listed in JRegressor<JEnergy, JSimplex>::pdf_t.
68 *
69 * \param fileDescriptor PDF file descriptor
70 */
71
72 JRegressor(const std::string& fileDescriptor):
73 estimator(new JMEstimatorNull())
74 {
75 using namespace std;
76 using namespace JPP;
77
78
79 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
80
81 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
82
83 try {
84
85 JPDF_t pdf;
86
87 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
88
89 NOTICE("loading PDF from file " << file_name << "... " << flush);
90
91 pdf.load(file_name.c_str());
92
93 NOTICE("OK" << endl);
94
95 pdf.setExceptionHandler(supervisor);
96
97 Y.push_back(JNPE_t(pdf));
98 }
99 catch(const JException& error) {
100 FATAL(error.what() << endl);
101 }
102 }
103
104 // Add PDFs
105
106 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
107 Y[i].add(Y[i-1]);
108 }
109
110 Y.erase(Y.begin());
111 }
112
113 /**
114 * Fit function.
115 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
116 *
117 * \param x energy
118 * \param npe number of photoelectrons
119 * \return chi2
120 */
121 double operator()(const JEnergy& x, const JShowerNPEHit& npe) const
122 {
123 using namespace JPP;
124
125 const double E = x.getE();
126 const double u = npe.getChi2(E);
127
128 return estimator->getRho(u);
129 }
130
131 /**
132 * Create data structure for handling light yields for PMT.
133 *
134 * \param axis PMT axis
135 * \param R_Hz singles rate [Hz]
136 * \return light yields
137 */
138 inline JShowerNPE getNPE(const JAxis3D& axis,
139 const double R_Hz) const
140 {
141 using namespace JPP;
142
143 const JPosition3D D(axis.getPosition());
144 const JDirection3D U(axis.getDirection());
145
146 const double U_length = std::sqrt(U.getDX()*U.getDX() +
147 U.getDY()*U.getDY() +
148 U.getDZ()*U.getDZ());
149
150 const double ct = U.getDot(D) / (D.getLength()*U_length);
151
152 const double y = getNPE(Y, D.getLength(), ct);
153
154 return JShowerNPE(getN(T_ns, R_Hz * 1.0e-9), y);
155 }
156
157
158 /**
159 * Get number of photo-electrons.
160 *
161 * \param NPE NPE tables
162 * \param D PMT distance from shower [m]
163 * \param cd cosine of the PMT angle wrt the photon direction
164 * \return number of photo-electrons
165 */
166 static inline double getNPE(const std::vector<JNPE_t>& NPE,
167 const double D,
168 const double cd)
169 {
170 double npe = 0.0;
171
172 for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
173
174 if (D <= i->getXmax()) {
175
176 try {
177
178 const double y = get_value((*i)(std::max(D, i->getXmin()), cd));
179
180 if (y > 0.0) {
181 npe += y;
182 }
183 }
184 catch(const JLANG::JException& error) {
185 ERROR(error << std::endl);
186 }
187 }
188 }
189
190 return npe;
191 }
192
193
194 static JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
195 static double Vmax_npe; //!< Maximal integral of PDF [npe]
196
197 static const int NUMBER_OF_PDFS = 2;
198
199 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
200
201 std::vector<JNPE_t> Y; //!< light from EM showers
202
204 };
205
206 /**
207 * PDF types.
208 */
209 const JPDFType_t JRegressor<JEnergy, JSimplex>::pdf_t[] = { DIRECT_LIGHT_FROM_BRIGHT_POINT,
210 SCATTERED_LIGHT_FROM_BRIGHT_POINT };
211
212 /**
213 * Default values.
214 */
216 double JRegressor<JEnergy, JSimplex>::Vmax_npe = std::numeric_limits<double>::max();
217}
218
219#endif
Auxiliary methods to evaluate Poisson probabilities and chi2.
Maximum likelihood estimator (M-estimators).
General purpose messaging.
#define ERROR(A)
Definition JMessage.hh:66
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
Auxiliary methods for PDF calculations.
Numbering scheme for PDF types.
Physics constants.
General purpose data regression method.
This include file containes various data structures that can be used as specific return types for the...
Definition of zero value for any class.
Data structure for fit of energy.
Definition JEnergy.hh:31
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++,...
Definition JSimplex.hh:44
Axis object.
Definition JAxis3D.hh:41
Data structure for direction in three dimensions.
const JDirection3D & getDirection() const
Get direction.
double getDot(const JAngle3D &angle) const
Get dot product.
Data structure for position in three dimensions.
const JPosition3D & getPosition() const
Get position.
double getLength() const
Get length.
Definition JVector3D.hh:246
double getDY() const
Get y direction.
Definition JVersor3D.hh:106
double getDX() const
Get x direction.
Definition JVersor3D.hh:95
double getDZ() const
Get z direction.
Definition JVersor3D.hh:117
General exception.
Definition JException.hh:24
virtual const char * what() const override
Get error message.
Definition JException.hh:64
The template JSharedPointer class can be used to share a pointer to an object.
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
Definition JNPETable.hh:46
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition JPDFTable.hh:44
void setExceptionHandler(const typename function_type::supervisor_type &supervisor)
Set the supervisor for handling of exceptions.
Auxiliary classes and methods for linear and iterative data regression.
Definition JEnergy.hh:15
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
JPDFType_t
PDF types.
Definition JPDFTypes.hh:24
@ SCATTERED_LIGHT_FROM_BRIGHT_POINT
scattered light from bright point
Definition JPDFTypes.hh:43
@ DIRECT_LIGHT_FROM_BRIGHT_POINT
direct light from bright point
Definition JPDFTypes.hh:42
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition JResult.hh:998
Abstract class for global fit method.
Definition JRegressor.hh:79
Null M-estimator.
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
JShowerNPE getNPE(const JAxis3D &axis, const double R_Hz) const
Create data structure for handling light yields for PMT.
double operator()(const JEnergy &x, const JShowerNPEHit &npe) const
Fit function.
static double getNPE(const std::vector< JNPE_t > &NPE, const double D, const double cd)
Get number of photo-electrons.
std::vector< JNPE_t > Y
light from EM showers
JRegressor(const std::string &fileDescriptor)
Parameterized constructor.
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.
JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMap, JTOOLS::JPolint1FunctionalGridMap >::maplist JMapList_t
static double Vmax_npe
Maximal integral of PDF [npe].
JPHYSICS::JNPETable< double, double, JMapList_t > JNPE_t
JPHYSICS::JPDFTable< JFunction1D_t, JMapList_t > JPDF_t
Template definition of a data regressor of given model.
Definition JRegressor.hh:70
Auxiliary class for simultaneously handling light yields and response of PMT.
double getChi2(const double E_GeV) const
Get chi2.
Auxiliary class for handling EM shower light yield.
Definition JShowerNPE.hh:27
void load(const char *file_name)
Load from input file.
Auxiliary class for recursive map list generation.
Definition JMapList.hh:109
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
Type definition of a spline interpolation method based on a JCollection with JResultPDF result type.