MarlinKinfit  0.4.0
SoftBWParticleConstraint.h
Go to the documentation of this file.
1 
17 #ifdef MARLIN_USE_ROOT
18 
19 #ifndef __SOFTBWPARTICLECONSTRAINT_H
20 #define __SOFTBWPARTICLECONSTRAINT_H
21 
22 #include "BaseSoftConstraint.h"
23 #include "BaseFitObject.h"
24 
25 #include<vector>
26 #include<cassert>
27 #include<limits>
28 
29 class ParticleFitObject;
30 
31 // Class SoftBWParticleConstraint:
33 
70 class SoftBWParticleConstraint: public BaseSoftConstraint {
71  public:
73  SoftBWParticleConstraint(double gamma_,
74  double emin_ = -std::numeric_limits<double>::infinity(),
75  double emax_ = std::numeric_limits<double>::infinity()
76  );
78  virtual ~SoftBWParticleConstraint() {};
79 
81  virtual void setFOList(std::vector <ParticleFitObject*> *fitobjects_
82  ){
83  for (int i = 0; i < (int) fitobjects_->size(); i++) {
84  fitobjects.push_back ((*fitobjects_)[i]);
85  flags.push_back (1);
86  }
87  };
89  virtual void addToFOList(ParticleFitObject& fitobject, int flag = 1
90  ){
91  fitobjects.push_back (&fitobject);
92  flags.push_back (flag);
93  };
94 
96  virtual double getValue() const = 0;
97 
99  virtual double getChi2() const;
100 
102  virtual double getError() const;
103 
105  virtual double getGamma() const;
106 
108  virtual double setGamma(double gamma_
109  );
110 
113  virtual void getDerivatives(int idim,
114  double der[]
115  ) const = 0;
117  virtual void add2ndDerivativesToMatrix(double *M,
118  int idim
119  ) const;
120 
122  virtual void addToGlobalChi2DerVector (double *y,
123  int idim
124  ) const;
125 
126 
128  virtual void invalidateCache() const;
129 
131  virtual void updateCache() const;
132 
134  virtual bool cacheValid() const;
135 
136  void test1stDerivatives ();
137  void test2ndDerivatives ();
138 
140  double num1stDerivative (int ifo,
141  int ilocal,
142  double eps
143  );
145  double num2ndDerivative (int ifo1,
146  int ilocal1,
147  double eps1,
148  int ifo2,
149  int ilocal2,
150  double eps2
151  );
152 
153 
155 
159  static double erfinv (double x);
160 
161  static double normal_quantile (double x);
162  static double normal_quantile_1stderiv (double x);
163  static double normal_quantile_2ndderiv (double x);
164  static double normal_pdf (double x);
165  static double normal_pdf_deriv (double x);
166 
168  double penalty (double e) const;
170  double penalty1stder (double e) const;
172  double penalty2ndder (double e) const;
173 
174  int getVarBasis() const;
175 
176  protected:
177 
179  virtual bool secondDerivatives (int i,
180  int j,
181  double *derivatives
182  ) const = 0;
184  virtual bool firstDerivatives (int i,
185  double *derivatives
186  ) const = 0;
187 
188 
190  typedef std::vector <ParticleFitObject *> FitObjectContainer;
192  typedef FitObjectContainer::iterator FitObjectIterator;
194  typedef FitObjectContainer::const_iterator ConstFitObjectIterator;
196  FitObjectContainer fitobjects;
198  std::vector <double> derivatives;
201  std::vector <int> flags;
202 
204  double gamma;
205  double emin;
206  double emax;
207 
208  mutable bool cachevalid;
209  mutable double atanxmin;
210  mutable double atanxmax;
211  mutable double diffatanx;
212 
213  enum { VAR_BASIS=BaseDefs::VARBASIS_EPXYZ }; // this means that the constraint knows about E,px,py,pz
214 
215 };
216 
217 #endif // __SOFTBWPARTICLECONSTRAINT_H
218 
219 #endif // MARLIN_USE_ROOT
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 t...
Abstract base class for particle objects of kinematic fits.
Definition: ParticleFitObject.h:63
virtual double getError() const
Returns the error on the value of the constraint.
Definition: BaseConstraint.cc:58
Abstract base class for soft constraints of kinematic fits.
Definition: BaseSoftConstraint.h:64
virtual double getValue() const =0
Returns the value of the constraint function.
Declares class BaseFitObject.
virtual double getChi2() const =0
Returns the chi2.
virtual void add2ndDerivativesToMatrix(double *M, int idim) const =0
Adds second order derivatives to global covariance matrix M.
virtual void addToGlobalChi2DerVector(double *y, int idim) const =0
Add derivatives of chi squared to global derivative matrix.
Declares class BaseSoftConstraint.