/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/SD0TagAlg/SD0TagAlg-00-00-03/src/K0pipi.cxx

Go to the documentation of this file.
00001 //
00002 //  K0pipi.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meson through the final states of
00003 //  K0pipi from D0 or anti-D0 meson decays. K0pipi.cxx was transfered from the Fortran routine "K0pipi.f"
00004 //  which was orignally used for study of the D0D0-bar production and D0 decays at the BES-II
00005 //  experiment during the time period from 2002 to 2008.
00006 //
00007 //  The orignal Fortran routine "K0pipi.f" used at the BES-II experiment was coded by G. Rong in 2001.
00008 //
00009 //  K0pipi.cxx was transfered by G. Rong and J. Liu in December, 2005.
00010 //
00011 //  Since 2008, G. Rong and L.L. Jiang have been working on developing this code to analyze of
00012 //  the data taken at 3.773 GeV with the BES-III detector at the BEPC-II collider.
00013 //
00014 //  During developing this code, many People made significant contributions to this code. These are
00015 //          G. Rong, L.L. Jiang, J. Liu, H.L. Ma, J.C. Chen, D.H. Zhang,
00016 //          M.G. Zhao, B. Zheng, L. Li, Y. Fang, Z.Y. Yi, H.H. Liu, Z.Q. Liu et al.
00017 //
00018 //                                       By G. Rong and L.L. Jiang
00019 //                                       March, 2009
00020 //
00021 //  ==========================================================================================
00022 //
00023 #include "SD0TagAlg/K0pipi.h"
00024 #include "SD0TagAlg/SingleBase.h"
00025 
00026 
00027 K0pipi::K0pipi()
00028 {}
00029 
00030 K0pipi::~K0pipi()
00031 {}
00032 
00033 
00034 void K0pipi::MTotal(double event,SmartDataPtr<EvtRecTrackCol> evtRecTrkCol, Vint iGood,Vint
00035     iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
00036 {
00037 
00038   int nGood=iGood.size();
00039   int nGam=iGam.size();
00040 
00041   iGoodtag.clear();
00042   iGamtag.clear();
00043   
00044   double mass_bcgg,delE_tag_temp;
00045   int m_chargetag,m_chargepi1,m_chargepi2,m_chargepi3,m_chargepi4;
00046   int ipi1_temp,ipi2_temp,ipi3_temp,ipi4_temp;
00047   HepLorentzVector pddd;
00048   HepLorentzVector pddd_temp;
00049 
00050   IDataProviderSvc* eventSvc = NULL;
00051   Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00052   SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc,EventModel::EvtRec::EvtRecEvent);
00053   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
00054 
00055   int runNo=eventHeader->runNumber();
00056   int rec=eventHeader->eventNumber();
00057 
00058   double xecm=2*Ebeam;
00059 
00060   k0pipimd=false;
00061   double  tagmode=0;
00062 
00063   if((evtRecEvent->totalCharged() < 4)){    return;  }
00064 
00065   double ecms = xecm;  
00066 
00067   ISimplePIDSvc* simple_pid;
00068   Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
00069 
00070   double deltaE_tem = 0.20;
00071   int ncount1 = 0; 
00072 
00073   Hep3Vector xorigin(0,0,0);
00074   HepSymMatrix xoriginEx(3,0);
00075   IVertexDbSvc*  vtxsvc;
00076   Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
00077   if(vtxsvc->isVertexValid())
00078   {
00079     double* dbv = vtxsvc->PrimaryVertex();
00080     double*  vv = vtxsvc->SigmaPrimaryVertex();
00081     xorigin.setX(dbv[0]);
00082     xorigin.setY(dbv[1]);
00083     xorigin.setZ(dbv[2]);
00084 
00085     xoriginEx[0][0] = vv[0] * vv[0];
00086     xoriginEx[1][1] = vv[1] * vv[1];
00087     xoriginEx[2][2] = vv[2] * vv[2];
00088 
00089   }
00090 
00091   double xv=xorigin.x();
00092   double yv=xorigin.y();
00093   double zv=xorigin.z();
00094 
00095   HepPoint3D point0(0.,0.,0.);
00096   HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
00098 
00099   for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
00100     EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
00101     
00102     int ipi1= (*itTrk)->trackId();
00103 
00104     if(!(*itTrk)->isMdcKalTrackValid()) continue;
00105     RecMdcKalTrack*  mdcKalTrk1 = (*itTrk)->mdcKalTrack();
00106     RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00107 
00108     m_chargepi1=mdcKalTrk1->charge();
00109     if(m_chargepi1 != 1) continue;
00110 
00112     HepVector a1 = mdcKalTrk1->getZHelix();
00113     HepSymMatrix Ea1 = mdcKalTrk1->getZError();
00114 
00115     VFHelix helixip3_1(point0,a1,Ea1);
00116     helixip3_1.pivot(IP);
00117     HepVector  vecipa1 = helixip3_1.a();
00118 
00119     double dr1 = fabs(vecipa1[0]);
00120     double dz1 = fabs(vecipa1[3]);
00121     double costheta1 = cos(mdcKalTrk1->theta());
00122 
00123     if (  dr1 >= 15.0) continue;
00124     if (  dz1 >= 25.0) continue; 
00125     if ( fabs(costheta1) >= 0.93) continue; 
00127     WTrackParameter pip1(xmass[2],mdcKalTrk1->getZHelix(),mdcKalTrk1->getZError() );
00128 
00129     //  
00130     // select pi2
00131     //  
00132     for(int j = 0; j < evtRecEvent->totalCharged(); j++) {
00133       EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
00134       
00135       int ipi2= (*itTrk)->trackId();
00136       if(ipi1==ipi2)  continue;
00137 
00138       if(!(*itTrk)->isMdcKalTrackValid()) continue;
00139       RecMdcKalTrack*  mdcKalTrk2 = (*itTrk)->mdcKalTrack();
00140       RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00141 
00142       m_chargepi2=mdcKalTrk2->charge();
00143       if((m_chargepi2 + m_chargepi1) != 0) continue;
00144 
00146       HepVector a2 = mdcKalTrk2->getZHelix();
00147       HepSymMatrix Ea2 = mdcKalTrk2->getZError();
00148       VFHelix helixip3_2(point0,a2,Ea2);
00149       helixip3_2.pivot(IP);
00150       HepVector  vecipa2 = helixip3_2.a();
00151 
00152       double dr2 = fabs(vecipa2[0]);
00153       double dz2 = fabs(vecipa2[3]);
00154       double costheta2 = cos(mdcKalTrk2->theta());
00155       if (  dr2 >= 15.0) continue;
00156       if (  dz2 >= 25.0) continue; 
00157       if ( fabs(costheta2) >= 0.93) continue; 
00159       WTrackParameter pim1(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
00160 
00161 
00162       HepVector pip1_val = HepVector(7,0);
00163       HepVector pim1_val = HepVector(7,0);
00164       pip1_val = pip1.w(); 
00165       pim1_val = pim1.w();
00166       HepLorentzVector ptrktagk0(pip1_val[0]+pim1_val[0],pip1_val[1]+pim1_val[1],pip1_val[2]+pim1_val[2],pip1_val[3]+pim1_val[3]);
00167       if(fabs(ptrktagk0.m()-0.498)>0.1) continue;
00168 
00169       HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
00170       HepSymMatrix Evx(3, 0);
00171       double bx = 1E+6; Evx[0][0] = bx*bx;
00172       double by = 1E+6; Evx[1][1] = by*by;
00173       double bz = 1E+6; Evx[2][2] = bz*bz;
00174       VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
00175 
00176       VertexFit *vtxfit0 = VertexFit::instance();
00177       vtxfit0->init();
00178       vtxfit0->AddTrack(0, pip1);
00179       vtxfit0->AddTrack(1, pim1);
00180       vtxfit0->AddVertex(0, vxpar, 0, 1);
00181       if(!(vtxfit0->Fit(0))) continue;
00182       vtxfit0->Swim(0); 
00183       vtxfit0->BuildVirtualParticle(0);
00184       WTrackParameter wksp = vtxfit0->wtrk(0);
00185       WTrackParameter wksm = vtxfit0->wtrk(1);
00186       WTrackParameter wks_Trk = vtxfit0->wVirtualTrack(0);
00187       VertexParameter wks_var = vtxfit0->vpar(0);
00188       
00189       //        
00190       //select pi3
00191       //        
00192       for(int k = 0; k < evtRecEvent->totalCharged(); k++) {
00193         EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + k;
00194 
00195         int ipi3= (*itTrk)->trackId();
00196         if(ipi2==ipi3 || ipi1==ipi3)  continue;
00197 
00198         if(!(*itTrk)->isMdcKalTrackValid()) continue;
00199         RecMdcKalTrack*  mdcKalTrk3 = (*itTrk)->mdcKalTrack();
00200         RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00201 
00202         m_chargepi3=mdcKalTrk3->charge();
00203         if((m_chargepi3) != 1) continue;
00204 
00206         HepVector a3 = mdcKalTrk3->getZHelix();
00207         HepSymMatrix Ea3 = mdcKalTrk3->getZError();
00208         VFHelix helixip3_3(point0,a3,Ea3);
00209         helixip3_3.pivot(IP);
00210         HepVector  vecipa3 = helixip3_3.a();
00211 
00212         double dr3 = fabs(vecipa3[0]);
00213         double dz3 = fabs(vecipa3[3]);
00214         double costheta3 = cos(mdcKalTrk3->theta());
00215         if (  dr3 >= 1.0) continue;
00216         if (  dz3 >= 10.0) continue; 
00217         if ( fabs(costheta3) >= 0.93) continue; 
00219         if(PID_flag == 5) {
00220           simple_pid->preparePID(*itTrk);
00221           if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00222         } 
00224         WTrackParameter pip2(xmass[2],mdcKalTrk3->getZHelix(),mdcKalTrk3->getZError() );
00225 
00226         //
00227         //select pi4
00228         //
00229         for(int l = 0; l< evtRecEvent->totalCharged(); l++) {
00230           EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + l;
00231 
00232           int ipi4= (*itTrk)->trackId();
00233           if(ipi4==ipi3 || ipi4==ipi2 || ipi4 ==ipi1)  continue;
00234 
00235           if(!(*itTrk)->isMdcKalTrackValid()) continue;
00236           RecMdcKalTrack*  mdcKalTrk4 = (*itTrk)->mdcKalTrack();
00237           RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00238 
00239           m_chargepi4=mdcKalTrk4->charge();
00240           if((m_chargepi4 + m_chargepi3) != 0) continue;
00241 
00243           HepVector a4 = mdcKalTrk4->getZHelix();
00244           HepSymMatrix Ea4 = mdcKalTrk4->getZError();
00245           VFHelix helixip3_4(point0,a4,Ea4);
00246           helixip3_4.pivot(IP);
00247           HepVector  vecipa4 = helixip3_4.a();
00248 
00249           double dr4 = fabs(vecipa4[0]);
00250           double dz4 = fabs(vecipa4[3]);
00251           double costheta4 = cos(mdcKalTrk4->theta());
00252           if (  dr4 >= 1.0) continue;
00253           if (  dz4 >= 10.0) continue; 
00254           if ( fabs(costheta4) >= 0.93) continue; 
00256           if(PID_flag == 5) {
00257             simple_pid->preparePID(*itTrk);
00258             if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00259           } 
00261           WTrackParameter pim2(xmass[2],mdcKalTrk4->getZHelix(),mdcKalTrk4->getZError() );
00262 
00263           //  all loop for the charged tracks overed here !!!!!!!
00264 
00265           VertexFit* vtxfit_2 = VertexFit::instance();
00266           vtxfit_2->init();
00267           vtxfit_2->AddTrack(0,  pip2);
00268           vtxfit_2->AddTrack(1,  pim2);
00269           vtxfit_2->AddVertex(0, vxpar, 0, 1);
00270           if(!vtxfit_2->Fit(0))  continue;
00271           vtxfit_2->Swim(0);
00272 
00273           WTrackParameter wpip2 = vtxfit_2->wtrk(0);
00274           WTrackParameter wpim2 = vtxfit_2->wtrk(1);
00275 
00276           SecondVertexFit *vtxfit = SecondVertexFit::instance();
00277           vtxfit->init();
00278           vxpar.setEvx(xoriginEx);
00279           vtxfit->setPrimaryVertex(vxpar);
00280           vtxfit->AddTrack(0, wks_Trk);
00281           vtxfit->setVpar(wks_var);
00282           if(!vtxfit->Fit()) continue;
00283           
00284           if(vtxfit->chisq() >999.) continue;
00285           if(vtxfit->decayLength()<0.0) continue;
00286 
00287           double m_massks1_tem = vtxfit->p4par().m();
00288           if(m_massks1_tem < 0.485 || m_massks1_tem > 0.515)  continue;
00289           HepLorentzVector  p4kstag =  vtxfit->p4par();
00290           WTrackParameter para_ks = vtxfit0->wVirtualTrack(0);
00291           WTrackParameter wksz = vtxfit->wpar();
00292 
00293           HepVector pip2_val = HepVector(7,0);
00294           HepVector pim2_val = HepVector(7,0);
00295           HepVector ksp_val = HepVector(7,0);
00296           HepVector ksm_val = HepVector(7,0);
00297 
00298           pip2_val = wpip2.w();
00299           pim2_val = wpim2.w();
00300           ksp_val = wksp.w();
00301           ksm_val = wksm.w();
00302 
00303           HepLorentzVector P_PIP2(pip2_val[0],pip2_val[1],pip2_val[2],pip2_val[3]);
00304           HepLorentzVector P_PIM2(pim2_val[0],pim2_val[1],pim2_val[2],pim2_val[3]);
00305           HepLorentzVector P_KSP(ksp_val[0],ksp_val[1],ksp_val[2],ksp_val[3]);
00306           HepLorentzVector P_KSM(ksm_val[0],ksm_val[1],ksm_val[2],ksm_val[3]);
00307 
00308           p4kstag.boost(-0.011,0,0); 
00309           P_PIP2.boost(-0.011,0,0); 
00310           P_PIM2.boost(-0.011,0,0); 
00311           P_KSP.boost(-0.011,0,0); 
00312           P_KSM.boost(-0.011,0,0);
00313           //pddd = P_KSP + P_KSM + P_PIP2 + P_PIM2;
00314           pddd = p4kstag + P_PIP2 + P_PIM2;
00315 
00316           double   pk0pipi=pddd.rho();
00317 
00318           double temp1 = (ecms/2)*(ecms/2)-pk0pipi*pk0pipi ;
00319           if(temp1<0) temp1 =0;
00320           double mass_bc_tem  = sqrt(temp1);
00321           if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
00322 
00323           double        delE_tag_tag = ecms/2-pddd.e();
00324 
00325           if(fabs(delE_tag_tag)<deltaE_tem){
00326             deltaE_tem = fabs(delE_tag_tag);
00327             delE_tag_temp = delE_tag_tag;
00328             mass_bcgg = mass_bc_tem;
00329 
00330             pddd_temp = pddd; 
00331 
00332             ipi1_temp=ipi1;
00333             ipi2_temp=ipi2;
00334             ipi3_temp=ipi3;
00335             ipi4_temp=ipi4;
00336 
00337             ncount1 = 1;
00338 
00339           }   
00340         }   
00341       }        
00342     }
00343   }
00344 
00345 
00346   if(ncount1 == 1){
00347     tagmode=14;
00348     if(m_chargetag<0)  tagmode=-14;
00349     tagmd=tagmode;
00350     mass_bc  = mass_bcgg;
00351     delE_tag = delE_tag_temp;
00352     cqtm     = 0.0;
00353 
00354     iGoodtag.push_back(ipi1_temp);
00355     iGoodtag.push_back(ipi2_temp);
00356     iGoodtag.push_back(ipi3_temp);
00357     iGoodtag.push_back(ipi4_temp);
00358     iGamtag.push_back(9999); 
00359     iGamtag.push_back(9999); 
00360     iGamtag.push_back(9999); 
00361     iGamtag.push_back(9999); 
00362    
00363     ptag = pddd_temp;
00364 
00365     k0pipimd=true;
00366   }
00367 
00368 }
00369 
00370 
00371 

Generated on Tue Nov 29 23:13:53 2016 for BOSS_7.0.2 by  doxygen 1.4.7