/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Analysis/VertexFit/VertexFit-00-02-78/VertexFit/VertexFit.h

Go to the documentation of this file.
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 // NOTE: if you want to update the parameters of daughter tracks after vertex fitting,
00011 // you should add the following code after invoking the interface "Fit()".
00012 // VertexFit->Swim(n); 
00013 // here, n is vertex number.
00014 //
00015 // You can find the corresponding tutorial on the following web page: 
00016 // http://docbes3.ihep.ac.cn/~offlinesoftware/index.php/Vertex_Fit
00017 
00018 class VertexFit : public TrackPool 
00019 {
00020 public:
00021         // constructor & deconstructor
00022         static VertexFit *instance();
00023         ~VertexFit();
00024 
00025         // initialization, must be called before VertexFit each time
00026         void init();
00027 
00028         // add methods
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         // build virtual particle, parameter number must be match with vertex number
00044         void BuildVirtualParticle(int number);
00045 
00046         // set iteration number and chisq cut
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         // fit function
00053         bool Fit();
00054         bool Fit(int n);
00055         bool BeamFit(int n);
00056         
00057         // renew track parameters and convariance
00058         void Swim(int n){ vertexCovMatrix(n); swimVertex(n);}
00059         
00060         //
00061         // Fit Results
00062         //
00063 
00064         // chisq of fit
00065         double chisq() const {return m_chi;}
00066         double chisq(int n) const {return m_chisq[n];}
00067         
00068         // Pull distribution for 5-helix parameters.
00069         // Return true on success, the resulting pull will be stored in p;
00070         // Return false on failure.
00071         bool pull(int n, int itk, HepVector& p);
00072         
00073         // updated WTrack parameter in vertex fit
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         // time counter
00081         HepVector cpu() const {return m_cpu;}
00082   
00083         // updated Vertex Parameter in vertex fit
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         // virtual particle from Vertex Fit
00091         WTrackParameter wVirtualTrack(int n) const {return m_virtual_wtrk[n];}
00092 
00093         // Users need not care below
00094 private:
00095         // renew vertex constraints
00096         void UpdateConstraints(const VertexConstraints &vc);
00097         // vertex fit
00098         void fitVertex(int n);
00099         // renew covariance of input track parameters
00100         void vertexCovMatrix(int n);
00101         // extrapolate input track parameters to the vertex
00102         void swimVertex(int n);
00103         
00104         void fitBeam(int n);
00105         void swimBeam(int n);
00106  
00107         // vertex parameters before fit
00108         std::vector<VertexParameter> m_vpar_origin;
00109         // vertex parameters in fit
00110         std::vector<VertexParameter> m_vpar_infit;
00111         // vertex constraints
00112         std::vector<VertexConstraints> m_vc;
00113         // chisquare counter
00114         std::vector<double> m_chisq;
00115         double m_chi;   // total chisquare
00116         int m_nvtrk;    // number of WTracks in VertexFit
00117         // virtual particle in WTrackParameter format
00118         std::vector<WTrackParameter> m_virtual_wtrk;
00119   
00120         // track parameters storage and access
00121         // origin vertex and its covariance matrix
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         // vertex and covariance matrix in fit
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         // track parameters and covariance matrice at initial
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         // track parameters and covariance matrice in fit
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         // some matrices convenient for calculation
00160         HepMatrix m_B;  // NCONSTR x NVTXPAR -- E
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; // NVTXPAR x NCONSTR -- E.T()
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;  // NCONSTR x NTRKPAR -- D
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; // NTRKPAR x NCONSTR -- D.T()
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; // NVTXPAR x NCONSTR -- Vx E.T() VD 
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;  // NCONSTR x 1  -- Dda + Edx + d
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;       // NCONSTR x NCONSTR -- VD
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;  // NTRKPAR x NVTXPAR -- -Va0 D.T() VD E Vx
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;        // transform matrix from 7x1 to 6x1
00193         HepMatrix m_TRB;        // transform matrix from 6x1 to 7x1
00194         // convert HepVector 6x1 to 7x1
00195         // (px, py, pz, x, y, z) -> (px, py, pz, e, x, y, z)
00196         HepVector Convert67(const double &mass, const HepVector &p);    
00197         // convert HepVector 7x1 to 6x1
00198         // (px, py, pz, e, x, y, z) -> (px, py, pz, x, y, z)
00199         HepVector Convert76(const HepVector &p);
00200         
00201         // Singleton Design
00202         VertexFit();
00203         static VertexFit *m_pointer;
00204 
00205         int m_niter;      //number of iteration for vertex fitting
00206         double m_chicut;  //chisquare upper limit
00207         double m_chiter;
00208         double m_factor;  //B Field correction factor
00209         HepVector m_cpu;
00210   
00211         static const int NTRKPAR;  //number of track parameters
00212         static const int NVTXPAR;  //number of vertex parameters
00213         static const int NCONSTR;  //number of vertex constraints
00214 };
00215 #endif  //VertexFit_VertexFit_H
00216 

Generated on Tue Nov 29 22:57:41 2016 for BOSS_7.0.2 by  doxygen 1.4.7