00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "SD0TagAlg/K0kk.h"
00024 #include "SD0TagAlg/SingleBase.h"
00025
00026 K0kk::K0kk()
00027 {}
00028
00029 K0kk::~K0kk()
00030 {}
00031
00032
00033 void K0kk::MTotal(double event,SmartDataPtr<EvtRecTrackCol> evtRecTrkCol, Vint iGood,Vint iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
00034 {
00035
00036 int nGood=iGood.size();
00037 int nGam=iGam.size();
00038
00039 iGoodtag.clear();
00040 iGamtag.clear();
00041
00042 double mass_bcgg,delE_tag_temp;
00043 int m_chargetag, m_chargepi1,m_chargepi2,m_chargek1,m_chargek2;
00044 int ik1_temp,ik2_temp,ipi1_temp,ipi2_temp;
00045 HepLorentzVector pddd;
00046 HepLorentzVector pddd_temp;
00047
00048 IDataProviderSvc* eventSvc = NULL;
00049 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00050 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc,EventModel::EvtRec::EvtRecEvent);
00051 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
00052
00053 int runNo=eventHeader->runNumber();
00054 int rec=eventHeader->eventNumber();
00055
00056 double xecm=2*Ebeam;
00057
00058 k0kkmd=false;
00059 double tagmode=0;
00060
00061 if((evtRecEvent->totalCharged() < 4)){ return; }
00062
00063 double ecms = xecm;
00064
00065 ISimplePIDSvc* simple_pid;
00066 Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
00067
00068 double deltaE_tem = 0.20;
00069 int ncount1 = 0;
00070
00071 Hep3Vector xorigin(0,0,0);
00072 HepSymMatrix xoriginEx(3,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 xoriginEx[0][0] = vv[0] * vv[0];
00084 xoriginEx[1][1] = vv[1] * vv[1];
00085 xoriginEx[2][2] = vv[2] * vv[2];
00086 }
00087
00088 double xv=xorigin.x();
00089 double yv=xorigin.y();
00090 double zv=xorigin.z();
00091
00092 HepPoint3D point0(0.,0.,0.);
00093 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
00095
00096 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
00097 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
00098
00099 int ipi1= (*itTrk)->trackId();
00100
00101 if(!(*itTrk)->isMdcKalTrackValid()) continue;
00102 RecMdcKalTrack* mdcKalTrk1 = (*itTrk)->mdcKalTrack();
00103 RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00104
00105 m_chargepi1=mdcKalTrk1->charge();
00106 if(abs(m_chargepi1) != 1) continue;
00107
00109 HepVector a1 = mdcKalTrk1->getZHelix();
00110 HepSymMatrix Ea1 = mdcKalTrk1->getZError();
00111
00112 VFHelix helixip3_1(point0,a1,Ea1);
00113 helixip3_1.pivot(IP);
00114 HepVector vecipa1 = helixip3_1.a();
00115
00116 double dr1 = fabs(vecipa1[0]);
00117 double dz1 = fabs(vecipa1[3]);
00118 double costheta1 = cos(mdcKalTrk1->theta());
00119
00120 if ( dr1 >= 15.0) continue;
00121 if ( dz1 >= 25.0) continue;
00122 if ( fabs(costheta1) >= 0.93) continue;
00124 WTrackParameter pip(xmass[2],mdcKalTrk1->getZHelix(),mdcKalTrk1->getZError() );
00125
00126
00127
00128
00129 for(int j = 0; j < evtRecEvent->totalCharged(); j++) {
00130 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
00131
00132 int ipi2= (*itTrk)->trackId();
00133 if(ipi1==ipi2) continue;
00134
00135 if(!(*itTrk)->isMdcKalTrackValid()) continue;
00136 RecMdcKalTrack* mdcKalTrk2 = (*itTrk)->mdcKalTrack();
00137 RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
00138
00139 m_chargepi2=mdcKalTrk2->charge();
00140 if((m_chargepi2 + m_chargepi1) != 0) continue;
00141
00143 HepVector a2 = mdcKalTrk2->getZHelix();
00144 HepSymMatrix Ea2 = mdcKalTrk2->getZError();
00145 VFHelix helixip3_2(point0,a2,Ea2);
00146 helixip3_2.pivot(IP);
00147 HepVector vecipa2 = helixip3_2.a();
00148
00149 double dr2 = fabs(vecipa2[0]);
00150 double dz2 = fabs(vecipa2[3]);
00151 double costheta2 = cos(mdcKalTrk2->theta());
00152 if ( dr2 >= 15.0) continue;
00153 if ( dz2 >= 25.0) continue;
00154 if ( fabs(costheta2) >= 0.93) continue;
00156 WTrackParameter pim(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
00157
00158
00159 HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
00160 HepSymMatrix Evx(3, 0);
00161 double bx = 1E+6; Evx[0][0] = bx*bx;
00162 double by = 1E+6; Evx[1][1] = by*by;
00163 double bz = 1E+6; Evx[2][2] = bz*bz;
00164 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
00165
00166 HepVector pip_val = HepVector(7,0);
00167 HepVector pim_val = HepVector(7,0);
00168 pip_val = pip.w();
00169 pim_val = pim.w();
00170 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]);
00171 double m_xmtagk0_tem = ptrktagk0.mag();
00172 if(fabs(ptrktagk0.m()-0.498)>0.1) continue;
00173
00174 VertexFit *vtxfit0 = VertexFit::instance();
00175 vtxfit0->init();
00176 vtxfit0->AddTrack(0, pip);
00177 vtxfit0->AddTrack(1, pim);
00178 vtxfit0->AddVertex(0, vxpar, 0, 1);
00179 if(!(vtxfit0->Fit(0))) continue;
00180 vtxfit0->Swim(0);
00181 vtxfit0->BuildVirtualParticle(0);
00182 WTrackParameter wksp = vtxfit0->wtrk(0);
00183 WTrackParameter wksm = vtxfit0->wtrk(1);
00184 WTrackParameter wks_Trk = vtxfit0->wVirtualTrack(0);
00185 VertexParameter wks_var = vtxfit0->vpar(0);
00186
00187
00188
00189
00190 for(int k = 0; k < evtRecEvent->totalCharged(); k++) {
00191 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + k;
00192
00193 int ik1= (*itTrk)->trackId();
00194 if(ipi2==ik1 || ipi1==ik1) continue;
00195
00196 if(!(*itTrk)->isMdcKalTrackValid()) continue;
00197 RecMdcKalTrack* mdcKalTrk3 = (*itTrk)->mdcKalTrack();
00198 RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
00199
00200 m_chargek1=mdcKalTrk3->charge();
00201 if(abs(m_chargek1) != 1) continue;
00202
00204 HepVector a3 = mdcKalTrk3->getZHelixK();
00205 HepSymMatrix Ea3 = mdcKalTrk3->getZErrorK();
00206 VFHelix helixip3_3(point0,a3,Ea3);
00207 helixip3_3.pivot(IP);
00208 HepVector vecipa3 = helixip3_3.a();
00209
00210 double dr3 = fabs(vecipa3[0]);
00211 double dz3 = fabs(vecipa3[3]);
00212 double costheta3 = cos(mdcKalTrk3->theta());
00213 if ( dr3 >= 1.0) continue;
00214 if ( dz3 >= 10.0) continue;
00215 if ( fabs(costheta3) >= 0.93) continue;
00217 if(PID_flag == 5) {
00218 simple_pid->preparePID(*itTrk);
00219 if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;
00220 }
00222 WTrackParameter kap(xmass[3],mdcKalTrk3->getZHelixK(),mdcKalTrk3->getZErrorK() );
00223
00224
00225
00226
00227 for(int l = 0; l < evtRecEvent->totalCharged(); l++) {
00228 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + l;
00229
00230 int ik2= (*itTrk)->trackId();
00231 if(ik2==ik1 || ik2==ipi2 || ik2 ==ipi1) continue;
00232
00233 if(!(*itTrk)->isMdcKalTrackValid()) continue;
00234 RecMdcKalTrack* mdcKalTrk4 = (*itTrk)->mdcKalTrack();
00235 RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
00236
00237 m_chargek2=mdcKalTrk4->charge();
00238 if((m_chargek1 + m_chargek2) != 0) continue;
00239
00241 HepVector a4 = mdcKalTrk4->getZHelixK();
00242 HepSymMatrix Ea4 = mdcKalTrk4->getZErrorK();
00243 VFHelix helixip3_4(point0,a4,Ea4);
00244 helixip3_4.pivot(IP);
00245 HepVector vecipa4 = helixip3_4.a();
00246
00247 double dr4 = fabs(vecipa4[0]);
00248 double dz4 = fabs(vecipa4[3]);
00249 double costheta4 = cos(mdcKalTrk4->theta());
00250 if ( dr4 >= 1.0) continue;
00251 if ( dz4 >= 10.0) continue;
00252 if ( fabs(costheta4) >= 0.93) continue;
00254 if(PID_flag == 5) {
00255 simple_pid->preparePID(*itTrk);
00256 if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;
00257 }
00259
00260 WTrackParameter kam(xmass[3],mdcKalTrk4->getZHelixK(),mdcKalTrk4->getZErrorK() );
00261
00262 VertexFit* vtxfit_2 = VertexFit::instance();
00263 vtxfit_2->init();
00264 vtxfit_2->AddTrack(0, kap);
00265 vtxfit_2->AddTrack(1, kam);
00266 vtxfit_2->AddVertex(0, vxpar, 0, 1);
00267 if(!vtxfit_2->Fit(0)) continue;
00268 vtxfit_2->Swim(0);
00269
00270 WTrackParameter wkap = vtxfit_2->wtrk(0);
00271 WTrackParameter wkam = vtxfit_2->wtrk(1);
00272
00273 SecondVertexFit *vtxfit = SecondVertexFit::instance();
00274 vtxfit->init();
00275 vxpar.setEvx(xoriginEx);
00276 vtxfit->setPrimaryVertex(vxpar);
00277 vtxfit->AddTrack(0, wks_Trk);
00278 vtxfit->setVpar(wks_var);
00279 if(!vtxfit->Fit()) continue;
00280
00281 if(vtxfit->chisq() >999.) continue;
00282 if(vtxfit->decayLength()<0.0) continue;
00283
00284 double m_massks1_tem = vtxfit->p4par().m();
00285 if(m_massks1_tem < 0.485 || m_massks1_tem > 0.515) continue;
00286 HepLorentzVector p4kstag = vtxfit->p4par();
00287 WTrackParameter para_ks = vtxfit0->wVirtualTrack(0);
00288
00289 HepVector kap_val = HepVector(7,0);
00290 HepVector kam_val = HepVector(7,0);
00291 HepVector ksp_val = HepVector(7,0);
00292 HepVector ksm_val = HepVector(7,0);
00293
00294 kap_val = wkap.w();
00295 kam_val = wkam.w();
00296 ksp_val = wksp.w();
00297 ksm_val = wksm.w();
00298
00299 HepLorentzVector P_KAP(kap_val[0],kap_val[1],kap_val[2],kap_val[3]);
00300 HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
00301 HepLorentzVector P_KSP(ksp_val[0],ksp_val[1],ksp_val[2],ksp_val[3]);
00302 HepLorentzVector P_KSM(ksm_val[0],ksm_val[1],ksm_val[2],ksm_val[3]);
00303
00304 P_KAM.boost(-0.011,0,0);
00305 P_KAP.boost(-0.011,0,0);
00306 P_KSP.boost(-0.011,0,0);
00307 P_KSM.boost(-0.011,0,0);
00308 p4kstag.boost(-0.011,0,0);
00309
00310 pddd = P_KAM + P_KAP + p4kstag;
00311
00312 double pk0kk=pddd.rho();
00313
00314 double temp1 = (ecms/2)*(ecms/2)-pk0kk*pk0kk ;
00315 if(temp1<0) temp1 =0;
00316 double mass_bc_tem = sqrt(temp1);
00317 if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
00318
00319 double delE_tag_tag = ecms/2-pddd.e();
00320
00321 if(fabs(delE_tag_tag)<deltaE_tem) {
00322 deltaE_tem = fabs(delE_tag_tag);
00323 delE_tag_temp = delE_tag_tag;
00324 mass_bcgg = mass_bc_tem;
00325
00326 pddd_temp = pddd;
00327
00328 ipi1_temp=ipi1;
00329 ipi2_temp=ipi2;
00330 ik1_temp=ik1;
00331 ik2_temp=ik2;
00332
00333 ncount1 = 1;
00334
00335 }
00336 }
00337 }
00338 }
00339 }
00340
00341 if(ncount1 == 1){
00342 tagmode=22;
00343 if(m_chargetag<0) tagmode=-22;
00344 tagmd=tagmode;
00345 mass_bc = mass_bcgg;
00346 delE_tag = delE_tag_temp;
00347 cqtm = 0.0;
00348
00349 iGoodtag.push_back(ipi1_temp);
00350 iGoodtag.push_back(ipi2_temp);
00351 iGoodtag.push_back(ik1_temp);
00352 iGoodtag.push_back(ik2_temp);
00353
00354 iGamtag.push_back(9999);
00355 iGamtag.push_back(9999);
00356 iGamtag.push_back(9999);
00357 iGamtag.push_back(9999);
00358
00359 ptag = pddd_temp;
00360
00361 k0kkmd=true;
00362 }
00363
00364 }
00365
00366
00367