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

Go to the documentation of this file.
00001 #ifndef VertexFit_KinematicFit_H
00002 #define VertexFit_KinematicFit_H
00003 
00004 #include <vector>
00005 #include "VertexFit/WTrackParameter.h"
00006 #include "VertexFit/KinematicConstraints.h"
00007 #include "VertexFit/TrackPool.h"
00008 #include "VertexFit/GammaShape.h"
00009 
00010 class KinematicFit : public  TrackPool{
00011 
00012  public:
00013 
00014   // constructor & destructor
00015 
00016   static KinematicFit * instance();
00017   ~KinematicFit();
00018   //
00019   //  Resonance Constraints 
00020   //
00021   void AddResonance(int number, double mres, std::vector<int> tlis);
00022   void AddResonance(int number, double mres, int n1);
00023   void AddResonance(int number, double mres, int n1, int n2);
00024   void AddResonance(int number, double mres, int n1, int n2, int n3);
00025   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4);
00026   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00027                     int n5);
00028   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00029                     int n5, int n6);
00030   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00031                     int n5, int n6, int n7);
00032   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00033                     int n5, int n6, int n7, int n8);
00034   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00035                     int n5, int n6, int n7, int n8, int n9);
00036   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00037                     int n5, int n6, int n7, int n8, int n9, 
00038                     int n10);
00039   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00040                     int n5, int n6, int n7, int n8, int n9, 
00041                     int n10, int n11);
00042   void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
00043                     int n5, int n6, int n7, int n8, int n9, 
00044                     int n10, int n11, int n12);
00045   //
00046   //  Total Energy Constraints
00047   //
00048   void AddTotalEnergy(int number, double etot, std::vector<int> lis);
00049   void AddTotalEnergy(int number, double etot, int n1);
00050   void AddTotalEnergy(int number, double etot, int n1, int n2);
00051   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3);
00052   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4);
00053   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00054                       int n5);
00055   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00056                       int n5, int n6);
00057   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00058                       int n5, int n6, int n7);
00059   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00060                       int n5, int n6, int n7, int n8);
00061   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00062                       int n5, int n6, int n7, int n8, int n9);
00063   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00064                       int n5, int n6, int n7, int n8, int n9, int n10);
00065   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00066                       int n5, int n6, int n7, int n8, int n9, int n10, int n11);
00067   void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
00068                       int n5, int n6, int n7, int n8, int n9, 
00069                       int n10, int n11, int n12);
00070 
00071   //
00072   //  Total Momentum Constraints
00073   //
00074   void AddTotalMomentum(int number, double ptot, std::vector<int> lis);
00075   void AddTotalMomentum(int number, double ptot, int n1);
00076   void AddTotalMomentum(int number, double ptot, int n1, int n2);
00077   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3);
00078   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4);
00079   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00080                         int n5);
00081   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00082                         int n5, int n6);
00083   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00084                         int n5, int n6, int n7);
00085   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00086                         int n5, int n6, int n7, int n8);
00087   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00088                         int n5, int n6, int n7, int n8, int n9);
00089   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00090                         int n5, int n6, int n7, int n8, int n9, 
00091                         int n10);
00092   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00093                         int n5, int n6, int n7, int n8, int n9, 
00094                         int n10, int n11);
00095   void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
00096                         int n5, int n6, int n7, int n8, int n9, 
00097                         int n10, int n11, int n12);
00098   //
00099   //  Three Momentum Constraints
00100   //
00101   void AddThreeMomentum(int number, Hep3Vector p3);
00102   //
00103   //  Four Momentum Constraints
00104   //
00105   void AddFourMomentum(int number, HepLorentzVector p4);
00106   void AddFourMomentum(int number, double etot);
00107 
00108   //
00109   //  Equal Mass Constraints 
00110   //
00111   
00112   void AddEqualMass(int number, std::vector<int> tlis1, std::vector<int> tlis2);
00113   
00114   //
00115   //  Position Constraints
00116   //
00117 //  void AddPosition(int number, HepPoint3D xorigin, std::vector<int> tlis_V); 
00118   
00119   //
00120   //  Build Virtual Particle
00121   //
00122   void BuildVirtualParticle(int number);
00123 
00124   // initialization called before fit
00125 
00126   void init();
00127   // 
00128   //  set iteration number and chisq cut
00129   //
00130   void setFlag(const bool flag = 1)  {m_flag = flag;}
00131   void setIterNumber(const int niter = 5) {m_niter = niter;}
00132   void setChisqCut(const double chicut = 200, const double chiter=0.05) {m_chicut = chicut;m_chiter=chiter;}
00133    //
00134    //  set error matrix parameters
00135    //
00136   void setKalman (const int kalman) {m_kalman = kalman;}
00137   void setEspread (const double espread = 0.0009) {m_espread = espread;}
00138   void setCollideangle (const double collideangle = 11e-3) {m_collideangle = collideangle;}
00139   void setDynamicerror (const bool dynamicerror = 1) {m_dynamicerror = dynamicerror;}     
00140   //
00141   // fit function
00142   //
00143   bool Fit();
00144   bool Fit(int n);
00145   //
00146   // Fit Results
00147   //
00148   //                        chisq of fit
00149   //
00150   double chisq() const {return m_chi;}
00151   double chisq(int n) const {return m_chisq[n];}
00152   //  updated WTrack parameter after kinematic fit
00153   //  HepLorentzVector pfit(int n) const {return wTrackInfit(n).p();}
00154   HepLorentzVector pfit(int n) const {return p4Infit(n);}
00155  // added by yanl 05.10.07
00156   //  HepLorentzVector pfit1(int n) const {return wTrackOrigin(n).p();}
00157   HepLorentzVector pfit1(int n) const {return p4Origin(n);}
00158 
00159 
00160   WTrackParameter origin(int n) const {return wTrackOrigin(n);}
00161   WTrackParameter infit(int n) const {return wTrackInfit(n);}
00162   
00163   HepVector pull(int n) ;
00164  // error Matrix parameters
00165   double espread() const {return m_espread;}
00166   double collideangle() const {return m_collideangle;} 
00167   bool dynamicerror() const {return m_dynamicerror;}
00168   // cpu time
00169   HepVector cpu() const {return m_cpu;}
00170 
00171   WTrackParameter  wVirtualTrack(int n) const {return m_virtual_wtrk[n];}
00172   private:
00173   //bulid virtual particle
00174   std::vector<WTrackParameter> m_virtual_wtrk;
00175   
00176 
00177   void updateConstraints(KinematicConstraints kc);
00178   void fits();
00179   void fit();
00180   //  void covMatrix();
00181   void upCovmtx();
00182   void fit(int n);
00183   void covMatrix(int n);
00184   void gda();
00185   private:
00186   std::vector<KinematicConstraints>    m_kc;
00187   std::vector<double>   m_chisq;
00188   double    m_chi;
00189   //  std::vector<HepMatrix> m_D;
00190   //  std::vector<HepMatrix> m_DT;
00191   HepMatrix m_D;
00192   HepMatrix D(int ic, int itk) const {return m_D.sub(ic+1, ic+1, itk*NTRKPAR+1, (itk+1)*NTRKPAR);}
00193   void setD(int ic, int itk, const HepMatrix &p) {m_D.sub(ic+1, itk*NTRKPAR+1, p);}
00194   HepMatrix m_DT;
00195   HepMatrix DT(int itk, int ic) const {return m_DT.sub(itk*NTRKPAR+1, (itk+1)*NTRKPAR, ic+1, ic+1);}
00196   void setDT(int itk, int ic, const HepMatrix &p) { m_DT.sub(itk*NTRKPAR+1, ic+1, p);}
00197   HepVector m_d;
00198   HepSymMatrix m_VD;
00199   HepMatrix m_KP;
00200   //  HepVector m_lambda;
00201   int m_nc;
00202   int m_nktrk;
00203   HepVector m_pOrigin;
00204   HepVector m_pInfit;
00205   HepSymMatrix m_covOrigin;
00206   HepSymMatrix m_covInfit;
00207   HepVector  m_massvector;    //add to save the mass of each particle
00208   HepVector pOrigin(int i) const {return m_pOrigin.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
00209   HepLorentzVector p4Origin(int i) const { HepVector p(3, 0); p = pOrigin(i); double E = sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2] + origin(i).mass() * origin(i).mass());return HepLorentzVector(p[0], p[1], p[2], E);}  //modified by yanl 2010.7.26 for changing the wtrackparameters
00210   HepVector pInfit(int i) const {return m_pInfit.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
00211   HepLorentzVector p4Infit(int i) const { HepVector p(3, 0); p = pInfit(i);  double E = sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2] + origin(i).mass() * origin(i).mass());  return HepLorentzVector(p[0], p[1], p[2], E); }   //modified by yanl 2010.7.26 for changing the wtrackparameters
00212   void setPOrigin(int i, const HepVector &p) { m_pOrigin.sub(i*NTRKPAR+1, p);}
00213   void setPInfit(int i, const HepVector &p) {m_pInfit.sub(i*NTRKPAR+1, p);}
00214   HepSymMatrix covOrigin(int i) const {return m_covOrigin.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
00215   HepSymMatrix covInfit(int i) const {return m_covInfit.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
00216   void setCovOrigin(int i, const HepSymMatrix &c) {m_covOrigin.sub(i*NTRKPAR+1, c);}
00217   void setCovInfit(int i, const HepSymMatrix &c) {m_covInfit.sub(i*NTRKPAR+1,c);}
00218   void setMassvector(int i, const double mass) {m_massvector[i] = mass;}
00219         private:
00220   KinematicFit();
00221   static KinematicFit * m_pointer;
00222         private:
00223   int m_niter;
00224   bool m_flag;
00225   double m_chicut;
00226   double m_chiter;
00227         private:
00228   int m_kalman;
00229   double m_espread;
00230   double m_collideangle;
00231         private:
00232   HepVector m_cpu;
00233         private:
00234   bool m_dynamicerror; 
00235         private:
00236   static const int NTRKPAR;
00237 
00238   static const int Resonance;
00239   static const int TotalEnergy;
00240   static const int TotalMomentum;
00241   static const int ThreeMomentum;
00242   static const int FourMomentum;
00243   static const int EqualMass;
00244   static const int Position;
00245 
00246 
00247 };
00248 #endif

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