Jpp  master_rocky-43-ge265d140c
the software that should make you happy
JPoint4DRegressor.hh
Go to the documentation of this file.
1 #ifndef __JPOINT4DREGRESSOR__
2 #define __JPOINT4DREGRESSOR__
3 
4 #include <cmath>
5 
6 #include "JPhysics/JConstants.hh"
7 
9 
10 #include "JLang/JSharedPointer.hh"
11 #include "JFit/JTimeRange.hh"
12 #include "JFit/JSimplex.hh"
13 #include "JFit/JGandalf.hh"
14 #include "JFit/JMEstimator.hh"
15 #include "JFit/JRegressor.hh"
16 #include "JFit/JPoint4D.hh"
17 
18 #include "Jeep/JMessage.hh"
19 
20 /**
21  * \author adomi
22  */
23 
24 namespace JFIT {
25 
26  /**
27  * Regressor function object for JPoint4D fit using JSimplex minimiser.
28  */
29  template<>
31  public JAbstractRegressor<JPoint4D, JSimplex>
32  {
34 
35  /**
36  * Constructor.
37  */
38  JRegressor(double sigma)
39  {
40  this->sigma = sigma;
41  }
42 
43  /* Fit Function
44  * This method is used to determine the chi2 of given hit with respect
45  * to Shower's vertex (brightest point)
46  *
47  * \param vx Shower's vertex
48  * \param hit hit
49  * \return chi2
50  */
51  template<class JHit_t>
52  double operator()(const JPoint4D& vx, const JHit_t& hit) const
53  {
54  using namespace JPP;
55 
56  const double dt = hit.getT() - vx.getT(hit.getPosition());
57 
58  const double u = dt / sigma;
59 
60  return estimator->getRho(u) * hit.getW();
61  }
62 
63  JLANG::JSharedPointer<JMEstimator> estimator; //!< M-Estimator function
64  double sigma; //!< Time resolution [ns]
65  };
66  template<>
68  public JAbstractRegressor<JPoint4D, JGandalf>
69  {
71 
72  /**
73  * Constructor.
74  */
75  JRegressor(double sigma)
76  {
77  this->sigma = sigma;
78  }
79 
80  /* Fit Function
81  * This method is used to determine the chi2 of given hit with respect
82  * to Shower's vertex (brightest point)
83  *
84  * \param vx Shower's vertex
85  * \param hit hit
86  * \return chi2
87  */
88  template<class JHit_t>
89  result_type operator()(const JPoint4D& vx, const JHit_t& hit) const
90  {
91  using namespace JPP;
92 
93  const double dt = hit.getT() - vx.getT(hit.getPosition());
94 
95  const double u = dt / sigma;
97  result.chi2 = estimator->getRho(u) * hit.getW();
98 
99  JVector3D d = hit.getPosition() - vx.getPosition();
100 
101  double weight = getIndexOfRefraction() * getInverseSpeedOfLight()/(d.getLength() * sigma);
102 
103  result.gradient = hit.getW() * JPoint4D( d * weight,
104  -1/sigma);
105  result.gradient.mul(0.5 * estimator->getPsi(u));
106 
107  return result;
108  }
109 
111  double sigma; //!< Time resolution [ns]
112  };
113 }
114 
115 #endif
Maximum likelihood estimator (M-estimators).
General purpose messaging.
Physics constants.
General purpose data regression method.
Fit method based on the Levenberg-Marquardt method.
Definition: JGandalf.hh:86
Data structure for vertex fit.
Definition: JPoint4D.hh:24
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++,...
Definition: JSimplex.hh:44
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
Data structure for vector in three dimensions.
Definition: JVector3D.hh:36
double getLength() const
Get length.
Definition: JVector3D.hh:246
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JVertex3D.hh:147
The template JSharedPointer class can be used to share a pointer to an object.
const double sigma[]
Definition: JQuadrature.cc:74
Auxiliary classes and methods for linear and iterative data regression.
Definition: JEnergy.hh:15
double getIndexOfRefraction()
Get average index of refraction of water corresponding to group velocity.
const double getInverseSpeedOfLight()
Get inverse speed of light.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double u[N+1]
Definition: JPolint.hh:865
Abstract class for global fit method.
Definition: JRegressor.hh:79
Data structure for return value of fit function.
Definition: JGandalf.hh:101
result_type operator()(const JPoint4D &vx, const JHit_t &hit) const
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function
double operator()(const JPoint4D &vx, const JHit_t &hit) const
Template definition of a data regressor of given model.
Definition: JRegressor.hh:70
Auxiliary class to set-up Hit.
Definition: JSirene.hh:58