/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Analysis/VertexFit/VertexFit-00-02-78/src/SecondVertexFit.cxx

Go to the documentation of this file.
00001 #include "VertexFit/SecondVertexFit.h"
00002 #include "VertexFit/BField.h"
00003 
00004 //----------------------------------------------------
00005 // In Second Vertex Fit:
00006 //
00007 // Fitting Parameters
00008 // (px, py, pz, E, xd, yd, zd, xp, yp, zp)
00009 //
00010 // Constraints (charge = 0)
00011 //
00012 // xp - xd + px/m * ct = 0
00013 // yp - yd + py/m * ct = 0
00014 // zp - zd + pz/m * ct = 0
00015 //
00016 //     ( 0 0 0 0 -1 0 0 1 0 0 )
00017 // D = ( 0 0 0 0 0 -1 0 0 1 0 )
00018 //     ( 0 0 0 0 0 0 -1 0 0 1 )
00019 //
00020 //     ( px/m )
00021 // E = ( py/m )
00022 //     ( pz/m )
00023 //
00024 //     ( xp - xd + px/m * ct )
00025 // d = ( yp - yd + py/m * ct )
00026 //     ( zp - zd + pz/m * ct )
00027 //
00028 // Constraints (charge != 0)
00029 //
00030 // xp - xd + px/a * sin(a ctau/m) + py/a(1-cos(a ctau/m)) = 0
00031 // yp - yd + py/a * sin(a ctau/m) - px/a(1-cos(a ctau/m)) = 0
00032 // zp - zd + pz/m ctau = 0
00033 //     ( 0 0 0 0 -1 0 0 1 0 0 )
00034 // D = ( 0 0 0 0 0 -1 0 0 1 0 )
00035 //     ( 0 0 0 0 0 0 -1 0 0 1 )
00036 //
00037 //     ( px/m cos(a * ct/m) + py/m * sin (a * ct/m))
00038 // E = ( py/m cos(a * ct/m) - px/m * sin (a * ct/m))
00039 //     ( pz/m )
00040 //
00041 //----------------------------------------------------
00042 
00043 SecondVertexFit *SecondVertexFit::m_pointer = 0;
00044 
00045 SecondVertexFit *SecondVertexFit::instance() 
00046 {
00047         if (m_pointer) 
00048                 return m_pointer;
00049         m_pointer = new SecondVertexFit();
00050         return m_pointer;
00051 }
00052 
00053 SecondVertexFit::SecondVertexFit()
00054 {
00055         HepVector vx(3,0);
00056         m_vpar_primary.setVx(vx);
00057         HepSymMatrix evx(3,0);
00058         evx[0][0] = 0.1 * 0.1;
00059         evx[1][1] = 0.1 * 0.1;
00060         evx[2][2] = 1.5 * 1.5;
00061         m_vpar_primary.setEvx(evx);
00062 }
00063 
00064 SecondVertexFit::~SecondVertexFit() 
00065 {
00066         //if(m_pointer) delete m_pointer;
00067 }
00068 
00069 void SecondVertexFit::init() 
00070 {
00071         clearWTrackOrigin();
00072         clearWTrackInfit();
00073         clearWTrackList();
00074         m_vpar_secondary = VertexParameter();
00075         m_lxyz       = 0;
00076         m_lxyz_error = 0;
00077         m_p4par      = HepLorentzVector(0, 0, 0, 0);
00078         m_crxyz      = HepVector(3, 0);
00079         m_chisq      = 9999;
00080         m_wtrk       = WTrackParameter();
00081         m_niter      = 10;
00082         m_chicut     = 500;
00083         m_chiter     = 1.0e-2;
00084         m_factor     = 1.000;
00085 }
00086 
00087 bool SecondVertexFit::Fit() 
00088 {
00089         bool okfit = false;
00090 
00091         HepVector aOrigin(10, 0);
00092         HepVector aInfit(10, 0);
00093         HepSymMatrix VaOrigin(10, 0);
00094         HepSymMatrix VaInfit(10, 0);
00095         aOrigin.sub(1, wTrackOrigin(0).w());
00096         aOrigin.sub(8, m_vpar_primary.Vx());
00097         VaOrigin.sub(1, wTrackOrigin(0).Ew());
00098         VaOrigin.sub(8, m_vpar_primary.Evx());
00099         HepVector ctOrigin(1, 0);
00100         HepVector ctInfit(1, 0);
00101         HepSymMatrix Vct(1, 0);
00102         aInfit  = aOrigin;
00103         ctInfit = ctOrigin;
00104 
00105         std::vector<double> chisq;
00106         chisq.clear();
00107         double chi2 = 999;
00108         for(int it = 0; it < m_niter; it++)
00109         {
00110                 HepMatrix D(3, 10, 0);
00111                 HepLorentzVector p4par = HepLorentzVector(aInfit[0], aInfit[1], aInfit[2], aInfit[3]);
00112                 HepMatrix E(3,1,0);
00113                 HepVector d(3, 0);
00114                 if (wTrackOrigin(0).charge() == 0) 
00115                 {
00116                         D[0][4] = -1.0;
00117                         D[0][7] = 1.0;
00118                         D[1][5] = -1.0;
00119                         D[1][8] = 1.0;
00120                         D[2][6] = -1.0;
00121                         D[2][9] = 1.0;
00122 
00123                         E[0][0] = p4par.px()/p4par.m();
00124                         E[1][0] = p4par.py()/p4par.m();
00125                         E[2][0] = p4par.pz()/p4par.m();
00126 
00127                         d[0] = aInfit[7]-aInfit[4]+ctInfit[0]*p4par.px()/p4par.m();
00128                         d[1] = aInfit[8]-aInfit[5]+ctInfit[0]*p4par.py()/p4par.m();
00129                         d[2] = aInfit[9]-aInfit[6]+ctInfit[0]*p4par.pz()/p4par.m();
00130                 }
00131                 else 
00132                 {
00133 //                      double afield = VertexFitBField::instance()->getCBz(m_vpar_primary.Vx(), m_vpar_secondary.Vx());
00134                         double afield = m_factor * VertexFitBField::instance()->getCBz(m_vpar_primary.Vx(), m_vpar_secondary.Vx());
00135                         double a = afield * wTrackOrigin(0).charge();
00136                         D[0][4] = -1.0;
00137                         D[0][7] = 1.0;
00138                         D[1][5] = -1.0;
00139                         D[1][8] = 1.0;
00140                         D[2][6] = -1.0;
00141                         D[2][9] = 1.0;
00142 
00143                         E[0][0] = p4par.px() / p4par.m() * cos(a * ctInfit[0] / p4par.m()) + p4par.py() / p4par.m() * sin(a * ctInfit[0] / p4par.m());
00144                         E[1][0] = p4par.py() / p4par.m() * cos(a * ctInfit[0] / p4par.m()) - p4par.px() / p4par.m() * sin(a * ctInfit[0] / p4par.m());
00145                         E[2][0] = p4par.pz() / p4par.m();
00146 
00147                         d[0] = aInfit[7] - aInfit[4]+p4par.px()/a * sin(a * ctInfit[0]/p4par.m()) + p4par.py()/a*(1-cos(a*ctInfit[0]/p4par.m()));
00148                         d[1] = aInfit[8] - aInfit[5]+p4par.py()/a * sin(a * ctInfit[0]/p4par.m()) - p4par.px()/a*(1-cos(a*ctInfit[0]/p4par.m()));
00149                         d[2] = aInfit[9] - aInfit[6]+ctInfit[0]*p4par.pz()/p4par.m();
00150                 }
00151                 
00152                 HepSymMatrix VD(3, 0);
00153                 HepVector dela0(10, 0);
00154                 HepVector lambda0(3, 0);
00155                 HepVector delct(1, 0);
00156                 HepVector lambda(3, 0);
00157                 int ifail;
00158 
00159                 VD      = (VaOrigin.similarity(D)).inverse(ifail);
00160                 dela0   = aOrigin - aInfit;
00161                 lambda0 = VD*(D*dela0 + d);
00162                 Vct     = (VD.similarity(E.T())).inverse(ifail);
00163                 delct   = -(Vct * E.T()) * lambda0;
00164                 ctInfit = ctInfit + delct;
00165                 lambda  = lambda0 + (VD * E) * delct;
00166                 aInfit  = aOrigin - (VaOrigin * D.T()) * lambda;
00167                 chi2    = dot(lambda, D*dela0 + d);
00168                 VaInfit = VaOrigin - (VD.similarity(D.T())).similarity(VaOrigin);
00169                 VaInfit = VaInfit + (((Vct.similarity(E)).similarity(VD)).similarity(D.T())).similarity(VaOrigin);
00170 
00171                 chisq.push_back(chi2);
00172 
00173                 if(it > 0) 
00174                 {
00175                         double delchi = chisq[it] - chisq[it-1];
00176                         if (fabs(delchi) < m_chiter) break;
00177                 }
00178         }
00179         if (chi2 < 0 || chi2 > m_chicut)
00180                 return okfit;
00181 
00182         HepLorentzVector p4par = HepLorentzVector(aInfit[0], aInfit[1], aInfit[2], aInfit[3]);
00183         m_ctau       = ctInfit[0];
00184         m_ctau_error = sqrt(Vct[0][0]);
00185         m_lxyz       = ctInfit[0] * p4par.rho() / p4par.m();
00186         m_lxyz_error = sqrt(Vct[0][0]) * p4par.rho() / p4par.m();
00187         m_chisq      = chi2;
00188         m_p4par      = p4par;
00189         for(int i = 0; i < 3; i++)
00190                 m_crxyz[i] = aInfit[4+i];
00191         HepVector w(7, 0);
00192         HepSymMatrix Ew(7, 0);
00193         for(int i = 0; i < 7; i++) 
00194         {
00195                 w[i] = aInfit[i];
00196                 for(int j = 0; j < 7; j++) 
00197                 {
00198                         Ew[i][j] = VaInfit[i][j];
00199                 }
00200         }
00201         m_wtrk.setW(w);
00202         m_wtrk.setEw(Ew);
00203         m_wtrk.setCharge(wTrackOrigin(0).charge());
00204         okfit = true;
00205         return okfit;
00206 }
00207 
00208 

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