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

Go to the documentation of this file.
00001 //
00002 //  K3pi.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meon through the final states of
00003 //  K3pi from D0 decays. K3pi.cxx was transfered from the Fortran routine "K3pi.f" which 
00004 //  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 "K3pi.f" used at the BES-II experiment was coded by G. Rong in 2002.
00008 //
00009 //  K3pi.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/K3pi.h"
00024 #include "SD0TagAlg/SingleBase.h"
00025 
00026 K3pi::K3pi()
00027 {}
00028 
00029 K3pi::~K3pi()
00030 {}
00031 
00032 
00033 void K3pi::MTotal(double event,SmartDataPtr<EvtRecTrackCol> evtRecTrkCol, Vint iGood,Vint
00034     iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
00035 {
00036 
00037   int nGood=iGood.size();
00038   int nGam=iGam.size();
00039   iGoodtag.clear();
00040   iGamtag.clear();
00041   
00042   double mass_bcgg, delE_tag_temp;
00043   int m_chargetag,m_chargek,m_chargepi1,m_chargepi2,m_chargepi3;
00044   int ika_temp,ipi1_temp,ipi2_temp,ipi3_temp,ipi4_temp;
00045   HepLorentzVector kmfit1,kmfit2,kmfit3,kmfit4,pddd;
00046 
00047   int cqtm_temp;
00048   HepLorentzVector pddd_temp;
00049   IDataProviderSvc* eventSvc = NULL;
00050   Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00051   SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc, EventModel::EvtRec::EvtRecEvent);
00052   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
00053 
00054   int runNo=eventHeader->runNumber();
00055   int rec=eventHeader->eventNumber();
00056 
00057   double xecm=2*Ebeam;
00058 
00059   k3pimd=false;
00060   double  tagmode=0;
00061 
00062   if((evtRecEvent->totalCharged() < 4)){     return;   }
00063 
00064   double ecms = xecm;
00065 
00066   ISimplePIDSvc* simple_pid;
00067   Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
00068 
00069   double deltaE_tem = 0.20;
00070   int ncount1 = 0; 
00071 
00072   Hep3Vector xorigin(0,0,0);
00073   IVertexDbSvc*  vtxsvc;
00074   Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
00075   if(vtxsvc->isVertexValid())
00076   {
00077     double* dbv = vtxsvc->PrimaryVertex();
00078     double*  vv = vtxsvc->SigmaPrimaryVertex();
00079     xorigin.setX(dbv[0]);
00080     xorigin.setY(dbv[1]);
00081     xorigin.setZ(dbv[2]);
00082   }
00083 
00084   double xv=xorigin.x();
00085   double yv=xorigin.y();
00086   double zv=xorigin.z();
00087 
00088   HepPoint3D point0(0.,0.,0.);
00089   HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
00090 
00091   HepLorentzVector ptrk1_temp, ptrk2_temp, ptrk3_temp, ptrk4_temp;
00093   for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
00094     EvtRecTrackIterator itTrk1 = evtRecTrkCol->begin() + i;
00095 
00096     int ika= (*itTrk1)->trackId();
00097 
00098     if(!(*itTrk1)->isMdcKalTrackValid()) continue;
00099     RecMdcKalTrack*  mdcKalTrk1 = (*itTrk1)->mdcKalTrack();
00100     RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
00102     m_chargek=mdcKalTrk1->charge();
00103     if(Charge_candidate_D != 0) {
00104       if(m_chargek != -Charge_candidate_D) continue;
00105     }
00106     if(Charge_candidate_D == 0) {
00107       if(abs(m_chargek) != 1) continue;
00108     }
00110     HepVector a1 = mdcKalTrk1->getZHelixK();
00111     HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
00112 
00113     VFHelix helixip3_1(point0,a1,Ea1);
00114     helixip3_1.pivot(IP);
00115     HepVector  vecipa1 = helixip3_1.a();
00116 
00117     double dr1 = fabs(vecipa1[0]);
00118     double dz1 = fabs(vecipa1[3]);
00119     double costheta1 = cos(mdcKalTrk1->theta());
00120 
00121     if (  dr1 >= 1.0) continue;
00122     if (  dz1 >= 10.0) continue; 
00123     if ( fabs(costheta1) >= 0.93) continue; 
00125     if(PID_flag == 5) {
00126       simple_pid->preparePID(*itTrk1);
00127       if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;  
00128     } 
00130     WTrackParameter kam(xmass[3],mdcKalTrk1->getZHelixK(),mdcKalTrk1->getZErrorK() );
00131 
00132     //  
00133     // select pi1
00134     //  
00135     for(int j = 0; j< evtRecEvent->totalCharged();j++) {
00136       EvtRecTrackIterator itTrk2 = evtRecTrkCol->begin() + j;
00137 
00138       int ipi1= (*itTrk2)->trackId();
00139       if(ipi1==ika)  continue;
00140 
00141       if(!(*itTrk2)->isMdcKalTrackValid()) continue;
00142       RecMdcKalTrack*  mdcKalTrk2 = (*itTrk2)->mdcKalTrack();
00143       RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00145       m_chargepi1=mdcKalTrk2->charge();
00146       if((m_chargek + m_chargepi1) != 0) continue;
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 >= 1.0) continue;
00158       if (  dz2 >= 10.0) continue; 
00159       if ( fabs(costheta2) >= 0.93) continue; 
00161       if(PID_flag == 5) {
00162         simple_pid->preparePID(*itTrk2);
00163         if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00164       } 
00166       WTrackParameter pip1(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
00167 
00168       //        
00169       //select pi2
00170       //        
00171       for(int k = 0; k< evtRecEvent->totalCharged(); k++) {
00172         EvtRecTrackIterator itTrk3 = evtRecTrkCol->begin() + k;
00173 
00174         int ipi2= (*itTrk3)->trackId();
00175         if(ipi2==ika || ipi2==ipi1)  continue;
00176 
00177         if(!(*itTrk3)->isMdcKalTrackValid()) continue;
00178         RecMdcKalTrack* mdcKalTrk3 = (*itTrk3)->mdcKalTrack();
00179         RecMdcKalTrack::setPidType  (RecMdcKalTrack::pion);
00181         m_chargepi2=mdcKalTrk3->charge();
00182         if((m_chargek + m_chargepi2) != 0) continue;
00184         HepVector a3 = mdcKalTrk3->getZHelix();
00185         HepSymMatrix Ea3 = mdcKalTrk3->getZError();
00186         VFHelix helixip3_3(point0,a3,Ea3);
00187         helixip3_3.pivot(IP);
00188         HepVector  vecipa3 = helixip3_3.a();
00189 
00190         double dr3 = fabs(vecipa3[0]);
00191         double dz3 = fabs(vecipa3[3]);
00192         double costheta3 = cos(mdcKalTrk3->theta());
00193         if (  dr3 >= 1.0) continue;
00194         if (  dz3 >= 10.0) continue; 
00195         if ( fabs(costheta3) >= 0.93) continue; 
00197         if(PID_flag == 5) {
00198           simple_pid->preparePID(*itTrk3);
00199           if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00200         } 
00202         WTrackParameter pip2(xmass[2],mdcKalTrk3->getZHelix(),mdcKalTrk3->getZError() );
00203 
00204         //
00205         // select pi3
00206         //
00207         for(int l = 0; l< evtRecEvent->totalCharged(); l++) {
00208           EvtRecTrackIterator itTrk4 = evtRecTrkCol->begin() + l;
00209 
00210           int ipi3= (*itTrk4)->trackId();
00211           if(ipi3==ika || ipi3==ipi1 || ipi3==ipi2 )  continue;
00212 
00213           if(!(*itTrk4)->isMdcKalTrackValid()) continue;
00214           RecMdcKalTrack* mdcKalTrk4 = (*itTrk4)->mdcKalTrack();
00215           RecMdcKalTrack::setPidType  (RecMdcKalTrack::pion);
00217           m_chargepi3=mdcKalTrk4->charge();
00218           if((m_chargepi2 + m_chargepi3) != 0) continue;        
00220           HepVector a4 = mdcKalTrk4->getZHelix();
00221           HepSymMatrix Ea4 = mdcKalTrk4->getZError();
00222           VFHelix helixip3_4(point0,a4,Ea4);
00223           helixip3_4.pivot(IP);
00224           HepVector  vecipa4 = helixip3_4.a();
00225 
00226           double dr4 = fabs(vecipa4[0]);
00227           double dz4 = fabs(vecipa4[3]);
00228           double costheta4 = cos(mdcKalTrk4->theta());
00229           if (  dr4 >= 1.0) continue;
00230           if (  dz4 >= 10.0) continue; 
00231           if ( fabs(costheta4) >= 0.93) continue; 
00233           if(PID_flag == 5) {
00234             simple_pid->preparePID(*itTrk4);
00235             if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00236           } 
00238           WTrackParameter pip3(xmass[2],mdcKalTrk4->getZHelix(),mdcKalTrk4->getZError() );
00239 
00241           HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
00242           HepSymMatrix Evx(3, 0);
00243           double bx = 1E+6; Evx[0][0] = bx*bx;
00244           double by = 1E+6; Evx[1][1] = by*by;
00245           double bz = 1E+6; Evx[2][2] = bz*bz;
00246           VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
00248 
00249           VertexFit* vtxfit = VertexFit::instance();
00250           vtxfit->init();
00251           vtxfit->AddTrack(0,  kam);
00252           vtxfit->AddTrack(1,  pip1);
00253           vtxfit->AddTrack(2,  pip2);
00254           vtxfit->AddTrack(3,  pip3);
00255           vtxfit->AddVertex(0, vxpar, 0, 1, 2, 3);
00256           if(!vtxfit->Fit(0))  continue;
00257           vtxfit->Swim(0);
00258 
00259           WTrackParameter wkam  = vtxfit->wtrk(0);
00260           WTrackParameter wpip1 = vtxfit->wtrk(1);
00261           WTrackParameter wpip2 = vtxfit->wtrk(2);
00262           WTrackParameter wpip3 = vtxfit->wtrk(3);
00263 
00264           HepVector kam_val = HepVector(7,0);
00265           HepVector pip1_val = HepVector(7,0);
00266           HepVector pip2_val = HepVector(7,0);
00267           HepVector pip3_val = HepVector(7,0);
00268           kam_val = wkam.w();
00269           pip1_val = wpip1.w();
00270           pip2_val = wpip2.w();
00271           pip3_val = wpip3.w();
00272 
00273           HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
00274           HepLorentzVector P_PIP1(pip1_val[0],pip1_val[1],pip1_val[2],pip1_val[3]);
00275           HepLorentzVector P_PIP2(pip2_val[0],pip2_val[1],pip2_val[2],pip2_val[3]);
00276           HepLorentzVector P_PIP3(pip3_val[0],pip3_val[1],pip3_val[2],pip3_val[3]);
00277 
00278           P_KAM.boost(-0.011,0,0);
00279           P_PIP1.boost(-0.011,0,0);
00280           P_PIP2.boost(-0.011,0,0);
00281           P_PIP3.boost(-0.011,0,0);
00282           pddd = P_KAM + P_PIP1 + P_PIP2 + P_PIP3;
00283 
00284           double   pk3pi=pddd.rho();
00285 
00286           double temp1 = (ecms/2)*(ecms/2)-pk3pi*pk3pi ;
00287           if(temp1<0) temp1 =0;
00288           double mass_bc_tem  = sqrt(temp1);
00289           if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
00290 
00291           double  delE_tag_tag = ecms/2-pddd.e();
00292 
00293           if(fabs(delE_tag_tag)<deltaE_tem) {
00294             deltaE_tem = fabs(delE_tag_tag);
00295             delE_tag_temp = delE_tag_tag;
00296             mass_bcgg = mass_bc_tem;
00297 
00298             pddd_temp = pddd;
00299             cqtm_temp = m_chargek;
00300 
00301             ika_temp=ika;
00302             ipi1_temp=ipi1;
00303             ipi2_temp=ipi2;
00304             ipi3_temp=ipi3;
00305             ncount1 = 1;
00306 
00307           }   
00308         }   
00309       }
00310     }
00311   }
00312 
00313   if(ncount1 == 1){  
00314     tagmode=13;
00315     if(cqtm_temp<0)  tagmode=-13;
00316     tagmd=tagmode;
00317     mass_bc  = mass_bcgg;
00318     delE_tag = delE_tag_temp; 
00319     cqtm     = -1.0*cqtm_temp;
00320 
00321     iGoodtag.push_back(ika_temp);
00322     iGoodtag.push_back(ipi1_temp);
00323     iGoodtag.push_back(ipi2_temp);
00324     iGoodtag.push_back(ipi3_temp);
00325 
00326     iGamtag.push_back(9999);
00327     iGamtag.push_back(9999);
00328     iGamtag.push_back(9999);
00329     iGamtag.push_back(9999);
00330 
00331     ptag = pddd_temp;  
00332 
00333     k3pimd=true;
00334 
00335   }
00336 }
00337 

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