CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
K0kk.cxx
Go to the documentation of this file.
1//
2// K0kk.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meson through the final states of
3// K0kk from D0 or anti-D0 meson decays. K0kk.cxx was transfered from the Fortran routine "K0kk.f"
4// which was orignally used for study of the D0D0-bar production and D0 decays at the BES-II
5// experiment during the time period from 2002 to 2008.
6//
7// The orignal Fortran routine "Pipipi0.f" used at the BES-II experiment was coded by G. Rong in 2002.
8//
9// K0kk.cxx was transfered by G. Rong and J. Liu in December, 2005.
10//
11// Since 2008, G. Rong and L.L. Jiang have been working on developing this code to analyze of
12// the data taken at 3.773 GeV with the BES-III detector at the BEPC-II collider.
13//
14// During developing this code, many People made significant contributions to this code. These are
15// G. Rong, L.L. Jiang, J. Liu, H.L. Ma, J.C. Chen, D.H. Zhang,
16// M.G. Zhao, B. Zheng, L. Li, Y. Fang, Z.Y. Yi, H.H. Liu, Z.Q. Liu et al.
17//
18// By G. Rong and L.L. Jiang
19// March, 2009
20//
21// ==========================================================================================
22//
23#include "SD0TagAlg/K0kk.h"
25
28
31
32
33void K0kk::MTotal(double event,SmartDataPtr<EvtRecTrackCol> evtRecTrkCol, Vint iGood,Vint iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
34{
35
36 int nGood=iGood.size();
37 int nGam=iGam.size();
38
39 iGoodtag.clear();
40 iGamtag.clear();
41
42 double mass_bcgg,delE_tag_temp;
43 int m_chargetag, m_chargepi1,m_chargepi2,m_chargek1,m_chargek2;
44 int ik1_temp,ik2_temp,ipi1_temp,ipi2_temp;
45 HepLorentzVector pddd;
46 HepLorentzVector pddd_temp;
47
48 IDataProviderSvc* eventSvc = NULL;
49 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
50 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc,EventModel::EvtRec::EvtRecEvent);
51 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
52
53 int runNo=eventHeader->runNumber();
54 int rec=eventHeader->eventNumber();
55
56 double xecm=2*Ebeam;
57
58 k0kkmd=false;
59 double tagmode=0;
60
61 if((evtRecEvent->totalCharged() < 4)){ return; }
62
63 double ecms = xecm;
64
65 ISimplePIDSvc* simple_pid;
66 Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
67
68 double deltaE_tem = 0.20;
69 int ncount1 = 0;
70
71 Hep3Vector xorigin(0,0,0);
72 HepSymMatrix xoriginEx(3,0);
73 IVertexDbSvc* vtxsvc;
74 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
75 if(vtxsvc->isVertexValid())
76 {
77 double* dbv = vtxsvc->PrimaryVertex();
78 double* vv = vtxsvc->SigmaPrimaryVertex();
79 xorigin.setX(dbv[0]);
80 xorigin.setY(dbv[1]);
81 xorigin.setZ(dbv[2]);
82
83 xoriginEx[0][0] = vv[0] * vv[0];
84 xoriginEx[1][1] = vv[1] * vv[1];
85 xoriginEx[2][2] = vv[2] * vv[2];
86 }
87
88 double xv=xorigin.x();
89 double yv=xorigin.y();
90 double zv=xorigin.z();
91
92 HepPoint3D point0(0.,0.,0.);
93 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
94 //////////////////////////////////////////////////////////////////
95
96 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
97 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
98
99 int ipi1= (*itTrk)->trackId();
100
101 if(!(*itTrk)->isMdcKalTrackValid()) continue;
102 RecMdcKalTrack* mdcKalTrk1 = (*itTrk)->mdcKalTrack();
104
105 m_chargepi1=mdcKalTrk1->charge();
106 if(abs(m_chargepi1) != 1) continue;
107
108 /////////////////////////////////////////
109 HepVector a1 = mdcKalTrk1->getZHelix();
110 HepSymMatrix Ea1 = mdcKalTrk1->getZError();
111
112 VFHelix helixip3_1(point0,a1,Ea1);
113 helixip3_1.pivot(IP);
114 HepVector vecipa1 = helixip3_1.a();
115
116 double dr1 = fabs(vecipa1[0]);
117 double dz1 = fabs(vecipa1[3]);
118 double costheta1 = cos(mdcKalTrk1->theta());
119
120 if ( dr1 >= 15.0) continue;
121 if ( dz1 >= 25.0) continue;
122 if ( fabs(costheta1) >= 0.93) continue;
123 /////////////////////////////////////////
124 WTrackParameter pip(xmass[2],mdcKalTrk1->getZHelix(),mdcKalTrk1->getZError() );
125
126 //
127 // select pi2
128 //
129 for(int j = 0; j < evtRecEvent->totalCharged(); j++) {
130 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
131
132 int ipi2= (*itTrk)->trackId();
133 if(ipi1==ipi2) continue;
134
135 if(!(*itTrk)->isMdcKalTrackValid()) continue;
136 RecMdcKalTrack* mdcKalTrk2 = (*itTrk)->mdcKalTrack();
138
139 m_chargepi2=mdcKalTrk2->charge();
140 if((m_chargepi2 + m_chargepi1) != 0) continue;
141
142 /////////////////////////////////////////
143 HepVector a2 = mdcKalTrk2->getZHelix();
144 HepSymMatrix Ea2 = mdcKalTrk2->getZError();
145 VFHelix helixip3_2(point0,a2,Ea2);
146 helixip3_2.pivot(IP);
147 HepVector vecipa2 = helixip3_2.a();
148
149 double dr2 = fabs(vecipa2[0]);
150 double dz2 = fabs(vecipa2[3]);
151 double costheta2 = cos(mdcKalTrk2->theta());
152 if ( dr2 >= 15.0) continue;
153 if ( dz2 >= 25.0) continue;
154 if ( fabs(costheta2) >= 0.93) continue;
155 /////////////////////////////////////////
156 WTrackParameter pim(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
157
158
159 HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
160 HepSymMatrix Evx(3, 0);
161 double bx = 1E+6; Evx[0][0] = bx*bx;
162 double by = 1E+6; Evx[1][1] = by*by;
163 double bz = 1E+6; Evx[2][2] = bz*bz;
164 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
165
166 HepVector pip_val = HepVector(7,0);
167 HepVector pim_val = HepVector(7,0);
168 pip_val = pip.w();
169 pim_val = pim.w();
170 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]);
171 double m_xmtagk0_tem = ptrktagk0.mag();
172 if(fabs(ptrktagk0.m()-0.498)>0.1) continue;
173
174 VertexFit *vtxfit0 = VertexFit::instance();
175 vtxfit0->init();
176 vtxfit0->AddTrack(0, pip);
177 vtxfit0->AddTrack(1, pim);
178 vtxfit0->AddVertex(0, vxpar, 0, 1);
179 if(!(vtxfit0->Fit(0))) continue;
180 vtxfit0->Swim(0);
181 vtxfit0->BuildVirtualParticle(0);
182 WTrackParameter wksp = vtxfit0->wtrk(0);
183 WTrackParameter wksm = vtxfit0->wtrk(1);
184 WTrackParameter wks_Trk = vtxfit0->wVirtualTrack(0);
185 VertexParameter wks_var = vtxfit0->vpar(0);
186
187 //
188 //select k1
189 //
190 for(int k = 0; k < evtRecEvent->totalCharged(); k++) {
191 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + k;
192
193 int ik1= (*itTrk)->trackId();
194 if(ipi2==ik1 || ipi1==ik1) continue;
195
196 if(!(*itTrk)->isMdcKalTrackValid()) continue;
197 RecMdcKalTrack* mdcKalTrk3 = (*itTrk)->mdcKalTrack();
199
200 m_chargek1=mdcKalTrk3->charge();
201 if(abs(m_chargek1) != 1) continue;
202
203 /////////////////////////////////////////
204 HepVector a3 = mdcKalTrk3->getZHelixK();
205 HepSymMatrix Ea3 = mdcKalTrk3->getZErrorK();
206 VFHelix helixip3_3(point0,a3,Ea3);
207 helixip3_3.pivot(IP);
208 HepVector vecipa3 = helixip3_3.a();
209
210 double dr3 = fabs(vecipa3[0]);
211 double dz3 = fabs(vecipa3[3]);
212 double costheta3 = cos(mdcKalTrk3->theta());
213 if ( dr3 >= 1.0) continue;
214 if ( dz3 >= 10.0) continue;
215 if ( fabs(costheta3) >= 0.93) continue;
216 /////////////////////////////////////////
217 if(PID_flag == 5) {
218 simple_pid->preparePID(*itTrk);
219 if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;
220 }
221 /////////////////////////////////////////
222 WTrackParameter kap(xmass[3],mdcKalTrk3->getZHelixK(),mdcKalTrk3->getZErrorK() );
223
224 //
225 //select k2
226 //
227 for(int l = 0; l < evtRecEvent->totalCharged(); l++) {
228 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + l;
229
230 int ik2= (*itTrk)->trackId();
231 if(ik2==ik1 || ik2==ipi2 || ik2 ==ipi1) continue;
232
233 if(!(*itTrk)->isMdcKalTrackValid()) continue;
234 RecMdcKalTrack* mdcKalTrk4 = (*itTrk)->mdcKalTrack();
236
237 m_chargek2=mdcKalTrk4->charge();
238 if((m_chargek1 + m_chargek2) != 0) continue;
239
240 /////////////////////////////////////////
241 HepVector a4 = mdcKalTrk4->getZHelixK();
242 HepSymMatrix Ea4 = mdcKalTrk4->getZErrorK();
243 VFHelix helixip3_4(point0,a4,Ea4);
244 helixip3_4.pivot(IP);
245 HepVector vecipa4 = helixip3_4.a();
246
247 double dr4 = fabs(vecipa4[0]);
248 double dz4 = fabs(vecipa4[3]);
249 double costheta4 = cos(mdcKalTrk4->theta());
250 if ( dr4 >= 1.0) continue;
251 if ( dz4 >= 10.0) continue;
252 if ( fabs(costheta4) >= 0.93) continue;
253 /////////////////////////////////////////
254 if(PID_flag == 5) {
255 simple_pid->preparePID(*itTrk);
256 if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;
257 }
258 /////////////////////////////////////////
259
260 WTrackParameter kam(xmass[3],mdcKalTrk4->getZHelixK(),mdcKalTrk4->getZErrorK() );
261
262 VertexFit* vtxfit_2 = VertexFit::instance();
263 vtxfit_2->init();
264 vtxfit_2->AddTrack(0, kap);
265 vtxfit_2->AddTrack(1, kam);
266 vtxfit_2->AddVertex(0, vxpar, 0, 1);
267 if(!vtxfit_2->Fit(0)) continue;
268 vtxfit_2->Swim(0);
269
270 WTrackParameter wkap = vtxfit_2->wtrk(0);
271 WTrackParameter wkam = vtxfit_2->wtrk(1);
272
274 vtxfit->init();
275 vxpar.setEvx(xoriginEx);
276 vtxfit->setPrimaryVertex(vxpar);
277 vtxfit->AddTrack(0, wks_Trk);
278 vtxfit->setVpar(wks_var);
279 if(!vtxfit->Fit()) continue;
280
281 if(vtxfit->chisq() >999.) continue;
282 if(vtxfit->decayLength()<0.0) continue;
283
284 double m_massks1_tem = vtxfit->p4par().m();
285 if(m_massks1_tem < 0.485 || m_massks1_tem > 0.515) continue;
286 HepLorentzVector p4kstag = vtxfit->p4par();
287 WTrackParameter para_ks = vtxfit0->wVirtualTrack(0);
288
289 HepVector kap_val = HepVector(7,0);
290 HepVector kam_val = HepVector(7,0);
291 HepVector ksp_val = HepVector(7,0);
292 HepVector ksm_val = HepVector(7,0);
293
294 kap_val = wkap.w();
295 kam_val = wkam.w();
296 ksp_val = wksp.w();
297 ksm_val = wksm.w();
298
299 HepLorentzVector P_KAP(kap_val[0],kap_val[1],kap_val[2],kap_val[3]);
300 HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
301 HepLorentzVector P_KSP(ksp_val[0],ksp_val[1],ksp_val[2],ksp_val[3]);
302 HepLorentzVector P_KSM(ksm_val[0],ksm_val[1],ksm_val[2],ksm_val[3]);
303
304 P_KAM.boost(-0.011,0,0);
305 P_KAP.boost(-0.011,0,0);
306 P_KSP.boost(-0.011,0,0);
307 P_KSM.boost(-0.011,0,0);
308 p4kstag.boost(-0.011,0,0);
309 //pddd = P_KAM + P_KAP + P_KSP + P_KSM;
310 pddd = P_KAM + P_KAP + p4kstag;
311
312 double pk0kk=pddd.rho();
313
314 double temp1 = (ecms/2)*(ecms/2)-pk0kk*pk0kk ;
315 if(temp1<0) temp1 =0;
316 double mass_bc_tem = sqrt(temp1);
317 if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
318
319 double delE_tag_tag = ecms/2-pddd.e();
320
321 if(fabs(delE_tag_tag)<deltaE_tem) {
322 deltaE_tem = fabs(delE_tag_tag);
323 delE_tag_temp = delE_tag_tag;
324 mass_bcgg = mass_bc_tem;
325
326 pddd_temp = pddd;
327
328 ipi1_temp=ipi1;
329 ipi2_temp=ipi2;
330 ik1_temp=ik1;
331 ik2_temp=ik2;
332
333 ncount1 = 1;
334
335 }
336 }
337 }
338 }
339 }
340
341 if(ncount1 == 1){
342 tagmode=22;
343 if(m_chargetag<0) tagmode=-22;
344 tagmd=tagmode;
345 mass_bc = mass_bcgg;
346 delE_tag = delE_tag_temp;
347 cqtm = 0.0;
348
349 iGoodtag.push_back(ipi1_temp);
350 iGoodtag.push_back(ipi2_temp);
351 iGoodtag.push_back(ik1_temp);
352 iGoodtag.push_back(ik2_temp);
353
354 iGamtag.push_back(9999);
355 iGamtag.push_back(9999);
356 iGamtag.push_back(9999);
357 iGamtag.push_back(9999);
358
359 ptag = pddd_temp;
360
361 k0kkmd=true;
362 }
363
364}
365
366
367
double cos(const BesAngle a)
Definition BesAngle.h:213
int runNo
double abs(const EvtComplex &c)
EvtRecTrackCol::iterator EvtRecTrackIterator
const double xmass[5]
Definition Gam4pikp.cxx:50
std::vector< int > Vint
Definition K0kk.h:16
const double theta() const
static void setPidType(PidType pidType)
const int charge() const
virtual double probKaon()=0
virtual void preparePID(EvtRecTrack *track)=0
virtual double probPion()=0
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
void MTotal(double event, SmartDataPtr< EvtRecTrackCol > evtRecTrkCol, Vint iGood, Vint iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
Definition K0kk.cxx:33
K0kk()
Definition K0kk.cxx:26
~K0kk()
Definition K0kk.cxx:29
const HepVector & getZHelix() const
HepVector & getZHelixK()
const HepSymMatrix & getZError() const
HepSymMatrix & getZErrorK()
HepLorentzVector p4par() const
void setPrimaryVertex(const VertexParameter vpar)
double decayLength() const
static SecondVertexFit * instance()
void setVpar(const VertexParameter vpar)
double chisq() const
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition TrackPool.cxx:22
const HepPoint3D & pivot(void) const
returns pivot position.
const HepVector & a(void) const
returns helix parameters.
WTrackParameter wtrk(int n) const
Definition VertexFit.h:78
WTrackParameter wVirtualTrack(int n) const
Definition VertexFit.h:91
void init()
Definition VertexFit.cxx:29
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
Definition VertexFit.cxx:89
static VertexFit * instance()
Definition VertexFit.cxx:15
VertexParameter vpar(int n) const
Definition VertexFit.h:88
void BuildVirtualParticle(int number)
void Swim(int n)
Definition VertexFit.h:58
bool Fit()
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
HepVector w() const
const double ecms
Definition inclkstar.cxx:42
_EXTERN_ std::string EvtRecEvent
Definition EventModel.h:134