00001
00020 #ifndef __VERTEXFITOBJECT_H
00021 #define __VERTEXFITOBJECT_H
00022
00023 #include "jbltools/kinfit/BaseFitObject.h"
00024
00025 #include <iostream>
00026 #include <cassert>
00027 #include <vector>
00028
00029 class ThreeVector;
00030 class FourVector;
00031 class TrackFitObject;
00032 class BaseFitter;
00033 class BaseConstraint;
00034
00035
00037
00056 class VertexFitObject: public BaseFitObject {
00057 public:
00059 VertexFitObject(const char *name_,
00060 double x,
00061 double y,
00062 double z
00063 );
00065 VertexFitObject (const VertexFitObject& rhs);
00067 VertexFitObject& operator= (const VertexFitObject& rhs);
00069 virtual ~VertexFitObject();
00070
00072 virtual bool setParam (int ilocal,
00073 double par_,
00074 bool measured_,
00075 bool fixed_ = false
00076 );
00078 virtual bool setParam (int ilocal,
00079 double par_
00080 );
00082 virtual bool setMParam (int ilocal,
00083 double mpar_
00084 );
00086 virtual bool setError (int ilocal,
00087 double err_
00088 );
00090 virtual bool setCov (int ilocal,
00091 int jlocal,
00092 double cov_
00093 );
00096 virtual bool setGlobalParNum (int ilocal, int iglobal);
00097
00099 virtual bool fixParam (int ilocal,
00100 bool fix=true
00101 );
00102
00104 virtual double getParam (int ilocal
00105 ) const;
00107 virtual double getMParam (int ilocal
00108 ) const;
00110 virtual double getError (int ilocal
00111 ) const;
00113 virtual double getCov (int ilocal,
00114 int jlocal
00115 ) const;
00117 virtual bool isParamMeasured (int ilocal) const;
00119 virtual bool isParamFixed (int ilocal) const;
00121 virtual int getGlobalParNum(int ilocal) const;
00123 virtual int getNPar() const;
00124
00126 virtual const char *getName () const;
00127
00129 virtual void setName (const char *name_);
00130
00132 virtual const char *getParamName (int ilocal
00133 ) const;
00134
00135
00137 virtual void getVertexEx (ThreeVector& p
00138 ) const;
00140 virtual ThreeVector getVertex() const;
00141
00143 virtual void getVertexDerivativeEx (int ilocal,
00144 ThreeVector& p
00145 ) const;
00147 virtual ThreeVector getVertexDerivative (int ilocal
00148 ) const;
00149
00152 virtual void addToGlobCov(double *cov, int idim) const;
00153
00154
00156 virtual double getChi2() const;
00158 virtual double getDChi2DParam(int ilocal) const {assert (0);};
00160 virtual double getD2Chi2DParam2(int ilocal1, int ilocal2) const {assert (0);};
00161
00163 virtual void addToGlobalChi2DerMatrix (int idim, double *M) const {assert (0);};
00165 virtual void addToGlobalDerMatrix (int idim, double c, double *M) const {assert (0);};
00166
00168 virtual std::ostream& print (std::ostream& os
00169 ) const;
00170
00172 virtual TrackFitObject *getTrack (int i
00173 ) const {return tracks[i].track;}
00174
00176 virtual void addTrack (TrackFitObject *track,
00177 bool inbound,
00178 bool measured
00179 );
00180
00181 enum {
00182 VX = 1, VY = 2, VZ = 4, VXY = 3, VXYZ=7,
00183 PX = 8, PY = 16, PZ = 32, PXY = 24, PXYZ = 56,
00184 E = 64, EPXYZ = 120,
00185 THE_FULL_MONTY = 127
00186 };
00187
00189 virtual void addConstraints (BaseFitter& fitter,
00190 int mask = THE_FULL_MONTY
00191 );
00192
00194 virtual ThreeVector estimatePosition ();
00195
00197 virtual void initForFit();
00198
00199 protected:
00201 virtual void addVertexConstraints (BaseFitter& fitter, int axis);
00203 virtual void addMomentumConstraint (BaseFitter& fitter, int axis);
00204
00206 virtual void initCov();
00207
00209 virtual bool calculateCovInv() const;
00210
00212 virtual void calculateChi2() const;
00214 virtual void copy (const VertexFitObject& source);
00215
00216
00218 enum {NPAR = 3};
00219
00221 double par[NPAR];
00223 double mpar[NPAR];
00225 double err[NPAR];
00227 bool measured[NPAR];
00229 bool fixed[NPAR];
00231 int globalParNum [NPAR];
00233 double cov [NPAR][NPAR];
00235 mutable double covinv [NPAR][NPAR];
00237 mutable bool covinvvalid;
00238
00239
00240 mutable double chi2;
00241 mutable double resid[NPAR];
00242 mutable bool chi2contr[NPAR];
00243
00244 char *name;
00245
00246 struct TrackDescriptor {
00247 TrackFitObject *track;
00248 bool inbound;
00249 bool measured;
00250 TrackDescriptor (TrackFitObject *track_, bool inbound_, bool measured_)
00251 : track (track_), inbound (inbound_), measured (measured_)
00252 {}
00253 TrackDescriptor ()
00254 : track (0), inbound (0), measured (0)
00255 {}
00256 };
00257
00258 typedef std::vector<TrackDescriptor> TContainer;
00259 typedef TContainer::iterator TIterator;
00260 TContainer tracks;
00261 typedef std::vector<BaseConstraint *> CContainer;
00262 typedef CContainer::iterator CIterator;
00263 CContainer constraints;
00264
00265 };
00266
00267 #endif // __VERTEXFITOBJECT_H
00268