MarlinKinfit
0.4.0
|
Abstract base class for particle objects of kinematic fits. More...
#include <BaseFitObject.h>
Public Member Functions | |
BaseFitObject () | |
Default constructor. | |
BaseFitObject (const BaseFitObject &rhs) | |
Copy constructor. More... | |
BaseFitObject & | operator= (const BaseFitObject &rhs) |
Assignment. More... | |
virtual | ~BaseFitObject () |
Virtual destructor. | |
virtual BaseFitObject * | copy () const =0 |
Return a new copy of itself. | |
virtual BaseFitObject & | assign (const BaseFitObject &source) |
Assign from anther object, if of same type. More... | |
virtual bool | setParam (int ilocal, double par_, bool measured_, bool fixed_=false) |
Set value and measured flag of parameter i; return: significant change. More... | |
virtual bool | setParam (int ilocal, double par_) |
Set value of parameter ilocal; return: significant change. More... | |
virtual bool | updateParams (double p[], int idim) |
Read values from global vector, readjust vector; return: significant change. More... | |
virtual bool | setMParam (int ilocal, double mpar_) |
Set measured value of parameter ilocal; return: success. More... | |
virtual bool | setError (int ilocal, double err_) |
Set error of parameter ilocal; return: success. More... | |
virtual bool | setCov (int ilocal, int jlocal, double cov_) |
Set covariance of parameters ilocal and jlocal; return: success. More... | |
virtual bool | setGlobalParNum (int ilocal, int iglobal) |
Set number of parameter ilocal in global list return true signals OK. More... | |
virtual bool | fixParam (int ilocal, bool fix=true) |
Fix a parameter (fix=true), or release it (fix=false) More... | |
virtual bool | releaseParam (int ilocal) |
Release a parameter. More... | |
virtual bool | isParamFixed (int ilocal) const |
Returns whether parameter is fixed. More... | |
virtual double | getParam (int ilocal) const |
Get current value of parameter ilocal. More... | |
virtual const char * | getParamName (int ilocal) const |
Get name of parameter ilocal. More... | |
virtual const char * | getName () const |
Get object's name. | |
virtual void | setName (const char *name_) |
Set object's name. | |
virtual double | getMParam (int ilocal) const |
Get measured value of parameter ilocal. More... | |
virtual double | getError (int ilocal) const |
Get error of parameter ilocal. More... | |
virtual double | getCov (int ilocal, int jlocal) const |
Get covariance between parameters ilocal and jlocal. More... | |
virtual double | getRho (int ilocal, int jlocal) const |
Get correlation coefficient between parameters ilocal and jlocal. More... | |
virtual bool | isParamMeasured (int ilocal) const |
Get measured flag for parameter ilocal. More... | |
virtual int | getGlobalParNum (int ilocal) const |
Get global parameter number of parameter ilocal. More... | |
virtual int | getNPar () const =0 |
Get total number of parameters of this FitObject. | |
virtual int | getNMeasured () const |
Get number of measured parameters of this FitObject. | |
virtual int | getNUnmeasured () const |
Get number of unmeasured parameters of this FitObject. | |
virtual int | getNFree () const |
Get number of free parameters of this FitObject. | |
virtual int | getNFixed () const |
Get number of fixed parameters of this FitObject. | |
virtual double | getChi2 () const |
Get chi squared from measured and fitted parameters. | |
virtual double | getDChi2DParam (int ilocal) const |
Get derivative of chi squared w.r.t. parameter ilocal. More... | |
virtual double | getD2Chi2DParam2 (int ilocal, int jlocal) const |
Get second derivative of chi squared w.r.t. parameters ilocal1 and ilocal2. More... | |
virtual std::ostream & | printParams (std::ostream &os) const |
print the parameters and errors More... | |
virtual std::ostream & | printRhoValues (std::ostream &os) const |
print the correlation coefficients More... | |
virtual std::ostream & | print1stDerivatives (std::ostream &os) const |
print the 1st derivatives wrt metaSet 0 (E, px, py, pz) More... | |
virtual std::ostream & | print2ndDerivatives (std::ostream &os) const |
print the 2nd derivatives wrt metaSet 0 (E, px, py, pz) More... | |
virtual std::ostream & | print (std::ostream &os) const =0 |
print object to ostream More... | |
virtual void | invalidateCache () const |
invalidate any cached quantities | |
virtual void | updateCache () const =0 |
virtual void | addToGlobCov (double *glcov, int idim) const |
Add covariance matrix elements to global covariance matrix of size idim x idim. More... | |
virtual void | addToGlobalChi2DerVector (double *y, int idim) const |
Add derivatives of chi squared to global derivative vector. More... | |
virtual void | addToGlobalChi2DerMatrix (double *M, int idim) const |
Add 2nd derivatives of chi squared to global derivative matrix. More... | |
virtual void | addToGlobalChi2DerVector (double *y, int idim, double lambda, double der[], int metaSet) const |
Add derivatives of momentum vector to global derivative vector. More... | |
virtual void | addTo1stDerivatives (double M[], int idim, double der[], int kglobal, int metaSet) const |
virtual void | addTo2ndDerivatives (double der2[], int idim, double factor[], int metaSet) const |
virtual void | addTo2ndDerivatives (double M[], int idim, double lambda, double der[], int metaSet) const |
virtual double | getFirstDerivative_Meta_Local (int iMeta, int ilocal, int metaSet) const =0 |
virtual double | getSecondDerivative_Meta_Local (int iMeta, int ilocal, int jlocal, int metaSet) const =0 |
virtual void | initCov () |
virtual double | getError2 (double der[], int metaset) const |
virtual void | getDerivatives (double der[], int idim) const =0 |
Protected Member Functions | |
virtual bool | calculateCovInv () const |
Calculate the inverse of the covariance matrix. | |
Protected Attributes | |
char * | name |
double | par [BaseDefs::MAXPAR] |
fit parameters | |
double | mpar [BaseDefs::MAXPAR] |
measured parameters | |
bool | measured [BaseDefs::MAXPAR] |
measured flag | |
bool | fixed [BaseDefs::MAXPAR] |
fixed flag | |
int | globalParNum [BaseDefs::MAXPAR] |
global paramter number for each parameter | |
double | cov [BaseDefs::MAXPAR][BaseDefs::MAXPAR] |
local covariance matrix | |
double | covinv [BaseDefs::MAXPAR][BaseDefs::MAXPAR] |
inverse pf local covariance matrix | |
bool | covinvvalid |
flag for valid inverse covariance matrix | |
bool | cachevalid |
flag for valid cache | |
Static Protected Attributes | |
static const double | eps2 = 0.0001 |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, const BaseFitObject &bfo) |
Prints out a BaseFitObject, using its print method. More... | |
Abstract base class for particle objects of kinematic fits.
This class defines the minimal functionality any fit object must provide. The main task of a fit object is to keep parameters (and errors) that define the four-momentum of a particle and encapsulate the actually chosen parametrisation from the rest of the fitting machinery.
Since for the fit a parametrisation distributed like a gaussian is most favorable, different kinds of particles (implying different kinds of measurements!) might require different parametrisations. For each desired parametrisation a concrete class should be derived from this abstract base class. It needs to be able to convert its parameters to E, px, py, pz and to provide the derivatives of E, px, py, pz with respect to the internal parameters.
Depending on the type of particle, some or all parameters might be unmeasured (neutrinos!), meaning that they come with a very large and/or unknown error. They are treated differently by the fit algorithm and are thus flagged accordingly.
In order to insert its derivatives into the global covariance matrix of all FitObjects in the event, each FitObjects needs to know the position of its parameters in the overall parameter list.
THIS iS JUNK!!!! It is done like this in JetFitObject.C, but using measured[i] which is the bool giving the measured/unmeasured status and NOT a bool containing the START VALUES!!!!! From its stored initial parameters and the current fit parameters the FitObject calculates its contribution to the $^2$ of the fit.
In its current state, a BaseFitObject has a set of parameters, some of them measured (i.e., they contribute to the ). These parameters have a local numbering, running from 0 to n-1. Global numbers can be assigned by the BaseFitter using setGlobalParNum.
The class WWFitter needs the following routines from BaseFitObject:
Author: Benno List, Jenny Böhme
Changelog:
BaseFitObject::BaseFitObject | ( | const BaseFitObject & | rhs | ) |
|
virtual |
Add 2nd derivatives of chi squared to global derivative matrix.
M | Global derivative matrix |
idim | First dimension of global derivative matrix |
References calculateCovInv(), covinvvalid, getD2Chi2DParam2(), getGlobalParNum(), getNPar(), isParamFixed(), and isParamMeasured().
|
virtual |
Add derivatives of chi squared to global derivative vector.
y | Vector of chi2 derivatives |
idim | Vector size |
References calculateCovInv(), covinvvalid, getDChi2DParam(), getGlobalParNum(), getNPar(), isParamFixed(), and isParamMeasured().
Referenced by SoftGaussParticleConstraint::add2ndDerivativesToMatrix(), BaseHardConstraint::addToGlobalChi2DerVector(), and SoftGaussParticleConstraint::addToGlobalChi2DerVector().
|
virtual |
Add derivatives of momentum vector to global derivative vector.
y | Vector of chi2 derivatives |
idim | Vector size |
lambda | The lambda value |
der | derivatives of constraint wrt intermediate variables (e.g. 4-vector with dg/dE, dg/dpx, dg/dpy, dg/dpz) |
metaSet | which set of intermediate variables |
References cachevalid, getNPar(), and globalParNum.
|
virtual |
Add covariance matrix elements to global covariance matrix of size idim x idim.
glcov | Global covariance matrix |
idim | First dimension of global derivative matrix |
References getCov(), getGlobalParNum(), getNPar(), isParamFixed(), and isParamMeasured().
|
virtual |
Assign from anther object, if of same type.
source | The source object |
Reimplemented in ParticleFitObject, VertexFitObject, JetFitObject, ISRPhotonFitObject, LeptonFitObject, SimplePhotonFitObject, NeutrinoFitObject, TrackParticleFitObject, and ZinvisibleFitObject.
References cachevalid, cov, covinvvalid, fixed, globalParNum, measured, mpar, par, and setName().
Referenced by VertexFitObject::assign(), ParticleFitObject::assign(), BaseFitObject(), and operator=().
|
virtual |
Fix a parameter (fix=true), or release it (fix=false)
ilocal | Local parameter number |
fix | fix if true, release if false |
References fixed, and getNPar().
Referenced by VertexFitObject::addConstraints(), TrackParticleFitObject::fixVertexParam(), and releaseParam().
|
virtual |
Get covariance between parameters ilocal and jlocal.
ilocal | Local parameter number i |
jlocal | Local parameter number j |
Reimplemented in JetFitObject.
References cov, and getNPar().
Referenced by addToGlobCov().
|
virtual |
Get second derivative of chi squared w.r.t. parameters ilocal1 and ilocal2.
ilocal | Local parameter number i |
jlocal | Local parameter number j |
References calculateCovInv(), covinv, covinvvalid, getNPar(), isParamFixed(), and isParamMeasured().
Referenced by addToGlobalChi2DerMatrix().
|
virtual |
Get derivative of chi squared w.r.t. parameter ilocal.
ilocal | Local parameter number |
References calculateCovInv(), covinv, covinvvalid, getNPar(), isParamFixed(), isParamMeasured(), mpar, and par.
Referenced by addToGlobalChi2DerVector().
|
virtual |
Get error of parameter ilocal.
ilocal | Local parameter number |
Reimplemented in JetFitObject.
References cov, and getNPar().
Referenced by NewtonFitterGSL::fit(), and printParams().
|
virtual |
Get global parameter number of parameter ilocal.
ilocal | Local parameter number |
References getNPar(), and globalParNum.
Referenced by BaseHardConstraint::add2ndDerivativesToMatrix(), SoftGaussParticleConstraint::add2ndDerivativesToMatrix(), addToGlobalChi2DerMatrix(), ParticleFitObject::addToGlobalChi2DerMatrixNum(), addToGlobalChi2DerVector(), ParticleFitObject::addToGlobalChi2DerVectorNum(), addToGlobCov(), NewtonFitterGSL::fit(), VertexConstraint::getDerivatives(), ZinvisibleFitObject::updateParams(), TrackParticleFitObject::updateParams(), NeutrinoFitObject::updateParams(), SimplePhotonFitObject::updateParams(), LeptonFitObject::updateParams(), ISRPhotonFitObject::updateParams(), JetFitObject::updateParams(), and updateParams().
|
virtual |
Get measured value of parameter ilocal.
ilocal | Local parameter number |
References getNPar(), and mpar.
Referenced by NewtonFitterGSL::fit().
|
virtual |
Get current value of parameter ilocal.
ilocal | Local parameter number |
References getNPar(), and par.
Referenced by NewtonFitterGSL::fit(), SoftGaussParticleConstraint::num1stDerivative(), BaseHardConstraint::num1stDerivative(), ParticleFitObject::num1stDerivative(), SoftGaussParticleConstraint::num2ndDerivative(), BaseHardConstraint::num2ndDerivative(), ParticleFitObject::num2ndDerivative(), printParams(), and updateParams().
|
inlinevirtual |
Get name of parameter ilocal.
ilocal | Local parameter number |
Reimplemented in VertexFitObject, JetFitObject, ISRPhotonFitObject, LeptonFitObject, SimplePhotonFitObject, NeutrinoFitObject, TrackParticleFitObject, and ZinvisibleFitObject.
Referenced by NewtonFitterGSL::fit().
|
virtual |
Get correlation coefficient between parameters ilocal and jlocal.
ilocal | Local parameter number i |
jlocal | Local parameter number j |
References cov, and getNPar().
Referenced by printRhoValues().
|
virtual |
Returns whether parameter is fixed.
ilocal | Local parameter number |
References fixed, and getNPar().
Referenced by addToGlobalChi2DerMatrix(), addToGlobalChi2DerVector(), addToGlobCov(), NewtonFitterGSL::fit(), ParticleFitObject::getChi2(), getChi2(), getD2Chi2DParam2(), getDChi2DParam(), VertexConstraint::getDerivatives(), getNFixed(), getNFree(), getNMeasured(), getNUnmeasured(), printParams(), and updateParams().
|
virtual |
Get measured flag for parameter ilocal.
ilocal | Local parameter number |
References getNPar(), and measured.
Referenced by addToGlobalChi2DerMatrix(), addToGlobalChi2DerVector(), addToGlobCov(), calculateCovInv(), NewtonFitterGSL::fit(), ParticleFitObject::getChi2(), getChi2(), getD2Chi2DParam2(), getDChi2DParam(), getNMeasured(), and getNUnmeasured().
BaseFitObject & BaseFitObject::operator= | ( | const BaseFitObject & | rhs | ) |
|
pure virtual |
print object to ostream
os | The output stream |
Implemented in VertexFitObject, and ParticleFitObject.
Referenced by operator<<().
|
virtual |
print the 1st derivatives wrt metaSet 0 (E, px, py, pz)
os | The output stream |
References getNPar().
|
virtual |
print the 2nd derivatives wrt metaSet 0 (E, px, py, pz)
os | The output stream |
References getNPar().
|
virtual |
print the parameters and errors
os | The output stream |
References getError(), getNPar(), getParam(), and isParamFixed().
Referenced by ParticleFitObject::print(), and VertexFitObject::print().
|
virtual |
|
inlinevirtual |
|
virtual |
Set covariance of parameters ilocal and jlocal; return: success.
ilocal | Local parameter number |
jlocal | Local parameter number |
cov_ | New error value |
References cov, covinvvalid, getNPar(), and invalidateCache().
Referenced by LeptonFitObject::LeptonFitObject().
|
virtual |
Set error of parameter ilocal; return: success.
ilocal | Local parameter number |
err_ | New error value |
References cov, covinvvalid, getNPar(), and invalidateCache().
Referenced by ISRPhotonFitObject::ISRPhotonFitObject(), LeptonFitObject::LeptonFitObject(), and SimplePhotonFitObject::SimplePhotonFitObject().
|
virtual |
Set number of parameter ilocal in global list return true signals OK.
ilocal | Local parameter number |
iglobal | New global parameter number |
References getNPar(), and globalParNum.
|
virtual |
Set measured value of parameter ilocal; return: success.
ilocal | Local parameter number |
mpar_ | New measured parameter value |
References getNPar(), invalidateCache(), and mpar.
Referenced by ISRPhotonFitObject::ISRPhotonFitObject(), LeptonFitObject::LeptonFitObject(), SimplePhotonFitObject::SimplePhotonFitObject(), and VertexFitObject::VertexFitObject().
|
virtual |
Set value and measured flag of parameter i; return: significant change.
ilocal | Local parameter number |
par_ | New parameter value |
measured_ | New "measured" flag |
fixed_ | New "fixed" flag |
References fixed, getNPar(), invalidateCache(), and measured.
Referenced by ISRPhotonFitObject::ISRPhotonFitObject(), LeptonFitObject::LeptonFitObject(), SoftGaussParticleConstraint::num1stDerivative(), BaseHardConstraint::num1stDerivative(), ParticleFitObject::num1stDerivative(), SoftGaussParticleConstraint::num2ndDerivative(), BaseHardConstraint::num2ndDerivative(), ParticleFitObject::num2ndDerivative(), SimplePhotonFitObject::SimplePhotonFitObject(), updateParams(), and VertexFitObject::VertexFitObject().
|
virtual |
Set value of parameter ilocal; return: significant change.
ilocal | Local parameter number |
par_ | New parameter value |
References cov, getNPar(), invalidateCache(), and par.
|
virtual |
Read values from global vector, readjust vector; return: significant change.
p | The parameter vector |
idim | Length of the vector |
Reimplemented in JetFitObject, ISRPhotonFitObject, LeptonFitObject, SimplePhotonFitObject, NeutrinoFitObject, TrackParticleFitObject, and ZinvisibleFitObject.
References getGlobalParNum(), getNPar(), getParam(), invalidateCache(), isParamFixed(), and setParam().
|
related |
Prints out a BaseFitObject, using its print method.
os | The output stream |
bfo | The object to print |
References print().