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

Implements a soft constraint with chi^2=((efact*sum(E_i) + pxfact*sum(p_x,i)+pyfact*sum(p_y,i)+pzfact*sum(p_z,i)-value)/sigma)^2. More...

#include <SoftGaussMomentumConstraint.h>

Inheritance diagram for SoftGaussMomentumConstraint:
Collaboration diagram for SoftGaussMomentumConstraint:

Public Member Functions

 SoftGaussMomentumConstraint (double sigma_=0, double efact_=0, double pxfact_=0, double pyfact_=0, double pzfact_=0, double value_=0)
 Constructor. More...
 
virtual ~SoftGaussMomentumConstraint ()
 Virtual destructor.
 
virtual double getValue () const override
 Returns the value of the constraint function.
 
virtual void getDerivatives (int idim, double der[]) const override
 Get first order derivatives. More...
 
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 getChi2 () const override
 Returns the chi2.
 
virtual double getError () const override
 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 add2ndDerivativesToMatrix (double *M, int idim) const override
 Adds second order derivatives to global covariance matrix M. More...
 
virtual void addToGlobalChi2DerVector (double *y, int idim) const override
 Add derivatives of chi squared to global derivative matrix. More...
 
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
 
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 = 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 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 efact
 
double pxfact
 
double pyfact
 
double pzfact
 
double value
 
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).
 
double sigma
 The sigma of the Gaussian.
 
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 a soft constraint with chi^2=((efact*sum(E_i) + pxfact*sum(p_x,i)+pyfact*sum(p_y,i)+pzfact*sum(p_z,i)-value)/sigma)^2.

This class implements soft constraints on the sum of energies, px, py, and pz. It can be used to for constraints of the form

  • chi^2 = (sum(E)-sqrt(s))^2/sigma^2
  • chi^2 = (sum(px))^2/sigma^2
  • chi^2 = (sum(py))^2/sigma^2
  • chi^2 = (sum(pz))^2/sigma^2
  • chi^2 = (sum(E)-sum(pz)-2 Ee)^2/sigma^2

Author: Jenny List, Benno List Last update:

Date
2008/02/18 09:59:34

by:

Author
blist

Definition at line 49 of file SoftGaussMomentumConstraint.h.

Constructor & Destructor Documentation

◆ SoftGaussMomentumConstraint()

SoftGaussMomentumConstraint ( double  sigma_ = 0,
double  efact_ = 0,
double  pxfact_ = 0,
double  pyfact_ = 0,
double  pzfact_ = 0,
double  value_ = 0 
)

Constructor.

Parameters
sigma_The sigma value
efact_Factor for energy sum
pxfact_Factor for px sum
pyfact_Factor for py sum
pzfact_Factor for pz sum
value_Target value of sum

Definition at line 33 of file SoftGaussMomentumConstraint.cc.

36  efact(efact_),
37  pxfact(pxfact_),
38  pyfact(pyfact_),
39  pzfact(pzfact_),
40  value(value_)
41  {}
SoftGaussParticleConstraint(double sigma_)
Creates an empty SoftGaussParticleConstraint object.

Member Function Documentation

◆ add2ndDerivativesToMatrix()

void add2ndDerivativesToMatrix ( double *  M,
int  idim 
) const
overridevirtualinherited

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 $$ \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!).

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 parts $$ \sum_i \frac{\partial g}{\partial P_i} \cdot \frac{\partial^2 P_i}{\partial a_k \partial a_l} $$ and $$ \frac{\partial^2 h}{\partial g^2} \sum_i \frac{\partial g}{\partial P_i} \cdot \frac{\partial P_i}{\partial a_k} \sum_j \frac{\partial g}{\partial P_j} \cdot \frac{\partial P_j}{\partial a_l} $$

Here, $\frac{\partial g}{\partial 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.

Definition at line 91 of file SoftGaussParticleConstraint.cc.

◆ addToGlobalChi2DerVector()

void addToGlobalChi2DerVector ( double *  y,
int  idim 
) const
overridevirtualinherited

Add derivatives of chi squared to global derivative matrix.

Parameters
yVector of chi2 derivatives
idimVector size

Implements BaseSoftConstraint.

Definition at line 243 of file SoftGaussParticleConstraint.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 SoftGaussParticleConstraint.

Definition at line 86 of file SoftGaussMomentumConstraint.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 SoftGaussParticleConstraint.

Definition at line 67 of file SoftGaussMomentumConstraint.cc.

◆ num1stDerivative()

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

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

Parameters
ifoNumber of FitObject
ilocalLocal parameter number
epsvariation of local parameter

Definition at line 312 of file SoftGaussParticleConstraint.cc.

◆ num2ndDerivative()

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

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 326 of file SoftGaussParticleConstraint.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 SoftGaussParticleConstraint.

Definition at line 96 of file SoftGaussMomentumConstraint.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 83 of file SoftGaussParticleConstraint.h.

◆ setSigma()

double setSigma ( double  sigma_)
virtualinherited

Sets the sigma.

Parameters
sigma_The new sigma value

Definition at line 42 of file SoftGaussParticleConstraint.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: