Jpp  19.0.0
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 | List of all members
JFIT::JRegressor< JShower3EZ, JAbstractMinimiser > Struct Template 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< JShower3EZ > 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_t
JPDF_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_t
JNPE_t
 
typedef JAbstractMinimiser
< JShower3EZ
minimiser_type
 
typedef JRegressor< JShower3EZ,
JAbstractMinimiser
regressor_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...
 
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
< JMEstimator
estimator
 M-Estimator function. More...
 
JShower3EZ 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

template<>
struct JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >

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

Definition at line 483 of file JShower3EZRegressor.hh.

Definition at line 487 of file JShower3EZRegressor.hh.

Definition at line 488 of file JShower3EZRegressor.hh.

Definition at line 493 of file JShower3EZRegressor.hh.

Definition at line 494 of file JShower3EZRegressor.hh.

Definition at line 80 of file JRegressor.hh.

Definition at line 81 of file JRegressor.hh.

Definition at line 82 of file JRegressor.hh.

Constructor & Destructor Documentation

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  :
506  estimator(new JMEstimatorNull())
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  }
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
void add(const JNPETable &input)
Add NPE table.
Definition: JNPETable.hh:124
static const JPDFType_t pdf_t[NUMBER_OF_PDFS]
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
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
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.

Member Function Documentation

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); // -log(lik)
585 
586  return estimator->getRho(u);
587  }
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.
double getPMTAngle(const double angle)
Constrain PMT angle to [0,pi].
JNPE_t::result_type getH0(const double R_Hz) const
Get background hypothesis value for time integrated PDF.
static double Vmax_npe
Maximal integral of PDF [npe].
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Definition: JDrawPDF.sh:45
double u[N+1]
Definition: JPolint.hh:865
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:56
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.
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  }
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
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  }
General exception.
Definition: JException.hh:24
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
#define ERROR(A)
Definition: JMessage.hh:66
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
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  }
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.
double getPMTAngle(const double angle)
Constrain PMT angle to [0,pi].
static double Vmax_npe
Maximal integral of PDF [npe].
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Definition: JDrawPDF.sh:45
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
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< JShower3EZ , JAbstractMinimiser >::operator() ( const JShower3EZ value,
T  __begin,
T  __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  }
JRegressor< JShower3EZ, JAbstractMinimiser > regressor_type
Definition: JRegressor.hh:81
JModel_t value
model value
Definition: JRegressor.hh:59
result_type JFIT::JAbstractMinimiser< JShower3EZ >::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 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  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106

Member Data Documentation

JTimeRange JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::T_ns
static

Time window with respect to Cherenkov hypothesis [ns].

Definition at line 677 of file JShower3EZRegressor.hh.

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.

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

Definition at line 680 of file JShower3EZRegressor.hh.

const JPDFType_t JFIT::JRegressor< JShower3EZ, JAbstractMinimiser >::pdf_t
static
Initial value:

Definition at line 682 of file JShower3EZRegressor.hh.

PDF.

Definition at line 684 of file JShower3EZRegressor.hh.

M-Estimator function.

Definition at line 686 of file JShower3EZRegressor.hh.

model value

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