Belle II Software  release-08-01-10
MassConstraint Class Reference

Implements constraint 0 = mass1 - mass2 - m. More...

#include <MassConstraint.h>

Inheritance diagram for MassConstraint:
Collaboration diagram for MassConstraint:

Public Member Functions

 MassConstraint (double mass_=0.)
 Constructor. More...
 
virtual ~MassConstraint ()
 Virtual destructor.
 
virtual double getValue () const override
 Returns the value of the constraint.
 
virtual void getDerivatives (int idim, double der[]) const override
 Get first order derivatives. More...
 
virtual double getMass (int flag=1)
 Get the actual invariant mass of the fit objects with a given flag. More...
 
virtual void setMass (double mass_)
 Sets the target mass of the constraint. More...
 
virtual int getVarBasis () const override
 
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 void invalidateCache () const
 Invalidates any cached values for the next event.
 
virtual void add1stDerivativesToMatrix (double *M, int idim) const
 Adds first order derivatives to global covariance matrix M. More...
 
virtual void add2ndDerivativesToMatrix (double *M, int idim, double lambda) const
 Adds second order derivatives to global covariance matrix M. More...
 
virtual void addToGlobalChi2DerVector (double *y, int idim, double lambda) const
 Add lambda times derivatives of chi squared to global derivative vector. More...
 
virtual double dirDer (double *p, double *w, int idim, double mu=1)
 Calculate directional derivative. More...
 
virtual double dirDerAbs (double *p, double *w, int idim, double mu=1)
 Calculate directional derivative for abs(c) More...
 
virtual double getError () const override
 Returns the error on the value of the constraint.
 
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. More...
 
virtual void printFirstDerivatives () const
 
virtual void printSecondDerivatives () const
 
virtual void test1stDerivatives ()
 
virtual void test2ndDerivatives ()
 
virtual double num1stDerivative (int ifo, int ilocal, double eps)
 Evaluates numerically the 1st derivative w.r.t. a parameter. More...
 
virtual 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...
 
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 More...
 

Protected Types

enum  { VAR_BASIS = 0 }
 
typedef std::vector< BaseFitObject * > 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 override
 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 override
 First derivatives with respect to the 4-vector of Fit objects i; result false if all derivatives are zero. More...
 

Protected Attributes

double mass
 The mass difference between object sets 1 and 2.
 
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).
 
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. More...
 

Detailed Description

Implements constraint 0 = mass1 - mass2 - m.

This class implements different mass constraints:

  • the invariant mass of several objects should be m
  • the difference of the invariant masses between two sets of objects should be m (normally m=0 in this case).

Author: Jenny List, Benno List Last update:

Date
2008/02/12 11:03:32

by:

Author
blist

Definition at line 46 of file MassConstraint.h.

Constructor & Destructor Documentation

◆ MassConstraint()

MassConstraint ( double  mass_ = 0.)
explicit

Constructor.

Parameters
mass_The mass difference between object sets 1 and 2

Definition at line 36 of file MassConstraint.cc.

37  : mass(mass_)
38  {}
double mass
The mass difference between object sets 1 and 2.

Member Function Documentation

◆ add1stDerivativesToMatrix()

void add1stDerivativesToMatrix ( double *  M,
int  idim 
) const
virtualinherited

Adds first order derivatives to global covariance matrix M.

Parameters
MGlobal covariance matrix, dimension at least idim x idim
idimFirst dimension of array der

Definition at line 37 of file BaseHardConstraint.cc.

◆ add2ndDerivativesToMatrix()

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

Adds second order derivatives to global covariance matrix M.

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

the various parameters, multiplies it by lambda and adds it to the global covariance matrix

in case of particlefitobject: We denote with P_i the 4-vector of the i-th ParticleFitObject, then $$ \frac{\partial ^2 g}{\partial a_k \partial a_l} = \sum_i \sum_j \frac{\partial ^2 g}{\partial P_i \partial P_j} \cdot \frac{\partial P_i}{\partial a_k} \cdot \frac{\partial P_j}{\partial a_l}

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

but here it's been generalised

First, treat the part $$ \frac{\partial ^2 g}{\partial P_i \partial P_j} \cdot \frac{\partial P_i}{\partial a_k} \cdot \frac{\partial P_j}{\partial a_l} $$

Second, treat the part $$ \sum_i \frac{\partial g}{\partial P_i} \cdot \frac{\partial^2 P_i}{\partial a_k \partial a_l} $$ Here, $\frac{\partial g}{\partial P_i}$ is a 4-vector, which we pass on to the FitObject

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

Definition at line 75 of file BaseHardConstraint.cc.

◆ addToGlobalChi2DerVector()

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

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

Parameters
yVector of chi2 derivatives
idimVector size

Definition at line 201 of file BaseHardConstraint.cc.

◆ dirDer()

double dirDer ( double *  p,
double *  w,
int  idim,
double  mu = 1 
)
virtualinherited

Calculate directional derivative.

Parameters
pVector of direction
wWork vector
idimVector size
muoptional multiplier

Definition at line 229 of file BaseHardConstraint.cc.

◆ dirDerAbs()

double dirDerAbs ( double *  p,
double *  w,
int  idim,
double  mu = 1 
)
virtualinherited

Calculate directional derivative for abs(c)

Parameters
pVector of direction
wWork vector
idimVector size
muoptional multiplier

Definition at line 239 of file BaseHardConstraint.cc.

◆ firstDerivatives()

bool firstDerivatives ( int  i,
double *  derivatives 
) const
overrideprotectedvirtual

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

Implements BaseHardConstraint.

Definition at line 208 of file MassConstraint.cc.

◆ getDerivatives()

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

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 BaseHardConstraint.

Definition at line 70 of file MassConstraint.cc.

◆ getMass()

double getMass ( int  flag = 1)
virtual

Get the actual invariant mass of the fit objects with a given flag.

Parameters
flagThe flag

Definition at line 137 of file MassConstraint.cc.

◆ num1stDerivative()

double num1stDerivative ( int  ifo,
int  ilocal,
double  eps 
)
virtualinherited

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

Parameters
ifoNumber of FitObject
ilocalLocal parameter number
epsvariation of local parameter

Definition at line 304 of file BaseHardConstraint.cc.

◆ num2ndDerivative()

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

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

Definition at line 318 of file BaseHardConstraint.cc.

◆ 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.

◆ secondDerivatives()

bool secondDerivatives ( int  i,
int  j,
double *  derivatives 
) const
overrideprotectedvirtual

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

Implements BaseHardConstraint.

Definition at line 162 of file MassConstraint.cc.

◆ setFOList()

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

Adds several ParticleFitObject objects to the list.

Parameters
fitobjects_A list of BaseFitObject objects

Definition at line 81 of file ParticleConstraint.h.

83  {
84  for (int i = 0; i < (int) fitobjects_->size(); i++) {
85  fitobjects.push_back(reinterpret_cast < BaseFitObject* >((*fitobjects_)[i]));
86  flags.push_back(1);
87  }
88  };
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...

◆ setGlobalNum()

virtual void setGlobalNum ( int  iglobal)
inlinevirtualinherited

Sets position of constraint in global constraint list.

Parameters
iglobalGlobal constraint number

Definition at line 140 of file BaseHardConstraint.h.

◆ setMass()

void setMass ( double  mass_)
virtual

Sets the target mass of the constraint.

Parameters
mass_The new mass

Definition at line 157 of file MassConstraint.cc.

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.


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