Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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< T >

Public Types

typedef JTOOLS::JMAPLIST
< JTOOLS::JPolint1FunctionalMap,
JTOOLS::JPolint1FunctionalGridMap,
JTOOLS::JPolint1FunctionalGridMap >
::maplist 
JNPEMaplist_t
 
typedef JPHYSICS::JNPETable
< double, double,
JNPEMaplist_t
JNPE_t
 
typedef JAbstractMinimiser
< JEnergy
minimiser_type
 
typedef JRegressor< JEnergy,
JAbstractMinimiser
regressor_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...
 
double operator() (const JEnergy &value, T __begin, T __end)
 Global fit. More...
 
double operator() (const JEnergy &value, T1 __begin1, T1 __end1, T2 __begin2, T2 __end2)
 Global fit. More...
 
double 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
< JMEstimator
estimator
 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 = 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

template<>
struct JFIT::JRegressor< JEnergy >

Regressor function object for JEnergy fit.

Definition at line 49 of file JEnergyRegressor.hh.

Member Typedef Documentation

Definition at line 57 of file JEnergyRegressor.hh.

Definition at line 58 of file JEnergyRegressor.hh.

Definition at line 76 of file JRegressor.hh.

Definition at line 77 of file JRegressor.hh.

Constructor & Destructor Documentation

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  }
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
General exception.
Definition: JException.hh:40
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:94
Type definition of a spline interpolation method based on a JCollection with double result type...
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:157
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition: JPDFTable.hh:37
std::vector< JNPE_t > Y1
light from muon
#define NOTICE(A)
Definition: JMessage.hh:62
Normal M-estimator.
Definition: JMEstimator.hh:66
static const JPDFType_t pdf_t[NUMBER_OF_PDFS]
PDF types.
#define FATAL(A)
Definition: JMessage.hh:65
std::string getFilename(const std::string &file_name)
Get file name part, i.e.
Definition: JeepToolkit.hh:85
virtual const char * what() const
Get error message.
Definition: JException.hh:65
std::vector< JNPE_t > YB
light from EM showers

Member Function Documentation

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  }
double getE() const
Get energy.
Definition: JEnergy.hh:144
double getChi2(const double E_GeV) const
Get chi2.
Definition: JNPEHit.hh:87
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
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  }
Auxiliary class for converting various rates to expectation values of the number of hits within a giv...
Definition: JK40.hh:30
JNPE getNPE(const JPMT &pmt, const double R_Hz) const
Create data structure for handling light yields for PMT.
std::vector< JNPE_t > Y1
light from muon
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
Auxiliary class for handling various light yields.
Definition: JNPE.hh:27
double getTanThetaC()
Get average tangent of Cherenkov angle of water.
Definition: JConstants.hh:122
std::vector< JNPE_t > YB
light from EM showers
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  }
double getYB() const
Get light yield due to bremsstrahlung.
Definition: JNPE.hh:80
Auxiliary class for converting various rates to expectation values of the number of hits within a giv...
Definition: JK40.hh:30
double getYA() const
Get light yield due to muon itself.
Definition: JNPE.hh:69
JNPE getNPE(const JPMT &pmt, const double R_Hz) const
Create data structure for handling light yields for PMT.
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
Auxiliary class for handling various light yields.
Definition: JNPE.hh:27
double getTanThetaC()
Get average tangent of Cherenkov angle of water.
Definition: JConstants.hh:122
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  }
std::vector< JNPE_t > Y1
light from muon
double getRmax() const
Get maximal road width of NPE.
std::vector< JNPE_t > YB
light from EM showers
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  }
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  }
General exception.
Definition: JException.hh:40
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:748
double 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 89 of file JRegressor.hh.

90  {
91  static_cast<minimiser_type&>(*this).value = value;
92 
93  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
94  }
JAbstractMinimiser< JEnergy > minimiser_type
Definition: JRegressor.hh:76
JRegressor< JEnergy, JAbstractMinimiser > regressor_type
Definition: JRegressor.hh:77
JModel_t value
model value
Definition: JRegressor.hh:55
double 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 108 of file JRegressor.hh.

111  {
112  static_cast<minimiser_type&>(*this).value = value;
113 
114  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin1, __end1, __begin2, __end2);
115  }
JAbstractMinimiser< JEnergy > minimiser_type
Definition: JRegressor.hh:76
JRegressor< JEnergy, JAbstractMinimiser > regressor_type
Definition: JRegressor.hh:77
JModel_t value
model value
Definition: JRegressor.hh:55
double 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 44 of file JRegressor.hh.

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

Member Data Documentation

light from muon

Definition at line 206 of file JEnergyRegressor.hh.

light from EM showers

Definition at line 207 of file JEnergyRegressor.hh.

JTimeRange JFIT::JRegressor< JEnergy >::T_ns
static

Time window with respect to Cherenkov hypothesis [ns].

Time range.

Definition at line 209 of file JEnergyRegressor.hh.

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

Definition at line 212 of file JEnergyRegressor.hh.

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

M-Estimator function.

Definition at line 216 of file JEnergyRegressor.hh.

model value

Definition at line 55 of file JRegressor.hh.

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

debug level (default is off).

Definition at line 43 of file JMessage.hh.


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