Belle II Software light-2406-ragdoll
TrackConstraint Class Referenceabstract

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

#include <TrackConstraint.h>

Inheritance diagram for TrackConstraint:
Collaboration diagram for TrackConstraint:

Public Member Functions

 TrackConstraint ()
 Creates an empty TrackConstraint object.
 
virtual ~TrackConstraint ()
 Virtual destructor.
 
virtual void setFOList (std::vector< TrackFitObject * > *fitobjects_)
 Adds several TrackFitObject objects to the list.
 
virtual void addToFOList (TrackFitObject &fitobject, int flag=1)
 Adds one TrackFitObject objects to the list.
 
virtual double getValue () const =0
 Returns the value of the constraint.
 
virtual void getDerivatives (int idim, double der[]) const =0
 Get first order derivatives.
 
virtual void add1stDerivativesToMatrix (double *M, int idim) const
 Adds first order derivatives to global covariance matrix M.
 
virtual void add2ndDerivativesToMatrix (double *M, int idim, double lambda) const
 Adds second order derivatives to global covariance matrix M.
 
virtual void addToGlobalChi2DerVector (double *y, int idim, double lambda) const
 Add lambda times derivatives of chi squared to global derivative matrix.
 
virtual int getGlobalNum () const
 Accesses position of constraint in global constraint list.
 
virtual void setGlobalNum (int iglobal)
 Sets position of constraint in global constraint list.
 
virtual void invalidateCache () const
 Invalidates any cached values for the next event.
 
virtual double getError () const
 Returns the error on the value of the constraint.
 
virtual const char * getName () const
 Returns the name of the constraint.
 
void setName (const char *name_)
 Set object's name.
 
virtual std::ostream & print (std::ostream &os) const
 print object to ostream
 

Protected Types

typedef std::vector< TrackFitObject * > FitObjectContainer
 Vector of pointers to TrackFitObjects.
 
typedef FitObjectContainer::iterator FitObjectIterator
 Iterator through vector of pointers to TrackFitObjects.
 
typedef FitObjectContainer::const_iterator ConstFitObjectIterator
 Constant iterator through vector of pointers to TrackFitObjects.
 

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).
 
std::vector< double > sign
 
int globalNum
 Position of constraint in global constraint list.
 
char * name
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const BaseConstraint &bc)
 Prints out a BaseConstraint, using its print method.
 

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 TrackFitObject and can be either set a whole (setFOList) or enlarged by adding a single TrackFitObject (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: Benno List, Jenny List

Date
2008/01/30 09:14:54
Author
blist

Definition at line 73 of file TrackConstraint.h.

Member Typedef Documentation

◆ ConstFitObjectIterator

typedef FitObjectContainer::const_iterator ConstFitObjectIterator
protected

Constant iterator through vector of pointers to TrackFitObjects.

Definition at line 137 of file TrackConstraint.h.

◆ FitObjectContainer

typedef std::vector<TrackFitObject*> FitObjectContainer
protected

Vector of pointers to TrackFitObjects.

Definition at line 133 of file TrackConstraint.h.

◆ FitObjectIterator

typedef FitObjectContainer::iterator FitObjectIterator
protected

Iterator through vector of pointers to TrackFitObjects.

Definition at line 135 of file TrackConstraint.h.

Constructor & Destructor Documentation

◆ TrackConstraint()

TrackConstraint ( )
inline

Creates an empty TrackConstraint object.

Definition at line 152 of file TrackConstraint.h.

153 {
155 }
virtual void invalidateCache() const
Invalidates any cached values for the next event.

◆ ~TrackConstraint()

virtual ~TrackConstraint ( )
inlinevirtual

Virtual destructor.

Definition at line 78 of file TrackConstraint.h.

78{};

Member Function Documentation

◆ add1stDerivativesToMatrix()

virtual void add1stDerivativesToMatrix ( double *  M,
int  idim 
) const
inlinevirtual

Adds first order derivatives to global covariance matrix M.

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

Definition at line 105 of file TrackConstraint.h.

108 {assert(false);}

◆ add2ndDerivativesToMatrix()

virtual void add2ndDerivativesToMatrix ( double *  M,
int  idim,
double  lambda 
) const
inlinevirtual

Adds second order derivatives to global covariance matrix M.

Parameters
MGlobal covariance matrix, dimension at least idim x idim
idimFirst dimension of array der
lambdaLagrange multiplier for this constraint

Definition at line 110 of file TrackConstraint.h.

114 {assert(false);}

◆ addToFOList()

virtual void addToFOList ( TrackFitObject &  fitobject,
int  flag = 1 
)
inlinevirtual

Adds one TrackFitObject objects to the list.

Definition at line 91 of file TrackConstraint.h.

93 {
94 fitobjects.push_back(&fitobject);
95 flags.push_back(flag);
96 sign.push_back(sign.size() == 0 ? 1 : -1);
97 };
FitObjectContainer fitobjects
The FitObjectContainer.
std::vector< int > flags
The flags can be used to divide the FitObjectContainer into several subsets used for example to imple...

◆ addToGlobalChi2DerVector()

virtual void addToGlobalChi2DerVector ( double *  y,
int  idim,
double  lambda 
) const
inlinevirtual

Add lambda times derivatives of chi squared to global derivative matrix.

Parameters
yVector of chi2 derivatives
idimVector size

Definition at line 117 of file TrackConstraint.h.

121 {assert(false);};

◆ getDerivatives()

virtual void 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!

Implements BaseConstraint.

◆ getError()

double getError ( ) const
virtualinherited

Returns the error on the value of the constraint.

Reimplemented in BaseHardConstraint, and SoftGaussParticleConstraint.

Definition at line 70 of file BaseConstraint.cc.

71 {
72 assert(false);
73 return 0;
74 }

◆ getGlobalNum()

virtual int getGlobalNum ( ) const
inlinevirtual

Accesses position of constraint in global constraint list.

Definition at line 124 of file TrackConstraint.h.

124{return globalNum;}
int globalNum
Position of constraint in global constraint list.

◆ getName()

const char * getName ( ) const
virtualinherited

Returns the name of the constraint.

Definition at line 56 of file BaseConstraint.cc.

57 {
58 return name;
59 }

◆ getValue()

virtual double getValue ( ) const
pure virtual

Returns the value of the constraint.

Implements BaseConstraint.

◆ invalidateCache()

virtual void invalidateCache ( ) const
inlinevirtual

Invalidates any cached values for the next event.

Definition at line 129 of file TrackConstraint.h.

129{};

◆ print()

std::ostream & print ( std::ostream &  os) const
virtualinherited

print object to ostream

Parameters
osThe output stream

Definition at line 76 of file BaseConstraint.cc.

77 {
78 os << getName() << "=" << getValue();
79 return os;
80 }
virtual double getValue() const =0
Returns the value of the constraint function.
virtual const char * getName() const
Returns the name of the constraint.

◆ setFOList()

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

Adds several TrackFitObject objects to the list.

Parameters
fitobjects_A list of BaseFitObject objects

Definition at line 81 of file TrackConstraint.h.

83 {
84 for (int i = 0; i < (int) fitobjects_->size(); i++) {
85 fitobjects.push_back((*fitobjects_)[i]);
86 flags.push_back(1);
87 sign.push_back(i == 0 ? 1 : -1);
88 }
89 };

◆ setGlobalNum()

virtual void setGlobalNum ( int  iglobal)
inlinevirtual

Sets position of constraint in global constraint list.

Definition at line 126 of file TrackConstraint.h.

126{globalNum = iglobal;}

◆ setName()

void setName ( const char *  name_)
inherited

Set object's name.

Definition at line 61 of file BaseConstraint.cc.

62 {
63 if (name_ == nullptr) return;
64 size_t l = strlen(name_);
65 if (name) delete[] name;
66 name = new char[l + 1];
67 strcpy(name, name_);
68 }

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const BaseConstraint bc 
)
related

Prints out a BaseConstraint, using its print method.

Parameters
osThe output stream
bcThe object to print

Definition at line 114 of file BaseConstraint.h.

117 {
118 return bc.print(os);
119 }

Member Data Documentation

◆ derivatives

std::vector<double> derivatives
protected

The derivatives.

Definition at line 141 of file TrackConstraint.h.

◆ fitobjects

FitObjectContainer fitobjects
protected

The FitObjectContainer.

Definition at line 139 of file TrackConstraint.h.

◆ flags

std::vector<int> 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).

Definition at line 144 of file TrackConstraint.h.

◆ globalNum

int globalNum
protected

Position of constraint in global constraint list.

Definition at line 148 of file TrackConstraint.h.

◆ name

char* name
protectedinherited

Definition at line 108 of file BaseConstraint.h.

◆ sign

std::vector<double> sign
protected

Definition at line 145 of file TrackConstraint.h.


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