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