Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JFIT Namespace Reference

Auxiliary classes and methods for linear and iterative data regression. More...

Namespaces

namespace  JFIT_LOCAL
 

Classes

class  JAbstractMinimiser
 Abstract minimiser. More...
 
struct  JAbstractRegressor
 Abstract class for global fit method. More...
 
class  JEnergy
 Data structure for fit of energy. More...
 
class  JEstimator
 Template definition of linear fit. More...
 
class  JEstimator< JLegendre< JOrdinate_t, N > >
 Linear fit of Legendre polynomial. More...
 
class  JEstimator< JLine1Z >
 Linear fit of straight line parallel to z-axis to set of hits (objects with position and time).
 
class  JEstimator< JPoint3D >
 Linear fit of crossing point (position) between axes (objects with position and direction). More...
 
class  JEstimator< JPoint4D >
 Linear fit of bright point (position and time) between hits (objects with position and time). More...
 
struct  JEvent
 Auxiliary class for historical event. More...
 
class  JEvt
 Data structure for set of track fit results. More...
 
class  JFit
 Data structure for track fit results with history and optional associated values. More...
 
class  JGandalf
 Fit method based on the Levenberg-Marquardt method. More...
 
struct  JGradient
 Conjugate gradient fit. More...
 
struct  JHistory
 Container for historical events. More...
 
struct  JK40
 Auxiliary class for handling light yields due to K40 decays. More...
 
struct  JK40Hit
 Auxiliary class for simultaneously handling light yields and response of module. More...
 
class  JLine1Z
 Data structure for fit of straight line paralel to z-axis. More...
 
class  JLine3EZ
 Data structure for fit of straight line in positive z-direction with energy. More...
 
class  JLine3Z
 Data structure for fit of straight line in positive z-direction. More...
 
class  JMatrixNZ
 Determination of the co-variance matrix of hits for a track along z-axis (JFIT::JLine1Z). More...
 
struct  JMEstimator
 Interface for maximum likelihood estimator (M-estimator). More...
 
struct  JMEstimatorLinear
 Linear M-estimator. More...
 
struct  JMEstimatorLorentzian
 Lorentzian M-estimator. More...
 
struct  JMEstimatorNormal
 Normal M-estimator. More...
 
struct  JMEstimatorNormalWithBackground
 Normal M-estimator with background. More...
 
struct  JMEstimatorNull
 Null M-estimator. More...
 
struct  JMEstimatorTukey
 Tukey's biweight M-estimator. More...
 
struct  JModel
 Auxiliary class to match data points with given model. More...
 
struct  JModel< JEnergy >
 Template specialisation of class JModel to match hit with muon energy. More...
 
struct  JModel< JLine1Z >
 Template specialisation of class JModel to match hit with muon trajectory along z-axis. More...
 
struct  JModel< JPoint4D >
 Template specialisation of class JModel to match hit with bright point. More...
 
struct  JModifier_t
 Auxiliary data structure for editable parameter. More...
 
struct  JNPE
 Auxiliary class for handling various light yields. More...
 
struct  JNPEHit
 Auxiliary class for simultaneously handling light yields and response of PMT. More...
 
struct  JParameter_t
 Auxiliary data structure for fit parameter. More...
 
struct  JPMTW0
 Auxiliary class for handling PMT geometry, rate and response. More...
 
class  JPoint3D
 Data structure for position fit. More...
 
class  JPoint4D
 Data structure for vertex fit. More...
 
class  JPoint4E
 Data structure for vertex fit. More...
 
struct  JRegressor
 Template definition of a data regressor of given model. More...
 
struct  JRegressor< JEnergy >
 Regressor function object for fit of muon energy.
 
struct  JRegressor< JEnergy, JSimplex >
 Regressor function object for JShower3EZ fit using JSimplex minimiser. More...
 
struct  JRegressor< JLine3Z, JGandalf >
 Regressor function object for JLine3Z fit using JGandalf minimiser.
 
struct  JRegressor< JLine3Z, JSimplex >
 Regressor function object for JLine3Z fit using JSimplex minimiser.
 
struct  JRegressor< JPoint4D, JGandalf >
 
struct  JRegressor< JPoint4D, JSimplex >
 Regressor function object for JPoint4D fit using JSimplex minimiser. More...
 
struct  JRegressor< JPoint4E, JGandalf >
 Regressor function object for JLine3Z fit using JGandalf minimiser.
 
struct  JRegressor< JShower3EZ, JAbstractMinimiser >
 Regressor function object for JShower3EZ fit using JGandalf minimiser.
 
struct  JRegressor< JShower3EZ, JGandalf >
 Regressor function object for JShower3EZ fit using JGandalf minimiser.
 
struct  JRegressor< JShower3EZ, JSimplex >
 Regressor function object for JShower3EZ fit using JGandalf minimiser. More...
 
struct  JRegressor< JShowerEH, JSimplex >
 Regressor function object for JShowerEH fit using JSimplex minimiser.
 
struct  JRegressorStorage
 Template data structure for storage of internal data. More...
 
struct  JRegressorStorage< JEnergy >
 Template specialisation for storage of PDF tables. More...
 
struct  JRegressorStorage< JLine3Z, JGandalf >
 Template specialisation for storage of PDF tables. More...
 
struct  JRegressorStorage< JPoint4E, JGandalf >
 Template specialisation for storage of PDF tables. More...
 
struct  JRegressorStorage< JShower3EZ, JAbstractMinimiser >
 Template specialisation for storage of PDF tables. More...
 
struct  JRegressorStorage< JShower3EZ, JGandalf >
 Template specialisation for storage of PDF tables. More...
 
struct  JRegressorStorage< JShower3EZ, JSimplex >
 Template specialisation for storage of PDF tables. More...
 
class  JShower3EZ
 Data structure for fit of straight line in positive z-direction with energy. More...
 
class  JShower3Z
 Data structure for cascade in positive z-direction. More...
 
class  JShowerEH
 Data structure for fit of straight line in positive z-direction with energy. More...
 
class  JShowerEnergyCorrection
 Auxiliary class for correction of energy determined by JShowerEnergy.cc. More...
 
struct  JShowerNPE
 Auxiliary class for handling EM shower light yield. More...
 
struct  JShowerNPEHit
 Auxiliary class for simultaneously handling light yields and response of PMT. More...
 
class  JSimplex
 Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++, W.H. More...
 
class  JVectorNZ
 Determination of the time residual vector of hits for a track along z-axis (JFIT::JLine1Z). More...
 

Typedefs

typedef JTOOLS::JRange< double > JZRange
 

Enumerations

enum  JMEstimator_t {
  EM_NORMAL = 0 , EM_LORENTZIAN = 1 , EM_LINEAR = 2 , EM_NULL = 3 ,
  EM_TUKEY = 4 , EM_NORMALWITHBACKGROUND = 5
}
 Definition of the various M-Estimators available to use. More...
 

Functions

double getP (const double expval, bool hit)
 Get Poisson probability to observe a hit or not for given expectation value for the number of hits.
 
double getChi2 (const double P)
 Get chi2 corresponding to given probability.
 
double getChi2 (const double expval, bool hit)
 Get chi2 to observe a hit or not for given expectation value for the number of hits.
 
template<class JModel_t , class JHit_t >
double getChi2 (const JModel_t &model, const JHit_t &hit, const double sigma)
 Determine chi2 of a hit for a given model and time resolution.
 
template<class JModel_t , class T >
double getChi2 (const JModel_t &model, T __begin, T __end, const double sigma)
 Determine chi2 of data for given model and time resolution.
 
double getChi2 (const JVectorNZ &Y, const JMatrixNZ &V)
 Determine chi2 using full covariance matrix.
 
template<class T >
double getChi2 (const JLine1Z &track, T __begin, T __end, const JMatrixNZ &V)
 Determine chi2 of data for given track using full covariance matrix.
 
template<class T >
double getChi2 (const JLine1Z &track, T __begin, T __end, const double alpha, const double sigma)
 Determine chi2 of data for given track and angular and time resolution.
 
double getChi2 (const JVectorNZ &Y, const JMatrixNZ &V, const int i)
 Determine difference between chi2 with and without hit using full covariance matrix.
 
template<class JModel_t , class JFit_t , class T >
double getChi2 (const JModel_t &model, const JFit_t &fit, T __begin, T __end)
 Get chi2 of data for given model and fit function.
 
double getProbability (const size_t N, const size_t M, const JK40Rates &R_Hz, const double T_ns)
 Get probability due to random background.
 
template<class JModel_t >
void model (JModel_t &value)
 Auxiliary function to constrain model during fit.
 
JMEstimatorgetMEstimator (const int type)
 Get M-Estimator.
 
double getPMTAngle (const double angle)
 Constrain PMT angle to [0,pi].
 
void model (JShower3EZ &value)
 Function to constrain the versor and energy during the fit, to prevent unphysical values.
 

Detailed Description

Auxiliary classes and methods for linear and iterative data regression.

Author
mdejong
adomi
vcarretero
lquinn
mdejong, adomi

Typedef Documentation

◆ JZRange

typedef JTOOLS::JRange<double> JFIT::JZRange

Definition at line 21 of file JFit/JModel.hh.

Enumeration Type Documentation

◆ JMEstimator_t

Definition of the various M-Estimators available to use.

Enumerator
EM_NORMAL 
EM_LORENTZIAN 
EM_LINEAR 
EM_NULL 
EM_TUKEY 
EM_NORMALWITHBACKGROUND 

Definition at line 188 of file JMEstimator.hh.

188 {
189 EM_NORMAL = 0,
190 EM_LORENTZIAN = 1,
191 EM_LINEAR = 2,
192 EM_NULL = 3,
193 EM_TUKEY = 4,
195 };
@ EM_NORMALWITHBACKGROUND

Function Documentation

◆ getP()

double JFIT::getP ( const double expval,
bool hit )
inline

Get Poisson probability to observe a hit or not for given expectation value for the number of hits.

Parameters
expvalexpectation value
hithit
Returns
probability

Definition at line 41 of file JFitToolkit.hh.

42 {
43 if (hit)
44 return -expm1(-expval); // 1 - P(0)
45 else
46 return exp(-expval); // P(0)
47 }

◆ getChi2() [1/9]

double JFIT::getChi2 ( const double P)
inline

Get chi2 corresponding to given probability.

Parameters
Pprobability
Returns
chi2

Definition at line 56 of file JFitToolkit.hh.

57 {
58 return -log(P);
59 }

◆ getChi2() [2/9]

double JFIT::getChi2 ( const double expval,
bool hit )
inline

Get chi2 to observe a hit or not for given expectation value for the number of hits.

Parameters
expvalexpectation value
hithit
Returns
probability

Definition at line 69 of file JFitToolkit.hh.

70 {
71 if (hit)
72 return -log1p(-exp(-expval));
73 else
74 return expval;
75 }

◆ getChi2() [3/9]

template<class JModel_t , class JHit_t >
double JFIT::getChi2 ( const JModel_t & model,
const JHit_t & hit,
const double sigma )
inline

Determine chi2 of a hit for a given model and time resolution.

The template argument JModel_t refers to a data structure which should provide for the following method:

  double getT(const JHit_t& hit) const;    // get expected time of hit
Parameters
modelmodel
hithit
sigmasigma
Returns
chi2

Definition at line 93 of file JFitToolkit.hh.

94 {
95 const double ds = (hit.getT() - model.getT(hit)) / sigma;
96
97 return ds * ds;
98 }

◆ getChi2() [4/9]

template<class JModel_t , class T >
double JFIT::getChi2 ( const JModel_t & model,
T __begin,
T __end,
const double sigma )
inline

Determine chi2 of data for given model and time resolution.

The template argument JModel_t refers to a data structure which should provide for the following method:

  double getT(const value_type& hit) const;    // expected time of hit

where value_type corresponds to the value type if the input data.

Parameters
modelmodel
__beginbegin of data
__endend of data
sigmatime resolution [ns]
Returns
chi2

Definition at line 118 of file JFitToolkit.hh.

119 {
120 double chi2 = 0.0;
121
122 for (T hit = __begin; hit != __end; ++hit) {
123 chi2 += getChi2(model, *hit, sigma);
124 }
125
126 return chi2;
127 }
double getChi2(const double P)
Get chi2 corresponding to given probability.

◆ getChi2() [5/9]

double JFIT::getChi2 ( const JVectorNZ & Y,
const JMatrixNZ & V )
inline

Determine chi2 using full covariance matrix.

Parameters
Yresiduals
Vcovariance matrix
Returns
chi2

Definition at line 137 of file JFitToolkit.hh.

139 {
140 return V.getDot(Y);
141 }
static double getDot(const variance &first, const variance &second)
Get dot product.
Definition JMatrixNZ.hh:196

◆ getChi2() [6/9]

template<class T >
double JFIT::getChi2 ( const JLine1Z & track,
T __begin,
T __end,
const JMatrixNZ & V )
inline

Determine chi2 of data for given track using full covariance matrix.

Parameters
tracktrack
__beginbegin of data
__endend of data
Vcovariance matrix
Returns
chi2

Definition at line 154 of file JFitToolkit.hh.

158 {
159 const JVectorNZ Y(track, __begin, __end);
160
161 return getChi2(Y, V);
162 }
Determination of the time residual vector of hits for a track along z-axis (JFIT::JLine1Z).
Definition JVectorNZ.hh:23

◆ getChi2() [7/9]

template<class T >
double JFIT::getChi2 ( const JLine1Z & track,
T __begin,
T __end,
const double alpha,
const double sigma )
inline

Determine chi2 of data for given track and angular and time resolution.

Parameters
tracktrack
__beginbegin of data
__endend of data
alphaangular resolution [deg]
sigmatime resolution [ns]
Returns
chi2

Definition at line 176 of file JFitToolkit.hh.

177 {
178 JMatrixNZ V(track, __begin, __end, alpha, sigma);
179
180 V.invert();
181
182 return getChi2(track, __begin, __end, V);
183 }
Determination of the co-variance matrix of hits for a track along z-axis (JFIT::JLine1Z).
Definition JMatrixNZ.hh:30

◆ getChi2() [8/9]

double JFIT::getChi2 ( const JVectorNZ & Y,
const JMatrixNZ & V,
const int i )
inline

Determine difference between chi2 with and without hit using full covariance matrix.

Parameters
Yresiduals
Vcovariance matrix
iindex of excluded hit
Returns
chi2

Definition at line 194 of file JFitToolkit.hh.

197 {
198 double chi2 = 0.0;
199
200 for (size_t j = 0; j != V.size(); ++j) {
201 chi2 += V(i,j) * Y[j];
202 }
203
204 return chi2*chi2 / V(i,i);
205 }
size_t size() const
Get dimension of matrix.
Definition JMatrixND.hh:202

◆ getChi2() [9/9]

template<class JModel_t , class JFit_t , class T >
double JFIT::getChi2 ( const JModel_t & model,
const JFit_t & fit,
T __begin,
T __end )
inline

Get chi2 of data for given model and fit function.

The template argument JFit_t refers to a data structure which should provide for the function object operator:

  double operator()(const JModel_t& model, const value_type&) const;    // chi2

where JModel_t refers to the given model and value_type to the value type if the input data. The return value should correspond to the chi2 of the hit.

Parameters
modelmodel
fitfit function
__beginbegin of data
__endend of data

Definition at line 227 of file JFitToolkit.hh.

228 {
229 double chi2 = 0.0;
230
231 for (T hit = __begin; hit != __end; ++hit) {
232 chi2 += fit(model, *hit);
233 }
234
235 return chi2;
236 }

◆ getProbability()

double JFIT::getProbability ( const size_t N,
const size_t M,
const JK40Rates & R_Hz,
const double T_ns )
inline

Get probability due to random background.

Parameters
Nnumber of active PMTs
Mmultiplicity of hits
R_Hzrates [Hz]
T_nstime window [ns]
Returns
probability

Definition at line 248 of file JFitToolkit.hh.

252 {
253 using namespace JPP;
254
255 if (N == 0) {
256 return (M == 0 ? 1.0 : 0.0);
257 }
258
259 const double T = T_ns * 1.0e-9;
260 const double p = -expm1(-R_Hz.getSinglesRate() * N * T); // 1 - P(0) due to singles rate
261
262 double P = 0.0;
263
264 for (multiplicity_type i = R_Hz.getLowerL1Multiplicity(); i <= R_Hz.getUpperL1Multiplicity(); ++i) {
265 P -= expm1(-R_Hz.getMultiplesRate(i) * T); // 1 - P(0) due to multiples rates
266 }
267
268 P *= (1.0 + p); // 1 - P(0) due to multiples rates M-1 combined with singles rate
269
270 return (poisson(M, R_Hz.getSinglesRate() * N * T) - // P(M) due to singles rate
271 expm1(-R_Hz.getMultiplesRate(M) * T) - // P(M) due to multiples rate
272 expm1(-R_Hz.getMultiplesRate(M-1) * T) * p) / (1.0 + P); // P(M-1) * P(1) due to multiples rate combined with singles rate
273 }
size_t multiplicity_type
Type definition of multiplicity.
Definition JK40Rates.hh:33
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getSinglesRate() const
Get singles rate.
Definition JK40Rates.hh:71
double getMultiplesRate(const multiplicity_type M) const
Get multiples rate at given multiplicity.
Definition JK40Rates.hh:94
multiplicity_type getLowerL1Multiplicity() const
Get lower multiplicty.
Definition JK40Rates.hh:108
multiplicity_type getUpperL1Multiplicity() const
Get upper multiplicty.
Definition JK40Rates.hh:119

◆ model() [1/2]

template<class JModel_t >
void JFIT::model ( JModel_t & value)
inline

Auxiliary function to constrain model during fit.

Parameters
valuemodel (I/O)

Definition at line 57 of file JGandalf.hh.

58 {}

◆ getMEstimator()

JMEstimator * JFIT::getMEstimator ( const int type)
inline

Get M-Estimator.

Note that for M-estimators with an additional parameter, defaults are used.

Parameters
typetype
Returns
pointer to newly created M-Estimator (may throw exception)

Definition at line 206 of file JMEstimator.hh.

207 {
208 switch (type) {
209
210 case EM_NORMAL:
211 return new JMEstimatorNormal();
212
213 case EM_LORENTZIAN:
214 return new JMEstimatorLorentzian();
215
216 case EM_LINEAR:
217 return new JMEstimatorLinear();
218
219 case EM_NULL:
220 return new JMEstimatorNull();
221
222 case EM_TUKEY:
223 return new JMEstimatorTukey(5.0);
224
226 return new JMEstimatorNormalWithBackground(1.0e-5);
227
228 default:
229 THROW(JPointerException, "Invalid M-Estimator type " << type);
230 }
231 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for accessing an invalid pointer.
Linear M-estimator.
Lorentzian M-estimator.
Normal M-estimator with background.
Normal M-estimator.
Null M-estimator.
Tukey's biweight M-estimator.

◆ getPMTAngle()

double JFIT::getPMTAngle ( const double angle)
inline

Constrain PMT angle to [0,pi].

Parameters
angleangle [rad]
Returns
angle [rad]

Definition at line 58 of file JShower3EZRegressor.hh.

59 {
60 const double epsilon = 1.0e-6;
61 const JTOOLS::JRange<double> range(epsilon, JMATH::PI - epsilon);
62
63 return range.constrain(fabs(angle));
64 }
Range of values.
Definition JRange.hh:42
static const double PI
Mathematical constants.

◆ model() [2/2]

void JFIT::model ( JShower3EZ & value)

Function to constrain the versor and energy during the fit, to prevent unphysical values.

Parameters
valuemodel (I/O)

Definition at line 72 of file JShower3EZRegressor.hh.

73 {
74 using namespace std;
75
76
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);
81
82 if (u > 1.0) {
83 Tx /= u;
84 Ty /= u;
85 }
86
87 value = JShower3EZ(static_cast<const JPoint4D&>(value), JVersor3Z(Tx,Ty), E, value.getBy());
88
89 }
double getBy() const
Get bjorken y.
Definition JShower3EZ.hh:76
double getE() const
Get E.
Definition JShower3EZ.hh:86
double getDY() const
Get y direction.
Definition JVersor3Z.hh:158
double getDX() const
Get x direction.
Definition JVersor3Z.hh:147