BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
K0pipipi0.cxx
Go to the documentation of this file.
1//
2// K0pipipi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meson through the final states of
3// K0pipipi0 from D0 decays. K0pipipi0.cxx was transfered from the Fortran routine "K0pipipi0.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 "K0pipipi0.f" used at the BES-II experiment was coded by G. Rong in 2002.
8//
9// K0pipipi0.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/K0pipipi0.h"
24#include "SD0TagAlg/SingleBase.h"
25
26
28{}
29
31{}
32
33
34void K0pipipi0::MTotal(double event,SmartDataPtr<EvtRecTrackCol> evtRecTrkCol, Vint iGood,Vint
35 iGam,double Ebeam, int PID_flag, int Charge_candidate_D)
36{
37
38 int nGood=iGood.size();
39 int nGam=iGam.size();
40
41 iGoodtag.clear();
42 iGamtag.clear();
43
44 double mass_bcgg, delE_tag_temp;
45 int m_chargetag,m_chargepi1,m_chargepi2,m_chargepi3,m_chargepi4;
46 int ik1_temp,ipi1_temp,ipi2_temp,ipi3_temp,ipi4_temp, iGam1_temp, iGam2_temp;
47 HepLorentzVector pddd;
48 HepLorentzVector pddd_temp;
49
50 IDataProviderSvc* eventSvc = NULL;
51 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
52 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc,EventModel::EvtRec::EvtRecEvent);
53 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
54
55 int runNo=eventHeader->runNumber();
56 int rec=eventHeader->eventNumber();
57
58 double xecm=2*Ebeam;
59
60 k0pipipi0md=false;
61 double tagmode=0;
62
63 if((evtRecEvent->totalCharged() < 4||nGam<2)){ return; }
64
65 double ecms = xecm;
66
67 ISimplePIDSvc* simple_pid;
68 Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
69
70 double deltaE_tem = 0.20;
71 int ncount1 = 0;
72
73 Hep3Vector xorigin(0,0,0);
74 HepSymMatrix xoriginEx(3,0);
75 IVertexDbSvc* vtxsvc;
76 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
77 if(vtxsvc->isVertexValid())
78 {
79 double* dbv = vtxsvc->PrimaryVertex();
80 double* vv = vtxsvc->SigmaPrimaryVertex();
81 xorigin.setX(dbv[0]);
82 xorigin.setY(dbv[1]);
83 xorigin.setZ(dbv[2]);
84
85 xoriginEx[0][0] = vv[0] * vv[0];
86 xoriginEx[1][1] = vv[1] * vv[1];
87 xoriginEx[2][2] = vv[2] * vv[2];
88
89 }
90
91 double xv=xorigin.x();
92 double yv=xorigin.y();
93 double zv=xorigin.z();
94
95 HepPoint3D point0(0.,0.,0.);
96 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
97 //////////////////////////////////////////////////////////////////
98
99 HepLorentzVector p2gfit;
100 HepLorentzVector p2gg;
101
102 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
103 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
104
105 int ipi1= (*itTrk)->trackId();
106
107 if(!(*itTrk)->isMdcKalTrackValid()) continue;
108 RecMdcKalTrack* mdcKalTrk1 = (*itTrk)->mdcKalTrack();
110
111 m_chargepi1=mdcKalTrk1->charge();
112 if(m_chargepi1 != 1) continue;
113
114 /////////////////////////////////////////
115 HepVector a1 = mdcKalTrk1->getZHelix();
116 HepSymMatrix Ea1 = mdcKalTrk1->getZError();
117
118 VFHelix helixip3_1(point0,a1,Ea1);
119 helixip3_1.pivot(IP);
120 HepVector vecipa1 = helixip3_1.a();
121
122 double dr1 = fabs(vecipa1[0]);
123 double dz1 = fabs(vecipa1[3]);
124 double costheta1 = cos(mdcKalTrk1->theta());
125
126 if ( dr1 >= 15.0) continue;
127 if ( dz1 >= 25.0) continue;
128 if ( fabs(costheta1) >= 0.93) continue;
129 /////////////////////////////////////////
130 WTrackParameter pip1(xmass[2],mdcKalTrk1->getZHelix(),mdcKalTrk1->getZError() );
131
132 //
133 // select pi2
134 //
135
136 for(int j = 0; j < evtRecEvent->totalCharged();j++) {
137 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
138
139 int ipi2= (*itTrk)->trackId();
140 if(ipi1==ipi2) continue;
141
142 if(!(*itTrk)->isMdcKalTrackValid()) continue;
143 RecMdcKalTrack* mdcKalTrk2 = (*itTrk)->mdcKalTrack();
145
146 m_chargepi2=mdcKalTrk2->charge();
147 if((m_chargepi2 + m_chargepi1) != 0) continue;
148
149 /////////////////////////////////////////
150 HepVector a2 = mdcKalTrk2->getZHelix();
151 HepSymMatrix Ea2 = mdcKalTrk2->getZError();
152 VFHelix helixip3_2(point0,a2,Ea2);
153 helixip3_2.pivot(IP);
154 HepVector vecipa2 = helixip3_2.a();
155
156 double dr2 = fabs(vecipa2[0]);
157 double dz2 = fabs(vecipa2[3]);
158 double costheta2 = cos(mdcKalTrk2->theta());
159 if ( dr2 >= 15.0) continue;
160 if ( dz2 >= 25.0) continue;
161 if ( fabs(costheta2) >= 0.93) continue;
162 /////////////////////////////////////////
163 WTrackParameter pim1(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
164
165
166 HepVector pip1_val = HepVector(7,0);
167 HepVector pim1_val = HepVector(7,0);
168 pip1_val = pip1.w();
169 pim1_val = pim1.w();
170 HepLorentzVector ptrktagk0(pip1_val[0]+pim1_val[0],pip1_val[1]+pim1_val[1],pip1_val[2]+pim1_val[2],pip1_val[3]+pim1_val[3]);
171 double m_xmtagk0_tem = ptrktagk0.mag();
172 if(fabs(ptrktagk0.m()-0.498)>0.1) continue;
173
174 HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
175 HepSymMatrix Evx(3, 0);
176 double bx = 1E+6; Evx[0][0] = bx*bx;
177 double by = 1E+6; Evx[1][1] = by*by;
178 double bz = 1E+6; Evx[2][2] = bz*bz;
179 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
180
181
182 VertexFit *vtxfit0 = VertexFit::instance();
183 vtxfit0->init();
184 vtxfit0->AddTrack(0, pip1);
185 vtxfit0->AddTrack(1, pim1);
186 vtxfit0->AddVertex(0, vxpar, 0, 1);
187 if(!(vtxfit0->Fit(0))) continue;
188 vtxfit0->Swim(0);
189 vtxfit0->BuildVirtualParticle(0);
190 WTrackParameter wksp = vtxfit0->wtrk(0);
191 WTrackParameter wksm = vtxfit0->wtrk(1);
192 WTrackParameter wks_Trk = vtxfit0->wVirtualTrack(0);
193 VertexParameter wks_var = vtxfit0->vpar(0);
194
195 //
196 //select pi3
197 //
198 for(int k = 0; k < evtRecEvent->totalCharged(); k++) {
199 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + k;
200
201 int ipi3= (*itTrk)->trackId();
202 if(ipi2==ipi3 || ipi1==ipi3) continue;
203
204 if(!(*itTrk)->isMdcKalTrackValid()) continue;
205 RecMdcKalTrack* mdcKalTrk3 = (*itTrk)->mdcKalTrack();
207
208 m_chargepi3=mdcKalTrk3->charge();
209 if(abs(m_chargepi3) != 1) continue;
210
211 /////////////////////////////////////////
212 HepVector a3 = mdcKalTrk3->getZHelix();
213 HepSymMatrix Ea3 = mdcKalTrk3->getZError();
214 VFHelix helixip3_3(point0,a3,Ea3);
215 helixip3_3.pivot(IP);
216 HepVector vecipa3 = helixip3_3.a();
217
218 double dr3 = fabs(vecipa3[0]);
219 double dz3 = fabs(vecipa3[3]);
220 double costheta3 = cos(mdcKalTrk3->theta());
221 if ( dr3 >= 1.0) continue;
222 if ( dz3 >= 10.0) continue;
223 if ( fabs(costheta3) >= 0.93) continue;
224 /////////////////////////////////////////
225 if(PID_flag == 5) {
226 simple_pid->preparePID(*itTrk);
227 if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;
228 }
229 /////////////////////////////////////////
230 WTrackParameter pip2(xmass[2],mdcKalTrk3->getZHelix(),mdcKalTrk3->getZError() );
231
232 //
233 //select pi4
234 //
235 for(int l = 0; l < evtRecEvent->totalCharged(); l++) {
236 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + l;
237
238 int ipi4= (*itTrk)->trackId();
239 if(ipi4==ipi3 || ipi4==ipi2 || ipi4 ==ipi1) continue;
240
241 if(!(*itTrk)->isMdcKalTrackValid()) continue;
242 RecMdcKalTrack* mdcKalTrk4 = (*itTrk)->mdcKalTrack();
244
245 m_chargepi4=mdcKalTrk4->charge();
246 if((m_chargepi4 + m_chargepi3) != 0) continue;
247
248 /////////////////////////////////////////
249 HepVector a4 = mdcKalTrk4->getZHelix();
250 HepSymMatrix Ea4 = mdcKalTrk4->getZError();
251 VFHelix helixip3_4(point0,a4,Ea4);
252 helixip3_4.pivot(IP);
253 HepVector vecipa4 = helixip3_4.a();
254
255 double dr4 = fabs(vecipa4[0]);
256 double dz4 = fabs(vecipa4[3]);
257 double costheta4 = cos(mdcKalTrk4->theta());
258 if ( dr4 >= 1.0) continue;
259 if ( dz4 >= 10.0) continue;
260 if ( fabs(costheta4) >= 0.93) continue;
261 /////////////////////////////////////////
262 if(PID_flag == 5) {
263 simple_pid->preparePID(*itTrk);
264 if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;
265 }
266 /////////////////////////////////////////
267 WTrackParameter pim2(xmass[2],mdcKalTrk4->getZHelix(),mdcKalTrk4->getZError() );
268
269 for(int m = 0; m < nGam-1; m++) {
270 if(iGam[m]==-1) continue;
271 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[m]))->emcShower();
272 double eraw1 = g1Trk->energy();
273 double phi1 = g1Trk->phi();
274 double the1 = g1Trk->theta();
275 HepLorentzVector ptrkg1,ptrkg10,ptrkg12;
276 ptrkg1.setPx(eraw1*sin(the1)*cos(phi1));
277 ptrkg1.setPy(eraw1*sin(the1)*sin(phi1));
278 ptrkg1.setPz(eraw1*cos(the1));
279 ptrkg1.setE(eraw1);
280 ptrkg10 = ptrkg1;
281 ptrkg12 = ptrkg1.boost(-0.011,0,0);
282
283 for(int n = m+1; n < nGam; n++) {
284 if(iGam[n]==-1) continue;
285 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[n]))->emcShower();
286 double eraw2 = g2Trk->energy();
287 double phi2 = g2Trk->phi();
288 double the2 = g2Trk->theta();
289 HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
290 ptrkg2.setPx(eraw2*sin(the2)*cos(phi2));
291 ptrkg2.setPy(eraw2*sin(the2)*sin(phi2));
292 ptrkg2.setPz(eraw2*cos(the2));
293 ptrkg2.setE(eraw2);
294 ptrkg20 = ptrkg2;
295 ptrkg22 = ptrkg2.boost(-0.011,0,0);
296
297 /////////////////////////////////////////////////////////////
298 HepLorentzVector ptrkpi0;
299 ptrkpi0 = ptrkg12+ptrkg22;
300 double m_xmpi0_tem = ptrkpi0.m();
301 if(m_xmpi0_tem>0.150||m_xmpi0_tem<0.115) continue;
302 /////////////////////////////////////////////////////////////
303 bool IsEndcap1 = false; bool IsEndcap2 = false;
304 if(fabs(cos(the1)) > 0.86 && fabs(cos(the1)) < 0.92) IsEndcap1 = true;
305 if(fabs(cos(the2)) > 0.86 && fabs(cos(the2)) < 0.92) IsEndcap2 = true;
306 if(IsEndcap1 && IsEndcap2) continue;
307 /////////////////////////////////////////////////////////////
309 kmfit->init();
310 kmfit->setChisqCut(2500);
311 kmfit->AddTrack(0, 0.0, g1Trk);
312 kmfit->AddTrack(1, 0.0, g2Trk);
313 kmfit->AddResonance(0, mpi0, 0, 1);
314
315 kmfit->Fit(0); // Perform fit
316 kmfit->BuildVirtualParticle(0);
317
318 double pi0_chisq = kmfit->chisq(0);
319 if ( pi0_chisq >= 2500) continue;
320 HepLorentzVector p2gfit = kmfit->pfit(0) + kmfit->pfit(1);
321 p2gfit.boost(-0.011,0,0);
322 /////////////////////////////////////////////////////////////
323
324 VertexFit* vtxfit_2 = VertexFit::instance();
325 vtxfit_2->init();
326 vtxfit_2->AddTrack(0, pip2);
327 vtxfit_2->AddTrack(1, pim2);
328 vtxfit_2->AddVertex(0, vxpar, 0, 1);
329 if(!vtxfit_2->Fit(0)) continue;
330 vtxfit_2->Swim(0);
331
332 WTrackParameter wpip2 = vtxfit_2->wtrk(0);
333 WTrackParameter wpim2 = vtxfit_2->wtrk(1);
334
336 vtxfit->init();
337 vxpar.setEvx(xoriginEx);
338 vtxfit->setPrimaryVertex(vxpar);
339 vtxfit->AddTrack(0, wks_Trk);
340 vtxfit->setVpar(wks_var);
341 if(!vtxfit->Fit()) continue;
342
343 if(vtxfit->chisq() >999.) continue;
344 if(vtxfit->decayLength()<0.0) continue;
345
346 double m_massks1_tem = vtxfit->p4par().m();
347 if(m_massks1_tem < 0.485 || m_massks1_tem > 0.515) continue;
348 HepLorentzVector p4kstag = vtxfit->p4par();
349 WTrackParameter para_ks = vtxfit0->wVirtualTrack(0);
350
351 HepVector pip2_val = HepVector(7,0);
352 HepVector pim2_val = HepVector(7,0);
353 HepVector ksp_val = HepVector(7,0);
354 HepVector ksm_val = HepVector(7,0);
355
356 pip2_val = wpip2.w();
357 pim2_val = wpim2.w();
358 ksp_val = wksp.w();
359 ksm_val = wksm.w();
360
361 HepLorentzVector P_PIP2(pip2_val[0],pip2_val[1],pip2_val[2],pip2_val[3]);
362 HepLorentzVector P_PIM2(pim2_val[0],pim2_val[1],pim2_val[2],pim2_val[3]);
363 HepLorentzVector P_KSP(ksp_val[0],ksp_val[1],ksp_val[2],ksp_val[3]);
364 HepLorentzVector P_KSM(ksm_val[0],ksm_val[1],ksm_val[2],ksm_val[3]);
365
366 p4kstag.boost(-0.011,0,0);
367 P_PIP2.boost(-0.011,0,0);
368 P_PIM2.boost(-0.011,0,0);
369 P_KSP.boost(-0.011,0,0);
370 P_KSM.boost(-0.011,0,0);
371
372 //pddd = P_PIP2 + P_PIM2 + P_KSP + P_KSM + p2gfit;
373 pddd = P_PIP2 + P_PIM2 + p4kstag + p2gfit;
374
375 double pk0pipipi0 = pddd.rho();
376
377 double temp1 = (ecms/2)*(ecms/2)-pk0pipipi0*pk0pipipi0 ;
378 if(temp1<0) temp1 =0;
379 double mass_bc_tem = sqrt(temp1);
380 if(mass_bc_tem <1.82 || mass_bc_tem > 1.89) continue;
381
382 double delE_tag_tag = ecms/2-pddd.e();
383
384 if(fabs(delE_tag_tag)<deltaE_tem) {
385 deltaE_tem = fabs(delE_tag_tag);
386 delE_tag_temp = delE_tag_tag;
387 mass_bcgg = mass_bc_tem;
388
389 pddd_temp = pddd;
390
391 ipi1_temp=ipi1;
392 ipi2_temp=ipi2;
393 ipi3_temp=ipi3;
394 ipi4_temp=ipi4;
395 iGam1_temp = iGam[m];
396 iGam2_temp = iGam[n];
397
398 ncount1 = 1;
399
400 }
401 }
402 }
403 }
404 }
405 }
406 }
407
408
409 if(ncount1 == 1){
410 tagmode=17;
411 if(m_chargetag<0) tagmode=-17;
412 tagmd=tagmode;
413 mass_bc = mass_bcgg;
414 delE_tag = delE_tag_temp;
415 cqtm = 0;
416
417 iGoodtag.push_back(ipi1_temp);
418 iGoodtag.push_back(ipi2_temp);
419 iGoodtag.push_back(ipi3_temp);
420 iGoodtag.push_back(ipi4_temp);
421
422 iGamtag.push_back(iGam1_temp);
423 iGamtag.push_back(iGam2_temp);
424 iGamtag.push_back(9999);
425 iGamtag.push_back(9999);
426
427 ptag = pddd_temp;
428
429 k0pipipi0md = true;
430 }
431
432}
433
434
435
const double mpi0
int runNo
Definition: DQA_TO_DB.cxx:12
const Int_t n
Double_t phi2
Double_t phi1
const double xmass[5]
Definition: Gam4pikp.cxx:50
double sin(const BesAngle a)
double cos(const BesAngle a)
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: K0pipipi0.cxx:34
void setChisqCut(const double chicut=200, const double chiter=0.05)
void BuildVirtualParticle(int number)
void AddResonance(int number, double mres, std::vector< int > tlis)
static KalmanKinematicFit * instance()
static SecondVertexFit * instance()
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.
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
void BuildVirtualParticle(int number)
Definition: VertexFit.cxx:619
bool Fit()
Definition: VertexFit.cxx:301
const double ecms
Definition: inclkstar.cxx:42