1#ifndef __JFIT__JENERGYREGRESSOR__
2#define __JFIT__JENERGYREGRESSOR__
8#include "JPhysics/JPDFTypes.hh"
9#include "JPhysics/JPDFTable.hh"
10#include "JPhysics/JNPETable.hh"
11#include "JPhysics/JPDFToolkit.hh"
12#include "JPhysics/JTimeRange.hh"
13#include "JPhysics/JConstants.hh"
14#include "JTools/JFunction1D_t.hh"
15#include "JTools/JFunctionalMap_t.hh"
16#include "JGeometry3D/JAxis3D.hh"
24#include "Jeep/JMessage.hh"
33namespace JPP {
using namespace JFIT; }
37 using JPHYSICS::JPDFType_t;
38 using JPHYSICS::DIRECT_LIGHT_FROM_MUON;
39 using JPHYSICS::SCATTERED_LIGHT_FROM_MUON;
40 using JPHYSICS::DIRECT_LIGHT_FROM_DELTARAYS;
41 using JPHYSICS::SCATTERED_LIGHT_FROM_DELTARAYS;
42 using JPHYSICS::DIRECT_LIGHT_FROM_EMSHOWERS;
43 using JPHYSICS::SCATTERED_LIGHT_FROM_EMSHOWERS;
44 using JGEOMETRY3D::JAxis3D;
53 typedef JTOOLS::JMAPLIST<JTOOLS::JPolint1FunctionalMap,
54 JTOOLS::JPolint1FunctionalGridMap,
56 typedef JPHYSICS::JNPETable<double, double, JNPEMaplist_t>
JNPE_t;
58 static const int NUMBER_OF_PDFS = 6;
79 JRegressorStorage(
const std::string& fileDescriptor,
const JTimeRange& T_ns = JTimeRange()) :
85 typedef JSplineFunction1D_t JFunction1D_t;
86 typedef JPDFTable<JFunction1D_t, JNPEMaplist_t> JPDF_t;
88 const JPDF_t::JSupervisor supervisor(
new JPDF_t::JDefaultResult(JMATH::zero));
90 for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
94 const JPDFType_t type = pdf_t[i];
95 const string file_name = getFilename(fileDescriptor, type);
97 pdf.load(file_name.c_str());
99 pdf.setExceptionHandler(supervisor);
101 if (is_bremsstrahlung(type))
102 _YB.push_back(
JNPE_t(pdf, T_ns));
103 else if (is_deltarays(type))
104 _YA.push_back(
JNPE_t(pdf, T_ns));
106 _Y1.push_back(
JNPE_t(pdf, T_ns));
111 if (_Y1.size() == 2) { _Y1[1].add(_Y1[0]); _Y1.erase(_Y1.begin()); }
112 if (_YA.size() == 2) { _YA[1].add(_YA[0]); _YA.erase(_YA.begin()); }
113 if (_YB.size() == 2) { _YB[1].add(_YB[0]); _YB.erase(_YB.begin()); }
153 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
168 SCATTERED_LIGHT_FROM_MUON,
169 DIRECT_LIGHT_FROM_DELTARAYS,
170 SCATTERED_LIGHT_FROM_DELTARAYS,
171 DIRECT_LIGHT_FROM_EMSHOWERS,
172 SCATTERED_LIGHT_FROM_EMSHOWERS };
188 using storage_type::getY1;
189 using storage_type::getYA;
190 using storage_type::getYB;
202 JRegressor(
const std::string& fileDescriptor,
const JTimeRange& T_ns = JTimeRange()) :
236 const double E = x.
getE();
237 const double u = npe.
getChi2(E);
239 return estimator->getRho(u);
251 inline double getY1(
const JAxis3D& axis)
const
253 return getNPE(Y1, hypot(axis.getX(), axis.getY()), axis.getTheta(), fabs(axis.getPhi()));
265 inline double getYA(
const JAxis3D& axis)
const
267 return getNPE(YA, hypot(axis.getX(), axis.getY()), axis.getTheta(), fabs(axis.getPhi()));
279 inline double getYB(
const JAxis3D& axis)
const
281 return getNPE(YB, hypot(axis.getX(), axis.getY()), axis.getTheta(), fabs(axis.getPhi()));
295 const double R_Hz)
const
300 const double x = axis.getX();
301 const double y = axis.getY();
302 const double R = sqrt(x*x + y*y);
303 const double z = axis.getZ() - R / getTanThetaC();
305 const double theta = axis.getTheta();
306 const double phi = fabs(axis.getPhi());
308 const double y1 = getNPE(Y1, R, theta, phi);
309 const double yA = getNPE(YA, R, theta, phi);
310 const double yB = getNPE(YB, R, theta, phi);
312 return JNPE(getN(T_ns, R_Hz * 1.0e-9), y1, yA, yB, z);
323 return std::max(getRmax(Y1), std::max(getRmax(YA), getRmax(YB)));
344 for (JNPEs_t::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
345 if (!i->empty() && i->getXmax() > xmax) {
368 using JTOOLS::get_value;
372 for (JNPEs_t::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
374 if (R <= i->getXmax()) {
378 const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
384 catch(
const JLANG::JException& error) {
385 ERROR(error << std::endl);
Maximum likelihood estimator (M-estimators).
General purpose data regression method.
Data structure for fit of energy.
double getE() const
Get energy.
Auxiliary classes and methods for linear and iterative data regression.
Abstract class for global fit method.
Auxiliary class for simultaneously handling light yields and response of PMT.
double getChi2(const double E_GeV) const
Get chi2.
Auxiliary class for handling various light yields.
Template specialisation for storage of PDF tables.
JRegressorStorage()
Default constructor.
JNPEs_t _YB
light from EM showers
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
time integrated PDF
JNPEs_t _YA
light from delta-rays
const JNPEs_t & getYB() const
Get light from EM showers.
JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMap, JTOOLS::JPolint1FunctionalGridMap, JTOOLS::JPolint1FunctionalGridMap >::maplist JNPEMaplist_t
std::vector< JNPE_t > JNPEs_t
NPEs.
JRegressorStorage(const std::string &fileDescriptor, const JTimeRange &T_ns=JTimeRange())
Constructor.
JNPEs_t _Y1
light from muon
const JNPEs_t & getY1() const
Get light from muon.
JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
const JNPEs_t & getYA() const
Get light from delta-rays.
Template data structure for storage of internal data.
JRegressorStorage< JEnergy > storage_type
double operator()(const JEnergy &x, const JNPEHit &npe) const
Fit function.
double getRmax() const
Get maximal road width of NPE.
static double getRmax(const JNPEs_t &NPE)
Get maximal road width of PDF.
double getY1(const JAxis3D &axis) const
Get number of photo-electrons from muon.
double getYA(const JAxis3D &axis) const
Get number of photo-electrons from delta-rays.
double getYB(const JAxis3D &axis) const
Get number of photo-electrons from Bremsstrahlung.
JRegressor(const std::string &fileDescriptor, const JTimeRange &T_ns=JTimeRange())
Constructor.
JNPE getNPE(const JAxis3D &axis, const double R_Hz) const
Create data structure for handling light yields for PMT.
JRegressor(const storage_type &storage)
Constructor.
static double getNPE(const JNPEs_t &NPE, const double R, const double theta, const double phi)
Get number of photo-electrons.
std::shared_ptr< JMEstimator > estimator
M-Estimator function.
Template definition of a data regressor of given model.