BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
K0pipipi0.cxx
Go to the documentation of this file.
1//
2// K0pipipi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meson through the
3// final states of K0pipipi0 from D0 decays. K0pipipi0.cxx was transfered from the Fortran
4// routine "K0pipipi0.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 "K0pipipi0.f" used at the BES-II experiment was coded by G.
8// Rong in 2002.
9//
10// K0pipipi0.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/K0pipipi0.h"
27
29
31
32void K0pipipi0::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_chargepi3, m_chargepi4;
43 int ik1_temp, ipi1_temp, ipi2_temp, ipi3_temp, ipi4_temp, iGam1_temp, iGam2_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 k0pipipi0md = false;
58 double tagmode = 0;
59
60 if ( ( evtRecEvent->totalCharged() < 4 || nGam < 2 ) ) { 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
95 HepLorentzVector p2gfit;
96 HepLorentzVector p2gg;
97
98 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
99 {
100 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
101
102 int ipi1 = ( *itTrk )->trackId();
103
104 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
105 RecMdcKalTrack* mdcKalTrk1 = ( *itTrk )->mdcKalTrack();
107
108 m_chargepi1 = mdcKalTrk1->charge();
109 if ( m_chargepi1 != 1 ) continue;
110
111 /////////////////////////////////////////
112 HepVector a1 = mdcKalTrk1->getZHelix();
113 HepSymMatrix Ea1 = mdcKalTrk1->getZError();
114
115 VFHelix helixip3_1( point0, a1, Ea1 );
116 helixip3_1.pivot( IP );
117 HepVector vecipa1 = helixip3_1.a();
118
119 double dr1 = fabs( vecipa1[0] );
120 double dz1 = fabs( vecipa1[3] );
121 double costheta1 = cos( mdcKalTrk1->theta() );
122
123 if ( dr1 >= 15.0 ) continue;
124 if ( dz1 >= 25.0 ) continue;
125 if ( fabs( costheta1 ) >= 0.93 ) continue;
126 /////////////////////////////////////////
127 WTrackParameter pip1( xmass[2], mdcKalTrk1->getZHelix(), mdcKalTrk1->getZError() );
128
129 //
130 // select pi2
131 //
132
133 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
134 {
135 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
136
137 int ipi2 = ( *itTrk )->trackId();
138 if ( ipi1 == ipi2 ) continue;
139
140 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
141 RecMdcKalTrack* mdcKalTrk2 = ( *itTrk )->mdcKalTrack();
143
144 m_chargepi2 = mdcKalTrk2->charge();
145 if ( ( m_chargepi2 + m_chargepi1 ) != 0 ) continue;
146
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 >= 15.0 ) continue;
158 if ( dz2 >= 25.0 ) continue;
159 if ( fabs( costheta2 ) >= 0.93 ) continue;
160 /////////////////////////////////////////
161 WTrackParameter pim1( xmass[2], mdcKalTrk2->getZHelix(), mdcKalTrk2->getZError() );
162
163 HepVector pip1_val = HepVector( 7, 0 );
164 HepVector pim1_val = HepVector( 7, 0 );
165 pip1_val = pip1.w();
166 pim1_val = pim1.w();
167 HepLorentzVector ptrktagk0( pip1_val[0] + pim1_val[0], pip1_val[1] + pim1_val[1],
168 pip1_val[2] + pim1_val[2], pip1_val[3] + pim1_val[3] );
169 double m_xmtagk0_tem = ptrktagk0.mag();
170 if ( fabs( ptrktagk0.m() - 0.498 ) > 0.1 ) continue;
171
172 HepPoint3D vx( xorigin.x(), xorigin.y(), xorigin.z() );
173 HepSymMatrix Evx( 3, 0 );
174 double bx = 1E+6;
175 Evx[0][0] = bx * bx;
176 double by = 1E+6;
177 Evx[1][1] = by * by;
178 double bz = 1E+6;
179 Evx[2][2] = bz * bz;
180 VertexParameter vxpar;
181 vxpar.setVx( vx );
182 vxpar.setEvx( Evx );
183
184 VertexFit* vtxfit0 = VertexFit::instance();
185 vtxfit0->init();
186 vtxfit0->AddTrack( 0, pip1 );
187 vtxfit0->AddTrack( 1, pim1 );
188 vtxfit0->AddVertex( 0, vxpar, 0, 1 );
189 if ( !( vtxfit0->Fit( 0 ) ) ) continue;
190 vtxfit0->Swim( 0 );
191 vtxfit0->BuildVirtualParticle( 0 );
192 WTrackParameter wksp = vtxfit0->wtrk( 0 );
193 WTrackParameter wksm = vtxfit0->wtrk( 1 );
194 WTrackParameter wks_Trk = vtxfit0->wVirtualTrack( 0 );
195 VertexParameter wks_var = vtxfit0->vpar( 0 );
196
197 //
198 // select pi3
199 //
200 for ( int k = 0; k < evtRecEvent->totalCharged(); k++ )
201 {
202 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + k;
203
204 int ipi3 = ( *itTrk )->trackId();
205 if ( ipi2 == ipi3 || ipi1 == ipi3 ) continue;
206
207 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
208 RecMdcKalTrack* mdcKalTrk3 = ( *itTrk )->mdcKalTrack();
210
211 m_chargepi3 = mdcKalTrk3->charge();
212 if ( abs( m_chargepi3 ) != 1 ) continue;
213
214 /////////////////////////////////////////
215 HepVector a3 = mdcKalTrk3->getZHelix();
216 HepSymMatrix Ea3 = mdcKalTrk3->getZError();
217 VFHelix helixip3_3( point0, a3, Ea3 );
218 helixip3_3.pivot( IP );
219 HepVector vecipa3 = helixip3_3.a();
220
221 double dr3 = fabs( vecipa3[0] );
222 double dz3 = fabs( vecipa3[3] );
223 double costheta3 = cos( mdcKalTrk3->theta() );
224 if ( dr3 >= 1.0 ) continue;
225 if ( dz3 >= 10.0 ) continue;
226 if ( fabs( costheta3 ) >= 0.93 ) continue;
227 /////////////////////////////////////////
228 if ( PID_flag == 5 )
229 {
230 simple_pid->preparePID( *itTrk );
231 if ( simple_pid->probPion() < 0.0 ||
232 simple_pid->probPion() < simple_pid->probKaon() )
233 continue;
234 }
235 /////////////////////////////////////////
236 WTrackParameter pip2( xmass[2], mdcKalTrk3->getZHelix(), mdcKalTrk3->getZError() );
237
238 //
239 // select pi4
240 //
241 for ( int l = 0; l < evtRecEvent->totalCharged(); l++ )
242 {
243 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + l;
244
245 int ipi4 = ( *itTrk )->trackId();
246 if ( ipi4 == ipi3 || ipi4 == ipi2 || ipi4 == ipi1 ) continue;
247
248 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
249 RecMdcKalTrack* mdcKalTrk4 = ( *itTrk )->mdcKalTrack();
251
252 m_chargepi4 = mdcKalTrk4->charge();
253 if ( ( m_chargepi4 + m_chargepi3 ) != 0 ) continue;
254
255 /////////////////////////////////////////
256 HepVector a4 = mdcKalTrk4->getZHelix();
257 HepSymMatrix Ea4 = mdcKalTrk4->getZError();
258 VFHelix helixip3_4( point0, a4, Ea4 );
259 helixip3_4.pivot( IP );
260 HepVector vecipa4 = helixip3_4.a();
261
262 double dr4 = fabs( vecipa4[0] );
263 double dz4 = fabs( vecipa4[3] );
264 double costheta4 = cos( mdcKalTrk4->theta() );
265 if ( dr4 >= 1.0 ) continue;
266 if ( dz4 >= 10.0 ) continue;
267 if ( fabs( costheta4 ) >= 0.93 ) continue;
268 /////////////////////////////////////////
269 if ( PID_flag == 5 )
270 {
271 simple_pid->preparePID( *itTrk );
272 if ( simple_pid->probPion() < 0.0 ||
273 simple_pid->probPion() < simple_pid->probKaon() )
274 continue;
275 }
276 /////////////////////////////////////////
277 WTrackParameter pim2( xmass[2], mdcKalTrk4->getZHelix(), mdcKalTrk4->getZError() );
278
279 for ( int m = 0; m < nGam - 1; m++ )
280 {
281 if ( iGam[m] == -1 ) continue;
282 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + iGam[m] ) )->emcShower();
283 double eraw1 = g1Trk->energy();
284 double phi1 = g1Trk->phi();
285 double the1 = g1Trk->theta();
286 HepLorentzVector ptrkg1, ptrkg10, ptrkg12;
287 ptrkg1.setPx( eraw1 * sin( the1 ) * cos( phi1 ) );
288 ptrkg1.setPy( eraw1 * sin( the1 ) * sin( phi1 ) );
289 ptrkg1.setPz( eraw1 * cos( the1 ) );
290 ptrkg1.setE( eraw1 );
291 ptrkg10 = ptrkg1;
292 ptrkg12 = ptrkg1.boost( -0.011, 0, 0 );
293
294 for ( int n = m + 1; n < nGam; n++ )
295 {
296 if ( iGam[n] == -1 ) continue;
297 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + iGam[n] ) )->emcShower();
298 double eraw2 = g2Trk->energy();
299 double phi2 = g2Trk->phi();
300 double the2 = g2Trk->theta();
301 HepLorentzVector ptrkg2, ptrkg20, ptrkg22;
302 ptrkg2.setPx( eraw2 * sin( the2 ) * cos( phi2 ) );
303 ptrkg2.setPy( eraw2 * sin( the2 ) * sin( phi2 ) );
304 ptrkg2.setPz( eraw2 * cos( the2 ) );
305 ptrkg2.setE( eraw2 );
306 ptrkg20 = ptrkg2;
307 ptrkg22 = ptrkg2.boost( -0.011, 0, 0 );
308
309 /////////////////////////////////////////////////////////////
310 HepLorentzVector ptrkpi0;
311 ptrkpi0 = ptrkg12 + ptrkg22;
312 double m_xmpi0_tem = ptrkpi0.m();
313 if ( m_xmpi0_tem > 0.150 || m_xmpi0_tem < 0.115 ) continue;
314 /////////////////////////////////////////////////////////////
315 bool IsEndcap1 = false;
316 bool IsEndcap2 = false;
317 if ( fabs( cos( the1 ) ) > 0.86 && fabs( cos( the1 ) ) < 0.92 ) IsEndcap1 = true;
318 if ( fabs( cos( the2 ) ) > 0.86 && fabs( cos( the2 ) ) < 0.92 ) IsEndcap2 = true;
319 if ( IsEndcap1 && IsEndcap2 ) continue;
320 /////////////////////////////////////////////////////////////
322 kmfit->init();
323 kmfit->setChisqCut( 2500 );
324 kmfit->AddTrack( 0, 0.0, g1Trk );
325 kmfit->AddTrack( 1, 0.0, g2Trk );
326 kmfit->AddResonance( 0, mpi0, 0, 1 );
327
328 kmfit->Fit( 0 ); // Perform fit
329 kmfit->BuildVirtualParticle( 0 );
330
331 double pi0_chisq = kmfit->chisq( 0 );
332 if ( pi0_chisq >= 2500 ) continue;
333 HepLorentzVector p2gfit = kmfit->pfit( 0 ) + kmfit->pfit( 1 );
334 p2gfit.boost( -0.011, 0, 0 );
335 /////////////////////////////////////////////////////////////
336
337 VertexFit* vtxfit_2 = VertexFit::instance();
338 vtxfit_2->init();
339 vtxfit_2->AddTrack( 0, pip2 );
340 vtxfit_2->AddTrack( 1, pim2 );
341 vtxfit_2->AddVertex( 0, vxpar, 0, 1 );
342 if ( !vtxfit_2->Fit( 0 ) ) continue;
343 vtxfit_2->Swim( 0 );
344
345 WTrackParameter wpip2 = vtxfit_2->wtrk( 0 );
346 WTrackParameter wpim2 = vtxfit_2->wtrk( 1 );
347
349 vtxfit->init();
350 vxpar.setEvx( xoriginEx );
351 vtxfit->setPrimaryVertex( vxpar );
352 vtxfit->AddTrack( 0, wks_Trk );
353 vtxfit->setVpar( wks_var );
354 if ( !vtxfit->Fit() ) continue;
355
356 if ( vtxfit->chisq() > 999. ) continue;
357 if ( vtxfit->decayLength() < 0.0 ) continue;
358
359 double m_massks1_tem = vtxfit->p4par().m();
360 if ( m_massks1_tem < 0.485 || m_massks1_tem > 0.515 ) continue;
361 HepLorentzVector p4kstag = vtxfit->p4par();
362 WTrackParameter para_ks = vtxfit0->wVirtualTrack( 0 );
363
364 HepVector pip2_val = HepVector( 7, 0 );
365 HepVector pim2_val = HepVector( 7, 0 );
366 HepVector ksp_val = HepVector( 7, 0 );
367 HepVector ksm_val = HepVector( 7, 0 );
368
369 pip2_val = wpip2.w();
370 pim2_val = wpim2.w();
371 ksp_val = wksp.w();
372 ksm_val = wksm.w();
373
374 HepLorentzVector P_PIP2( pip2_val[0], pip2_val[1], pip2_val[2], pip2_val[3] );
375 HepLorentzVector P_PIM2( pim2_val[0], pim2_val[1], pim2_val[2], pim2_val[3] );
376 HepLorentzVector P_KSP( ksp_val[0], ksp_val[1], ksp_val[2], ksp_val[3] );
377 HepLorentzVector P_KSM( ksm_val[0], ksm_val[1], ksm_val[2], ksm_val[3] );
378
379 p4kstag.boost( -0.011, 0, 0 );
380 P_PIP2.boost( -0.011, 0, 0 );
381 P_PIM2.boost( -0.011, 0, 0 );
382 P_KSP.boost( -0.011, 0, 0 );
383 P_KSM.boost( -0.011, 0, 0 );
384
385 // pddd = P_PIP2 + P_PIM2 + P_KSP + P_KSM + p2gfit;
386 pddd = P_PIP2 + P_PIM2 + p4kstag + p2gfit;
387
388 double pk0pipipi0 = pddd.rho();
389
390 double temp1 = ( ecms / 2 ) * ( ecms / 2 ) - pk0pipipi0 * pk0pipipi0;
391 if ( temp1 < 0 ) temp1 = 0;
392 double mass_bc_tem = sqrt( temp1 );
393 if ( mass_bc_tem < 1.82 || mass_bc_tem > 1.89 ) continue;
394
395 double delE_tag_tag = ecms / 2 - pddd.e();
396
397 if ( fabs( delE_tag_tag ) < deltaE_tem )
398 {
399 deltaE_tem = fabs( delE_tag_tag );
400 delE_tag_temp = delE_tag_tag;
401 mass_bcgg = mass_bc_tem;
402
403 pddd_temp = pddd;
404
405 ipi1_temp = ipi1;
406 ipi2_temp = ipi2;
407 ipi3_temp = ipi3;
408 ipi4_temp = ipi4;
409 iGam1_temp = iGam[m];
410 iGam2_temp = iGam[n];
411
412 ncount1 = 1;
413 }
414 }
415 }
416 }
417 }
418 }
419 }
420
421 if ( ncount1 == 1 )
422 {
423 tagmode = 17;
424 if ( m_chargetag < 0 ) tagmode = -17;
425 tagmd = tagmode;
426 mass_bc = mass_bcgg;
427 delE_tag = delE_tag_temp;
428 cqtm = 0;
429
430 iGoodtag.push_back( ipi1_temp );
431 iGoodtag.push_back( ipi2_temp );
432 iGoodtag.push_back( ipi3_temp );
433 iGoodtag.push_back( ipi4_temp );
434
435 iGamtag.push_back( iGam1_temp );
436 iGamtag.push_back( iGam2_temp );
437 iGamtag.push_back( 9999 );
438 iGamtag.push_back( 9999 );
439
440 ptag = pddd_temp;
441
442 k0pipipi0md = true;
443 }
444}
int runNo
Definition DQA_TO_DB.cxx:13
const Int_t n
Double_t phi2
Double_t phi1
EvtRecTrackCol::iterator EvtRecTrackIterator
double mpi0
const double xmass[5]
Definition Gam4pikp.cxx:35
std::vector< int > Vint
Definition K0pipipi0.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 K0pipipi0.cxx:32
void setChisqCut(const double chicut=200, const double chiter=0.05)
void BuildVirtualParticle(int number)
void AddResonance(int number, double mres, std::vector< int > tlis)
static KalmanKinematicFit * instance()
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