Jpp  19.1.0-rc.1
the software that should make you happy
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
JFIT::JRegressor< JShower3EZ, JAbstractMinimiser > Struct Reference

Regressor function object for JShower3EZ fit using Abstract minimiser, that just computes the chi2 without a fit. More...

#include <JShower3EZRegressor.hh>

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

Public Types

typedef JTOOLS::JSplineFunction1S_t JFunction1D_t
 
typedef JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JPDFMaplist_t
 
typedef JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_tJPDF_t
 
typedef JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JNPEMaplist_t
 
typedef JPHYSICS::JNPETable< double, double, JNPEMaplist_tJNPE_t
 
typedef JAbstractMinimiser< JShower3EZminimiser_type
 
typedef JRegressor< JShower3EZ, JAbstractMinimiserregressor_type
 
typedef minimiser_type::result_type result_type
 

Public Member Functions

 JRegressor (const std::string &fileDescriptor)
 Parameterized constructor. More...
 
double operator() (const JShower3EZ &shower, const JPMTW0 &pmt) const
 Fit function. More...
 
JNPE_t::result_type getH0 (const double R_Hz) const
 Get background hypothesis value for time integrated PDF. More...
 
JNPE_t::result_type getH1 (const double D, const double cd, const double theta, const double phi, const double E) const
 Get signal hypothesis value for time integrated PDF. More...
 
JNPE_t::result_type getH1 (const JShower3EZ &shower, const JPMTW0 &pmt) const
 Get signal hypothesis value for time integrated PDF. More...
 
result_type operator() (const JShower3EZ &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

JNPE_t npe [NUMBER_OF_PDFS]
 PDF. More...
 
JLANG::JSharedPointer< 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 double Vmax_npe = std::numeric_limits<double>::max()
 Maximal integral of PDF [npe]. More...
 
static const int NUMBER_OF_PDFS = 2
 
static const JPDFType_t pdf_t [NUMBER_OF_PDFS]
 
static int debug = 0
 debug level (default is off). More...
 

Detailed Description

Regressor function object for JShower3EZ fit using Abstract minimiser, that just computes the chi2 without a fit.

Definition at line 478 of file JShower3EZRegressor.hh.

Member Typedef Documentation

◆ JFunction1D_t

Definition at line 483 of file JShower3EZRegressor.hh.

◆ JPDFMaplist_t

Definition at line 487 of file JShower3EZRegressor.hh.

◆ JPDF_t

Definition at line 488 of file JShower3EZRegressor.hh.

◆ JNPEMaplist_t

Definition at line 493 of file JShower3EZRegressor.hh.

◆ JNPE_t

Definition at line 494 of file JShower3EZRegressor.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< JShower3EZ, JAbstractMinimiser >::JRegressor ( const std::string &  fileDescriptor)
inline

Parameterized constructor.

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

Parameters
fileDescriptorPDF file descriptor

Definition at line 505 of file JShower3EZRegressor.hh.

505  :
507  {
508  using namespace std;
509  using namespace JPP;
510 
511  const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
512 
513  for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
514 
515  try {
516 
517  JPDF_t pdf;
518 
519  const string file_name = getFilename(fileDescriptor, pdf_t[i]);
520 
521  NOTICE("loading PDF from file " << file_name << "... " << flush);
522 
523  pdf.load(file_name.c_str());
524 
525  NOTICE("OK" << endl);
526 
527  pdf.setExceptionHandler(supervisor);
528 
529  npe[ i ] = JNPE_t(pdf);
530  }
531  catch(const JException& error) {
532  FATAL(error.what() << endl);
533  }
534  }
535 
536  // Add PDFs
537  for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
538 
539  npe[ i ].add(npe[i-1]);
540 
541  JNPE_t buffer;
542 
543  npe[i-1].swap(buffer);
544  }
545  }
#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
void add(const JNPETable &input)
Add NPE table.
Definition: JNPETable.hh:124
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
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Null M-estimator.
Definition: JMEstimator.hh:94
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
static const JPDFType_t pdf_t[NUMBER_OF_PDFS]
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.

Member Function Documentation

◆ operator()() [1/3]

double JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::operator() ( const JShower3EZ shower,
const JPMTW0 pmt 
) const
inline

Fit function.

This method is used to determine the chi2 of given PMT with respect to shower hypothesis.

Parameters
showershower
pmtpmt
Returns
chi2

Definition at line 555 of file JShower3EZRegressor.hh.

556  {
557  using namespace JPP;
558 
559  JPosition3D D(pmt.getPosition());
560  JDirection3D U(pmt.getDirection());
561 
562  D.sub(shower.getPosition());
563 
564  const double z = D.getDot(shower.getDirection());
565  const double x = D.getX();
566  const double y = D.getY();
567  const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
568 
569  U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
570 
571  const double theta = getPMTAngle(U.getTheta());
572  const double phi = getPMTAngle(U.getPhi());
573 
574  JNPE_t::result_type H0 = getH0(pmt.getR()); // background hypothesis value for time integrated PDF.
575  JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, shower.getE()); // signal hypothesis value for time integrated PDF.
576 
577  if (get_value(H1) >= Vmax_npe) {
578  H1 *= Vmax_npe / get_value(H1);
579  }
580 
581  H1 += H0; // now H1 is signal + background
582 
583  const bool hit = pmt.getN() != 0;
584  const double u = getChi2(get_value(H1), hit) - getChi2(get_value(H0), hit); // -log likelihood ratio
585 
586  return estimator->getRho(u);
587  }
double getE() const
Get E.
Definition: JShower3EZ.hh:86
const JVersor3Z & getDirection() const
Get direction.
Definition: JVersor3Z.hh:81
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:35
const JDirection3D & getDirection() const
Get direction.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:38
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
Rotation around Z-axis.
Definition: JRotation3D.hh:87
double getPMTAngle(const double angle)
Constrain PMT angle to [0,pi].
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:56
double u[N+1]
Definition: JPolint.hh:865
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998
int getN() const
Get number of hits.
Definition: JPMTW0.hh:67
double getR() const
Get rate.
Definition: JPMTW0.hh:56
JNPE_t::result_type getH1(const double D, const double cd, const double theta, const double phi, const double E) const
Get signal hypothesis value for time integrated PDF.
static double Vmax_npe
Maximal integral of PDF [npe].
JNPE_t::result_type getH0(const double R_Hz) const
Get background hypothesis value for time integrated PDF.

◆ getH0()

JNPE_t::result_type JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::getH0 ( const double  R_Hz) const
inline

Get background hypothesis value for time integrated PDF.

Parameters
R_Hzrate [Hz]
Returns
hypothesis value

Definition at line 595 of file JShower3EZRegressor.hh.

596  {
597  return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength());
598  }
T getLength() const
Get length (difference between upper and lower limit).
Definition: JRange.hh:289
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].

◆ getH1() [1/2]

JNPE_t::result_type JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::getH1 ( const double  D,
const double  cd,
const double  theta,
const double  phi,
const double  E 
) const
inline

Get signal hypothesis value for time integrated PDF.

Parameters
DPMT distance from shower [m]
cdcosine angle between shower direction and PMT position
thetaPMT zenith angle [deg]
phiPMT azimuth angle [deg]
Eshower energy [GeV]
Returns
hypothesis value

Definition at line 610 of file JShower3EZRegressor.hh.

615  {
616  JNPE_t::result_type h1 = JMATH::zero;
617 
618  for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
619 
620  if (!npe[i].empty() && D <= npe[i].getXmax()) {
621 
622  try {
623 
624  JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
625 
626  // safety measure
627 
628  if(y1 < 0){
629  y1 = 0;
630  }
631 
632  h1 += y1;
633 
634  }
635  catch(JLANG::JException& error) {
636  ERROR(error << std::endl);
637  }
638  }
639  }
640 
641  return h1;
642  }
#define ERROR(A)
Definition: JMessage.hh:66

◆ getH1() [2/2]

JNPE_t::result_type JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::getH1 ( const JShower3EZ shower,
const JPMTW0 pmt 
) const
inline

Get signal hypothesis value for time integrated PDF.

Parameters
showershower
pmtpmt
Returns
hypothesis value

Definition at line 651 of file JShower3EZRegressor.hh.

652  {
653  using namespace JPP;
654 
655  JPosition3D D(pmt.getPosition());
656  JDirection3D U(pmt.getDirection());
657 
658 
659  const double z = D.getDot(shower.getDirection());
660  const double x = D.getX();
661  const double y = D.getY();
662  const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
663 
664  U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
665 
666  const double theta = getPMTAngle(U.getTheta());
667  const double phi = getPMTAngle(U.getPhi());
668 
669  JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, 1.0); // signal hypothesis value for time integrated PDF. E=1 because it is linear with E.
670 
671  if (get_value(H1) >= Vmax_npe) {
672  H1 *= Vmax_npe / get_value(H1);
673  }
674 
675  return H1;
676  }

◆ operator()() [2/3]

result_type JFIT::JAbstractRegressor< JShower3EZ , JAbstractMinimiser >::operator() ( const JShower3EZ 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
JRegressor< JShower3EZ, 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

◆ T_ns

Time window with respect to Cherenkov hypothesis [ns].

Definition at line 677 of file JShower3EZRegressor.hh.

◆ Vmax_npe

double JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::Vmax_npe = std::numeric_limits<double>::max()
static

Maximal integral of PDF [npe].

Definition at line 678 of file JShower3EZRegressor.hh.

◆ NUMBER_OF_PDFS

const int JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::NUMBER_OF_PDFS = 2
static

Definition at line 680 of file JShower3EZRegressor.hh.

◆ pdf_t

const JPDFType_t JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::pdf_t
static
Initial value:
@ SCATTERED_LIGHT_FROM_EMSHOWER
scattered light from EM shower
Definition: JPDFTypes.hh:38
@ DIRECT_LIGHT_FROM_EMSHOWER
direct light from EM shower
Definition: JPDFTypes.hh:37

Definition at line 682 of file JShower3EZRegressor.hh.

◆ npe

PDF.

Definition at line 684 of file JShower3EZRegressor.hh.

◆ estimator

M-Estimator function.

Definition at line 686 of file JShower3EZRegressor.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: