33 Vint iGam,
double Ebeam,
int PID_flag,
int Charge_candidate_D ) {
35 int nGood = iGood.size();
36 int nGam = iGam.size();
41 double mass_bcgg, delE_tag_temp;
42 int m_chargetag, m_chargepi1, m_chargepi2;
43 int ika_temp, ipi1_temp, ipi2_temp, ipi3_temp, iGam1_temp, iGam2_temp;
44 HepLorentzVector pddd;
45 HepLorentzVector pddd_temp;
47 IDataProviderSvc* eventSvc = NULL;
48 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc );
50 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc,
"/Event/EventHeader" );
52 int runNo = eventHeader->runNumber();
53 int rec = eventHeader->eventNumber();
55 double xecm = 2 * Ebeam;
60 if ( ( evtRecEvent->totalCharged() < 2 || nGam < 2 ) ) {
return; }
65 Gaudi::svcLocator()->service(
"SimplePIDSvc", simple_pid );
67 double deltaE_tem = 0.20;
70 Hep3Vector xorigin( 0, 0, 0 );
71 HepSymMatrix xoriginEx( 3, 0 );
73 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc );
78 xorigin.setX( dbv[0] );
79 xorigin.setY( dbv[1] );
80 xorigin.setZ( dbv[2] );
82 xoriginEx[0][0] = vv[0] * vv[0];
83 xoriginEx[1][1] = vv[1] * vv[1];
84 xoriginEx[2][2] = vv[2] * vv[2];
87 double xv = xorigin.x();
88 double yv = xorigin.y();
89 double zv = xorigin.z();
91 HepPoint3D point0( 0., 0., 0. );
92 HepPoint3D IP( xorigin[0], xorigin[1], xorigin[2] );
94 HepLorentzVector p2gfit;
95 HepLorentzVector p2gg;
97 for (
int i = 0; i < evtRecEvent->totalCharged(); i++ )
101 int ipi1 = ( *itTrk )->trackId();
103 if ( !( *itTrk )->isMdcKalTrackValid() )
continue;
107 m_chargepi1 = mdcKalTrk1->
charge();
108 if ( m_chargepi1 != 1 )
continue;
112 HepSymMatrix Ea1 = mdcKalTrk1->
getZError();
114 VFHelix helixip3_1( point0, a1, Ea1 );
115 helixip3_1.
pivot( IP );
116 HepVector vecipa1 = helixip3_1.
a();
118 double dr1 = fabs( vecipa1[0] );
119 double dz1 = fabs( vecipa1[3] );
120 double costheta1 =
cos( mdcKalTrk1->
theta() );
122 if ( dr1 >= 15.0 )
continue;
123 if ( dz1 >= 25.0 )
continue;
124 if ( fabs( costheta1 ) >= 0.93 )
continue;
131 for (
int j = 0; j < evtRecEvent->totalCharged(); j++ )
135 int ipi2 = ( *itTrk )->trackId();
136 if ( ipi1 == ipi2 )
continue;
138 if ( !( *itTrk )->isMdcKalTrackValid() )
continue;
142 m_chargepi2 = mdcKalTrk2->
charge();
143 if ( ( m_chargepi1 + m_chargepi2 ) != 0 )
continue;
147 HepSymMatrix Ea2 = mdcKalTrk2->
getZError();
148 VFHelix helixip3_2( point0, a2, Ea2 );
149 helixip3_2.
pivot( IP );
150 HepVector vecipa2 = helixip3_2.
a();
152 double dr2 = fabs( vecipa2[0] );
153 double dz2 = fabs( vecipa2[3] );
154 double costheta2 =
cos( mdcKalTrk2->
theta() );
155 if ( dr2 >= 15.0 )
continue;
156 if ( dz2 >= 25.0 )
continue;
157 if ( fabs( costheta2 ) >= 0.93 )
continue;
161 HepVector pip_val = HepVector( 7, 0 );
162 HepVector pim_val = HepVector( 7, 0 );
165 HepLorentzVector ptrktagk0( pip_val[0] + pim_val[0], pip_val[1] + pim_val[1],
166 pip_val[2] + pim_val[2], pip_val[3] + pim_val[3] );
167 double m_xmtagk0_tem = ptrktagk0.mag();
168 if ( fabs( ptrktagk0.m() - 0.498 ) > 0.1 )
continue;
170 HepPoint3D vx( xorigin.x(), xorigin.y(), xorigin.z() );
171 HepSymMatrix Evx( 3, 0 );
187 if ( !( vtxfit0->
Fit( 0 ) ) )
continue;
197 vxpar.
setEvx( xoriginEx );
201 if ( !vtxfit->
Fit() )
continue;
203 if ( vtxfit->
chisq() > 999. )
continue;
206 double m_massks1_tem = vtxfit->
p4par().m();
207 if ( m_massks1_tem < 0.485 || m_massks1_tem > 0.515 )
continue;
208 HepLorentzVector p4kstag = vtxfit->
p4par();
209 p4kstag.boost( -0.011, 0, 0 );
212 for (
int m = 0; m < nGam - 1; m++ )
214 if ( iGam[m] == -1 )
continue;
215 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + iGam[m] ) )->emcShower();
216 double eraw1 = g1Trk->
energy();
218 double the1 = g1Trk->
theta();
219 HepLorentzVector ptrkg1, ptrkg10, ptrkg12;
220 ptrkg1.setPx( eraw1 *
sin( the1 ) *
cos(
phi1 ) );
221 ptrkg1.setPy( eraw1 *
sin( the1 ) *
sin(
phi1 ) );
222 ptrkg1.setPz( eraw1 *
cos( the1 ) );
223 ptrkg1.setE( eraw1 );
225 ptrkg12 = ptrkg1.boost( -0.011, 0, 0 );
227 for (
int n = m + 1;
n < nGam;
n++ )
229 if ( iGam[
n] == -1 )
continue;
230 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + iGam[
n] ) )->emcShower();
231 double eraw2 = g2Trk->
energy();
233 double the2 = g2Trk->
theta();
234 HepLorentzVector ptrkg2, ptrkg20, ptrkg22;
235 ptrkg2.setPx( eraw2 *
sin( the2 ) *
cos(
phi2 ) );
236 ptrkg2.setPy( eraw2 *
sin( the2 ) *
sin(
phi2 ) );
237 ptrkg2.setPz( eraw2 *
cos( the2 ) );
238 ptrkg2.setE( eraw2 );
240 ptrkg22 = ptrkg2.boost( -0.011, 0, 0 );
243 HepLorentzVector ptrkpi0;
244 ptrkpi0 = ptrkg12 + ptrkg22;
245 double m_xmpi0_tem = ptrkpi0.m();
246 if ( m_xmpi0_tem > 0.150 || m_xmpi0_tem < 0.115 )
continue;
248 bool IsEndcap1 =
false;
249 bool IsEndcap2 =
false;
250 if ( fabs(
cos( the1 ) ) > 0.86 && fabs(
cos( the1 ) ) < 0.92 ) IsEndcap1 =
true;
251 if ( fabs(
cos( the2 ) ) > 0.86 && fabs(
cos( the2 ) ) < 0.92 ) IsEndcap2 =
true;
252 if ( IsEndcap1 && IsEndcap2 )
continue;
264 double pi0_chisq = kmfit->
chisq( 0 );
265 if ( pi0_chisq >= 2500 )
continue;
266 HepLorentzVector p2gfit = kmfit->
pfit( 0 ) + kmfit->
pfit( 1 );
267 p2gfit.boost( -0.011, 0, 0 );
270 HepVector ksp_val = HepVector( 7, 0 );
271 HepVector ksm_val = HepVector( 7, 0 );
275 HepLorentzVector P_KSP( ksp_val[0], ksp_val[1], ksp_val[2], ksp_val[3] );
276 HepLorentzVector P_KSM( ksm_val[0], ksm_val[1], ksm_val[2], ksm_val[3] );
278 P_KSP.boost( -0.011, 0, 0 );
279 P_KSM.boost( -0.011, 0, 0 );
280 pddd = p4kstag + p2gfit;
282 double pk0pi0 = pddd.rho();
284 double temp1 = (
ecms / 2 ) * (
ecms / 2 ) - pk0pi0 * pk0pi0;
285 if ( temp1 < 0 ) temp1 = 0;
286 double mass_bc_tem = sqrt( temp1 );
287 if ( mass_bc_tem < 1.82 || mass_bc_tem > 1.89 )
continue;
289 double delE_tag_tag =
ecms / 2 - pddd.e();
291 if ( fabs( delE_tag_tag ) < deltaE_tem )
293 deltaE_tem = fabs( delE_tag_tag );
294 delE_tag_temp = delE_tag_tag;
295 mass_bcgg = mass_bc_tem;
302 iGam1_temp = iGam[m];
303 iGam2_temp = iGam[
n];
315 if ( m_chargetag < 0 ) tagmode = -18;
318 delE_tag = delE_tag_temp;
321 iGoodtag.push_back( ipi1_temp );
322 iGoodtag.push_back( ipi2_temp );
323 iGamtag.push_back( iGam1_temp );
324 iGamtag.push_back( iGam2_temp );
325 iGamtag.push_back( 9999 );
326 iGamtag.push_back( 9999 );