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