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