Jpp master_rocky-44-g75b7c4f75
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
12#include "JMath/JZero.hh"
13
15
16#include "JFit/JEnergy.hh"
17#include "JFit/JSimplex.hh"
18#include "JFit/JMEstimator.hh"
19#include "JFit/JRegressor.hh"
20#include "JFit/JFitToolkit.hh"
21#include "JFit/JShowerNPE.hh"
22#include "JFit/JShowerNPEHit.hh"
23#include "JFit/JTimeRange.hh"
24
25#include "Jeep/JMessage.hh"
26
27/**
28 * \file
29 * Data regression method for JFIT::JShower3EZ only focused on the energy estimation from
30 * a bright point emission PDF and considering the hit/non hit information for each PMT.
31 *
32 * \author adomi
33 */
34
35namespace JFIT {}
36namespace JPP { using namespace JFIT; }
37
38namespace JFIT {
39
45
46 /**
47 * Regressor function object for JShower3EZ fit using JSimplex minimiser.
48 */
49 template<>
51 public JAbstractRegressor<JEnergy, JSimplex>
52 {
53 using JAbstractRegressor<JEnergy, JSimplex>::operator();
54
59
61
62 /**
63 * Parameterized constructor
64 *
65 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
66 * will be replaced by the corresponding PDF types listed in JRegressor<JEnergy, JSimplex>::pdf_t.
67 *
68 * \param fileDescriptor PDF file descriptor
69 */
70
71 JRegressor(const std::string& fileDescriptor):
72 estimator(new JMEstimatorNull())
73 {
74 using namespace std;
75 using namespace JPP;
76
77
78 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
79
80 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
81
82 try {
83
84 JPDF_t pdf;
85
86 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
87
88 NOTICE("loading PDF from file " << file_name << "... " << flush);
89
90 pdf.load(file_name.c_str());
91
92 NOTICE("OK" << endl);
93
94 pdf.setExceptionHandler(supervisor);
95
96 Y.push_back(JNPE_t(pdf));
97 }
98 catch(const JException& error) {
99 FATAL(error.what() << endl);
100 }
101 }
102
103 // Add PDFs
104
105 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
106 Y[i].add(Y[i-1]);
107 }
108
109 Y.erase(Y.begin());
110 }
111
112 /**
113 * Fit function.
114 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
115 *
116 * \param x energy
117 * \param npe number of photoelectrons
118 * \return chi2
119 */
120 double operator()(const JEnergy& x, const JShowerNPEHit& npe) const
121 {
122 using namespace JPP;
123
124 const double E = x.getE();
125 const double u = npe.getChi2(E);
126
127 return estimator->getRho(u);
128 }
129
130 /**
131 * Create data structure for handling light yields for PMT.
132 *
133 * \param axis PMT axis
134 * \param R_Hz singles rate [Hz]
135 * \return light yields
136 */
137 inline JShowerNPE getNPE(const JAxis3D& axis,
138 const double R_Hz) const
139 {
140 using namespace JPP;
141
142 const JPosition3D D(axis.getPosition());
143 const JDirection3D U(axis.getDirection());
144
145 const double U_length = std::sqrt(U.getDX()*U.getDX() +
146 U.getDY()*U.getDY() +
147 U.getDZ()*U.getDZ());
148
149 const double ct = U.getDot(D) / (D.getLength()*U_length);
150
151 const double y = getNPE(Y, D.getLength(), ct);
152
153 return JShowerNPE(getN(T_ns, R_Hz * 1.0e-9), y);
154 }
155
156
157 /**
158 * Get number of photo-electrons.
159 *
160 * \param NPE NPE tables
161 * \param D PMT distance from shower [m]
162 * \param cd cosine of the PMT angle wrt the photon direction
163 * \return number of photo-electrons
164 */
165 static inline double getNPE(const std::vector<JNPE_t>& NPE,
166 const double D,
167 const double cd)
168 {
169 double npe = 0.0;
170
171 for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
172
173 if (D <= i->getXmax()) {
174
175 try {
176
177 const double y = get_value((*i)(std::max(D, i->getXmin()), cd));
178
179 if (y > 0.0) {
180 npe += y;
181 }
182 }
183 catch(const JLANG::JException& error) {
184 ERROR(error << std::endl);
185 }
186 }
187 }
188
189 return npe;
190 }
191
192
193 static JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
194 static double Vmax_npe; //!< Maximal integral of PDF [npe]
195
196 static const int NUMBER_OF_PDFS = 2;
197
198 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
199
200 std::vector<JNPE_t> Y; //!< light from EM showers
201
203 };
204
205 /**
206 * PDF types.
207 */
208 const JPDFType_t JRegressor<JEnergy, JSimplex>::pdf_t[] = { DIRECT_LIGHT_FROM_BRIGHT_POINT,
209 SCATTERED_LIGHT_FROM_BRIGHT_POINT };
210
211 /**
212 * Default values.
213 */
215 double JRegressor<JEnergy, JSimplex>::Vmax_npe = std::numeric_limits<double>::max();
216}
217
218#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:43
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.