33 {
34
35 int nGood = iGood.size();
36 int nGam = iGam.size();
37 iGoodtag.clear();
38 iGamtag.clear();
39
40 double mass_bcgg, delE_tag_temp;
41 int m_chargetag, m_chargek, m_chargepi1, m_chargepi2, m_chargepi3;
42 int ika_temp, ipi1_temp, ipi2_temp, ipi3_temp, ipi4_temp, iGam1_temp, iGam2_temp;
43 HepLorentzVector kmfit1, kmfit2, kmfit3, kmfit4, pddd;
44
45 int cqtm_temp;
46 HepLorentzVector pddd_temp;
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 k3pipi0md = false;
58 double tagmode = 0;
59
60 if ( ( evtRecEvent->totalCharged() < 4 || nGam < 2 ) ) { 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 HepLorentzVector p2gfit;
71 HepLorentzVector p2gg;
72
73 Hep3Vector xorigin( 0, 0, 0 );
74 IVertexDbSvc* vtxsvc;
75 Gaudi::svcLocator()->service( "VertexDbSvc", vtxsvc );
77 {
80 xorigin.setX( dbv[0] );
81 xorigin.setY( dbv[1] );
82 xorigin.setZ( dbv[2] );
83 }
84
85 double xv = xorigin.x();
86 double yv = xorigin.y();
87 double zv = xorigin.z();
88
90 HepPoint3D IP( xorigin[0], xorigin[1], xorigin[2] );
91
92 HepLorentzVector ptrk1_temp, ptrk2_temp, ptrk3_temp, ptrk4_temp, ptrk5_temp, ptrk6_temp,
93 ptrk7_temp;
94
95 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
96 {
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 {
108 if ( m_chargek != -Charge_candidate_D ) continue;
109 }
110 if ( Charge_candidate_D == 0 )
111 {
112 if (
abs( m_chargek ) != 1 )
continue;
113 }
114
117 VFHelix helixip3_1( point0, a1, Ea1 );
118 helixip3_1.pivot( IP );
119 HepVector vecipa1 = helixip3_1.a();
120
121 double dr1 = fabs( vecipa1[0] );
122 double dz1 = fabs( vecipa1[3] );
123 double costheta1 =
cos( mdcKalTrk1->
theta() );
124 if ( dr1 >= 1.0 ) continue;
125 if ( dz1 >= 10.0 ) continue;
126 if ( fabs( costheta1 ) >= 0.93 ) continue;
127
128 if ( PID_flag == 5 )
129 {
132 continue;
133 }
134
135
136
138
139
140
141
142 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
143 {
145
146 int ipi1 = ( *itTrk2 )->trackId();
147 if ( ipi1 == ika ) continue;
148
149 if ( !( *itTrk2 )->isMdcKalTrackValid() ) continue;
150 RecMdcKalTrack* mdcKalTrk2 = ( *itTrk2 )->mdcKalTrack();
152
153 m_chargepi1 = mdcKalTrk2->
charge();
154 if ( ( m_chargek + m_chargepi1 ) != 0 ) continue;
155
157 HepSymMatrix Ea2 = mdcKalTrk2->
getZError();
158 VFHelix helixip3_2( point0, a2, Ea2 );
159 helixip3_2.pivot( IP );
160 HepVector vecipa2 = helixip3_2.a();
161
162 double dr2 = fabs( vecipa2[0] );
163 double dz2 = fabs( vecipa2[3] );
164 double costheta2 =
cos( mdcKalTrk2->
theta() );
165 if ( dr2 >= 1.0 ) continue;
166 if ( dz2 >= 10.0 ) continue;
167 if ( fabs( costheta2 ) >= 0.93 ) continue;
168
169 if ( PID_flag == 5 )
170 {
173 continue;
174 }
175
177
178
179
180
181 for ( int k = 0; k < evtRecEvent->totalCharged(); k++ )
182 {
184
185 int ipi2 = ( *itTrk3 )->trackId();
186 if ( ipi2 == ika || ipi2 == ipi1 ) continue;
187
188 if ( !( *itTrk3 )->isMdcKalTrackValid() ) continue;
189 RecMdcKalTrack* mdcKalTrk3 = ( *itTrk3 )->mdcKalTrack();
191
192 m_chargepi2 = mdcKalTrk3->
charge();
193 if ( ( m_chargek + m_chargepi2 ) != 0 ) continue;
194
196 HepSymMatrix Ea3 = mdcKalTrk3->
getZError();
197 VFHelix helixip3_3( point0, a3, Ea3 );
198 helixip3_3.pivot( IP );
199 HepVector vecipa3 = helixip3_3.a();
200
201 double dr3 = fabs( vecipa3[0] );
202 double dz3 = fabs( vecipa3[3] );
203 double costheta3 =
cos( mdcKalTrk3->
theta() );
204 if ( dr3 >= 1.0 ) continue;
205 if ( dz3 >= 10.0 ) continue;
206 if ( fabs( costheta3 ) >= 0.93 ) continue;
207
208 if ( PID_flag == 5 )
209 {
211 if ( simple_pid->
probPion() < 0.0 ||
213 continue;
214 }
215
217
218
219
220
221 for ( int l = 0; l < evtRecEvent->totalCharged(); l++ )
222 {
224
225 int ipi3 = ( *itTrk4 )->trackId();
226 if ( ipi3 == ika || ipi3 == ipi1 || ipi3 == ipi2 ) continue;
227
228 if ( !( *itTrk4 )->isMdcKalTrackValid() ) continue;
229 RecMdcKalTrack* mdcKalTrk4 = ( *itTrk4 )->mdcKalTrack();
231
232 m_chargepi3 = mdcKalTrk4->
charge();
233 if ( ( m_chargepi2 + m_chargepi3 ) != 0 ) continue;
234
236 HepSymMatrix Ea4 = mdcKalTrk4->
getZError();
237 VFHelix helixip3_4( point0, a4, Ea4 );
238 helixip3_4.pivot( IP );
239 HepVector vecipa4 = helixip3_4.a();
240
241 double dr4 = fabs( vecipa4[0] );
242 double dz4 = fabs( vecipa4[3] );
243 double costheta4 =
cos( mdcKalTrk4->
theta() );
244 if ( dr4 >= 1.0 ) continue;
245 if ( dz4 >= 10.0 ) continue;
246 if ( fabs( costheta4 ) >= 0.93 ) continue;
247
248 if ( PID_flag == 5 )
249 {
251 if ( simple_pid->
probPion() < 0.0 ||
253 continue;
254 }
255
257
258 for ( int m = 0; m < nGam - 1; m++ )
259 {
260 if ( iGam[m] == -1 ) continue;
261 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + iGam[m] ) )->emcShower();
262 double eraw1 = g1Trk->
energy();
264 double the1 = g1Trk->
theta();
265 HepLorentzVector ptrkg1, ptrkg10, ptrkg12;
266 ptrkg1.setPx( eraw1 *
sin( the1 ) *
cos(
phi1 ) );
267 ptrkg1.setPy( eraw1 *
sin( the1 ) *
sin(
phi1 ) );
268 ptrkg1.setPz( eraw1 *
cos( the1 ) );
269 ptrkg1.setE( eraw1 );
270 ptrkg10 = ptrkg1;
271 ptrkg12 = ptrkg1.boost( -0.011, 0, 0 );
272
273 for (
int n = m + 1;
n < nGam;
n++ )
274 {
275 if ( iGam[
n] == -1 )
continue;
276 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + iGam[
n] ) )->emcShower();
277 double eraw2 = g2Trk->
energy();
279 double the2 = g2Trk->
theta();
280 HepLorentzVector ptrkg2, ptrkg20, ptrkg22;
281 ptrkg2.setPx( eraw2 *
sin( the2 ) *
cos(
phi2 ) );
282 ptrkg2.setPy( eraw2 *
sin( the2 ) *
sin(
phi2 ) );
283 ptrkg2.setPz( eraw2 *
cos( the2 ) );
284 ptrkg2.setE( eraw2 );
285 ptrkg20 = ptrkg2;
286 ptrkg22 = ptrkg2.boost( -0.011, 0, 0 );
287
288
289 HepLorentzVector ptrkpi0;
290 ptrkpi0 = ptrkg12 + ptrkg22;
291 double m_xmpi0_tem = ptrkpi0.mag();
292 if ( m_xmpi0_tem > 0.150 || m_xmpi0_tem < 0.115 ) continue;
293
294 bool IsEndcap1 = false;
295 bool IsEndcap2 = false;
296 if ( fabs(
cos( the1 ) ) > 0.86 && fabs(
cos( the1 ) ) < 0.92 ) IsEndcap1 =
true;
297 if ( fabs(
cos( the2 ) ) > 0.86 && fabs(
cos( the2 ) ) < 0.92 ) IsEndcap2 =
true;
298 if ( IsEndcap1 && IsEndcap2 ) continue;
299
300
307
310
311 double pi0_chisq = kmfit->
chisq( 0 );
312 if ( pi0_chisq >= 2500 ) continue;
313 HepLorentzVector p2gfit = kmfit->
pfit( 0 ) + kmfit->
pfit( 1 );
314 p2gfit.boost( -0.011, 0, 0 );
315
316
317 HepPoint3D vx( xorigin.x(), xorigin.y(), xorigin.z() );
318 HepSymMatrix Evx( 3, 0 );
319 double bx = 1E+6;
320 Evx[0][0] = bx * bx;
321 double by = 1E+6;
322 Evx[1][1] = by * by;
323 double bz = 1E+6;
324 Evx[2][2] = bz * bz;
325 VertexParameter vxpar;
328
329
336 vtxfit->
AddVertex( 0, vxpar, 0, 1, 2, 3 );
337 if ( !vtxfit->
Fit( 0 ) )
continue;
339
340 WTrackParameter wkam = vtxfit->
wtrk( 0 );
341 WTrackParameter wpip1 = vtxfit->
wtrk( 1 );
342 WTrackParameter wpip2 = vtxfit->
wtrk( 2 );
343 WTrackParameter wpip3 = vtxfit->
wtrk( 3 );
344
345 HepVector kam_val = HepVector( 7, 0 );
346 HepVector pip1_val = HepVector( 7, 0 );
347 HepVector pip2_val = HepVector( 7, 0 );
348 HepVector pip3_val = HepVector( 7, 0 );
350 pip1_val = wpip1.
w();
351 pip2_val = wpip2.
w();
352 pip3_val = wpip3.
w();
353
354 HepLorentzVector P_KAM( kam_val[0], kam_val[1], kam_val[2], kam_val[3] );
355 HepLorentzVector P_PIP1( pip1_val[0], pip1_val[1], pip1_val[2], pip1_val[3] );
356 HepLorentzVector P_PIP2( pip2_val[0], pip2_val[1], pip2_val[2], pip2_val[3] );
357 HepLorentzVector P_PIP3( pip3_val[0], pip3_val[1], pip3_val[2], pip3_val[3] );
358
359 P_KAM.boost( -0.011, 0, 0 );
360 P_PIP1.boost( -0.011, 0, 0 );
361 P_PIP2.boost( -0.011, 0, 0 );
362 P_PIP3.boost( -0.011, 0, 0 );
363 pddd = P_KAM + P_PIP1 + P_PIP2 + P_PIP3 + p2gfit;
364
365 double pk3pipi0 = pddd.rho();
366
367 double temp1 = (
ecms / 2 ) * (
ecms / 2 ) - pk3pipi0 * pk3pipi0;
368 if ( temp1 < 0 ) temp1 = 0;
369 double mass_bc_tem = sqrt( temp1 );
370 if ( mass_bc_tem < 1.82 || mass_bc_tem > 1.89 ) continue;
371
372 double delE_tag_tag =
ecms / 2 - pddd.e();
373
374 if ( fabs( delE_tag_tag ) < deltaE_tem )
375 {
376 deltaE_tem = fabs( delE_tag_tag );
377 delE_tag_temp = delE_tag_tag;
378 mass_bcgg = mass_bc_tem;
379
380 pddd_temp = pddd;
381 cqtm_temp = m_chargek;
382
383 ika_temp = ika;
384 ipi1_temp = ipi1;
385 ipi2_temp = ipi2;
386 ipi3_temp = ipi3;
387 iGam1_temp = iGam[m];
388 iGam2_temp = iGam[
n];
389
390 ncount1 = 1;
391 }
392 }
393 }
394 }
395 }
396 }
397 }
398 if ( ncount1 == 1 )
399 {
400 tagmode = 24;
401 if ( cqtm_temp < 0 ) tagmode = -24;
402 tagmd = tagmode;
403 mass_bc = mass_bcgg;
404 delE_tag = delE_tag_temp;
405 cqtm = -1.0 * cqtm_temp;
406
407 iGoodtag.push_back( ika_temp );
408 iGoodtag.push_back( ipi1_temp );
409 iGoodtag.push_back( ipi2_temp );
410 iGoodtag.push_back( ipi3_temp );
411
412 iGamtag.push_back( iGam1_temp );
413 iGamtag.push_back( iGam2_temp );
414 iGamtag.push_back( 9999 );
415 iGamtag.push_back( 9999 );
416
417 ptag = pddd_temp;
418
419 k3pipi0md = true;
420 }
421}
HepGeom::Point3D< double > HepPoint3D
EvtRecTrackCol::iterator EvtRecTrackIterator
double sin(const BesAngle a)
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
void setChisqCut(const double chicut=200, const double chiter=0.05)
HepLorentzVector pfit(int n) const
void BuildVirtualParticle(int number)
void AddResonance(int number, double mres, std::vector< int > tlis)
static KalmanKinematicFit * instance()
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
HepSymMatrix & getZErrorK()
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
WTrackParameter wtrk(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
static VertexFit * instance()
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
_EXTERN_ std::string EvtRecEvent