33 {
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 );
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
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 );
75 {
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
92 HepPoint3D IP( xorigin[0], xorigin[1], xorigin[2] );
93
94 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
95 {
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
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
124
125
126
127
128 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
129 {
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
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
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;
178
184 if ( !( vtxfit0->
Fit( 0 ) ) )
continue;
187 WTrackParameter wksp = vtxfit0->
wtrk( 0 );
188 WTrackParameter wksm = vtxfit0->
wtrk( 1 );
190 VertexParameter wks_var = vtxfit0->
vpar( 0 );
191
192
193
194 for ( int k = 0; k < evtRecEvent->totalCharged(); k++ )
195 {
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
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 {
225 if ( simple_pid->
probKaon() < 0.0 ||
227 continue;
228 }
229
231
232
233
234
235 for ( int l = 0; l < evtRecEvent->totalCharged(); l++ )
236 {
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
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 {
266 if ( simple_pid->
probPion() < 0.0 ||
268 continue;
269 }
270
272
278 if ( !vtxfit_2->
Fit( 0 ) )
continue;
280
281 WTrackParameter wka = vtxfit_2->
wtrk( 0 );
282 WTrackParameter wpi = vtxfit_2->
wtrk( 1 );
283
286 vxpar.
setEvx( xoriginEx );
290 if ( !vtxfit->
Fit() )
continue;
291
292 if ( vtxfit->
chisq() > 999. )
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();
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
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
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}
HepGeom::Point3D< double > HepPoint3D
EvtRecTrackCol::iterator EvtRecTrackIterator
double cos(const BesAngle a)
const double theta() const
static void setPidType(PidType pidType)
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
const HepVector & getZHelix() const
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)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
WTrackParameter wtrk(int n) const
WTrackParameter wVirtualTrack(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
static VertexFit * instance()
VertexParameter vpar(int n) const
void BuildVirtualParticle(int number)
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
_EXTERN_ std::string EvtRecEvent