Jpp  15.0.5
the software that should make you happy
 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_tYA
 light from delta-rays 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 = 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

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

69  :
71  {
72  using namespace std;
73  using namespace JPP;
74 
75  typedef JSplineFunction1D_t JFunction1D_t;
76  typedef JPDFTable<JFunction1D_t, JNPEMaplist_t> JPDF_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  }
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
General exception.
Definition: JException.hh:23
std::vector< JNPE_t > YA
light from delta-rays
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
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:27
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
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:177
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 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 getE() const
Get energy.
Definition: JEnergy.hh:170
double getChi2(const double E_GeV) const
Get chi2.
Definition: JNPEHit.hh:87
then usage E
Definition: JMuonPostfit.sh:35
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
double u[N+1]
Definition: JPolint.hh:739
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(JK40(T_ns, R_Hz), y1, yA, yB, z);
162  }
std::vector< JNPE_t > YA
light from delta-rays
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:28
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
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 176 of file JEnergyRegressor.hh.

179  {
180  using namespace std;
181  using namespace JPP;
182 
183  double y1 = 0.0;
184  double yA = 0.0;
185  double yB = 0.0;
186  double z = 0.0;
187 
188  for (T i = __begin; i != __end; ++i) {
189 
190  const JNPE npe = this->getNPE(*i, rates_Hz.getSinglesRate());
191  const double x = i->getX();
192  const double y = i->getY();
193  const double R = sqrt(x*x + y*y);
194 
195  y1 += npe.getY1();
196  yA += npe.getYA();
197  yB += npe.getYB();
198  z += i->getZ() - R / getTanThetaC();
199  }
200 
201  const int N = distance(__begin, __end);
202 
203  return JNPE(JK40(T_ns, N, rates_Hz), y1, yA, yB, z / N);
204  }
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:92
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
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 delta-rays.
Definition: JNPE.hh:81
double getY1() const
Get light yield due to muon itself.
Definition: JNPE.hh:70
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:28
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
double JFIT::JRegressor< JEnergy >::getRmax ( ) const
inline

Get maximal road width of NPE.

Returns
road width [m]

Definition at line 212 of file JEnergyRegressor.hh.

213  {
214  return std::max(getRmax(Y1), std::max(getRmax(YA), getRmax(YB)));
215  }
std::vector< JNPE_t > YA
light from delta-rays
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 239 of file JEnergyRegressor.hh.

240  {
241  double xmax = 0.0;
242 
243  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
244  if (!i->empty() && i->getXmax() > xmax) {
245  xmax = i->getXmax();
246  }
247  }
248 
249  return xmax;
250  }
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 262 of file JEnergyRegressor.hh.

266  {
267  using JTOOLS::get_value;
268 
269  double npe = 0.0;
270 
271  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
272 
273  if (R <= i->getXmax()) {
274 
275  try {
276 
277  const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
278 
279  if (y > 0.0) {
280  npe += y;
281  }
282  }
283  catch(const JLANG::JException& error) {
284  ERROR(error << std::endl);
285  }
286  }
287  }
288 
289  return npe;
290  }
General exception.
Definition: JException.hh:23
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
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 218 of file JEnergyRegressor.hh.

light from delta-rays

Definition at line 219 of file JEnergyRegressor.hh.

light from EM showers

Definition at line 220 of file JEnergyRegressor.hh.

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

Time window with respect to Cherenkov hypothesis [ns].

Time range.

Definition at line 222 of file JEnergyRegressor.hh.

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

Definition at line 225 of file JEnergyRegressor.hh.

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

M-Estimator function.

Definition at line 229 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: