Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Typedefs | Enumerations | Functions
JFIT Namespace Reference

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

Classes

class  JEnergy
 Data structure for fit of energy. More...
 
struct  JRegressor< JEnergy >
 Regressor function object for JEnergy fit. More...
 
struct  JEstimator
 Template definition of linear fit. More...
 
class  JGandalf
 Fit method based on the Levenberg-Marquardt method. More...
 
struct  JK40
 Auxiliary class for converting various rates to expectation values of the number of hits within a given time interval. More...
 
struct  JK40Hit
 Auxiliary class for simultaneously handling light yields and response of module. More...
 
class  JEstimator< JLegendre< JOrdinate_t, N > >
 Linear fit of Legendre polynomial. More...
 
class  JLine1Z
 Data structure for fit of straight line paralel to z-axis. More...
 
class  JEstimator< JLine1Z >
 Linear fit of straight line parallel to z-axis to set of hits (objects with position and time). 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...
 
struct  JRegressor< JLine3Z, JSimplex >
 Regressor function object for JLine3Z fit using JSimplex minimiser. More...
 
struct  JRegressor< JLine3Z, JGandalf >
 Regressor function object for JLine3Z fit using JGandalf minimiser. 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  JMEstimatorNull
 Null M-estimator. More...
 
struct  JMEstimatorNormal
 Normal M-estimator. More...
 
struct  JMEstimatorLorentzian
 Lorentzian M-estimator. More...
 
struct  JMEstimatorLinear
 Linear 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< JLine1Z >
 Template specialisation of class JModel to match hit with muon trajectory along z-axis. More...
 
struct  JModel< JEnergy >
 Template specialisation of class JModel to match hit with muon energy. More...
 
struct  JModel< JPoint4D >
 Template specialisation of class JModel to match hit with bright point. 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  JPMTW0
 Auxiliary class for handling PMT geometry, rate and response. More...
 
class  JPoint3D
 Data structure for position fit. More...
 
class  JEstimator< JPoint3D >
 Linear fit of crossing point (position) between axes (objects with position and direction). More...
 
class  JPoint4D
 Data structure for vertex fit. More...
 
class  JEstimator< JPoint4D >
 Linear fit of bright point (position and time) between hits (objects with position and time). More...
 
struct  JRegressor< JPoint4D, JSimplex >
 Regressor function object for JPoint4D fit using JSimplex minimiser. More...
 
struct  JAbstractMinimiser
 Abstract minimiser. More...
 
struct  JRegressor
 Template definition of a data regressor of given model. More...
 
struct  JAbstractRegressor
 Abstract class for global fit method. More...
 
class  JShower3EZ
 Data structure for fit of straight line in positive z-direction with energy. More...
 
struct  JRegressor< JShower3EZ, JSimplex >
 Regressor function object for JShower3EZ fit using JSimplex minimiser. More...
 
struct  JRegressor< JShower3EZ, JGandalf >
 Regressor function object for JShower3EZ fit using JGandalf minimiser. More...
 
class  JShower3Z
 Data structure for cascade in positive z-direction. More...
 
struct  JRegressor< JShowerEH, JSimplex >
 Regressor function object for JShowerEH fit using JSimplex minimiser. More...
 
struct  JRegressor< JPoint4D, JGandalf >
 Regressor function object for JPoint4D fit using JGandalf minimiser. More...
 
class  JShowerEH
 Data structure for fit of straight line in positive z-direction with energy. More...
 
struct  JRegressor< JEnergy, JSimplex >
 Regressor function object for JShower3EZ fit using JSimplex minimiser. 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...
 
class  JEnergyCorrection
 Auxiliary class for correction of energy determined by JEnergy.cc. More...
 
class  JFit
 Data structure for track fit results with history and optional associated values. More...
 
class  JEvt
 Data structure for set of track fit results. More...
 
struct  JEvent
 Auxiliary class for historical event. More...
 
struct  JHistory
 Container for historical events. More...
 
class  JShowerEnergyCorrection
 Auxiliary class for correction of energy determined by JShowerEnergy.cc. More...
 

Typedefs

typedef JTOOLS::JRange< double > JZRange
 

Enumerations

enum  JMEstimator_t { EM_NORMAL = 0, EM_LORENTZIAN = 1, EM_LINEAR = 2, EM_NULL = 3 }
 Definition of the various M-Estimators available to use. More...
 
enum  JFitStatus_t { ERROR = -100, INSUFFICIENT_NUMBER_OF_HITS, INSUFFICIENT_NUMBER_OF_DOMS, OKAY = 1 }
 

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. More...
 
double getP (const double expval, const size_t numberOfHits)
 Get Poisson probability to observe given number of hits for the given expectation value for the number of hits. More...
 
double getChi2 (const double P)
 Get chi2 corresponding to given probability. More...
 
double getChi2 (const double expval, bool hit)
 Get chi2 to observe a hit or not for given expectation value for the number of hits. More...
 
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. More...
 
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. More...
 
double getChi2 (const JVectorNZ &Y, const JMatrixNZ &V)
 Determine chi2 using full covariance matrix. More...
 
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. More...
 
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. More...
 
double getChi2 (const JVectorNZ &Y, const JMatrixNZ &V, const int i)
 Determine difference between chi2 with and without hit using full covariance matrix. More...
 
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. More...
 
JMEstimatorgetMEstimator (const int type)
 Get M-Estimator. More...
 

Detailed Description

Auxiliary classes and methods for linear and iterative data regression.

Author
mdejong
adomi
lquinn
mdejong, adomi

Typedef Documentation

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

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

Enumeration Type Documentation

Definition of the various M-Estimators available to use.

Enumerator
EM_NORMAL 
EM_LORENTZIAN 
EM_LINEAR 
EM_NULL 

Definition at line 152 of file JMEstimator.hh.

152  {
153  EM_NORMAL = 0,
154  EM_LORENTZIAN = 1,
155  EM_LINEAR = 2,
156  EM_NULL = 3
157  };
Enumerator
ERROR 
INSUFFICIENT_NUMBER_OF_HITS 
INSUFFICIENT_NUMBER_OF_DOMS 
OKAY 

Definition at line 16 of file JFitStatus.hh.

Function Documentation

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 34 of file JFitToolkit.hh.

35  {
36  if (hit)
37  return -expm1(-expval); // 1 - P(0)
38  else
39  return exp(-expval); // P(0)
40  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` typeset -Z 4 STRING JOpera1D -f hydrophone.root
double JFIT::getP ( const double  expval,
const size_t  numberOfHits 
)
inline

Get Poisson probability to observe given number of hits for the given expectation value for the number of hits.

Parameters
expvalexpectation value
numberOfHitsnumber of hits
Returns
propability

Definition at line 50 of file JFitToolkit.hh.

51  {
52  using namespace JPP;
53 
54  double P = exp(-expval);
55 
56  for (size_t i = numberOfHits; i != 0; --i) {
57  P *= expval / (double) i;
58  }
59 
60  return P;
61  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` typeset -Z 4 STRING JOpera1D -f hydrophone.root
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62
double JFIT::getChi2 ( const double  P)
inline

Get chi2 corresponding to given probability.

Parameters
Pprobability
Returns
chi2

Definition at line 70 of file JFitToolkit.hh.

71  {
72  return -log(P);
73  }
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62
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 83 of file JFitToolkit.hh.

84  {
85  if (hit)
86  return -log1p(-exp(-expval));
87  else
88  return expval;
89  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` typeset -Z 4 STRING JOpera1D -f hydrophone.root
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 107 of file JFitToolkit.hh.

108  {
109  const double ds = (hit.getT() - model.getT(hit)) / sigma;
110 
111  return ds * ds;
112  }
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 132 of file JFitToolkit.hh.

133  {
134  double chi2 = 0.0;
135 
136  for (T hit = __begin; hit != __end; ++hit) {
137  chi2 += getChi2(model, *hit, sigma);
138  }
139 
140  return chi2;
141  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:70
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 151 of file JFitToolkit.hh.

153  {
154  return V.getDot(Y);
155  }
static double getDot(const variance &first, const variance &second)
Get dot product.
Definition: JMatrixNZ.hh:196
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 168 of file JFitToolkit.hh.

172  {
173  const JVectorNZ Y(track, __begin, __end);
174 
175  return getChi2(Y, V);
176  }
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
Determination of the time residual vector of hits for a track along z-axis (JFIT::JLine1Z).
Definition: JVectorNZ.hh:21
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:70
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 190 of file JFitToolkit.hh.

191  {
192  JMatrixNZ V(track, __begin, __end, alpha, sigma);
193 
194  V.invert();
195 
196  return getChi2(track, __begin, __end, V);
197  }
Determination of the co-variance matrix of hits for a track along z-axis (JFIT::JLine1Z).
Definition: JMatrixNZ.hh:28
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:70
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 208 of file JFitToolkit.hh.

211  {
212  double chi2 = 0.0;
213 
214  for (size_t j = 0; j != V.size(); ++j) {
215  chi2 += V(i,j) * Y[j];
216  }
217 
218  return chi2*chi2 / V(i,i);
219  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:157
int j
Definition: JPolint.hh:666
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 241 of file JFitToolkit.hh.

242  {
243  double chi2 = 0.0;
244 
245  for (T hit = __begin; hit != __end; ++hit) {
246  chi2 += fit(model, *hit);
247  }
248 
249  return chi2;
250  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JMEstimator* JFIT::getMEstimator ( const int  type)
inline

Get M-Estimator.

Parameters
typetype
Returns
pointer to newly created M-Estimator (maybe NULL)

Definition at line 166 of file JMEstimator.hh.

167  {
168  switch (type) {
169 
170  case EM_NORMAL:
171  return new JMEstimatorNormal();
172 
173  case EM_LORENTZIAN:
174  return new JMEstimatorLorentzian();
175 
176  case EM_LINEAR:
177  return new JMEstimatorLinear();
178 
179  case EM_NULL:
180  return new JMEstimatorNull();
181 
182  default:
183  return NULL;
184  }
185  }
Null M-estimator.
Definition: JMEstimator.hh:53
Linear M-estimator.
Definition: JMEstimator.hh:92
Normal M-estimator.
Definition: JMEstimator.hh:66
Lorentzian M-estimator.
Definition: JMEstimator.hh:79