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

Go to the documentation of this file.
00001 //
00002 //  K3pipi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 through the final states of
00003 //  K3pipi0 from D0 decays. K3pipi0.cxx was transfered from the Fortran routine "K3pipi0.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 "K3pipi0.f" used at the BES-II experiment was coded by G. Rong in 2001.
00008 //
00009 //  K3pipi0.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/K3pipi0.h"
00024 #include "SD0TagAlg/SingleBase.h"
00025 
00026 K3pipi0::K3pipi0()
00027 {}
00028 
00029 K3pipi0::~K3pipi0()
00030 {}
00031 
00032 
00033 void K3pipi0::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, iGam1_temp, iGam2_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   k3pipi0md = false;
00060   double  tagmode=0;
00061 
00062   if((evtRecEvent->totalCharged() < 4 || nGam <2)){     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   HepLorentzVector p2gfit;
00073   HepLorentzVector p2gg;
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]);
00093 
00094    HepLorentzVector ptrk1_temp, ptrk2_temp, ptrk3_temp, ptrk4_temp, ptrk5_temp, ptrk6_temp, ptrk7_temp;
00096    for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
00097      EvtRecTrackIterator itTrk1 = evtRecTrkCol->begin() + i;
00098 
00099      int ika= (*itTrk1)->trackId();
00100 
00101      if(!(*itTrk1)->isMdcKalTrackValid()) continue;
00102      RecMdcKalTrack*  mdcKalTrk1 = (*itTrk1)->mdcKalTrack();
00103      RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
00105      m_chargek=mdcKalTrk1->charge();
00106      if(Charge_candidate_D != 0) {
00107        if(m_chargek != -Charge_candidate_D) continue;
00108      }
00109      if(Charge_candidate_D == 0) {
00110        if(abs(m_chargek) != 1) continue;
00111      }
00113      HepVector a1 = mdcKalTrk1->getZHelixK();
00114      HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
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      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(*itTrk1);
00128        if(simple_pid->probKaon() < 0.0 ||simple_pid->probKaon() < simple_pid->probPion()) continue;  
00129      } 
00130 
00132 
00133      WTrackParameter kam(xmass[3],mdcKalTrk1->getZHelixK(),mdcKalTrk1->getZErrorK() );
00134 
00135      // 
00136      // select pi1
00137      // 
00138      for(int j = 0; j< evtRecEvent->totalCharged();j++) {
00139        EvtRecTrackIterator itTrk2 = evtRecTrkCol->begin() + j;
00140 
00141        int ipi1= (*itTrk2)->trackId();
00142        if(ipi1==ika)  continue;
00143 
00144        if(!(*itTrk2)->isMdcKalTrackValid()) continue;
00145        RecMdcKalTrack*  mdcKalTrk2 = (*itTrk2)->mdcKalTrack();
00146        RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00148        m_chargepi1=mdcKalTrk2->charge();
00149        if((m_chargek + m_chargepi1) != 0) continue;
00151        HepVector a2 = mdcKalTrk2->getZHelix();
00152        HepSymMatrix Ea2 = mdcKalTrk2->getZError();
00153        VFHelix helixip3_2(point0,a2,Ea2);
00154        helixip3_2.pivot(IP);
00155        HepVector  vecipa2 = helixip3_2.a();
00156 
00157        double dr2 = fabs(vecipa2[0]);
00158        double dz2 = fabs(vecipa2[3]);
00159        double costheta2 = cos(mdcKalTrk2->theta());
00160        if (  dr2 >= 1.0) continue;
00161        if (  dz2 >= 10.0) continue; 
00162        if ( fabs(costheta2) >= 0.93) continue; 
00164        if(PID_flag == 5) {
00165          simple_pid->preparePID(*itTrk2);
00166          if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00167        } 
00169        WTrackParameter pip1(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
00170 
00171        //       
00172        //select pi2
00173        //       
00174        for(int k = 0; k< evtRecEvent->totalCharged(); k++) {
00175          EvtRecTrackIterator itTrk3 = evtRecTrkCol->begin() + k;
00176 
00177          int ipi2= (*itTrk3)->trackId();
00178          if(ipi2==ika || ipi2==ipi1)  continue;
00179 
00180          if(!(*itTrk3)->isMdcKalTrackValid()) continue;
00181          RecMdcKalTrack* mdcKalTrk3 = (*itTrk3)->mdcKalTrack();
00182          RecMdcKalTrack::setPidType  (RecMdcKalTrack::pion);
00184          m_chargepi2=mdcKalTrk3->charge();
00185          if((m_chargek + m_chargepi2) != 0) continue;
00187          HepVector a3 = mdcKalTrk3->getZHelix();
00188          HepSymMatrix Ea3 = mdcKalTrk3->getZError();
00189          VFHelix helixip3_3(point0,a3,Ea3);
00190          helixip3_3.pivot(IP);
00191          HepVector  vecipa3 = helixip3_3.a();
00192 
00193          double dr3 = fabs(vecipa3[0]);
00194          double dz3 = fabs(vecipa3[3]);
00195          double costheta3 = cos(mdcKalTrk3->theta());
00196          if (  dr3 >= 1.0) continue;
00197          if (  dz3 >= 10.0) continue; 
00198          if ( fabs(costheta3) >= 0.93) continue; 
00200          if(PID_flag == 5) {
00201            simple_pid->preparePID(*itTrk3);
00202            if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00203          } 
00205          WTrackParameter pip2(xmass[2],mdcKalTrk3->getZHelix(),mdcKalTrk3->getZError() );
00206 
00207          //
00208          // select pi3
00209          //
00210          for(int l = 0; l< evtRecEvent->totalCharged();l++) {
00211            EvtRecTrackIterator itTrk4 = evtRecTrkCol->begin() + l;
00212 
00213            int ipi3= (*itTrk4)->trackId();
00214            if(ipi3==ika || ipi3==ipi1 || ipi3==ipi2 )  continue;
00215 
00216            if(!(*itTrk4)->isMdcKalTrackValid()) continue;
00217            RecMdcKalTrack* mdcKalTrk4 = (*itTrk4)->mdcKalTrack();
00218            RecMdcKalTrack::setPidType  (RecMdcKalTrack::pion);
00220            m_chargepi3=mdcKalTrk4->charge();
00221            if((m_chargepi2 + m_chargepi3) != 0) continue;
00223            HepVector a4 = mdcKalTrk4->getZHelix();
00224            HepSymMatrix Ea4 = mdcKalTrk4->getZError();
00225            VFHelix helixip3_4(point0,a4,Ea4);
00226            helixip3_4.pivot(IP);
00227            HepVector  vecipa4 = helixip3_4.a();
00228 
00229            double dr4 = fabs(vecipa4[0]);
00230            double dz4 = fabs(vecipa4[3]);
00231            double costheta4 = cos(mdcKalTrk4->theta());
00232            if (  dr4 >= 1.0) continue;
00233            if (  dz4 >= 10.0) continue; 
00234            if ( fabs(costheta4) >= 0.93) continue; 
00236            if(PID_flag == 5) {
00237              simple_pid->preparePID(*itTrk4);
00238              if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;  
00239            } 
00241            WTrackParameter pip3(xmass[2],mdcKalTrk4->getZHelix(),mdcKalTrk4->getZError() );
00242 
00243 
00244            for(int m = 0; m < nGam-1; m++) {
00245              if(iGam[m]==-1) continue;
00246              RecEmcShower *g1Trk =(*(evtRecTrkCol->begin()+iGam[m]))->emcShower();
00247              double eraw1 = g1Trk->energy();
00248              double phi1 = g1Trk->phi();
00249              double the1 = g1Trk->theta();
00250              HepLorentzVector ptrkg1,ptrkg10,ptrkg12;
00251              ptrkg1.setPx(eraw1*sin(the1)*cos(phi1));
00252              ptrkg1.setPy(eraw1*sin(the1)*sin(phi1));
00253              ptrkg1.setPz(eraw1*cos(the1));
00254              ptrkg1.setE(eraw1);
00255              ptrkg10 = ptrkg1;
00256              ptrkg12 = ptrkg1.boost(-0.011,0,0);
00257 
00258              for(int n = m+1; n < nGam; n++) {
00259                if(iGam[n]==-1) continue;
00260                RecEmcShower *g2Trk =(*(evtRecTrkCol->begin()+iGam[n]))->emcShower();
00261                double eraw2 = g2Trk->energy();
00262                double phi2 = g2Trk->phi();
00263                double the2 = g2Trk->theta();
00264                HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
00265                ptrkg2.setPx(eraw2*sin(the2)*cos(phi2));
00266                ptrkg2.setPy(eraw2*sin(the2)*sin(phi2));
00267                ptrkg2.setPz(eraw2*cos(the2));
00268                ptrkg2.setE(eraw2);
00269                ptrkg20 = ptrkg2;
00270                ptrkg22 = ptrkg2.boost(-0.011,0,0);
00271 
00273                HepLorentzVector  ptrkpi0;
00274                ptrkpi0 = ptrkg12+ptrkg22;
00275                double m_xmpi0_tem = ptrkpi0.mag();
00276                if(m_xmpi0_tem>0.150||m_xmpi0_tem<0.115)  continue;
00278                bool IsEndcap1 = false; bool IsEndcap2 = false;
00279                if(fabs(cos(the1)) > 0.86 && fabs(cos(the1)) < 0.92) IsEndcap1 = true;
00280                if(fabs(cos(the2)) > 0.86 && fabs(cos(the2)) < 0.92) IsEndcap2 = true;
00281                if(IsEndcap1 && IsEndcap2)  continue;
00283 
00284                KalmanKinematicFit * kmfit = KalmanKinematicFit::instance();
00285                kmfit->init();
00286                kmfit->setChisqCut(2500);
00287                kmfit->AddTrack(0, 0.0 , g1Trk);
00288                kmfit->AddTrack(1, 0.0 , g2Trk);
00289                kmfit->AddResonance(0, mpi0, 0, 1);
00290 
00291                kmfit->Fit(0);  // Perform fit
00292                kmfit->BuildVirtualParticle(0);
00293 
00294                double pi0_chisq = kmfit->chisq(0);
00295                if ( pi0_chisq >= 2500) continue;
00296                HepLorentzVector p2gfit = kmfit->pfit(0) + kmfit->pfit(1);
00297                p2gfit.boost(-0.011,0,0);
00298 
00300                HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
00301                HepSymMatrix Evx(3, 0);
00302                double bx = 1E+6; Evx[0][0] = bx*bx;
00303                double by = 1E+6; Evx[1][1] = by*by;
00304                double bz = 1E+6; Evx[2][2] = bz*bz;
00305                VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
00307 
00308                VertexFit* vtxfit = VertexFit::instance();
00309                vtxfit->init();
00310                vtxfit->AddTrack(0,  kam);
00311                vtxfit->AddTrack(1,  pip1);
00312                vtxfit->AddTrack(2,  pip2);
00313                vtxfit->AddTrack(3,  pip3);
00314                vtxfit->AddVertex(0, vxpar, 0, 1, 2, 3);
00315                if(!vtxfit->Fit(0))  continue;
00316                vtxfit->Swim(0);
00317 
00318                WTrackParameter wkam  = vtxfit->wtrk(0);
00319                WTrackParameter wpip1 = vtxfit->wtrk(1);
00320                WTrackParameter wpip2 = vtxfit->wtrk(2);
00321                WTrackParameter wpip3 = vtxfit->wtrk(3);
00322 
00323                HepVector kam_val  = HepVector(7,0);
00324                HepVector pip1_val = HepVector(7,0);
00325                HepVector pip2_val = HepVector(7,0);
00326                HepVector pip3_val = HepVector(7,0);
00327                kam_val  = wkam.w();
00328                pip1_val = wpip1.w();
00329                pip2_val = wpip2.w();
00330                pip3_val = wpip3.w();
00331 
00332                HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
00333                HepLorentzVector P_PIP1(pip1_val[0],pip1_val[1],pip1_val[2],pip1_val[3]);
00334                HepLorentzVector P_PIP2(pip2_val[0],pip2_val[1],pip2_val[2],pip2_val[3]);
00335                HepLorentzVector P_PIP3(pip3_val[0],pip3_val[1],pip3_val[2],pip3_val[3]);
00336 
00337                P_KAM.boost(-0.011,0,0);
00338                P_PIP1.boost(-0.011,0,0);
00339                P_PIP2.boost(-0.011,0,0);
00340                P_PIP3.boost(-0.011,0,0);
00341                pddd = P_KAM + P_PIP1 + P_PIP2 + P_PIP3 + p2gfit;
00342 
00343                double   pk3pipi0=pddd.rho();
00344 
00345                double temp1 = (ecms/2)*(ecms/2)-pk3pipi0*pk3pipi0 ;
00346                if(temp1<0) temp1 =0;
00347                double mass_bc_tem  = sqrt(temp1);
00348                if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
00349 
00350                double  delE_tag_tag = ecms/2-pddd.e();
00351 
00352               if(fabs(delE_tag_tag)<deltaE_tem) {
00353                 deltaE_tem = fabs(delE_tag_tag);
00354                 delE_tag_temp = delE_tag_tag;
00355                 mass_bcgg = mass_bc_tem;
00356 
00357                 pddd_temp = pddd;
00358                 cqtm_temp = m_chargek;
00359 
00360                 ika_temp=ika;
00361                 ipi1_temp=ipi1;
00362                 ipi2_temp=ipi2;
00363                 ipi3_temp=ipi3;
00364                 iGam1_temp = iGam[m];
00365                 iGam2_temp = iGam[n];
00366 
00367                 ncount1 = 1;
00368 
00369 
00370               } 
00371             }   
00372           }
00373         }
00374       }
00375     }
00376   }
00377   if(ncount1 == 1){  
00378     tagmode=24;
00379     if(cqtm_temp<0)  tagmode=-24;
00380     tagmd=tagmode;
00381     mass_bc  = mass_bcgg;
00382     delE_tag = delE_tag_temp; 
00383     cqtm     = -1.0*cqtm_temp;
00384 
00385     iGoodtag.push_back(ika_temp);
00386     iGoodtag.push_back(ipi1_temp);
00387     iGoodtag.push_back(ipi2_temp);
00388     iGoodtag.push_back(ipi3_temp);
00389 
00390     iGamtag.push_back(iGam1_temp);
00391     iGamtag.push_back(iGam2_temp);
00392     iGamtag.push_back(9999);
00393     iGamtag.push_back(9999);
00394 
00395     ptag = pddd_temp;  
00396 
00397     k3pipi0md = true;
00398 
00399   }
00400 }
00401 

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