Belle II Software light-2406-ragdoll
BaseConstraint Class Referenceabstract

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

#include <BaseConstraint.h>

Inheritance diagram for BaseConstraint:

Public Member Functions

 BaseConstraint ()
 Creates an empty BaseConstraint object.
 
 BaseConstraint (const BaseConstraint &rhs)
 Copy constructor.
 
BaseConstraintoperator= (const BaseConstraint &rhs)
 Assignment.
 
virtual ~BaseConstraint ()
 Virtual destructor.
 
virtual double getValue () const =0
 Returns the value of the constraint function.
 
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 void getDerivatives (int idim, double der[]) const =0
 Get first order derivatives of the constraint function Call this with a predefined array "der" with the necessary number of entries!
 
virtual std::ostream & print (std::ostream &os) const
 print object to ostream
 

Protected Attributes

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 BaseFitObject and can be either set a whole (setFOList) or enlarged by adding a single BaseFitObject (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 Last update:

Date
2011/03/03 15:03:02

by:

Author
blist

Definition at line 71 of file BaseConstraint.h.

Constructor & Destructor Documentation

◆ BaseConstraint() [1/2]

Creates an empty BaseConstraint object.

Definition at line 30 of file BaseConstraint.cc.

31 : name(nullptr)
32 {
33 setName("???");
34 }
void setName(const char *name_)
Set object's name.

◆ BaseConstraint() [2/2]

BaseConstraint ( const BaseConstraint rhs)

Copy constructor.

Parameters
rhsright hand side

Definition at line 36 of file BaseConstraint.cc.

37 : name(nullptr)
38 {
39 if (rhs.name) setName(rhs.name);
40 else setName("???");
41 }

◆ ~BaseConstraint()

~BaseConstraint ( )
virtual

Virtual destructor.

Definition at line 51 of file BaseConstraint.cc.

52 {
53 delete[] name;
54 }

Member Function Documentation

◆ getDerivatives()

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

Get first order derivatives of the constraint function Call this with a predefined array "der" with the necessary number of entries!

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

Implemented in TrackConstraint, MassConstraint, MomentumConstraint, RecoilMassConstraint, SoftGaussMassConstraint, SoftGaussMomentumConstraint, BaseHardConstraint, and SoftGaussParticleConstraint.

◆ getError()

double getError ( ) const
virtual

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 }

◆ getName()

const char * getName ( ) const
virtual

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

◆ operator=()

BaseConstraint & operator= ( const BaseConstraint rhs)

Assignment.

Parameters
rhsright hand side

Definition at line 42 of file BaseConstraint.cc.

43 {
44 if (this != &rhs) {
45 if (rhs.name) setName(rhs.name);
46 else setName("???");
47 }
48 return *this;
49 }

◆ print()

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

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.

◆ setName()

void setName ( const char *  name_)

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

◆ name

char* name
protected

Definition at line 108 of file BaseConstraint.h.


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