MarlinKinfit  0.4.0
VertexFitObject.h
Go to the documentation of this file.
1 
26 #ifndef __VERTEXFITOBJECT_H
27 #define __VERTEXFITOBJECT_H
28 
29 #include "BaseFitObject.h"
30 
31 #include <iostream>
32 #include <cassert>
33 #include <vector>
34 
35 class ThreeVector;
36 class FourVector;
38 class BaseFitter;
39 class BaseConstraint;
40 
41 // Class VertexFitObject
43 
63  public:
65  VertexFitObject(const char *name_,
66  double x,
67  double y,
68  double z
69  );
71  VertexFitObject (const VertexFitObject& rhs);
72 
75 
77  virtual VertexFitObject *copy() const ;
78 
80  virtual VertexFitObject& assign (const BaseFitObject& source
81  ) ;
82 
84  virtual ~VertexFitObject();
85 
86 
87 
88 // these are now defined upstream
89 // /// Set value and measured flag of parameter ilocal; return=success
90 // virtual bool setParam (int ilocal, ///< Local parameter number
91 // double par_, ///< New parameter value
92 // bool measured_, ///< New "measured" flag
93 // bool fixed_ = false ///< New "fixed" flag
94 // );
95 // /// Set value of parameter ilocal; return=success
96 // virtual bool setParam (int ilocal, ///< Local parameter number
97 // double par_ ///< New parameter value
98 // );
99 // /// Set measured value of parameter ilocal; return=success
100 // virtual bool setMParam (int ilocal, ///< Local parameter number
101 // double mpar_ ///< Measured parameter value
102 // );
103 // /// Set error of parameter ilocal
104 // virtual bool setError (int ilocal, ///< Local parameter number
105 // double err_ ///< New error value
106 // );
107 // /// Set covariance of parameters ilocal and jlocal
108 // virtual bool setCov (int ilocal, ///< Local parameter number
109 // int jlocal, ///< Local parameter number
110 // double cov_ ///< New error value
111 // );
112 // /// Set number of parameter ilocal in global list
113 // /// return true signals OK
114 // virtual bool setGlobalParNum (int ilocal, int iglobal);
115 //
116 // /// Fix a parameter (fix=true), or release it (fix=false)
117 // virtual bool fixParam (int ilocal, ///< Local parameter number
118 // bool fix=true ///< fix if true, release if false
119 // );
120 //
121 // /// Get parameter ilocal
122 // virtual double getParam (int ilocal ///< Local parameter number
123 // ) const;
124 // /// Get measured value of parameter ilocal
125 // virtual double getMParam (int ilocal ///< Local parameter number
126 // ) const;
127 // /// Get error of parameter ilocal
128 // virtual double getError (int ilocal ///< Local parameter number
129 // ) const;
130 // /// Get covariance between parameters ilocal and jlocal
131 // virtual double getCov (int ilocal, ///< Local parameter number
132 // int jlocal ///< Local parameter number
133 // ) const;
134 // /// Get measured flag for parameter i
135 // virtual bool isParamMeasured (int ilocal) const;
136 // /// Get fixed flag for parameter i
137 // virtual bool isParamFixed (int ilocal) const;
138 // /// Get global parameter number of parameter ilocal
139 // virtual int getGlobalParNum(int ilocal) const;
140 // /// Get number of parameters of this FitObject
141 // virtual int getNPar() const;
142  virtual int getNPar() const {return NPAR;}
143 
145  // virtual const char *getName () const;
146 
148 // virtual void setName (const char *name_);
149 
151  virtual const char *getParamName (int ilocal
152  ) const;
153 
154 
156  virtual void getVertexEx (ThreeVector& p
157  ) const;
158 
160  virtual ThreeVector getVertex() const;
161 
163  virtual void getVertexDerivativeEx (int ilocal,
164  ThreeVector& p
165  ) const;
166 
168  virtual ThreeVector getVertexDerivative (int ilocal
169  ) const;
170 
171 
172  virtual void getDerivatives (double der[], int idim) const {}
173 
174 // /// Add covariance matrix elements to
175 // /// global covariance matrix of size idim x idim
176 // virtual void addToGlobCov(double *cov, int idim) const;
177 
178 // /// Get chi squared from measured and fitted parameters
179 // virtual double getChi2() const;
180 // /// Get derivative of chi squared w.r.t. parameter ilocal
181 // virtual double getDChi2DParam(int ilocal) const
182 // {assert (0);}
183 // /// Get second derivative of chi squared w.r.t. parameters ilocal1 and ilocal2
184 // virtual double getD2Chi2DParam2(int ilocal1, int ilocal2) const {assert (0);};
185 //
186 // /// Add derivatives of chi squared to global covariance matrix
187 // virtual void addToGlobalChi2DerMatrix (double *M, ///< Global covariance matrix
188 // int idim ///< First dimension of global covariance matrix
189 // ) const
190 // {assert (0);}
191 // /// Add derivatives of chi squared to global derivative matrix
192 // virtual void addToGlobalChi2DerVector (double *y, ///< Vector of chi2 derivatives
193 // int idim ///< Vector size
194 // ) const
195 // {assert (0);}
196 //
197 // /// Add derivatives to global covariance matrix
198 // virtual void addToGlobalDerMatrix (int idim, double c, double *M) const {assert (0);};
199 //
200 
201  // print object to ostream
202  virtual std::ostream& print (std::ostream& os
203  ) const;
204 
207  ) const {return tracks[i].track;}
208 
210  virtual void addTrack (TrackParticleFitObject *track,
211  bool inbound,
212  bool measured
213  );
214 
215  enum {
216  VX = 1, VY = 2, VZ = 4, VXY = 3, VXYZ=7,
217  PX = 8, PY = 16, PZ = 32, PXY = 24, PXYZ = 56,
218  E = 64, EPXYZ = 120,
219  THE_FULL_MONTY = 127
220  };
221 
223  virtual void addConstraints (BaseFitter& fitter,
224  int mask = THE_FULL_MONTY
225  );
226 
228  virtual ThreeVector estimatePosition ();
229 
231  virtual void initForFit();
232 
233  virtual double getFirstDerivative_Meta_Local(int iMeta, int ilocal , int metaSet) const;
234  virtual double getSecondDerivative_Meta_Local(int iMeta, int ilocal , int jlocal , int metaSet) const;
235 
236  protected:
237 
238  virtual void updateCache() const {assert (0);}
239 
240 
241 
243  virtual void addVertexConstraints (BaseFitter& fitter, int axis);
245  virtual void addMomentumConstraint (BaseFitter& fitter, int axis);
246 
248  // virtual void initCov();
250  // virtual bool calculateCovInv() const;
252  // virtual void calculateChi2() const;
254  // virtual void copy (const VertexFitObject& source);
255  // virtual VertexFitObject* copy() const;
256 
257 
259  enum {NPAR = 3};
260 
261 // /// fit parameters
262 // double par[NPAR];
263 // /// measured parameters
264 // double mpar[NPAR];
265 // /// errors
266 // double err[NPAR];
267 // /// measured flag
268 // bool measured[NPAR];
269 // /// fixed flag
270 // bool fixed[NPAR];
271 // /// global paramter number for each parameter
272 // int globalParNum [NPAR];
273 // /// local covariance matrix
274 // double cov [NPAR][NPAR];
275 // /// inverse of local covariance matrix
276 // mutable double covinv [NPAR][NPAR];
277 // /// flag for valid inverse covariance matrix
278 // mutable bool covinvvalid;
279 
280  // Cache variables
281  // mutable double chi2; ///< chi^2
282  // mutable double resid[NPAR]; ///< residuals
283  // mutable bool chi2contr[NPAR]; ///< contributes to chi2?
284 
285  // char *name; ///< object name
286 
288  TrackParticleFitObject *track;
289  bool inbound;
290  bool measured;
291  TrackDescriptor (TrackParticleFitObject *track_, bool inbound_, bool measured_)
292  : track (track_), inbound (inbound_), measured (measured_)
293  {}
294  TrackDescriptor ()
295  : track (0), inbound (0), measured (0)
296  {}
297  };
298 
299  typedef std::vector<TrackDescriptor> TContainer;
300  typedef TContainer::iterator TIterator;
301  TContainer tracks;
302  typedef std::vector<BaseConstraint *> CContainer;
303  typedef CContainer::iterator CIterator;
304  CContainer constraints;
305 
306 };
307 
308 #endif // __VERTEXFITOBJECT_H
309 
virtual void getVertexDerivativeEx(int ilocal, ThreeVector &p) const
Get derivative of vertex w.r.t. parameter ilocal into existing 3-vector.
Definition: VertexFitObject.cc:130
virtual void addTrack(TrackParticleFitObject *track, bool inbound, bool measured)
add track
Definition: VertexFitObject.cc:229
Class that represents vertices.
Definition: VertexFitObject.h:62
virtual void addMomentumConstraint(BaseFitter &fitter, int axis)
generate momentum constraints
Definition: VertexFitObject.cc:197
Abstract base class for fitting engines of kinematic fits.
Definition: BaseFitter.h:63
virtual VertexFitObject * copy() const
Return a new copy of itself.
Definition: VertexFitObject.cc:73
virtual std::ostream & print(std::ostream &os) const
print object to ostream
Definition: VertexFitObject.cc:108
virtual VertexFitObject & assign(const BaseFitObject &source)
Assign from anther object, if of same type.
Definition: VertexFitObject.cc:77
virtual ~VertexFitObject()
Destructor.
Definition: VertexFitObject.cc:91
virtual TrackParticleFitObject * getTrack(int i) const
get track i
Definition: VertexFitObject.h:206
virtual ThreeVector getVertexDerivative(int ilocal) const
Get derivative of vertex w.r.t. parameter ilocal.
Definition: VertexFitObject.cc:124
bool measured[BaseDefs::MAXPAR]
measured flag
Definition: BaseFitObject.h:340
virtual ThreeVector getVertex() const
Get vertex.
Definition: VertexFitObject.cc:114
virtual void getVertexEx(ThreeVector &p) const
Get vertex into existing 3-vector.
Definition: VertexFitObject.cc:120
virtual void initForFit()
Initialize this object and attatched tracks for fit with initial estimates.
Definition: VertexFitObject.cc:270
Definition: VertexFitObject.h:287
virtual void addConstraints(BaseFitter &fitter, int mask=THE_FULL_MONTY)
Create constraints and add them to a BaseFit object.
Definition: VertexFitObject.cc:217
virtual const char * getParamName(int ilocal) const
Get object's name.
Definition: VertexFitObject.cc:99
VertexFitObject(const char *name_, double x, double y, double z)
Constructor.
Definition: VertexFitObject.cc:39
virtual int getNPar() const
Get total number of parameters of this FitObject.
Definition: VertexFitObject.h:142
VertexFitObject & operator=(const VertexFitObject &rhs)
assignment
Definition: VertexFitObject.cc:66
Declares class BaseFitObject.
Abstract base class for constraints of kinematic fits.
Definition: BaseConstraint.h:85
Definition: TrackParticleFitObject.h:20
Abstract base class for particle objects of kinematic fits.
Definition: BaseFitObject.h:110
virtual ThreeVector estimatePosition()
Estimate vertex position.
Definition: VertexFitObject.cc:234
virtual void addVertexConstraints(BaseFitter &fitter, int axis)
generate vertex constraints
Definition: VertexFitObject.cc:171
Definition: ThreeVector.h:18