Jpp - 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. 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 unsigned int numberOfHits, const double precision=1.0e-5)
 Get Poisson probability to observe given number of hits or more 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 36 of file JFitToolkit.hh.

37  {
38  if (hit)
39  return -expm1(-expval); // 1 - P(0)
40  else
41  return exp(-expval); // P(0)
42  }
then set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))*exp(-0.5 *(y-[1])*(y-[1])/([2]*[2]))" JF2 -o $WORKDIR/f2.root -F "$FORMULA" -@ "p0
double JFIT::getP ( const double  expval,
const unsigned int  numberOfHits,
const double  precision = 1.0e-5 
)
inline

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

Parameters
expvalexpectation value
numberOfHitsnumber of hits
precisionprecision
Returns
propability

Definition at line 54 of file JFitToolkit.hh.

55  {
56  double P = 0.0;
57 
58  for (int i = numberOfHits; ; ++i) {
59 
60  const double p = TMath::PoissonI(i, expval);
61 
62  P += p;
63 
64  if ((double) i > expval && p < precision) {
65  break;
66  }
67  }
68 
69  return P;
70  }
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:60
double JFIT::getChi2 ( const double  P)
inline

Get chi2 corresponding to given probability.

Parameters
Pprobability
Returns
chi2

Definition at line 79 of file JFitToolkit.hh.

80  {
81  return -log(P);
82  }
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:60
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 92 of file JFitToolkit.hh.

93  {
94  if (hit)
95  return -log1p(-exp(-expval));
96  else
97  return expval;
98  }
then set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))*exp(-0.5 *(y-[1])*(y-[1])/([2]*[2]))" JF2 -o $WORKDIR/f2.root -F "$FORMULA" -@ "p0
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 116 of file JFitToolkit.hh.

117  {
118  const double ds = (hit.getT() - model.getT(hit)) / sigma;
119 
120  return ds * ds;
121  }
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 141 of file JFitToolkit.hh.

142  {
143  double chi2 = 0.0;
144 
145  for (T hit = __begin; hit != __end; ++hit) {
146  chi2 += getChi2(model, *hit, sigma);
147  }
148 
149  return chi2;
150  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:79
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 160 of file JFitToolkit.hh.

162  {
163  return V.getDot(Y);
164  }
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 177 of file JFitToolkit.hh.

181  {
182  const JVectorNZ Y(track, __begin, __end);
183 
184  return getChi2(Y, V);
185  }
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:79
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 199 of file JFitToolkit.hh.

200  {
201  JMatrixNZ V(track, __begin, __end, alpha, sigma);
202 
203  V.invert();
204 
205  return getChi2(track, __begin, __end, V);
206  }
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:79
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 217 of file JFitToolkit.hh.

220  {
221  double chi2 = 0.0;
222 
223  for (size_t j = 0; j != V.size(); ++j) {
224  chi2 += V(i,j) * Y[j];
225  }
226 
227  return chi2*chi2 / V(i,i);
228  }
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 250 of file JFitToolkit.hh.

251  {
252  double chi2 = 0.0;
253 
254  for (T hit = __begin; hit != __end; ++hit) {
255  chi2 += fit(model, *hit);
256  }
257 
258  return chi2;
259  }
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