CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
K3pi.cxx
Go to the documentation of this file.
1//
2// K3pi.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meon through the final states of
3// K3pi from D0 decays. K3pi.cxx was transfered from the Fortran routine "K3pi.f" which
4// 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 "K3pi.f" used at the BES-II experiment was coded by G. Rong in 2002.
8//
9// K3pi.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/K3pi.h"
24#include "SD0TagAlg/SingleBase.h"
25
27{}
28
30{}
31
32
33void K3pi::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;
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 k3pimd=false;
60 double tagmode=0;
61
62 if((evtRecEvent->totalCharged() < 4)){ 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 Hep3Vector xorigin(0,0,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
84 double xv=xorigin.x();
85 double yv=xorigin.y();
86 double zv=xorigin.z();
87
88 HepPoint3D point0(0.,0.,0.);
89 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
90
91 HepLorentzVector ptrk1_temp, ptrk2_temp, ptrk3_temp, ptrk4_temp;
92 //////////////////////////////////////////////////////////////////
93 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
94 EvtRecTrackIterator itTrk1 = evtRecTrkCol->begin() + i;
95
96 int ika= (*itTrk1)->trackId();
97
98 if(!(*itTrk1)->isMdcKalTrackValid()) continue;
99 RecMdcKalTrack* mdcKalTrk1 = (*itTrk1)->mdcKalTrack();
101 /////////////////////////////////////////
102 m_chargek=mdcKalTrk1->charge();
103 if(Charge_candidate_D != 0) {
104 if(m_chargek != -Charge_candidate_D) continue;
105 }
106 if(Charge_candidate_D == 0) {
107 if(abs(m_chargek) != 1) continue;
108 }
109 /////////////////////////////////////////
110 HepVector a1 = mdcKalTrk1->getZHelixK();
111 HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
112
113 VFHelix helixip3_1(point0,a1,Ea1);
114 helixip3_1.pivot(IP);
115 HepVector vecipa1 = helixip3_1.a();
116
117 double dr1 = fabs(vecipa1[0]);
118 double dz1 = fabs(vecipa1[3]);
119 double costheta1 = cos(mdcKalTrk1->theta());
120
121 if ( dr1 >= 1.0) continue;
122 if ( dz1 >= 10.0) continue;
123 if ( fabs(costheta1) >= 0.93) continue;
124 /////////////////////////////////////////
125 if(PID_flag == 5) {
126 simple_pid->preparePID(*itTrk1);
127 if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;
128 }
129 /////////////////////////////////////////
130 WTrackParameter kam(xmass[3],mdcKalTrk1->getZHelixK(),mdcKalTrk1->getZErrorK() );
131
132 //
133 // select pi1
134 //
135 for(int j = 0; j< evtRecEvent->totalCharged();j++) {
136 EvtRecTrackIterator itTrk2 = evtRecTrkCol->begin() + j;
137
138 int ipi1= (*itTrk2)->trackId();
139 if(ipi1==ika) continue;
140
141 if(!(*itTrk2)->isMdcKalTrackValid()) continue;
142 RecMdcKalTrack* mdcKalTrk2 = (*itTrk2)->mdcKalTrack();
144 /////////////////////////////////////////
145 m_chargepi1=mdcKalTrk2->charge();
146 if((m_chargek + m_chargepi1) != 0) continue;
147 /////////////////////////////////////////
148 HepVector a2 = mdcKalTrk2->getZHelix();
149 HepSymMatrix Ea2 = mdcKalTrk2->getZError();
150 VFHelix helixip3_2(point0,a2,Ea2);
151 helixip3_2.pivot(IP);
152 HepVector vecipa2 = helixip3_2.a();
153
154 double dr2 = fabs(vecipa2[0]);
155 double dz2 = fabs(vecipa2[3]);
156 double costheta2 = cos(mdcKalTrk2->theta());
157 if ( dr2 >= 1.0) continue;
158 if ( dz2 >= 10.0) continue;
159 if ( fabs(costheta2) >= 0.93) continue;
160 /////////////////////////////////////////
161 if(PID_flag == 5) {
162 simple_pid->preparePID(*itTrk2);
163 if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;
164 }
165 /////////////////////////////////////////
166 WTrackParameter pip1(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
167
168 //
169 //select pi2
170 //
171 for(int k = 0; k< evtRecEvent->totalCharged(); k++) {
172 EvtRecTrackIterator itTrk3 = evtRecTrkCol->begin() + k;
173
174 int ipi2= (*itTrk3)->trackId();
175 if(ipi2==ika || ipi2==ipi1) continue;
176
177 if(!(*itTrk3)->isMdcKalTrackValid()) continue;
178 RecMdcKalTrack* mdcKalTrk3 = (*itTrk3)->mdcKalTrack();
180 /////////////////////////////////////////
181 m_chargepi2=mdcKalTrk3->charge();
182 if((m_chargek + m_chargepi2) != 0) continue;
183 /////////////////////////////////////////
184 HepVector a3 = mdcKalTrk3->getZHelix();
185 HepSymMatrix Ea3 = mdcKalTrk3->getZError();
186 VFHelix helixip3_3(point0,a3,Ea3);
187 helixip3_3.pivot(IP);
188 HepVector vecipa3 = helixip3_3.a();
189
190 double dr3 = fabs(vecipa3[0]);
191 double dz3 = fabs(vecipa3[3]);
192 double costheta3 = cos(mdcKalTrk3->theta());
193 if ( dr3 >= 1.0) continue;
194 if ( dz3 >= 10.0) continue;
195 if ( fabs(costheta3) >= 0.93) continue;
196 /////////////////////////////////////////
197 if(PID_flag == 5) {
198 simple_pid->preparePID(*itTrk3);
199 if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;
200 }
201 /////////////////////////////////////////
202 WTrackParameter pip2(xmass[2],mdcKalTrk3->getZHelix(),mdcKalTrk3->getZError() );
203
204 //
205 // select pi3
206 //
207 for(int l = 0; l< evtRecEvent->totalCharged(); l++) {
208 EvtRecTrackIterator itTrk4 = evtRecTrkCol->begin() + l;
209
210 int ipi3= (*itTrk4)->trackId();
211 if(ipi3==ika || ipi3==ipi1 || ipi3==ipi2 ) continue;
212
213 if(!(*itTrk4)->isMdcKalTrackValid()) continue;
214 RecMdcKalTrack* mdcKalTrk4 = (*itTrk4)->mdcKalTrack();
216 /////////////////////////////////////////
217 m_chargepi3=mdcKalTrk4->charge();
218 if((m_chargepi2 + m_chargepi3) != 0) continue;
219 /////////////////////////////////////////
220 HepVector a4 = mdcKalTrk4->getZHelix();
221 HepSymMatrix Ea4 = mdcKalTrk4->getZError();
222 VFHelix helixip3_4(point0,a4,Ea4);
223 helixip3_4.pivot(IP);
224 HepVector vecipa4 = helixip3_4.a();
225
226 double dr4 = fabs(vecipa4[0]);
227 double dz4 = fabs(vecipa4[3]);
228 double costheta4 = cos(mdcKalTrk4->theta());
229 if ( dr4 >= 1.0) continue;
230 if ( dz4 >= 10.0) continue;
231 if ( fabs(costheta4) >= 0.93) continue;
232 /////////////////////////////////////////
233 if(PID_flag == 5) {
234 simple_pid->preparePID(*itTrk4);
235 if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;
236 }
237 /////////////////////////////////////////
238 WTrackParameter pip3(xmass[2],mdcKalTrk4->getZHelix(),mdcKalTrk4->getZError() );
239
240 //////////////////////////////////////////////////////////////
241 HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
242 HepSymMatrix Evx(3, 0);
243 double bx = 1E+6; Evx[0][0] = bx*bx;
244 double by = 1E+6; Evx[1][1] = by*by;
245 double bz = 1E+6; Evx[2][2] = bz*bz;
246 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
247 //////////////////////////////////////////////////////////////
248
249 VertexFit* vtxfit = VertexFit::instance();
250 vtxfit->init();
251 vtxfit->AddTrack(0, kam);
252 vtxfit->AddTrack(1, pip1);
253 vtxfit->AddTrack(2, pip2);
254 vtxfit->AddTrack(3, pip3);
255 vtxfit->AddVertex(0, vxpar, 0, 1, 2, 3);
256 if(!vtxfit->Fit(0)) continue;
257 vtxfit->Swim(0);
258
259 WTrackParameter wkam = vtxfit->wtrk(0);
260 WTrackParameter wpip1 = vtxfit->wtrk(1);
261 WTrackParameter wpip2 = vtxfit->wtrk(2);
262 WTrackParameter wpip3 = vtxfit->wtrk(3);
263
264 HepVector kam_val = HepVector(7,0);
265 HepVector pip1_val = HepVector(7,0);
266 HepVector pip2_val = HepVector(7,0);
267 HepVector pip3_val = HepVector(7,0);
268 kam_val = wkam.w();
269 pip1_val = wpip1.w();
270 pip2_val = wpip2.w();
271 pip3_val = wpip3.w();
272
273 HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
274 HepLorentzVector P_PIP1(pip1_val[0],pip1_val[1],pip1_val[2],pip1_val[3]);
275 HepLorentzVector P_PIP2(pip2_val[0],pip2_val[1],pip2_val[2],pip2_val[3]);
276 HepLorentzVector P_PIP3(pip3_val[0],pip3_val[1],pip3_val[2],pip3_val[3]);
277
278 P_KAM.boost(-0.011,0,0);
279 P_PIP1.boost(-0.011,0,0);
280 P_PIP2.boost(-0.011,0,0);
281 P_PIP3.boost(-0.011,0,0);
282 pddd = P_KAM + P_PIP1 + P_PIP2 + P_PIP3;
283
284 double pk3pi=pddd.rho();
285
286 double temp1 = (ecms/2)*(ecms/2)-pk3pi*pk3pi ;
287 if(temp1<0) temp1 =0;
288 double mass_bc_tem = sqrt(temp1);
289 if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
290
291 double delE_tag_tag = ecms/2-pddd.e();
292
293 if(fabs(delE_tag_tag)<deltaE_tem) {
294 deltaE_tem = fabs(delE_tag_tag);
295 delE_tag_temp = delE_tag_tag;
296 mass_bcgg = mass_bc_tem;
297
298 pddd_temp = pddd;
299 cqtm_temp = m_chargek;
300
301 ika_temp=ika;
302 ipi1_temp=ipi1;
303 ipi2_temp=ipi2;
304 ipi3_temp=ipi3;
305 ncount1 = 1;
306
307 }
308 }
309 }
310 }
311 }
312
313 if(ncount1 == 1){
314 tagmode=13;
315 if(cqtm_temp<0) tagmode=-13;
316 tagmd=tagmode;
317 mass_bc = mass_bcgg;
318 delE_tag = delE_tag_temp;
319 cqtm = -1.0*cqtm_temp;
320
321 iGoodtag.push_back(ika_temp);
322 iGoodtag.push_back(ipi1_temp);
323 iGoodtag.push_back(ipi2_temp);
324 iGoodtag.push_back(ipi3_temp);
325
326 iGamtag.push_back(9999);
327 iGamtag.push_back(9999);
328 iGamtag.push_back(9999);
329 iGamtag.push_back(9999);
330
331 ptag = pddd_temp;
332
333 k3pimd=true;
334
335 }
336}
337
int runNo
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
const double xmass[5]
Definition: Gam4pikp.cxx:50
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: K3pi.cxx:33
K3pi()
Definition: K3pi.cxx:26
~K3pi()
Definition: K3pi.cxx:29
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