1#ifndef __JFIT__JSHOWER3EZREGRESSOR__ 
    2#define __JFIT__JSHOWER3EZREGRESSOR__ 
   60    const double epsilon = 1.0e-6;
 
 
   77    double Tx = value.
getDX();
 
   78    double Ty = value.
getDY();
 
   79    double E = max(0.0,value.
getE());
 
   80    const double u = hypot(Tx, Ty);
 
 
  111    static const int    NUMBER_OF_PDFS = 2;
 
  135      const JPDF_t::JSupervisor supervisor(
new JPDF_t::JDefaultResult(
JMATH::zero));
 
  137      for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
 
  139        const string file_name = getFilename(fileDescriptor, pdf_t[i]);
 
  142        _pdf.
load(file_name.c_str());
 
  149      for (
int i = 1; i < NUMBER_OF_PDFS; i += 2) {
 
  151        _npe[ i ].add(_npe[i-1]);
 
  155        _npe[i-1].swap(buffer);
 
 
 
  184    DIRECT_LIGHT_FROM_EMSHOWER,
 
  185    SCATTERED_LIGHT_FROM_EMSHOWER
 
  229      npe(storage.getNPE()),
 
 
  252      const double x  = D.
getX();
 
  253      const double y  = D.
getY();
 
  264      if (get_value(H1) >= Vmax_npe) {
 
  265        H1 *= Vmax_npe / get_value(H1);
 
  270      const bool hit = pmt.
getN() != 0;
 
  271      const double u = 
getChi2(get_value(H1), hit) - 
getChi2(get_value(H0), hit); 
 
  273      return estimator->getRho(u);
 
 
  301                              const double E)
 const 
  305      for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
 
  307        if (!npe[i].empty() && D <= npe[i].getXmax()) {
 
  323            ERROR(error << std::endl);
 
 
 
  360    static const int    NUMBER_OF_PDFS = 2;
 
  384      const JPDF_t::JSupervisor supervisor(
new JPDF_t::JDefaultResult(
JMATH::zero));
 
  386      for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
 
  388        const string file_name = getFilename(fileDescriptor, pdf_t[i]);
 
  391        _pdf.
load(file_name.c_str());
 
  400      for (
int i = 1; i < NUMBER_OF_PDFS; i += 2) {
 
  402        _npe[ i ].add(_npe[i-1]);
 
  406        _npe[i-1].swap(buffer);
 
 
 
  434    DIRECT_LIGHT_FROM_EMSHOWER,
 
  435    SCATTERED_LIGHT_FROM_EMSHOWER
 
  467    JRegressor(
const std::string& fileDescriptor) :
 
  468      storage_type(fileDescriptor),
 
  502      const double x  = D.getX();
 
  503      const double y  = D.getY();
 
  504      const double d  = D.getLength();  
 
  512      JNPE_t::result_type H0 = getH0(pmt.
getR());                        
 
  513      JNPE_t::result_type H1 = getH1(d, cd, theta, phi, shower.
getE());  
 
  515      if (get_value(H1) >= Vmax_npe) {
 
  516        H1 *= Vmax_npe / get_value(H1);
 
  519      double signal_npe = get_value(H1);
 
  523      double expectation = get_value(H1);
 
  525      const bool hit = pmt.
getN() != 0;
 
  526      const double u = H1.getChi2(hit) - H0.getChi2(hit);
 
  530      result.chi2     = estimator->getRho(u);
 
  532      double energy_gradient = signal_npe/shower.
getE(); 
 
  533      if(hit) energy_gradient *= -exp(-expectation)/(1-exp(-expectation)); 
 
  543      result.gradient.mul(estimator->getPsi(u));
 
  544      static_cast<JShower3Z&
>(
result.gradient).mul(H1.getDerivativeOfChi2(hit) - H0.getDerivativeOfChi2(hit));                    
 
  555    JNPE_t::result_type getH0(
const double R_Hz)
 const 
  557      return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength(), 0.0);
 
  570    JNPE_t::result_type getH1(
const double D,
 
  574                              const double E)
 const 
  578      for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
 
  580        if (!npe[i].empty() && D <= npe[i].getXmax()) {
 
  584            JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
 
  586            if (get_value(y1) > 0.0) {
 
  592            ERROR(error << std::endl);
 
  602    static double       Vmax_npe;                  
 
  606    std::shared_ptr<JMEstimator>       estimator;  
 
  631    static const int    NUMBER_OF_PDFS = 2;
 
  655      const JPDF_t::JSupervisor supervisor(
new JPDF_t::JDefaultResult(
JMATH::zero));
 
  657      for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
 
  659        const string file_name = getFilename(fileDescriptor, pdf_t[i]);
 
  662        _pdf.
load(file_name.c_str());
 
  671      for (
int i = 1; i < NUMBER_OF_PDFS; i += 2) {
 
  673        _npe[i].add(_npe[i-1]);
 
  677        _npe[i-1].swap(buffer);
 
 
 
  706    DIRECT_LIGHT_FROM_EMSHOWER,
 
  707    SCATTERED_LIGHT_FROM_EMSHOWER
 
  739    JRegressor(
const std::string& fileDescriptor) :
 
  740      storage_type(fileDescriptor),
 
  773      const double x  = D.getX();
 
  774      const double y  = D.getY();
 
  775      const double cd = z/D.getLength();                   
 
  782      JNPE_t::result_type H0 = getH0(pmt.
getR());                                    
 
  783      JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, shower.
getE());  
 
  785      if (get_value(H1) >= Vmax_npe) {
 
  786        H1 *= Vmax_npe / get_value(H1);
 
  791      const bool hit = pmt.
getN() != 0;
 
  792      const double u = 
getChi2(get_value(H1), hit) - 
getChi2(get_value(H0), hit); 
 
  794      return estimator->getRho(u);
 
  803    JNPE_t::result_type getH0(
const double R_Hz)
 const 
  805      return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength());
 
  818    JNPE_t::result_type getH1(
const double D,
 
  822                              const double E)
 const 
  826      for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
 
  828        if (!npe[i].empty() && D <= npe[i].getXmax()) {
 
  832            JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
 
  844            ERROR(error << std::endl);
 
  859    JNPE_t::result_type getH1(
const JShower3EZ& shower, 
const JPMTW0& pmt)
 const 
  868      const double x  = D.getX();
 
  869      const double y  = D.getY();
 
  870      const double cd = z/D.getLength();                   
 
  877      JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, 1.0);  
 
  879      if (get_value(H1) >= Vmax_npe) {
 
  880        H1 *= Vmax_npe / get_value(H1);
 
  886    static double       Vmax_npe;                  
 
  890    std::shared_ptr<JMEstimator>       estimator;  
 
Various implementations of functional maps.
 
Maximum likelihood estimator (M-estimators).
 
General purpose messaging.
 
Numbering scheme for PDF types.
 
Auxiliary class to define a range between two values.
 
General purpose data regression method.
 
This include file containes various data structures that can be used as specific return types for the...
 
Definition of zero value for any class.
 
Place holder for custom implementation.
 
Fit method based on the Levenberg-Marquardt method.
 
Data structure for vertex fit.
 
Data structure for fit of straight line in positive z-direction with energy.
 
double getBy() const
Get bjorken y.
 
double getE() const
Get E.
 
Data structure for cascade in positive z-direction.
 
const JVersor3Z & getDirection() const
Get direction.
 
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++,...
 
Data structure for direction in three dimensions.
 
JDirection3D & rotate(const JRotation3D &R)
Rotate.
 
const JDirection3D & getDirection() const
Get direction.
 
Data structure for position in three dimensions.
 
double getDot(const JAngle3D &angle) const
Get dot product.
 
const JPosition3D & getPosition() const
Get position.
 
Data structure for vector in three dimensions.
 
double getY() const
Get y position.
 
double getLength() const
Get length.
 
JVector3D & sub(const JVector3D &vector)
Subtract vector.
 
double getX() const
Get x position.
 
double getTheta() const
Get theta angle.
 
double getPhi() const
Get phi angle.
 
Data structure for normalised vector in positive z-direction.
 
double getDY() const
Get y direction.
 
double getDX() const
Get x direction.
 
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
 
multifunction_t::result_type result_type
 
Multi-dimensional PDF table for arrival time of Cherenkov light.
 
double getNPE(const Hit &hit)
Get true charge of hit.
 
Auxiliary classes and methods for linear and iterative data regression.
 
double getPMTAngle(const double angle)
Constrain PMT angle to [0,pi].
 
double getChi2(const double P)
Get chi2 corresponding to given probability.
 
void model(JModel_t &value)
Auxiliary function to constrain model during fit.
 
static const JZero zero
Function object to assign zero value.
 
static const double PI
Mathematical constants.
 
@ SCATTERED_LIGHT_FROM_EMSHOWER
scattered light from EM shower
 
@ DIRECT_LIGHT_FROM_EMSHOWER
direct light from EM shower
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Abstract class for global fit method.
 
Auxiliary class for handling PMT geometry, rate and response.
 
int getN() const
Get number of hits.
 
double getR() const
Get rate.
 
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JPDFMaplist_t
 
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
 
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
 
JRegressorStorage()
Default constructor.
 
JTOOLS::JPolint1Function1D_t JFunction1D_t
 
std::array< JNPE_t, NUMBER_OF_PDFS > JNPEs_t
NPEs.
 
const JNPEs_t & getNPE() const
Get NPEs.
 
JRegressorStorage(const std::string &fileDescriptor)
Parameterized constructor.
 
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JNPEMaplist_t
 
JRegressorStorage(const std::string &fileDescriptor)
Parameterized constructor.
 
std::array< JNPE_t, NUMBER_OF_PDFS > JNPEs_t
NPEs.
 
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
 
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JPDFMaplist_t
 
JTOOLS::JMapList< JTOOLS::JPolint1FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalMapH, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap > > > > JNPEMaplist_t
 
const JNPEs_t & getNPE() const
Get NPEs.
 
JRegressorStorage()
Default constructor.
 
JTOOLS::JPolint1Function1D_t JFunction1D_t
 
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
 
Template specialisation for storage of PDF tables.
 
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
 
JTOOLS::JPolint1Function1D_t JFunction1D_t
 
const JNPEs_t & getNPE() const
Get NPEs.
 
std::array< JNPE_t, NUMBER_OF_PDFS > JNPEs_t
NPEs.
 
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JNPEMaplist_t
 
JRegressorStorage(const std::string &fileDescriptor)
Constructor.
 
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JPDFMaplist_t
 
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
 
JRegressorStorage()
Default constructor.
 
Template data structure for storage of internal data.
 
JRegressorStorage< JShower3EZ, JSimplex > storage_type
 
std::shared_ptr< JMEstimator > estimator
M-Estimator function.
 
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.
 
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.
 
JRegressor()
Default constructor.
 
double operator()(const JShower3EZ &shower, const JPMTW0 &pmt) const
Fit function.
 
JRegressor(const storage_type &storage)
Constructor.
 
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
 
JRegressor(const std::string &fileDescriptor)
Constructor.
 
Template definition of a data regressor of given model.
 
void load(const char *file_name)
Load from input file.