MarlinKinfit  0.4.0
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
SoftGaussParticleConstraint Class Referenceabstract

Abstract base class for constraints of kinematic fits. More...

#include <SoftGaussParticleConstraint.h>

Inheritance diagram for SoftGaussParticleConstraint:
BaseSoftConstraint BaseConstraint SoftGaussMassConstraint SoftGaussMomentumConstraint

Public Member Functions

 SoftGaussParticleConstraint (double sigma_)
 Creates an empty SoftGaussParticleConstraint object. More...
 
virtual ~SoftGaussParticleConstraint ()
 Virtual destructor.
 
virtual void setFOList (std::vector< ParticleFitObject * > *fitobjects_)
 Adds several ParticleFitObject objects to the list. More...
 
virtual void addToFOList (ParticleFitObject &fitobject, int flag=1)
 Adds one ParticleFitObject objects to the list.
 
virtual void resetFOList ()
 Resests ParticleFitObject list.
 
virtual double getValue () const =0
 Returns the value of the constraint function.
 
virtual double getChi2 () const
 Returns the chi2.
 
virtual double getError () const
 Returns the error on the value of the constraint.
 
virtual double getSigma () const
 Returns the sigma.
 
virtual double setSigma (double sigma_)
 Sets the sigma. More...
 
virtual void getDerivatives (int idim, double der[]) const =0
 Get first order derivatives. More...
 
virtual void add2ndDerivativesToMatrix (double *M, int idim) const
 Adds second order derivatives to global covariance matrix M. More...
 
virtual void addToGlobalChi2DerVector (double *y, int idim) const
 Add derivatives of chi squared to global derivative matrix. More...
 
virtual void invalidateCache () const
 Invalidates any cached values for the next event.
 
void test1stDerivatives ()
 
void test2ndDerivatives ()
 
double num1stDerivative (int ifo, int ilocal, double eps)
 Evaluates numerically the 1st derivative w.r.t. a parameter. More...
 
double num2ndDerivative (int ifo1, int ilocal1, double eps1, int ifo2, int ilocal2, double eps2)
 Evaluates numerically the 2nd derivative w.r.t. 2 parameters. More...
 
int getVarBasis () const
 
- Public Member Functions inherited from BaseSoftConstraint
virtual ~BaseSoftConstraint ()
 Virtual destructor.
 
- Public Member Functions inherited from BaseConstraint
 BaseConstraint ()
 Creates an empty BaseConstraint object.
 
 BaseConstraint (const BaseConstraint &rhs)
 Copy constructor. More...
 
BaseConstraintoperator= (const BaseConstraint &rhs)
 Assignment. More...
 
virtual ~BaseConstraint ()
 Virtual destructor.
 
virtual const char * getName () const
 Returns the name of the constraint.
 
virtual void setName (const char *name_)
 Set object's name.
 
virtual std::ostream & print (std::ostream &os) const
 print object to ostream More...
 

Protected Types

enum  { VAR_BASIS =BaseDefs::VARBASIS_EPXYZ }
 
typedef std::vector
< ParticleFitObject * > 
FitObjectContainer
 Vector of pointers to ParticleFitObjects.
 
typedef
FitObjectContainer::iterator 
FitObjectIterator
 Iterator through vector of pointers to ParticleFitObjects.
 
typedef
FitObjectContainer::const_iterator 
ConstFitObjectIterator
 Constant iterator through vector of pointers to ParticleFitObjects.
 

Protected Member Functions

virtual bool secondDerivatives (int i, int j, double *derivatives) const =0
 Second derivatives with respect to the 4-vectors of Fit objects i and j; result false if all derivatives are zero. More...
 
virtual bool firstDerivatives (int i, double *derivatives) const =0
 First derivatives with respect to the 4-vector of Fit objects i; result false if all derivatives are zero. More...
 

Protected Attributes

FitObjectContainer fitobjects
 The FitObjectContainer.
 
std::vector< double > derivatives
 The derivatives.
 
std::vector< int > flags
 The flags can be used to divide the FitObjectContainer into several subsets used for example to implement an equal mass constraint (see MassConstraint). More...
 
double sigma
 The sigma of the Gaussian.
 
- Protected Attributes inherited from BaseSoftConstraint
char * name
 
- Protected Attributes inherited from BaseConstraint
char * name
 

Additional Inherited Members

Detailed Description

Abstract base class for constraints of kinematic fits.

This class defines the minimal functionality any constraint class must provide. First of all a constraint should know on with particles (or FitObject) it is applied. Where as for example a constraint on the total transvese momentum takes into account all particles in the event, an invariant mass constraint usually applies only to a subset of particles.

The particle list is implemented as a vector containing pointers to objects derived from ParticleFitObject and can be either set a whole (setFOList) or enlarged by adding a single ParticleFitObject (addToFOList).

From the four–momenta of all concerned fit objects the constraint has to be able to calculate its current value (getValue). Constraints should be formulated such that a value of zero corresponds to a perfectly fulfilled constraint.

In order to find a solution to the constrained minimisation problem, fit algorithms usually need the first order derivatives of the constraint with respect to the fit parameters. Since many constraints can be most easily expressed in terms of E, px, py, pz, the constraints supply their derivatives w.r.t. these parameters. If a FitObject uses a different parametrisation, it is its own task to provide the additional derivatives of E, px, py, pz w.r.t. the parameters of the FitObject. Thus it is easily possible to use FitObjects with different kinds of parametrisations under the same constraint. Some fit algorithms also need the second derivatives of the constraint, i.e. the NewtonFitter.

First and second order derivatives of each constraint can be added directly to the global covariance matrix containing the derivatives of all constraints w.r.t. to all parameters (add1stDerivativesToMatrix, add2ndDerivativesToMatrix). This requires the constraint to know its position in the overall list of constraints (globalNum).

Author: Jenny List, Benno List

Date:
2008/02/13 12:37:38
Author:
blist

Constructor & Destructor Documentation

SoftGaussParticleConstraint::SoftGaussParticleConstraint ( double  sigma_)

Creates an empty SoftGaussParticleConstraint object.

Parameters
sigma_The sigma value

References invalidateCache().

Member Function Documentation

void SoftGaussParticleConstraint::add2ndDerivativesToMatrix ( double *  M,
int  idim 
) const
virtual

Adds second order derivatives to global covariance matrix M.

Calculates the second derivative of the constraint g w.r.t.

the various parameters and adds it to the global covariance matrix

We denote with P_i the 4-vector of the i-th ParticleFitObject, then $$ { ^2 g}{ a_k a_l} = { ^2 g}{ P_i P_j} { P_i}{ a_k} { P_j}{ a_l}

  • { g}{ P_i} {^2 P_i}{ a_k a_l} $$ Here, ${ P_i}{ a_k}$ is a $4 n_i$ Matrix, where $n_i$ is the number of parameters of FitObject i; Correspondingly, ${^2 P_i}{ a_k a_l}$ is a $4 n_i n_i$ matrix. Also, ${ ^2 g}{ P_i P_j}$ is a $4 4$ matrix for a given i and j, and ${ g}{ P_i}$ is a 4-vector (though not a Lorentz-vector!).

First, treat the part $$ { ^2 g}{ P_i P_j} { P_i}{ a_k} { P_j}{ a_l} $$

Second, treat the parts $$ { g}{ P_i} {^2 P_i}{ a_k a_l} $$ and $$ {^2 h}{ g^2} { g}{ P_i} { P_i}{ a_k} { g}{ P_j} { P_j}{ a_l} $$

Here, ${ g}{ P_i}$ is a 4-vector, which we pass on to the FitObject

Parameters
MCovariance matrix, at least idim x idim
idimFirst dimension of the array

Implements BaseSoftConstraint.

References BaseFitObject::addToGlobalChi2DerVector(), firstDerivatives(), fitobjects, BaseFitObject::getGlobalParNum(), BaseFitObject::getNPar(), getSigma(), getValue(), and secondDerivatives().

void SoftGaussParticleConstraint::addToGlobalChi2DerVector ( double *  y,
int  idim 
) const
virtual

Add derivatives of chi squared to global derivative matrix.

Parameters
yVector of chi2 derivatives
idimVector size

Implements BaseSoftConstraint.

References BaseFitObject::addToGlobalChi2DerVector(), firstDerivatives(), fitobjects, getSigma(), and getValue().

virtual bool SoftGaussParticleConstraint::firstDerivatives ( int  i,
double *  derivatives 
) const
protectedpure virtual

First derivatives with respect to the 4-vector of Fit objects i; result false if all derivatives are zero.

Parameters
inumber of 1st FitObject
derivativesThe result 4-vector

Implemented in SoftGaussMassConstraint, and SoftGaussMomentumConstraint.

Referenced by add2ndDerivativesToMatrix(), addToGlobalChi2DerVector(), and getError().

virtual void SoftGaussParticleConstraint::getDerivatives ( int  idim,
double  der[] 
) const
pure virtual

Get first order derivatives.

Call this with a predefined array "der" with the necessary number of entries!

Parameters
idimFirst dimension of the array
derArray of derivatives, at least idim x idim

Implements BaseConstraint.

Implemented in SoftGaussMassConstraint, and SoftGaussMomentumConstraint.

double SoftGaussParticleConstraint::num1stDerivative ( int  ifo,
int  ilocal,
double  eps 
)

Evaluates numerically the 1st derivative w.r.t. a parameter.

Parameters
ifoNumber of FitObject
ilocalLocal parameter number
epsvariation of local parameter

References fitobjects, getChi2(), BaseFitObject::getParam(), and BaseFitObject::setParam().

double SoftGaussParticleConstraint::num2ndDerivative ( int  ifo1,
int  ilocal1,
double  eps1,
int  ifo2,
int  ilocal2,
double  eps2 
)

Evaluates numerically the 2nd derivative w.r.t. 2 parameters.

Parameters
ifo1Number of 1st FitObject
ilocal11st local parameter number
eps1variation of 1st local parameter
ifo2Number of 1st FitObject
ilocal21st local parameter number
eps2variation of 2nd local parameter

References fitobjects, getChi2(), BaseFitObject::getParam(), and BaseFitObject::setParam().

virtual bool SoftGaussParticleConstraint::secondDerivatives ( int  i,
int  j,
double *  derivatives 
) const
protectedpure virtual

Second derivatives with respect to the 4-vectors of Fit objects i and j; result false if all derivatives are zero.

Parameters
inumber of 1st FitObject
jnumber of 2nd FitObject
derivativesThe result 4x4 matrix

Implemented in SoftGaussMassConstraint, and SoftGaussMomentumConstraint.

Referenced by add2ndDerivativesToMatrix().

virtual void SoftGaussParticleConstraint::setFOList ( std::vector< ParticleFitObject * > *  fitobjects_)
inlinevirtual

Adds several ParticleFitObject objects to the list.

Parameters
fitobjects_A list of BaseFitObject objects

References fitobjects, and flags.

double SoftGaussParticleConstraint::setSigma ( double  sigma_)
virtual

Sets the sigma.

Parameters
sigma_The new sigma value

References sigma.

Member Data Documentation

std::vector<int> SoftGaussParticleConstraint::flags
protected

The flags can be used to divide the FitObjectContainer into several subsets used for example to implement an equal mass constraint (see MassConstraint).

Referenced by addToFOList(), SoftGaussMassConstraint::firstDerivatives(), SoftGaussMassConstraint::getDerivatives(), SoftGaussMassConstraint::getMass(), SoftGaussMassConstraint::getValue(), resetFOList(), SoftGaussMassConstraint::secondDerivatives(), and setFOList().


The documentation for this class was generated from the following files: