Belle II Software development
|
Abstract base class for constraints of kinematic fits. More...
#include <BaseHardConstraint.h>
Public Member Functions | |
virtual | ~BaseHardConstraint () |
Virtual destructor. | |
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 vector. | |
virtual double | dirDer (double *p, double *w, int idim, double mu=1) |
Calculate directional derivative. | |
virtual double | dirDerAbs (double *p, double *w, int idim, double mu=1) |
Calculate directional derivative for abs(c) | |
virtual bool | secondDerivatives (int i, int j, double *derivatives) const =0 |
Second derivatives with respect to the meta-variables of Fit objects i and j; result false if all derivatives are zero. | |
virtual bool | firstDerivatives (int i, double *derivatives) const =0 |
First derivatives with respect to the meta-variables of Fit objects i; result false if all derivatives are zero. | |
virtual int | getVarBasis () const =0 |
virtual double | getValue () const override=0 |
Returns the value of the constraint. | |
virtual double | getError () const override |
Returns the error on the value of the constraint. | |
virtual void | getDerivatives (int idim, double der[]) const override=0 |
Get first order derivatives. | |
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 | 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. | |
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. | |
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< 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 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). | |
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. | |
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:
by:
Definition at line 75 of file BaseHardConstraint.h.
|
protected |
Constant iterator through vector of pointers to ParticleFitObjects.
Definition at line 175 of file BaseHardConstraint.h.
|
protected |
Vector of pointers to ParticleFitObjects.
Definition at line 171 of file BaseHardConstraint.h.
|
protected |
Iterator through vector of pointers to ParticleFitObjects.
Definition at line 173 of file BaseHardConstraint.h.
|
inline |
Definition at line 189 of file BaseHardConstraint.h.
|
virtual |
Adds first order derivatives to global covariance matrix M.
M | Global covariance matrix, dimension at least idim x idim |
idim | First dimension of array der |
Definition at line 37 of file BaseHardConstraint.cc.
|
virtual |
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
Here, is a Matrix, where is the number of parameters of FitObject i; Correspondingly, is a matrix. Also, is a matrix for a given i and j, and is a 4-vector (though not a Lorentz-vector!).
but here it's been generalised
First, treat the part
Second, treat the part
Here, is a 4-vector, which we pass on to the FitObject
M | Global covariance matrix, dimension at least idim x idim |
idim | First dimension of array der |
lambda | Lagrange multiplier for this constraint |
Definition at line 76 of file BaseHardConstraint.cc.
|
virtual |
Add lambda times derivatives of chi squared to global derivative vector.
y | Vector of chi2 derivatives |
idim | Vector size |
Definition at line 204 of file BaseHardConstraint.cc.
|
virtual |
Calculate directional derivative.
p | Vector of direction |
w | Work vector |
idim | Vector size |
mu | optional multiplier |
Definition at line 232 of file BaseHardConstraint.cc.
|
virtual |
Calculate directional derivative for abs(c)
p | Vector of direction |
w | Work vector |
idim | Vector size |
mu | optional multiplier |
Definition at line 242 of file BaseHardConstraint.cc.
|
pure virtual |
First derivatives with respect to the meta-variables of Fit objects i; result false if all derivatives are zero.
i | number of 1st FitObject |
derivatives | The result 4-vector |
Implemented in MassConstraint, MomentumConstraint, and RecoilMassConstraint.
|
overridepure virtual |
Get first order derivatives.
Call this with a predefined array "der" with the necessary number of entries!
idim | First dimension of the array |
der | Array of derivatives, at least idim x idim |
Implements BaseConstraint.
Implemented in MassConstraint, MomentumConstraint, and RecoilMassConstraint.
|
overridevirtual |
Returns the error on the value of the constraint.
Reimplemented from BaseConstraint.
Definition at line 217 of file BaseHardConstraint.cc.
|
inlinevirtual |
Accesses position of constraint in global constraint list.
Definition at line 137 of file BaseHardConstraint.h.
|
virtualinherited |
Returns the name of the constraint.
Definition at line 56 of file BaseConstraint.cc.
|
overridepure virtual |
Returns the value of the constraint.
Implements BaseConstraint.
Implemented in MassConstraint, MomentumConstraint, and RecoilMassConstraint.
|
virtual |
Evaluates numerically the 1st derivative w.r.t. a parameter.
ifo | Number of FitObject |
ilocal | Local parameter number |
eps | variation of local parameter |
Definition at line 307 of file BaseHardConstraint.cc.
|
virtual |
Evaluates numerically the 2nd derivative w.r.t. 2 parameters.
ifo1 | Number of 1st FitObject |
ilocal1 | 1st local parameter number |
eps1 | variation of 1st local parameter |
ifo2 | Number of 1st FitObject |
ilocal2 | 1st local parameter number |
eps2 | variation of 2nd local parameter |
Definition at line 321 of file BaseHardConstraint.cc.
|
virtualinherited |
print object to ostream
os | The output stream |
Definition at line 76 of file BaseConstraint.cc.
|
virtual |
Definition at line 360 of file BaseHardConstraint.cc.
|
virtual |
Definition at line 379 of file BaseHardConstraint.cc.
|
pure virtual |
Second derivatives with respect to the meta-variables of Fit objects i and j; result false if all derivatives are zero.
i | number of 1st FitObject |
j | number of 2nd FitObject |
derivatives | The result 4x4 matrix |
Implemented in MassConstraint, MomentumConstraint, and RecoilMassConstraint.
|
inlinevirtual |
Sets position of constraint in global constraint list.
iglobal | Global constraint number |
Definition at line 140 of file BaseHardConstraint.h.
|
inherited |
Set object's name.
Definition at line 61 of file BaseConstraint.cc.
|
virtual |
Definition at line 251 of file BaseHardConstraint.cc.
|
virtual |
Definition at line 272 of file BaseHardConstraint.cc.
|
related |
Prints out a BaseConstraint, using its print method.
os | The output stream |
bc | The object to print |
Definition at line 114 of file BaseConstraint.h.
|
protected |
The derivatives.
Definition at line 179 of file BaseHardConstraint.h.
|
protected |
The FitObjectContainer.
Definition at line 177 of file BaseHardConstraint.h.
|
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 182 of file BaseHardConstraint.h.
|
protected |
Position of constraint in global constraint list.
Definition at line 185 of file BaseHardConstraint.h.
|
protectedinherited |
Definition at line 108 of file BaseConstraint.h.