Jpp  debug
the software that should make you happy
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | List of all members
JFIT::JRegressor< JEnergy > Struct Reference

Regressor function object for fit of muon energy. More...

#include <JEnergyRegressor.hh>

Inheritance diagram for JFIT::JRegressor< JEnergy >:
JFIT::JAbstractRegressor< JEnergy > JFIT::JAbstractMinimiser< JModel_t > JEEP::JMessage< T >

Public Types

typedef JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMap, JTOOLS::JPolint1FunctionalGridMap, JTOOLS::JPolint1FunctionalGridMap >::maplist JNPEMaplist_t
 
typedef JPHYSICS::JNPETable< double, double, JNPEMaplist_tJNPE_t
 
typedef JAbstractMinimiser< JEnergyminimiser_type
 
typedef JRegressor< JEnergy, JAbstractMinimiserregressor_type
 
typedef minimiser_type::result_type result_type
 

Public Member Functions

 JRegressor (const std::string &fileDescriptor)
 Constructor. More...
 
double operator() (const JEnergy &x, const JNPEHit &npe) const
 Fit function. More...
 
JNPE getNPE (const JAxis3D &axis, const double R_Hz) const
 Create data structure for handling light yields for PMT. More...
 
double getRmax () const
 Get maximal road width of NPE. More...
 
result_type operator() (const JEnergy &value, T __begin, T __end)
 Global fit. More...
 
template<class JFunction_t , class T >
result_type operator() (const JFunction_t &fit, T __begin, T __end)
 Get chi2. More...
 

Public Attributes

std::vector< JNPE_tY1
 light from muon More...
 
std::vector< JNPE_tYA
 light from delta-rays More...
 
std::vector< JNPE_tYB
 light from EM showers More...
 
JLANG::JSinglePointer< JMEstimatorestimator
 M-Estimator function. More...
 
JModel_t value
 model value More...
 

Static Public Attributes

static JTimeRange T_ns
 Time window with respect to Cherenkov hypothesis [ns]. More...
 
static const int NUMBER_OF_PDFS = 6
 
static const JPDFType_t pdf_t [NUMBER_OF_PDFS]
 PDF types. More...
 
static int debug = 0
 debug level (default is off). More...
 

Static Protected Member Functions

static double getRmax (const std::vector< JNPE_t > &NPE)
 Get maximal road width of PDF. More...
 
static double getNPE (const std::vector< JNPE_t > &NPE, const double R, const double theta, const double phi)
 Get number of photo-electrons. More...
 

Detailed Description

Regressor function object for fit of muon energy.

Definition at line 49 of file JEnergyRegressor.hh.

Member Typedef Documentation

◆ JNPEMaplist_t

Definition at line 57 of file JEnergyRegressor.hh.

◆ JNPE_t

Definition at line 58 of file JEnergyRegressor.hh.

◆ minimiser_type

Definition at line 80 of file JRegressor.hh.

◆ regressor_type

Definition at line 81 of file JRegressor.hh.

◆ result_type

Definition at line 82 of file JRegressor.hh.

Constructor & Destructor Documentation

◆ JRegressor()

JFIT::JRegressor< JEnergy >::JRegressor ( const std::string &  fileDescriptor)
inline

Constructor.

The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which will be replaced by the PDF types listed in JRegressor<JEnergy, JSimplex>::pdf_t.

Parameters
fileDescriptorPDF file descriptor

Definition at line 69 of file JEnergyRegressor.hh.

69  :
71  {
72  using namespace std;
73  using namespace JPP;
74 
75  typedef JSplineFunction1D_t JFunction1D_t;
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 JPDFType_t type = pdf_t[i];
87  const string file_name = getFilename(fileDescriptor, type);
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  if (is_bremsstrahlung(type))
98  YB.push_back(JNPE_t(pdf));
99  else if (is_deltarays(type))
100  YA.push_back(JNPE_t(pdf));
101  else
102  Y1.push_back(JNPE_t(pdf));
103  }
104  catch(const JLANG::JException& error) {
105  FATAL(error.what() << endl);
106  }
107  }
108 
109  // Add PDFs
110 
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()); }
114  }
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
General exception.
Definition: JException.hh:24
virtual const char * what() const override
Get error message.
Definition: JException.hh:64
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition: JPDFTable.hh:44
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:151
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:137
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:24
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Normal M-estimator.
Definition: JMEstimator.hh:54
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
std::vector< JNPE_t > YA
light from delta-rays
std::vector< JNPE_t > Y1
light from muon
static const JPDFType_t pdf_t[NUMBER_OF_PDFS]
PDF types.
std::vector< JNPE_t > YB
light from EM showers
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
Type definition of a spline interpolation method based on a JCollection with double result type.

Member Function Documentation

◆ operator()() [1/3]

double JFIT::JRegressor< JEnergy >::operator() ( const JEnergy x,
const JNPEHit npe 
) const
inline

Fit function.

This method is used to determine chi2 of given number of photo-electrons for given energy of muon.

Parameters
xenergy
npenpe
Returns
chi2

Definition at line 125 of file JEnergyRegressor.hh.

126  {
127  const double E = x.getE();
128  const double u = npe.getChi2(E);
129 
130  return estimator->getRho(u);
131  }
double u[N+1]
Definition: JPolint.hh:865
double getChi2(const double E_GeV) const
Get chi2.
Definition: JNPEHit.hh:87

◆ getNPE() [1/2]

JNPE JFIT::JRegressor< JEnergy >::getNPE ( const JAxis3D axis,
const double  R_Hz 
) const
inline

Create data structure for handling light yields for PMT.

Note that the PMT geometry should be relative to the muon trajectory, conform method JGEOMETRY3D::JAxis3D::transform.

Parameters
axisPMT axis
R_Hzsingles rate [Hz]
Returns
light yields

Definition at line 143 of file JEnergyRegressor.hh.

145  {
146  using namespace std;
147  using namespace JPP;
148 
149  const double x = axis.getX();
150  const double y = axis.getY();
151  const double R = sqrt(x*x + y*y);
152  const double z = axis.getZ() - R / getTanThetaC();
153 
154  const double theta = axis.getTheta();
155  const double phi = fabs(axis.getPhi());
156 
157  const double y1 = getNPE(Y1, R, theta, phi);
158  const double yA = getNPE(YA, R, theta, phi);
159  const double yB = getNPE(YB, R, theta, phi);
160 
161  return JNPE(getN(T_ns, R_Hz * 1.0e-9), y1, yA, yB, z);
162  }
double getY() const
Get y position.
Definition: JVector3D.hh:104
double getZ() const
Get z position.
Definition: JVector3D.hh:115
double getX() const
Get x position.
Definition: JVector3D.hh:94
double getTheta() const
Get theta angle.
Definition: JVersor3D.hh:128
double getPhi() const
Get phi angle.
Definition: JVersor3D.hh:144
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
double getN(const JRange< T > &range, const double R)
Get expected number of occurrences due to given rate within specified interval.
Definition: JRange.hh:704
Auxiliary class for handling various light yields.
Definition: JNPE.hh:32
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
JNPE getNPE(const JAxis3D &axis, const double R_Hz) const
Create data structure for handling light yields for PMT.

◆ getRmax() [1/2]

double JFIT::JRegressor< JEnergy >::getRmax ( ) const
inline

Get maximal road width of NPE.

Returns
road width [m]

Definition at line 170 of file JEnergyRegressor.hh.

171  {
172  return std::max(getRmax(Y1), std::max(getRmax(YA), getRmax(YB)));
173  }
double getRmax() const
Get maximal road width of NPE.

◆ getRmax() [2/2]

static double JFIT::JRegressor< JEnergy >::getRmax ( const std::vector< JNPE_t > &  NPE)
inlinestaticprotected

Get maximal road width of PDF.

Parameters
NPENPE tables
Returns
road width [m]

Definition at line 197 of file JEnergyRegressor.hh.

198  {
199  double xmax = 0.0;
200 
201  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
202  if (!i->empty() && i->getXmax() > xmax) {
203  xmax = i->getXmax();
204  }
205  }
206 
207  return xmax;
208  }
const double xmax
Definition: JQuadrature.cc:24

◆ getNPE() [2/2]

static double JFIT::JRegressor< JEnergy >::getNPE ( const std::vector< JNPE_t > &  NPE,
const double  R,
const double  theta,
const double  phi 
)
inlinestaticprotected

Get number of photo-electrons.

Parameters
NPENPE tables
Rdistance between muon and PMT [m]
thetazenith angle orientation PMT [rad]
phiazimuth angle orientation PMT [rad]
Returns
number of photo-electrons

Definition at line 220 of file JEnergyRegressor.hh.

224  {
225  using JTOOLS::get_value;
226 
227  double npe = 0.0;
228 
229  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
230 
231  if (R <= i->getXmax()) {
232 
233  try {
234 
235  const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
236 
237  if (y > 0.0) {
238  npe += y;
239  }
240  }
241  catch(const JLANG::JException& error) {
242  ERROR(error << std::endl);
243  }
244  }
245  }
246 
247  return npe;
248  }
#define ERROR(A)
Definition: JMessage.hh:66
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998

◆ operator()() [2/3]

result_type JFIT::JAbstractRegressor< JEnergy , JAbstractMinimiser >::operator() ( const JEnergy value,
__begin,
__end 
)
inlineinherited

Global fit.

Parameters
valuestart value
__beginbegin of data set
__endend of data set
Returns
chi2

Definition at line 94 of file JRegressor.hh.

95  {
96  static_cast<minimiser_type&>(*this).value = value;
97 
98  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
99  }
JModel_t value
model value
Definition: JRegressor.hh:59
JAbstractMinimiser< JEnergy > minimiser_type
Definition: JRegressor.hh:80
JRegressor< JEnergy, JAbstractMinimiser > regressor_type
Definition: JRegressor.hh:81

◆ operator()() [3/3]

template<class JModel_t >
template<class JFunction_t , class T >
result_type JFIT::JAbstractMinimiser< JModel_t >::operator() ( const JFunction_t &  fit,
__begin,
__end 
)
inlineinherited

Get chi2.

Parameters
fitfit function
__beginbegin of data
__endend of data
Returns
chi2

Definition at line 48 of file JRegressor.hh.

49  {
50  double chi2 = 0.0;
51 
52  for (T i = __begin; i != __end; ++i) {
53  chi2 += fit(value, *i);
54  }
55 
56  return chi2;
57  }

Member Data Documentation

◆ Y1

light from muon

Definition at line 176 of file JEnergyRegressor.hh.

◆ YA

light from delta-rays

Definition at line 177 of file JEnergyRegressor.hh.

◆ YB

light from EM showers

Definition at line 178 of file JEnergyRegressor.hh.

◆ T_ns

Time window with respect to Cherenkov hypothesis [ns].

Time range.

Definition at line 180 of file JEnergyRegressor.hh.

◆ NUMBER_OF_PDFS

const int JFIT::JRegressor< JEnergy >::NUMBER_OF_PDFS = 6
static

Definition at line 183 of file JEnergyRegressor.hh.

◆ pdf_t

const JPDFType_t JFIT::JRegressor< JEnergy >::pdf_t
static
Initial value:
@ SCATTERED_LIGHT_FROM_DELTARAYS
scattered light from delta-rays
Definition: JPDFTypes.hh:33
@ DIRECT_LIGHT_FROM_EMSHOWERS
direct light from EM showers
Definition: JPDFTypes.hh:29
@ SCATTERED_LIGHT_FROM_EMSHOWERS
scattered light from EM showers
Definition: JPDFTypes.hh:30
@ SCATTERED_LIGHT_FROM_MUON
scattered light from muon
Definition: JPDFTypes.hh:27
@ DIRECT_LIGHT_FROM_DELTARAYS
direct light from delta-rays
Definition: JPDFTypes.hh:32
@ DIRECT_LIGHT_FROM_MUON
direct light from muon
Definition: JPDFTypes.hh:26

PDF types.

Definition at line 185 of file JEnergyRegressor.hh.

◆ estimator

M-Estimator function.

Definition at line 187 of file JEnergyRegressor.hh.

◆ value

template<class JModel_t >
JModel_t JFIT::JAbstractMinimiser< JModel_t >::value
inherited

model value

Definition at line 59 of file JRegressor.hh.

◆ debug

template<class T >
int JEEP::JMessage< T >::debug = 0
staticinherited

debug level (default is off).

Definition at line 45 of file JMessage.hh.


The documentation for this struct was generated from the following file: