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

Go to the documentation of this file.
00001 //
00002 //  K0pi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meson through the final states of
00003 //  K0pi0 from D0 or anti-D0 meson decays. K0pi0.cxx was transfered from the Fortran routine "K0pi0.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 "K0pi0.f" used at the BES-II experiment was coded by G. Rong in 2002.
00008 //
00009 //  K0pi0.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/K0pi0.h"
00024 #include "SD0TagAlg/SingleBase.h"
00025 
00026 
00027 K0pi0::K0pi0()
00028 {}
00029 
00030 K0pi0::~K0pi0()
00031 {}
00032 
00033 
00034 void K0pi0::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;
00046   int ika_temp,ipi1_temp,ipi2_temp,ipi3_temp, iGam1_temp, iGam2_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   k0pi0md=false;
00061   double  tagmode=0;
00062 
00063   if((evtRecEvent->totalCharged() < 2||nGam<2)){    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   HepLorentzVector p2gfit;
00099   HepLorentzVector p2gg;
00100 
00101   for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
00102     EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
00103 
00104     int ipi1= (*itTrk)->trackId();
00105 
00106     if(!(*itTrk)->isMdcKalTrackValid()) continue;
00107     RecMdcKalTrack*  mdcKalTrk1 = (*itTrk)->mdcKalTrack();
00108     RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00109 
00110     m_chargepi1=mdcKalTrk1->charge();
00111     if(m_chargepi1 != 1) continue;
00112 
00114     HepVector a1 = mdcKalTrk1->getZHelix();
00115     HepSymMatrix Ea1 = mdcKalTrk1->getZError();
00116 
00117     VFHelix helixip3_1(point0,a1,Ea1);
00118     helixip3_1.pivot(IP);
00119     HepVector  vecipa1 = helixip3_1.a();
00120 
00121     double dr1 = fabs(vecipa1[0]);
00122     double dz1 = fabs(vecipa1[3]);
00123     double costheta1 = cos(mdcKalTrk1->theta());
00124 
00125     if (  dr1 >= 15.0) continue;
00126     if (  dz1 >= 25.0) continue; 
00127     if ( fabs(costheta1) >= 0.93) continue; 
00129     WTrackParameter pip(xmass[2],mdcKalTrk1->getZHelix(),mdcKalTrk1->getZError() );
00130     
00131     //  
00132     // select pi
00133     //  
00134     for(int j = 0; j < evtRecEvent->totalCharged();j++) {
00135       EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
00136       
00137       int ipi2= (*itTrk)->trackId();
00138       if(ipi1==ipi2)  continue;
00139      
00140       if(!(*itTrk)->isMdcKalTrackValid()) continue;
00141       RecMdcKalTrack*  mdcKalTrk2 = (*itTrk)->mdcKalTrack();
00142       RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00143 
00144       m_chargepi2=mdcKalTrk2->charge();
00145       if((m_chargepi1 + m_chargepi2) != 0) continue;
00146 
00148       HepVector a2 = mdcKalTrk2->getZHelix();
00149       HepSymMatrix Ea2 = mdcKalTrk2->getZError();
00150       VFHelix helixip3_2(point0,a2,Ea2);
00151       helixip3_2.pivot(IP);
00152       HepVector  vecipa2 = helixip3_2.a();
00153 
00154       double dr2 = fabs(vecipa2[0]);
00155       double dz2 = fabs(vecipa2[3]);
00156       double costheta2 = cos(mdcKalTrk2->theta());
00157       if (  dr2 >= 15.0) continue;
00158       if (  dz2 >= 25.0) continue; 
00159       if ( fabs(costheta2) >= 0.93) continue; 
00161       WTrackParameter pim(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
00162 
00163       HepVector pip_val = HepVector(7,0);
00164       HepVector pim_val = HepVector(7,0);
00165       pip_val = pip.w(); 
00166       pim_val = pim.w();
00167       HepLorentzVector ptrktagk0(pip_val[0]+pim_val[0],pip_val[1]+pim_val[1],pip_val[2]+pim_val[2],pip_val[3]+pim_val[3]);
00168       double m_xmtagk0_tem = ptrktagk0.mag();
00169       if(fabs(ptrktagk0.m()-0.498)>0.1) continue;
00170 
00171       HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
00172       HepSymMatrix Evx(3, 0);
00173       double bx = 1E+6; Evx[0][0] = bx*bx;
00174       double by = 1E+6; Evx[1][1] = by*by;
00175       double bz = 1E+6; Evx[2][2] = bz*bz;
00176       VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
00177 
00178       VertexFit *vtxfit0 = VertexFit::instance();
00179       vtxfit0->init();
00180       vtxfit0->AddTrack(0, pip);
00181       vtxfit0->AddTrack(1, pim);
00182       vtxfit0->AddVertex(0, vxpar, 0, 1);
00183       if(!(vtxfit0->Fit(0))) continue;
00184       vtxfit0->Swim(0); 
00185       vtxfit0->BuildVirtualParticle(0);
00186       WTrackParameter wksp = vtxfit0->wtrk(0);
00187       WTrackParameter wksm = vtxfit0->wtrk(1);
00188       WTrackParameter wks_Trk = vtxfit0->wVirtualTrack(0);
00189       VertexParameter wks_var = vtxfit0->vpar(0);
00190       
00191       SecondVertexFit *vtxfit = SecondVertexFit::instance();
00192       vtxfit->init();
00193       vxpar.setEvx(xoriginEx);
00194       vtxfit->setPrimaryVertex(vxpar);
00195       vtxfit->AddTrack(0, wks_Trk);
00196       vtxfit->setVpar(wks_var);
00197       if(!vtxfit->Fit()) continue;
00198       
00199       if(vtxfit->chisq() > 999.) continue;
00200       if(vtxfit->decayLength()<0.0) continue;
00201 
00202       double m_massks1_tem = vtxfit->p4par().m();
00203       if(m_massks1_tem < 0.485 || m_massks1_tem > 0.515)  continue;
00204       HepLorentzVector  p4kstag =  vtxfit->p4par();
00205       p4kstag.boost(-0.011,0,0);
00206       WTrackParameter para_ks = vtxfit0->wVirtualTrack(0);
00207 
00208       for(int m = 0; m < nGam-1; m++) {
00209         if(iGam[m]==-1) continue;
00210         RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[m]))->emcShower();
00211         double eraw1 = g1Trk->energy();
00212         double phi1 = g1Trk->phi();
00213         double the1 = g1Trk->theta();
00214         HepLorentzVector ptrkg1,ptrkg10,ptrkg12;
00215         ptrkg1.setPx(eraw1*sin(the1)*cos(phi1));
00216         ptrkg1.setPy(eraw1*sin(the1)*sin(phi1));
00217         ptrkg1.setPz(eraw1*cos(the1));
00218         ptrkg1.setE(eraw1);
00219         ptrkg10 = ptrkg1;
00220         ptrkg12 = ptrkg1.boost(-0.011,0,0);
00221 
00222         for(int n = m+1; n < nGam; n++) {
00223           if(iGam[n]==-1) continue;
00224           RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[n]))->emcShower();
00225           double eraw2 = g2Trk->energy();
00226           double phi2 = g2Trk->phi();
00227           double the2 = g2Trk->theta();
00228           HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
00229           ptrkg2.setPx(eraw2*sin(the2)*cos(phi2));
00230           ptrkg2.setPy(eraw2*sin(the2)*sin(phi2));
00231           ptrkg2.setPz(eraw2*cos(the2));
00232           ptrkg2.setE(eraw2);
00233           ptrkg20 = ptrkg2;
00234           ptrkg22 = ptrkg2.boost(-0.011,0,0);
00235 
00237           HepLorentzVector  ptrkpi0;
00238           ptrkpi0 = ptrkg12+ptrkg22;
00239           double m_xmpi0_tem = ptrkpi0.m();
00240           if(m_xmpi0_tem>0.150||m_xmpi0_tem<0.115)  continue;
00242           bool IsEndcap1 = false; bool IsEndcap2 = false;
00243           if(fabs(cos(the1)) > 0.86 && fabs(cos(the1)) < 0.92) IsEndcap1 = true; 
00244           if(fabs(cos(the2)) > 0.86 && fabs(cos(the2)) < 0.92) IsEndcap2 = true; 
00245           if(IsEndcap1 && IsEndcap2)  continue;
00247           KalmanKinematicFit * kmfit = KalmanKinematicFit::instance();
00248           kmfit->init();
00249           kmfit->setChisqCut(2500);
00250           kmfit->AddTrack(0, 0.0, g1Trk);
00251           kmfit->AddTrack(1, 0.0, g2Trk);
00252           kmfit->AddResonance(0, mpi0, 0, 1);
00253 
00254           kmfit->Fit(0);  // Perform fit
00255           kmfit->BuildVirtualParticle(0);
00256 
00257           double pi0_chisq = kmfit->chisq(0);
00258           if ( pi0_chisq >= 2500) continue;
00259           HepLorentzVector p2gfit = kmfit->pfit(0) + kmfit->pfit(1);
00260           p2gfit.boost(-0.011,0,0);
00262 
00263           HepVector ksp_val = HepVector(7,0);
00264           HepVector ksm_val = HepVector(7,0);
00265           ksp_val = wksp.w();
00266           ksm_val = wksm.w();
00267 
00268           HepLorentzVector P_KSP(ksp_val[0],ksp_val[1],ksp_val[2],ksp_val[3]);
00269           HepLorentzVector P_KSM(ksm_val[0],ksm_val[1],ksm_val[2],ksm_val[3]);
00270 
00271           P_KSP.boost(-0.011,0,0);
00272           P_KSM.boost(-0.011,0,0);
00273           pddd = p4kstag + p2gfit;
00274 
00275           double   pk0pi0=pddd.rho();
00276 
00277           double temp1 = (ecms/2)*(ecms/2)-pk0pi0*pk0pi0 ;
00278           if(temp1<0) temp1 =0;
00279           double mass_bc_tem  = sqrt(temp1);
00280           if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
00281           
00282           double  delE_tag_tag = ecms/2-pddd.e();
00283 
00284           if(fabs(delE_tag_tag)<deltaE_tem){
00285             deltaE_tem = fabs(delE_tag_tag);
00286             delE_tag_temp = delE_tag_tag;
00287             mass_bcgg = mass_bc_tem;
00288 
00289             pddd_temp = pddd;
00290 
00291             ipi1_temp=ipi1;
00292             ipi2_temp=ipi2;
00293 
00294             iGam1_temp = iGam[m];
00295             iGam2_temp = iGam[n];
00296             
00297             ncount1 = 1;
00298           }   
00299         }   
00300       }
00301     }
00302   }
00303 
00304   if(ncount1 == 1){
00305     tagmode=18;
00306     if(m_chargetag<0)  tagmode=-18;
00307     tagmd=tagmode;
00308     mass_bc = mass_bcgg;
00309     delE_tag = delE_tag_temp;
00310     cqtm    = 0.0;
00311 
00312     iGoodtag.push_back(ipi1_temp);
00313     iGoodtag.push_back(ipi2_temp);
00314     iGamtag.push_back(iGam1_temp);
00315     iGamtag.push_back(iGam2_temp);
00316     iGamtag.push_back(9999);
00317     iGamtag.push_back(9999);
00318 
00319     ptag = pddd_temp;
00320 
00321     k0pi0md = true;
00322 
00323   }
00324 }
00325 
00326 
00327 

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