00001 #ifndef VertexFit_VertexFit_H
00002 #define VertexFit_VertexFit_H
00003
00004 #include <vector>
00005 #include "VertexFit/WTrackParameter.h"
00006 #include "VertexFit/VertexParameter.h"
00007 #include "VertexFit/VertexConstraints.h"
00008 #include "VertexFit/TrackPool.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 class VertexFit : public TrackPool
00019 {
00020 public:
00021
00022 static VertexFit *instance();
00023 ~VertexFit();
00024
00025
00026 void init();
00027
00028
00029 void AddVertex(int number, VertexParameter vpar, std::vector<int> lis);
00030 void AddVertex(int number, VertexParameter vpar, int n1, int n2);
00031 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3);
00032 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4);
00033 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5);
00034 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5, int n6);
00035 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5, int n6, int n7);
00036 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8);
00037 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9);
00038 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10);
00039 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11);
00040 void AddVertex(int number, VertexParameter vpar, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11, int n12);
00041 void AddBeamFit(int number, VertexParameter vpar, int n);
00042
00043
00044 void BuildVirtualParticle(int number);
00045
00046
00047 void setIterNumber(const int niter = 10) { m_niter = niter; }
00048 void setChisqCut(const double chicut = 1000, const double chiter = 1.0e-3) { m_chicut = chicut;m_chiter = chiter; }
00049 void setMagCorrFactor(const double factor = 1.000) { m_factor = factor; }
00050 double factor() const { return m_factor; }
00051
00052
00053 bool Fit();
00054 bool Fit(int n);
00055 bool BeamFit(int n);
00056
00057
00058 void Swim(int n){ vertexCovMatrix(n); swimVertex(n);}
00059
00060
00061
00062
00063
00064
00065 double chisq() const {return m_chi;}
00066 double chisq(int n) const {return m_chisq[n];}
00067
00068
00069
00070
00071 bool pull(int n, int itk, HepVector& p);
00072
00073
00074 HepLorentzVector pfit(int n) const {return wTrackInfit(n).p();}
00075 HepPoint3D xfit(int n) const {return wTrackInfit(n).x();}
00076 HepVector w(int n) const {return wTrackInfit(n).w();}
00077 HepSymMatrix Ew(int n) const {return wTrackInfit(n).Ew();}
00078 WTrackParameter wtrk(int n) const {return wTrackInfit(n);}
00079
00080
00081 HepVector cpu() const {return m_cpu;}
00082
00083
00084 HepPoint3D vx(int n) const { return m_vpar_infit[n].vx();}
00085 HepVector Vx(int n) const { return m_vpar_infit[n].Vx();}
00086 HepSymMatrix Evx(int n) const { return m_vpar_infit[n].Evx();}
00087 double errorVx(int n, int i) const { return sqrt((m_vpar_infit[n].Evx())[i][i]);}
00088 VertexParameter vpar(int n) const {return m_vpar_infit[n];}
00089
00090
00091 WTrackParameter wVirtualTrack(int n) const {return m_virtual_wtrk[n];}
00092
00093
00094 private:
00095
00096 void UpdateConstraints(const VertexConstraints &vc);
00097
00098 void fitVertex(int n);
00099
00100 void vertexCovMatrix(int n);
00101
00102 void swimVertex(int n);
00103
00104 void fitBeam(int n);
00105 void swimBeam(int n);
00106
00107
00108 std::vector<VertexParameter> m_vpar_origin;
00109
00110 std::vector<VertexParameter> m_vpar_infit;
00111
00112 std::vector<VertexConstraints> m_vc;
00113
00114 std::vector<double> m_chisq;
00115 double m_chi;
00116 int m_nvtrk;
00117
00118 std::vector<WTrackParameter> m_virtual_wtrk;
00119
00120
00121
00122 HepVector m_xOrigin;
00123 HepSymMatrix m_xcovOrigin;
00124 HepSymMatrix m_xcovOriginInversed;
00125 inline HepVector xOrigin() const {return m_xOrigin;}
00126 inline void setXOrigin(const HepVector &x) { m_xOrigin = x;}
00127 inline HepSymMatrix xcovOrigin() const {return m_xcovOrigin;}
00128 inline void setXCovOrigin(const HepSymMatrix &v) {m_xcovOrigin = v;}
00129 inline HepSymMatrix xcovOriginInversed() const {return m_xcovOriginInversed;}
00130 inline void setXCovOriginInversed(const HepSymMatrix &v){m_xcovOriginInversed = v;}
00131
00132
00133 HepVector m_xInfit;
00134 HepSymMatrix m_xcovInfit;
00135 HepSymMatrix m_xcovInfitInversed;
00136 inline HepVector xInfit() const {return m_xInfit;}
00137 inline void setXInfit(const HepVector &x) {m_xInfit = x;}
00138 inline HepSymMatrix xcovInfit() const {return m_xcovInfit;}
00139 void setXCovInfit(const HepSymMatrix &v) {m_xcovInfit = v;}
00140 inline HepSymMatrix xcovInfitInversed() const {return m_xcovInfitInversed;}
00141 void setXCovInfitInversed(const HepSymMatrix &v) {m_xcovInfitInversed = v;}
00142
00143
00144 HepVector m_pOrigin;
00145 HepSymMatrix m_pcovOrigin;
00146 inline HepVector pOrigin(int i) const { return m_pOrigin.sub(i*NTRKPAR+1, (i+1)*NTRKPAR); }
00147 inline void setPOrigin(int i, const HepVector &p) { m_pOrigin.sub(i*NTRKPAR+1, p); }
00148 inline HepSymMatrix pcovOrigin(int i) const { return m_pcovOrigin.sub(i*NTRKPAR+1, (i+1)*NTRKPAR); }
00149 inline void setPCovOrigin(int i, const HepSymMatrix &v) { m_pcovOrigin.sub(i*NTRKPAR+1,v); }
00150
00151
00152 HepVector m_pInfit;
00153 HepSymMatrix m_pcovInfit;
00154 inline HepVector pInfit(int i) const { return m_pInfit.sub(i*NTRKPAR+1, (i+1)*NTRKPAR); }
00155 inline void setPInfit(int i, const HepVector &p) { m_pInfit.sub(i*NTRKPAR+1, p); }
00156 inline HepSymMatrix pcovInfit(int i) const { return m_pcovInfit.sub(i*NTRKPAR+1, (i+1)*NTRKPAR); }
00157 inline void setPCovInfit(int i, const HepSymMatrix &v) { m_pcovInfit.sub(i*NTRKPAR+1, v); }
00158
00159
00160 HepMatrix m_B;
00161 inline HepMatrix vfB(int i) const {return m_B.sub(i*NCONSTR+1, (i+1)*NCONSTR, 1, NVTXPAR);}
00162 inline void setB(int i, const HepMatrix &e) {m_B.sub(i*NCONSTR+1, 1, e);}
00163
00164 HepMatrix m_BT;
00165 inline HepMatrix vfBT(int i) const {return m_BT.sub(1, NVTXPAR, i*NCONSTR+1, (i+1)*NCONSTR);}
00166 inline void setBT(int i, const HepMatrix &e) {m_BT.sub(1, i*NCONSTR+1, e);}
00167
00168 HepMatrix m_A;
00169 inline HepMatrix vfA(int i) const {return m_A.sub(i*NCONSTR+1, (i+1)*NCONSTR, i*NTRKPAR+1, (i+1)*NTRKPAR);}
00170 inline void setA(int i, const HepMatrix &d) {m_A.sub(i*NCONSTR+1, i*NTRKPAR+1, d);}
00171
00172 HepMatrix m_AT;
00173 inline HepMatrix vfAT(int i) const {return m_AT.sub(i*NTRKPAR+1, (i+1)*NTRKPAR, i*NCONSTR+1, (i+1)*NCONSTR);}
00174 inline void setAT(int i, const HepMatrix &d) {m_AT.sub(i*NTRKPAR+1, i*NCONSTR+1, d);}
00175
00176 HepMatrix m_KQ;
00177 inline HepMatrix vfKQ(int i) const {return m_KQ.sub(1, NVTXPAR, i*NCONSTR+1, (i+1)*NCONSTR);}
00178 inline void setKQ(int i, const HepMatrix &d) {m_KQ.sub(1, i*NCONSTR+1, d);}
00179
00180 HepVector m_G;
00181 inline HepVector vfG(int i) const {return m_G.sub(i*NCONSTR+1, (i+1)*NCONSTR);}
00182 inline void setG(int i, const HepVector &p) {m_G.sub(i*NCONSTR+1, p);}
00183
00184 HepSymMatrix m_W;
00185 inline HepSymMatrix vfW(int i) const {return m_W.sub(i*NCONSTR+1, (i+1)*NCONSTR);}
00186 inline void setW(int i, HepSymMatrix &m) {m_W.sub(i*NCONSTR+1, m);}
00187
00188 HepMatrix m_E;
00189 inline HepMatrix vfE(int i) const {return m_E.sub(i*NTRKPAR+1, (i+1)*NTRKPAR, 1, NVTXPAR);}
00190 inline void setE(int i, const HepMatrix &p){m_E.sub(i*NTRKPAR+1, 1, p);}
00191
00192 HepMatrix m_TRA;
00193 HepMatrix m_TRB;
00194
00195
00196 HepVector Convert67(const double &mass, const HepVector &p);
00197
00198
00199 HepVector Convert76(const HepVector &p);
00200
00201
00202 VertexFit();
00203 static VertexFit *m_pointer;
00204
00205 int m_niter;
00206 double m_chicut;
00207 double m_chiter;
00208 double m_factor;
00209 HepVector m_cpu;
00210
00211 static const int NTRKPAR;
00212 static const int NVTXPAR;
00213 static const int NCONSTR;
00214 };
00215 #endif //VertexFit_VertexFit_H
00216