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
 
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...
 
template<class T >
JNPE getNPE (T __begin, T __end, const JK40Rates &rates_Hz) const
 Create data structure for handling light yields for set of PMTs. 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 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 47 of file JEnergyRegressor.hh.

Member Typedef Documentation

Definition at line 55 of file JEnergyRegressor.hh.

Definition at line 56 of file JEnergyRegressor.hh.

Definition at line 78 of file JRegressor.hh.

Definition at line 79 of file JRegressor.hh.

Definition at line 80 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 67 of file JEnergyRegressor.hh.

67  :
69  {
70  using namespace std;
71  using namespace JPP;
72 
73  typedef JSplineFunction1D_t JFunction1D_t;
74  typedef JPDFTable<JFunction1D_t, JNPEMaplist_t> JPDF_t;
75 
76  const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
77 
78  for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
79 
80  try {
81 
82  JPDF_t pdf;
83 
84  const string file_name = getFilename(fileDescriptor, pdf_t[i]);
85 
86  NOTICE("loading PDF from file " << file_name << "... " << flush);
87 
88  pdf.load(file_name.c_str());
89 
90  NOTICE("OK" << endl);
91 
92  pdf.setExceptionHandler(supervisor);
93 
94  if (!is_bremsstrahlung(pdf_t[i]))
95  Y1.push_back(JNPE_t(pdf));
96  else
97  YB.push_back(JNPE_t(pdf));
98  }
99  catch(const JLANG::JException& error) {
100  FATAL(error.what() << endl);
101  }
102  }
103 
104  // Add PDFs
105 
106  if (Y1.size() == 2) { Y1[1].add(Y1[0]); Y1.erase(Y1.begin()); }
107  if (YB.size() == 2) { YB[1].add(YB[0]); YB.erase(YB.begin()); }
108  }
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
General exception.
Definition: JException.hh:23
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:163
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
std::vector< JNPE_t > Y1
light from muon
#define NOTICE(A)
Definition: JMessage.hh:64
Normal M-estimator.
Definition: JMEstimator.hh:66
static const JPDFType_t pdf_t[NUMBER_OF_PDFS]
PDF types.
#define FATAL(A)
Definition: JMessage.hh:67
virtual const char * what() const override
Get error message.
Definition: JException.hh:48
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:88
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 119 of file JEnergyRegressor.hh.

120  {
121  const double E = x.getE();
122  const double u = npe.getChi2(E);
123 
124  return estimator->getRho(u);
125  }
double getE() const
Get energy.
Definition: JEnergy.hh:170
double getChi2(const double E_GeV) const
Get chi2.
Definition: JNPEHit.hh:87
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
double u[N+1]
Definition: JPolint.hh:739
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition: JMuonPostfit.sh:37
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 137 of file JEnergyRegressor.hh.

139  {
140  using namespace std;
141  using namespace JPP;
142 
143  const double x = axis.getX();
144  const double y = axis.getY();
145  const double R = sqrt(x*x + y*y);
146  const double z = axis.getZ() - R / getTanThetaC();
147 
148  const double theta = axis.getTheta();
149  const double phi = fabs(axis.getPhi());
150 
151  const double yA = getNPE(Y1, R, theta, phi);
152  const double yB = getNPE(YB, R, theta, phi);
153 
154  return JNPE(JK40(T_ns, R_Hz), yA, yB, z);
155  }
Auxiliary class for converting various rates to expectation values of the number of hits within a giv...
Definition: JK40.hh:29
JNPE getNPE(const JAxis3D &axis, 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
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:40
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
std::vector< JNPE_t > YB
light from EM showers
template<class T >
JNPE JFIT::JRegressor< JEnergy >::getNPE ( T  __begin,
T  __end,
const JK40Rates rates_Hz 
) const
inline

Create data structure for handling light yields for set of PMTs.

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

Parameters
__beginbegin of PMTs
__endend of PMTs
rates_HzK40 singles and multiples rates [Hz]
Returns
light yields

Definition at line 169 of file JEnergyRegressor.hh.

172  {
173  using namespace std;
174  using namespace JPP;
175 
176  double yA = 0.0;
177  double yB = 0.0;
178  double z = 0.0;
179 
180  for (T i = __begin; i != __end; ++i) {
181 
182  const JNPE npe = this->getNPE(*i, rates_Hz.getSinglesRate());
183  const double x = i->getX();
184  const double y = i->getY();
185  const double R = sqrt(x*x + y*y);
186 
187  yA += npe.getYA();
188  yB += npe.getYB();
189  z += i->getZ() - R / getTanThetaC();
190  }
191 
192  const int N = distance(__begin, __end);
193 
194  return JNPE(JK40(T_ns, N, rates_Hz), yA, yB, z / N);
195  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
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:29
double getYA() const
Get light yield due to muon itself.
Definition: JNPE.hh:69
JNPE getNPE(const JAxis3D &axis, const double R_Hz) const
Create data structure for handling light yields for PMT.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
Auxiliary class for handling various light yields.
Definition: JNPE.hh:27
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:40
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
double JFIT::JRegressor< JEnergy >::getRmax ( ) const
inline

Get maximal road width of NPE.

Returns
road width [m]

Definition at line 203 of file JEnergyRegressor.hh.

204  {
205  return std::max(getRmax(Y1),
206  getRmax(YB));
207  }
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 230 of file JEnergyRegressor.hh.

231  {
232  double xmax = 0.0;
233 
234  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
235  if (!i->empty() && i->getXmax() > xmax) {
236  xmax = i->getXmax();
237  }
238  }
239 
240  return xmax;
241  }
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 253 of file JEnergyRegressor.hh.

257  {
258  using JTOOLS::get_value;
259 
260  double npe = 0.0;
261 
262  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
263 
264  if (R <= i->getXmax()) {
265 
266  try {
267 
268  const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
269 
270  if (y > 0.0) {
271  npe += y;
272  }
273  }
274  catch(const JLANG::JException& error) {
275  ERROR(error << std::endl);
276  }
277  }
278  }
279 
280  return npe;
281  }
General exception.
Definition: JException.hh:23
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:40
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998
result_type JFIT::JAbstractRegressor< JEnergy , JAbstractMinimiser >::operator() ( const JEnergy value,
T  __begin,
T  __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  }
JAbstractMinimiser< JEnergy > minimiser_type
Definition: JRegressor.hh:78
JRegressor< JEnergy, JAbstractMinimiser > regressor_type
Definition: JRegressor.hh:79
JModel_t value
model value
Definition: JRegressor.hh:57
result_type JFIT::JAbstractMinimiser< JEnergy >::operator() ( const JFunction_t &  fit,
T  __begin,
T  __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  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T

Member Data Documentation

light from muon

Definition at line 210 of file JEnergyRegressor.hh.

light from EM showers

Definition at line 211 of file JEnergyRegressor.hh.

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

Time window with respect to Cherenkov hypothesis [ns].

Time range.

Definition at line 213 of file JEnergyRegressor.hh.

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

Definition at line 216 of file JEnergyRegressor.hh.

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

M-Estimator function.

Definition at line 220 of file JEnergyRegressor.hh.

model value

Definition at line 57 of file JRegressor.hh.

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: