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

Go to the documentation of this file.
00001 //
00002 //  Kkpi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 through the final states of
00003 //  Kkpi0 from D0 decays. Kkpi0.cxx was transfered from the Fortran routine "Kkpi0.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 "Kkpi0.f" used at the BES-II experiment was coded by H.L. Ma
00008 //  and G. Rong in 2003.
00009 //
00010 //  Kkpi0.cxx was transfered by G. Rong and J. Liu in December, 2005.
00011 //
00012 //  Since 2008, G. Rong and L.L. Jiang have been working on developing this code to analyze of
00013 //  the data taken at 3.773 GeV with the BES-III detector at the BEPC-II collider.
00014 //
00015 //  During developing this code, many People made significant contributions to this code. These are
00016 //          G. Rong, L.L. Jiang, J. Liu, H.L. Ma, J.C. Chen, D.H. Zhang,
00017 //          M.G. Zhao, B. Zheng, L. Li, Y. Fang, Z.Y. Yi, H.H. Liu, Z.Q. Liu et al.
00018 //
00019 //                                       By G. Rong and L.L. Jiang
00020 //                                       March, 2009
00021 //
00022 //  ==========================================================================================
00023 //
00024 #include "SD0TagAlg/Kkpi0.h"
00025 #include "SD0TagAlg/SingleBase.h"
00026 
00027 
00028 Kkpi0::Kkpi0()
00029 {}
00030 
00031 Kkpi0::~Kkpi0()
00032 {}
00033 
00034 
00035 void Kkpi0::MTotal(double event,SmartDataPtr<EvtRecTrackCol> evtRecTrkCol, Vint iGood,Vint
00036     iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
00037 {
00038 
00039   int nGood=iGood.size();
00040   int nGam=iGam.size();
00041 
00042   iGoodtag.clear();
00043   iGamtag.clear();
00044   
00045   double mass_bcgg,delE_tag_temp;
00046   int m_chargetag,m_chargek1,m_chargek2;
00047   int ik1_temp,ik2_temp, iGam1_temp, iGam2_temp;
00048   HepLorentzVector pddd;
00049   HepLorentzVector pddd_temp;
00050 
00051   IDataProviderSvc* eventSvc = NULL;
00052   Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00053   SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc,EventModel::EvtRec::EvtRecEvent);
00054   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
00055 
00056   int runNo=eventHeader->runNumber();
00057   int rec=eventHeader->eventNumber();
00058 
00059   double xecm=2*Ebeam;
00060 
00061   kkpi0md=false;
00062   double  tagmode=0;
00063 
00064   if((evtRecEvent->totalCharged() < 2||nGam<2)){    return;  }
00065 
00066   double ecms = xecm; 
00067 
00068 
00069   ISimplePIDSvc* simple_pid;
00070   Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
00071 
00072   double deltaE_tem = 0.20;
00073   int ncount1 = 0; 
00074 
00075   Hep3Vector xorigin(0,0,0);
00076   IVertexDbSvc*  vtxsvc;
00077   Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
00078   if(vtxsvc->isVertexValid())
00079   {
00080     double* dbv = vtxsvc->PrimaryVertex();
00081     double*  vv = vtxsvc->SigmaPrimaryVertex();
00082     xorigin.setX(dbv[0]);
00083     xorigin.setY(dbv[1]);
00084     xorigin.setZ(dbv[2]);
00085   }
00086 
00087   double xv=xorigin.x();
00088   double yv=xorigin.y();
00089   double zv=xorigin.z();
00090 
00091   HepPoint3D point0(0.,0.,0.);
00092   HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
00094 
00095   HepLorentzVector p2gfit;
00096   HepLorentzVector p2gg;
00097 
00098   for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
00099     EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
00100 
00101     int ik1 = (*itTrk)->trackId();
00102 
00103     if(!(*itTrk)->isMdcKalTrackValid()) continue;
00104     RecMdcKalTrack*  mdcKalTrk1 = (*itTrk)->mdcKalTrack();
00105     RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
00106 
00107     m_chargek1 = mdcKalTrk1->charge();
00108     if(abs(m_chargek1) != 1) continue;
00109 
00111     HepVector a1 = mdcKalTrk1->getZHelixK();
00112     HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
00113 
00114     VFHelix helixip3_1(point0,a1,Ea1);
00115     helixip3_1.pivot(IP);
00116     HepVector  vecipa1 = helixip3_1.a();
00117 
00118     double dr1 = fabs(vecipa1[0]);
00119     double dz1 = fabs(vecipa1[3]);
00120     double costheta1 = cos(mdcKalTrk1->theta());
00121 
00122     if (  dr1 >= 1.0) continue;
00123     if (  dz1 >= 10.0) continue; 
00124     if ( fabs(costheta1) >= 0.93) continue; 
00126     if(PID_flag == 5) {
00127       simple_pid->preparePID(*itTrk);
00128       if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;  
00129     } 
00131     WTrackParameter kap(xmass[3],mdcKalTrk1->getZHelixK(),mdcKalTrk1->getZErrorK() );
00132 
00133     //  
00134     // select K2
00135     //  
00136     for(int j = 0; j< evtRecEvent->totalCharged(); j++) {
00137       EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
00138 
00139       int ik2= (*itTrk)->trackId();
00140       if(ik2==ik1)  continue;
00141 
00142       if(!(*itTrk)->isMdcKalTrackValid()) continue;
00143       RecMdcKalTrack*  mdcKalTrk2 = (*itTrk)->mdcKalTrack();
00144       RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
00145 
00146       m_chargek2 = mdcKalTrk2->charge();
00147       if((m_chargek1 + m_chargek2) != 0) continue;
00148 
00150       HepVector a2 = mdcKalTrk2->getZHelixK();
00151       HepSymMatrix Ea2 = mdcKalTrk2->getZErrorK();
00152       VFHelix helixip3_2(point0,a2,Ea2);
00153       helixip3_2.pivot(IP);
00154       HepVector  vecipa2 = helixip3_2.a();
00155 
00156       double dr2 = fabs(vecipa2[0]);
00157       double dz2 = fabs(vecipa2[3]);
00158       double costheta2 = cos(mdcKalTrk2->theta());
00159       if (  dr2 >= 1.0) continue;
00160       if (  dz2 >= 10.0) continue; 
00161       if ( fabs(costheta2) >= 0.93) continue; 
00163       if(PID_flag == 5) {
00164         simple_pid->preparePID(*itTrk);
00165         if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;  
00166       } 
00168       WTrackParameter kam(xmass[3],mdcKalTrk2->getZHelixK(),mdcKalTrk2->getZErrorK() );
00169 
00170 
00171       for(int m = 0; m < nGam-1; m++) {
00172         if(iGam[m]==-1) continue;
00173         RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[m]))->emcShower();
00174         double eraw1 = g1Trk->energy();
00175         double phi1 = g1Trk->phi();
00176         double the1 = g1Trk->theta();
00177         HepLorentzVector ptrkg1,ptrkg10,ptrkg12;
00178         ptrkg1.setPx(eraw1*sin(the1)*cos(phi1));
00179         ptrkg1.setPy(eraw1*sin(the1)*sin(phi1));
00180         ptrkg1.setPz(eraw1*cos(the1));
00181         ptrkg1.setE(eraw1);
00182         ptrkg10 = ptrkg1;
00183         ptrkg12 = ptrkg1.boost(-0.011,0,0);
00184 
00185 
00186         for(int n = m+1; n < nGam; n++) {
00187           if(iGam[n]==-1) continue;
00188           RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[n]))->emcShower();
00189           double eraw2 = g2Trk->energy();
00190           double phi2 = g2Trk->phi();
00191           double the2 = g2Trk->theta();
00192           HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
00193           ptrkg2.setPx(eraw2*sin(the2)*cos(phi2));
00194           ptrkg2.setPy(eraw2*sin(the2)*sin(phi2));
00195           ptrkg2.setPz(eraw2*cos(the2));
00196           ptrkg2.setE(eraw2);
00197           ptrkg20 = ptrkg2;
00198           ptrkg22 = ptrkg2.boost(-0.011,0,0);
00199 
00201           HepLorentzVector  ptrkpi0;
00202           ptrkpi0 = ptrkg12+ptrkg22;
00203           double m_xmpi0_tem = ptrkpi0.m();
00204           if(m_xmpi0_tem>0.150||m_xmpi0_tem<0.115)  continue;
00206           bool IsEndcap1 = false; bool IsEndcap2 = false;
00207           if(fabs(cos(the1)) > 0.86 && fabs(cos(the1)) < 0.92) IsEndcap1 = true; 
00208           if(fabs(cos(the2)) > 0.86 && fabs(cos(the2)) < 0.92) IsEndcap2 = true; 
00209           if(IsEndcap1 && IsEndcap2)  continue;
00211           KalmanKinematicFit * kmfit = KalmanKinematicFit::instance();
00212           kmfit->init();
00213           kmfit->setChisqCut(2500);
00214           kmfit->AddTrack(0, 0.0, g1Trk);
00215           kmfit->AddTrack(1, 0.0, g2Trk);
00216           kmfit->AddResonance(0, mpi0, 0, 1);
00217 
00218           kmfit->Fit(0);  // Perform fit
00219           kmfit->BuildVirtualParticle(0);
00220 
00221           double pi0_chisq = kmfit->chisq(0);
00222           if ( pi0_chisq >= 2500) continue;
00223           HepLorentzVector p2gfit = kmfit->pfit(0) + kmfit->pfit(1);
00224           p2gfit.boost(-0.011,0,0);
00225 
00227           HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
00228           HepSymMatrix Evx(3, 0);
00229           double bx = 1E+6; Evx[0][0] = bx*bx;
00230           double by = 1E+6; Evx[1][1] = by*by;
00231           double bz = 1E+6; Evx[2][2] = bz*bz;
00232           VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
00234 
00235           VertexFit* vtxfit = VertexFit::instance();
00236           vtxfit->init();
00237           vtxfit->AddTrack(0,  kam);
00238           vtxfit->AddTrack(1,  kap);
00239           vtxfit->AddVertex(0, vxpar, 0, 1);
00240           if(!vtxfit->Fit(0))  continue;
00241           vtxfit->Swim(0);
00242 
00243           WTrackParameter wkam = vtxfit->wtrk(0);
00244           WTrackParameter wkap = vtxfit->wtrk(1);
00245 
00246           HepVector kam_val = HepVector(7,0);
00247           kam_val = wkam.w();
00248           HepVector kap_val = HepVector(7,0);
00249           kap_val = wkap.w();
00250 
00251           HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
00252           HepLorentzVector P_KAP(kap_val[0],kap_val[1],kap_val[2],kap_val[3]);
00253 
00254           P_KAM.boost(-0.011,0,0);
00255           P_KAP.boost(-0.011,0,0);
00256           pddd = P_KAM + P_KAP + p2gfit;
00257 
00258           double pkkpi0 = pddd.rho(); 
00259 
00260           double temp1 = (ecms/2)*(ecms/2)-pkkpi0*pkkpi0 ;
00261           if(temp1<0) temp1 =0;
00262           double mass_bc_tem  = sqrt(temp1);
00263           if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
00264           
00265           double delE_tag_tag = ecms/2-pddd.e();
00266 
00267           if(fabs(delE_tag_tag)<deltaE_tem)  {
00268             deltaE_tem = fabs(delE_tag_tag);
00269             delE_tag_temp = delE_tag_tag;
00270             mass_bcgg = mass_bc_tem;
00271 
00272             pddd_temp = pddd;
00273 
00274             ik1_temp = ik1;
00275             ik2_temp = ik2;
00276             iGam1_temp = iGam[m];
00277             iGam2_temp = iGam[n];
00278             ncount1 = 1;
00279 
00280           }
00281         }
00282       }
00283     }
00284   }
00285 
00286   if(ncount1 == 1) {
00287     tagmode=23;
00288     if(m_chargetag<0)  tagmode=-23;
00289     tagmd=tagmode;
00290     mass_bc  = mass_bcgg;
00291     delE_tag = delE_tag_temp;
00292     cqtm     = 0.0;
00293 
00294     iGoodtag.push_back(ik1_temp);
00295     iGoodtag.push_back(ik2_temp);
00296  
00297     iGamtag.push_back(iGam1_temp); 
00298     iGamtag.push_back(iGam2_temp); 
00299     iGamtag.push_back(9999); 
00300     iGamtag.push_back(9999); 
00301 
00302     ptag = pddd_temp;
00303 
00304     kkpi0md = true;
00305   }
00306 }
00307 
00308 
00309 

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