Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JPoint4DRegressor.hh
Go to the documentation of this file.
1#ifndef __JPOINT4DREGRESSOR__
2#define __JPOINT4DREGRESSOR__
3
4#include <memory>
5#include <cmath>
6
8
10
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
24namespace JFIT {
25
26 /**
27 * Regressor function object for JPoint4D fit using JSimplex minimiser.
28 */
29 template<>
31 public JAbstractRegressor<JPoint4D, JSimplex>
32 {
33 using JAbstractRegressor<JPoint4D, JSimplex>::operator();
34
35
36 /**
37 * Constructor.
38 */
39 JRegressor(double sigma)
40 {
41 this->sigma = sigma;
42 }
43
44 /* Fit Function
45 * This method is used to determine the chi2 of given hit with respect
46 * to Shower's vertex (brightest point)
47 *
48 * \param vx Shower's vertex
49 * \param hit hit
50 * \return chi2
51 */
52 template<class JHit_t>
53 double operator()(const JPoint4D& vx, const JHit_t& hit) const
54 {
55 const double dt = hit.getT() - vx.getT(hit.getPosition());
56
57 const double u = dt / sigma;
58
59 return estimator->getRho(u) * hit.getW();
60 }
61
62 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
63 double sigma; //!< Time resolution [ns]
64 };
65
66
67 template<>
69 public JAbstractRegressor<JPoint4D, JGandalf>
70 {
71 using JAbstractRegressor<JPoint4D, JGandalf>::operator();
72
73 constexpr static const double DMIN = 0.1; //!< minimal distance [m]
74
75 /**
76 * Constructor.
77 */
78 JRegressor(double sigma)
79 {
80 this->sigma = sigma;
81 }
82
83 /* Fit Function
84 * This method is used to determine the chi2 of given hit with respect
85 * to Shower's vertex (brightest point)
86 *
87 * \param vx Shower's vertex
88 * \param hit hit
89 * \return chi2
90 */
91 template<class JHit_t>
92 result_type operator()(const JPoint4D& vx, const JHit_t& hit) const
93 {
94 using namespace JPP;
95
96 result_type result;
97
98 const double dt = hit.getT() - vx.getT(hit.getPosition());
99
100 const double u = dt / sigma;
101
102 const JVector3D pos = hit.getPosition() - vx.getPosition();
103 const double D = pos.getLength();
104
105 const double weight = getIndexOfRefraction() * getInverseSpeedOfLight() / ((D < DMIN ? DMIN : D) * sigma);
106
107 result.chi2 = estimator->getRho(u) * hit.getW();
108
109 result.gradient = hit.getW() * JPoint4D(pos * weight, -1.0 / sigma);
110
111 result.gradient.mul(0.5 * estimator->getPsi(u));
112
113 return result;
114 }
115
116 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
117 double sigma; //!< Time resolution [ns]
118 };
119}
120
121#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:87
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
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:160
Auxiliary classes and methods for linear and iterative data regression.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Abstract class for global fit method.
Definition JRegressor.hh:79
std::shared_ptr< 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