Jpp
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | List of all members
JFIT::JRegressor< JEnergy > Struct Template Reference

Regressor function object for JEnergy fit. More...

#include <JEnergyRegressor.hh>

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

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 JPMT &pmt, const double R_Hz) const
 Create data structure for handling light yields for PMT. More...
 
JNPE getNPE (const JModule &module, const JK40Rates &rates_Hz) const
 Create data structure for handling light yields for module. More...
 
double getRmax () const
 Get maximal road width of NPE. More...
 
result_type operator() (const JEnergy &value, T __begin, T __end)
 Global fit. More...
 
result_type operator() (const JEnergy &value, T1 __begin1, T1 __end1, T2 __begin2, T2 __end2)
 Global fit. More...
 
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_tYB
 light from EM showers More...
 
JLANG::JSinglePointer< JMEstimatorestimator
 M-Estimator function. More...
 
JEnergy 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 = 4
 
static const JPDFType_t pdf_t [NUMBER_OF_PDFS]
 PDF types. More...
 
static int debug
 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

template<>
struct JFIT::JRegressor< JEnergy >

Regressor function object for JEnergy fit.

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 78 of file JRegressor.hh.

◆ regressor_type

Definition at line 79 of file JRegressor.hh.

◆ result_type

Definition at line 80 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::WILD_CARD 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 JTOOLS;
74  using namespace JPHYSICS;
75 
76  typedef JSplineFunction1D_t JFunction1D_t;
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  if (!is_bremsstrahlung(pdf_t[i]))
98  Y1.push_back(JNPE_t(pdf));
99  else
100  YB.push_back(JNPE_t(pdf));
101  }
102  catch(const JLANG::JException& error) {
103  FATAL(error.what() << endl);
104  }
105  }
106 
107  // Add PDFs
108 
109  if (Y1.size() == 2) { Y1[1].add(Y1[0]); Y1.erase(Y1.begin()); }
110  if (YB.size() == 2) { YB[1].add(YB[0]); YB.erase(YB.begin()); }
111  }

Member Function Documentation

◆ operator()() [1/4]

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 122 of file JEnergyRegressor.hh.

123  {
124  const double E = x.getE();
125  const double u = npe.getChi2(E);
126 
127  return estimator->getRho(u);
128  }

◆ getNPE() [1/3]

JNPE JFIT::JRegressor< JEnergy >::getNPE ( const JPMT pmt,
const double  R_Hz 
) const
inline

Create data structure for handling light yields for PMT.

Note that the PMT geometry is relative to the muon trajectory, conform method JDETECTOR::JPMT::transform.

Parameters
pmtPMT
R_Hzsingles rate [Hz]
Returns
light yields

Definition at line 140 of file JEnergyRegressor.hh.

142  {
143  using namespace JTOOLS;
144 
145  const double x = pmt.getX();
146  const double y = pmt.getY();
147  const double R = sqrt(x*x + y*y);
148  const double z = pmt.getZ() - R / getTanThetaC();
149 
150  const double theta = pmt.getTheta();
151  const double phi = fabs(pmt.getPhi());
152 
153  const double yA = getNPE(Y1, R, theta, phi);
154  const double yB = getNPE(YB, R, theta, phi);
155 
156  return JNPE(JK40(T_ns, R_Hz), yA, yB, z);
157  }

◆ getNPE() [2/3]

JNPE JFIT::JRegressor< JEnergy >::getNPE ( const JModule module,
const JK40Rates rates_Hz 
) const
inline

Create data structure for handling light yields for module.

Note that the module geometry is relative to the muon trajectory, conform method JDETECTOR::JModule::transform.

Parameters
modulemodule
rates_HzK40 singles and multiples rates [Hz]
Returns
light yields

Definition at line 169 of file JEnergyRegressor.hh.

171  {
172  using namespace JTOOLS;
173 
174  const double x = module.getX();
175  const double y = module.getY();
176  const double R = sqrt(x*x + y*y);
177  const double z = module.getZ() - R / getTanThetaC();
178 
179  double yA = 0.0;
180  double yB = 0.0;
181 
182  for (JModule::const_iterator pmt = module.begin(); pmt != module.end(); ++pmt) {
183 
184  const JNPE npe = this->getNPE(*pmt, rates_Hz.getSinglesRate());
185 
186  yA += npe.getYA();
187  yB += npe.getYB();
188  }
189 
190  return JNPE(JK40(T_ns, module.size(), rates_Hz), yA, yB, z);
191  }

◆ getRmax() [1/2]

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

Get maximal road width of NPE.

Returns
road width [m]

Definition at line 199 of file JEnergyRegressor.hh.

200  {
201  return std::max(getRmax(Y1),
202  getRmax(YB));
203  }

◆ 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 226 of file JEnergyRegressor.hh.

227  {
228  double xmax = 0.0;
229 
230  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
231  if (!i->empty() && i->getXmax() > xmax) {
232  xmax = i->getXmax();
233  }
234  }
235 
236  return xmax;
237  }

◆ getNPE() [3/3]

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 249 of file JEnergyRegressor.hh.

253  {
254  using JTOOLS::get_value;
255 
256  double npe = 0.0;
257 
258  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
259 
260  if (R <= i->getXmax()) {
261 
262  try {
263 
264  const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
265 
266  if (y > 0.0) {
267  npe += y;
268  }
269  }
270  catch(const JLANG::JException& error) {
271  ERROR(error << std::endl);
272  }
273  }
274  }
275 
276  return npe;
277  }

◆ operator()() [2/4]

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 92 of file JRegressor.hh.

93  {
94  static_cast<minimiser_type&>(*this).value = value;
95 
96  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
97  }

◆ operator()() [3/4]

result_type JFIT::JAbstractRegressor< JEnergy , JAbstractMinimiser >::operator() ( const JEnergy value,
T1  __begin1,
T1  __end1,
T2  __begin2,
T2  __end2 
)
inlineinherited

Global fit.

Parameters
valuestart value
__begin1begin of first data set
__end1end of first data set
__begin2begin of second data set
__end2end of second data set
Returns
chi2

Definition at line 111 of file JRegressor.hh.

114  {
115  static_cast<minimiser_type&>(*this).value = value;
116 
117  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin1, __end1, __begin2, __end2);
118  }

◆ operator()() [4/4]

result_type JFIT::JAbstractMinimiser< JEnergy >::operator() ( const JFunction_t &  fit,
__begin,
__end 
)
inlineinherited

Get chi2.

Parameters
fitfit function
__beginbegin of data
__endend of data
Returns
chi2

Definition at line 46 of file JRegressor.hh.

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

Member Data Documentation

◆ Y1

light from muon

Definition at line 206 of file JEnergyRegressor.hh.

◆ YB

light from EM showers

Definition at line 207 of file JEnergyRegressor.hh.

◆ T_ns

Time window with respect to Cherenkov hypothesis [ns].

Time range.

Definition at line 209 of file JEnergyRegressor.hh.

◆ NUMBER_OF_PDFS

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

Definition at line 212 of file JEnergyRegressor.hh.

◆ pdf_t

const JPDFType_t JFIT::JRegressor< JEnergy >::pdf_t
static

◆ estimator

M-Estimator function.

Definition at line 216 of file JEnergyRegressor.hh.

◆ value

model value

Definition at line 57 of file JRegressor.hh.

◆ debug

int JEEP::JMessage< JAbstractMinimiser< JEnergy > >::debug
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:
JFIT::JRegressor< JEnergy >::NUMBER_OF_PDFS
static const int NUMBER_OF_PDFS
Definition: JEnergyRegressor.hh:212
JFIT::JEnergy::getE
double getE() const
Get energy.
Definition: JEnergy.hh:144
JFIT::ERROR
Definition: JFitStatus.hh:18
JTOOLS::u
double u[N+1]
Definition: JPolint.hh:706
std::vector
Definition: JSTDTypes.hh:12
JFIT::JRegressor< JEnergy >::T_ns
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
Definition: JEnergyRegressor.hh:209
JPHYSICS
Auxiliary classes and methods for calculation of PDF and muon energy loss.
Definition: JAbstractMedium.hh:9
JFIT::JNPE::getYB
double getYB() const
Get light yield due to bremsstrahlung.
Definition: JNPE.hh:80
JFIT::JRegressor< JEnergy >::Y1
std::vector< JNPE_t > Y1
light from muon
Definition: JEnergyRegressor.hh:206
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JTOOLS::get_value
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:936
JFIT::JAbstractMinimiser< JEnergy >::value
JEnergy value
model value
Definition: JRegressor.hh:57
JFIT::JNPEHit::getChi2
double getChi2(const double E_GeV) const
Get chi2.
Definition: JNPEHit.hh:87
JFIT::JRegressor< JEnergy >::getNPE
JNPE getNPE(const JPMT &pmt, const double R_Hz) const
Create data structure for handling light yields for PMT.
Definition: JEnergyRegressor.hh:140
JPHYSICS::is_bremsstrahlung
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:158
JFIT::JK40
Auxiliary class for converting various rates to expectation values of the number of hits within a giv...
Definition: JK40.hh:30
JEEP::getFilename
std::string getFilename(const std::string &file_name)
Get file name part, i.e.
Definition: JeepToolkit.hh:86
JPHYSICS::JPDFTable
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition: JPDFTable.hh:39
JTOOLS::JSplineFunction1D_t
Type definition of a spline interpolation method based on a JCollection with double result type.
Definition: JFunction1D_t.hh:35
JFIT::JMEstimatorNormal
Normal M-estimator.
Definition: JMEstimator.hh:66
JPHYSICS::SCATTERED_LIGHT_FROM_EMSHOWERS
scattered light from EM showers
Definition: JPDFTypes.hh:33
JFIT::JNPE
Auxiliary class for handling various light yields.
Definition: JNPE.hh:27
JTOOLS::getTanThetaC
double getTanThetaC()
Get average tangent of Cherenkov angle of water.
Definition: JConstants.hh:133
JFIT::JRegressor< JEnergy >::getRmax
double getRmax() const
Get maximal road width of NPE.
Definition: JEnergyRegressor.hh:199
std
Definition: jaanetDictionary.h:36
JFIT::JRegressor< JEnergy >::YB
std::vector< JNPE_t > YB
light from EM showers
Definition: JEnergyRegressor.hh:207
JLANG::JException::what
virtual const char * what() const
Get error message.
Definition: JException.hh:48
JPHYSICS::DIRECT_LIGHT_FROM_MUON
direct light from muon
Definition: JPDFTypes.hh:29
JMATH::zero
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:94
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JFIT::JRegressor< JEnergy >::estimator
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
Definition: JEnergyRegressor.hh:216
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
JPHYSICS::DIRECT_LIGHT_FROM_EMSHOWERS
direct light from EM showers
Definition: JPDFTypes.hh:32
JFIT::JNPE::getYA
double getYA() const
Get light yield due to muon itself.
Definition: JNPE.hh:69
JFIT::JRegressor< JEnergy >::pdf_t
static const JPDFType_t pdf_t[NUMBER_OF_PDFS]
PDF types.
Definition: JEnergyRegressor.hh:214
JLANG::JException
General exception.
Definition: JException.hh:23
JFIT::JRegressor< JEnergy >::JNPE_t
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
Definition: JEnergyRegressor.hh:58
JPHYSICS::SCATTERED_LIGHT_FROM_MUON
scattered light from muon
Definition: JPDFTypes.hh:30