Belle II Software development
BaseHardConstraint.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * Forked from https://github.com/iLCSoft/MarlinKinfit *
6 * *
7 * Further information about the fit engine and the user interface *
8 * provided in MarlinKinfit can be found at *
9 * https://www.desy.de/~blist/kinfit/doc/html/ *
10 * and in the LCNotes LC-TOOL-2009-001 and LC-TOOL-2009-004 available *
11 * from http://www-flc.desy.de/lcnotes/ *
12 * *
13 * See git log for contributors and copyright holders. *
14 * This file is licensed under LGPL-3.0, see LICENSE.md. *
15 **************************************************************************/
16
17#ifndef __BASEHARDCONSTRAINT_H
18#define __BASEHARDCONSTRAINT_H
19
20#include "analysis/OrcaKinFit/BaseDefs.h"
21#include "analysis/OrcaKinFit/BaseConstraint.h"
22#include "analysis/OrcaKinFit/BaseFitObject.h"
23
24#include <vector>
25
26namespace Belle2 {
32 namespace OrcaKinFit {
33
34 class BaseFitObject;
35
36// Class BasehardConstraint:
38
76 public:
77
78 inline BaseHardConstraint();
79
82
84 virtual void add1stDerivativesToMatrix(double* M,
85 int idim
86 ) const;
87
89 virtual void add2ndDerivativesToMatrix(double* M,
90 int idim,
91 double lambda
92 ) const;
94 virtual void addToGlobalChi2DerVector(double* y,
95 int idim,
96 double lambda //< The lambda value
97 ) const;
99 virtual double dirDer(double* p,
100 double* w,
101 int idim,
102 double mu = 1
103 );
104
106 virtual double dirDerAbs(double* p,
107 double* w,
108 int idim,
109 double mu = 1
110 );
111
113 virtual bool secondDerivatives(int i,
114 int j,
115 double* derivatives
116 ) const = 0;
118 virtual bool firstDerivatives(int i,
119 double* derivatives
120 ) const = 0;
121
122 virtual int getVarBasis() const = 0;
123
125 virtual double getValue() const override = 0;
126
128 virtual double getError() const override;
129
132 virtual void getDerivatives(int idim,
133 double der[]
134 ) const override = 0;
135
137 virtual int getGlobalNum() const
138 {return globalNum;}
140 virtual void setGlobalNum(int iglobal
141 )
142 {globalNum = iglobal;}
143
144 virtual void printFirstDerivatives() const;
145 virtual void printSecondDerivatives() const;
146
147 virtual void test1stDerivatives();
148 virtual void test2ndDerivatives();
149
151 virtual double num1stDerivative(int ifo,
152 int ilocal,
153 double eps
154 );
156 virtual double num2ndDerivative(int ifo1,
157 int ilocal1,
158 double eps1,
159 int ifo2,
160 int ilocal2,
161 double eps2
162 );
163
164
165
166
167
168 protected:
169
171 typedef std::vector <BaseFitObject*> FitObjectContainer;
173 typedef FitObjectContainer::iterator FitObjectIterator;
175 typedef FitObjectContainer::const_iterator ConstFitObjectIterator;
179 std::vector <double> derivatives;
182 std::vector <int> flags;
183
186
187 };
188
189 BaseHardConstraint::BaseHardConstraint()
190 : fitobjects(FitObjectContainer()), derivatives(std::vector <double> ()), flags(std::vector <int> ()), globalNum(0)
191 {
192 }
193
194 }// end OrcaKinFit namespace
196} // end Belle2 namespace
197
198#endif // __BASEHARDCONSTRAINT_H
Abstract base class for constraints of kinematic fits.
Abstract base class for constraints of kinematic fits.
FitObjectContainer::iterator FitObjectIterator
Iterator through vector of pointers to ParticleFitObjects.
virtual ~BaseHardConstraint()
Virtual destructor.
virtual int getGlobalNum() const
Accesses position of constraint in global constraint list.
virtual double getValue() const override=0
Returns the value of the constraint.
std::vector< double > derivatives
The derivatives.
int globalNum
Position of constraint in global constraint list.
FitObjectContainer fitobjects
The FitObjectContainer.
virtual void add1stDerivativesToMatrix(double *M, int idim) const
Adds first order derivatives to global covariance matrix M.
virtual double getError() const override
Returns the error on the value of the constraint.
virtual void addToGlobalChi2DerVector(double *y, int idim, double lambda) const
Add lambda times derivatives of chi squared to global derivative vector.
virtual double dirDerAbs(double *p, double *w, int idim, double mu=1)
Calculate directional derivative for abs(c)
virtual void setGlobalNum(int iglobal)
Sets position of constraint in global constraint list.
virtual double dirDer(double *p, double *w, int idim, double mu=1)
Calculate directional derivative.
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 der...
virtual void getDerivatives(int idim, double der[]) const override=0
Get first order derivatives.
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 derivative...
std::vector< BaseFitObject * > FitObjectContainer
Vector of pointers to ParticleFitObjects.
virtual void add2ndDerivativesToMatrix(double *M, int idim, double lambda) const
Adds second order derivatives to global covariance matrix M.
FitObjectContainer::const_iterator ConstFitObjectIterator
Constant iterator through vector of pointers to ParticleFitObjects.
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.
std::vector< int > flags
The flags can be used to divide the FitObjectContainer into several subsets used for example to imple...
virtual double num1stDerivative(int ifo, int ilocal, double eps)
Evaluates numerically the 1st derivative w.r.t. a parameter.
Abstract base class for different kinds of events.
STL namespace.