Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 
00016 //
00017 // Attention: In this new Version, in order to find out why chisquare can be negative,
00018 // so when successfully returned from Fit(int n), you will find chisq may be negative.
00019 // You can Add this code:
00020 //
00021 // if (chisq < 0) return StatusCode::SUCCESS
00022 //
00023 // to avoid this situation  
00024 //
00026 class VertexFit : public TrackPool 
00027 {
00028 public:
00029         // constructor & deconstructor
00030         static VertexFit *instance();
00031         ~VertexFit();
00032 
00033         // initialization, must be called before VertexFit each time
00034         void init();
00035 
00036         // add methods
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         // build virtual particle, parameter number must be match with vertex number
00052         void BuildVirtualParticle(int number);
00053 
00054         // set iteration number and chisq cut
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         // fit function
00059         bool Fit();
00060         bool Fit(int n);
00061         bool BeamFit(int n);
00062         
00063         // renew track parameters and convariance
00064         void Swim(int n){ vertexCovMatrix(n); swimVertex(n);}
00065         
00066         //
00067         // Fit Results
00068         //
00069 
00070         // chisq of fit
00071         double chisq() const {return m_chi;}
00072         double chisq(int n) const {return m_chisq[n];}
00073         
00074         // Pull distribution for 5-helix parameters.
00075         // Return true on success, the resulting pull will be stored in p;
00076         // Return false on failure.
00077         bool pull(int n, int itk, HepVector& p);
00078         
00079         // updated WTrack parameter in vertex fit
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         // time counter
00087         HepVector cpu() const {return m_cpu;}
00088   
00089         // updated Vertex Parameter in vertex fit
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         // virtual particle from Vertex Fit
00097         WTrackParameter wVirtualTrack(int n) const {return m_virtual_wtrk[n];}
00098 
00099         // Users need not care below
00100 private:
00101         // renew vertex constraints
00102         void UpdateConstraints(const VertexConstraints &vc);
00103         // vertex fit
00104         void fitVertex(int n);
00105         // renew covariance of input track parameters
00106         void vertexCovMatrix(int n);
00107         // extrapolate input track parameters to the vertex
00108         void swimVertex(int n);
00109         
00110         void fitBeam(int n);
00111         void swimBeam(int n);
00112  
00113         // vertex parameters before fit
00114         std::vector<VertexParameter> m_vpar_origin;
00115         // vertex parameters in fit
00116         std::vector<VertexParameter> m_vpar_infit;
00117         // vertex constraints
00118         std::vector<VertexConstraints> m_vc;
00119         // chisquare counter
00120         std::vector<double> m_chisq;
00121         double m_chi;   // total chisquare
00122         int m_nvtrk;    // number of WTracks in VertexFit
00123         // virtual particle in WTrackParameter format
00124         std::vector<WTrackParameter> m_virtual_wtrk;
00125   
00126         // track parameters storage and access
00127         // origin vertex and its covariance matrix
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         // vertex and covariance matrix in fit
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         // track parameters and covariance matrice at initial
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         // track parameters and covariance matrice in fit
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         // some matrices convenient for calculation
00166         HepMatrix m_B;  // NCONSTR x NVTXPAR -- E
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; // NVTXPAR x NCONSTR -- E.T()
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;  // NCONSTR x NTRKPAR -- D
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; // NTRKPAR x NCONSTR -- D.T()
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; // NVTXPAR x NCONSTR -- Vx E.T() VD 
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;  // NCONSTR x 1  -- Dda + Edx + d
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;       // NCONSTR x NCONSTR -- VD
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;  // NTRKPAR x NVTXPAR -- -Va0 D.T() VD E Vx
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         //NEW ADDED
00199         HepMatrix m_TRA;        // transform matrix from 7x1 to 6x1
00200         HepMatrix m_TRB;        // transform matrix from 6x1 to 7x1
00201         // convert HepVector 6x1 to 7x1
00202         // (px, py, pz, x, y, z) -> (px, py, pz, e, x, y, z)
00203         HepVector Convert67(const double &mass, const HepVector &p);    
00204         // convert HepVector 7x1 to 6x1
00205         // (px, py, pz, e, x, y, z) -> (px, py, pz, x, y, z)
00206         HepVector Convert76(const HepVector &p);
00207         //NEW ADDED
00208         
00209         // Singleton Design
00210         VertexFit();
00211         static VertexFit *m_pointer;
00212 
00213         int m_niter;    //number of iteration for vertex fitting
00214         double m_chicut;        //chisquare upper limit
00215         double m_chiter;
00216         HepVector m_cpu;
00217   
00218         static const int NTRKPAR;       //number of track parameters
00219         static const int NVTXPAR;       //number of vertex parameters
00220         static const int NCONSTR;       //number of vertex constraints
00221 };
00222 #endif  //VertexFit_VertexFit_H
00223 

Generated on Wed Feb 2 15:41:20 2011 for BOSS6.5.5 by  doxygen 1.3.9.1