BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Kkpipi.cxx
Go to the documentation of this file.
1//
2// Kkpipi.cxx is the single D0 tag code to reconstruct D0 or anti-D0 through the final states
3// of Kkpipi from D0 decays. Kkpipi.cxx was transfered from the Fortran routine "kkpipi.f"
4// which was orignally used for study of the D0D0-bar production and D0 decays at the BES-II
5// experiment during the time period from 2002 to 2008.
6//
7// The orignal Fortran routine "Kkpipi.f" used at the BES-II experiment was coded by G. Rong
8// in 2002.
9//
10// Kkpipi.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/Kkpipi.h"
27
29
31
32void Kkpipi::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_chargek1, m_chargek2, m_chargepi1, m_chargepi2;
43 int ik1_temp, ik2_temp, ipi1_temp, ipi2_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 kkpipimd = 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 IVertexDbSvc* vtxsvc;
72 Gaudi::svcLocator()->service( "VertexDbSvc", vtxsvc );
73 if ( vtxsvc->isVertexValid() )
74 {
75 double* dbv = vtxsvc->PrimaryVertex();
76 double* vv = vtxsvc->SigmaPrimaryVertex();
77 xorigin.setX( dbv[0] );
78 xorigin.setY( dbv[1] );
79 xorigin.setZ( dbv[2] );
80 }
81
82 double xv = xorigin.x();
83 double yv = xorigin.y();
84 double zv = xorigin.z();
85
86 HepPoint3D point0( 0., 0., 0. );
87 HepPoint3D IP( xorigin[0], xorigin[1], xorigin[2] );
88 //////////////////////////////////////////////////////////////////
89 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
90 {
91 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
92
93 int ik1 = ( *itTrk )->trackId();
94
95 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
96 RecMdcKalTrack* mdcKalTrk1 = ( *itTrk )->mdcKalTrack();
98
99 m_chargek1 = mdcKalTrk1->charge();
100 if ( m_chargek1 != 1 ) continue;
101
102 /////////////////////////////////////////
103 HepVector a1 = mdcKalTrk1->getZHelixK();
104 HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
105
106 VFHelix helixip3_1( point0, a1, Ea1 );
107 helixip3_1.pivot( IP );
108 HepVector vecipa1 = helixip3_1.a();
109
110 double dr1 = fabs( vecipa1[0] );
111 double dz1 = fabs( vecipa1[3] );
112 double costheta1 = cos( mdcKalTrk1->theta() );
113
114 if ( dr1 >= 1.0 ) continue;
115 if ( dz1 >= 10.0 ) continue;
116 if ( fabs( costheta1 ) >= 0.93 ) continue;
117 /////////////////////////////////////////
118 if ( PID_flag == 5 )
119 {
120 simple_pid->preparePID( *itTrk );
121 if ( simple_pid->probKaon() < 0 || simple_pid->probKaon() < simple_pid->probPion() )
122 continue;
123 }
124 /////////////////////////////////////////
125
126 WTrackParameter kap( xmass[3], mdcKalTrk1->getZHelixK(), mdcKalTrk1->getZErrorK() );
127
128 //
129 // select K2
130 //
131 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
132 {
133 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
134
135 int ik2 = ( *itTrk )->trackId();
136 if ( ik1 == ik2 ) continue;
137
138 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
139 RecMdcKalTrack* mdcKalTrk2 = ( *itTrk )->mdcKalTrack();
141
142 m_chargek2 = mdcKalTrk2->charge();
143 if ( ( m_chargek1 + m_chargek2 ) != 0 ) continue;
144
145 /////////////////////////////////////////
146 HepVector a2 = mdcKalTrk2->getZHelixK();
147 HepSymMatrix Ea2 = mdcKalTrk2->getZErrorK();
148 VFHelix helixip3_2( point0, a2, Ea2 );
149 helixip3_2.pivot( IP );
150 HepVector vecipa2 = helixip3_2.a();
151
152 double dr2 = fabs( vecipa2[0] );
153 double dz2 = fabs( vecipa2[3] );
154 double costheta2 = cos( mdcKalTrk2->theta() );
155 if ( dr2 >= 1.0 ) continue;
156 if ( dz2 >= 10.0 ) continue;
157 if ( fabs( costheta2 ) >= 0.93 ) continue;
158 /////////////////////////////////////////
159 if ( PID_flag == 5 )
160 {
161 simple_pid->preparePID( *itTrk );
162 if ( simple_pid->probKaon() < 0 || simple_pid->probKaon() < simple_pid->probPion() )
163 continue;
164 }
165 /////////////////////////////////////////
166
167 WTrackParameter kam( xmass[3], mdcKalTrk2->getZHelixK(), mdcKalTrk2->getZErrorK() );
168
169 //
170 // select pi1
171 //
172 for ( int k = 0; k < evtRecEvent->totalCharged(); k++ )
173 {
174 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + k;
175
176 int ipi1 = ( *itTrk )->trackId();
177 if ( ipi1 == ik1 || ipi1 == ik2 ) continue;
178
179 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
180 RecMdcKalTrack* mdcKalTrk3 = ( *itTrk )->mdcKalTrack();
182
183 m_chargepi1 = mdcKalTrk3->charge();
184 if ( m_chargepi1 != 1 ) continue;
185
186 /////////////////////////////////////////
187 HepVector a3 = mdcKalTrk3->getZHelix();
188 HepSymMatrix Ea3 = mdcKalTrk3->getZError();
189 VFHelix helixip3_3( point0, a3, Ea3 );
190 helixip3_3.pivot( IP );
191 HepVector vecipa3 = helixip3_3.a();
192
193 double dr3 = fabs( vecipa3[0] );
194 double dz3 = fabs( vecipa3[3] );
195 double costheta3 = cos( mdcKalTrk3->theta() );
196 if ( dr3 >= 1.0 ) continue;
197 if ( dz3 >= 10.0 ) continue;
198 if ( fabs( costheta3 ) >= 0.93 ) continue;
199 /////////////////////////////////////////
200 if ( PID_flag == 5 )
201 {
202 simple_pid->preparePID( *itTrk );
203 if ( simple_pid->probPion() < 0.0 ||
204 simple_pid->probPion() < simple_pid->probKaon() )
205 continue;
206 }
207 /////////////////////////////////////////
208 WTrackParameter pip( xmass[2], mdcKalTrk3->getZHelix(), mdcKalTrk3->getZError() );
209
210 //
211 // select pi2
212 //
213 for ( int l = 0; l < evtRecEvent->totalCharged(); l++ )
214 {
215 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + l;
216
217 int ipi2 = ( *itTrk )->trackId();
218 if ( ipi2 == ik1 || ipi2 == ik2 || ipi2 == ipi1 ) continue;
219
220 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
221 RecMdcKalTrack* mdcKalTrk4 = ( *itTrk )->mdcKalTrack();
223
224 m_chargepi2 = mdcKalTrk4->charge();
225 if ( ( m_chargepi1 + m_chargepi2 ) != 0 ) continue;
226
227 /////////////////////////////////////////
228 HepVector a4 = mdcKalTrk4->getZHelix();
229 HepSymMatrix Ea4 = mdcKalTrk4->getZError();
230 VFHelix helixip3_4( point0, a4, Ea4 );
231 helixip3_4.pivot( IP );
232 HepVector vecipa4 = helixip3_4.a();
233
234 double dr4 = fabs( vecipa4[0] );
235 double dz4 = fabs( vecipa4[3] );
236 double costheta4 = cos( mdcKalTrk4->theta() );
237 if ( dr4 >= 1.0 ) continue;
238 if ( dz4 >= 10.0 ) continue;
239 if ( fabs( costheta4 ) >= 0.93 ) continue;
240 /////////////////////////////////////////
241 if ( PID_flag == 5 )
242 {
243 simple_pid->preparePID( *itTrk );
244 if ( simple_pid->probPion() < 0.0 ||
245 simple_pid->probPion() < simple_pid->probKaon() )
246 continue;
247 }
248 /////////////////////////////////////////
249
250 WTrackParameter pim( xmass[2], mdcKalTrk4->getZHelix(), mdcKalTrk4->getZError() );
251
252 //////////////////////////////////////////////////////////////
253 HepPoint3D vx( xorigin.x(), xorigin.y(), xorigin.z() );
254 HepSymMatrix Evx( 3, 0 );
255 double bx = 1E+6;
256 Evx[0][0] = bx * bx;
257 double by = 1E+6;
258 Evx[1][1] = by * by;
259 double bz = 1E+6;
260 Evx[2][2] = bz * bz;
261 VertexParameter vxpar;
262 vxpar.setVx( vx );
263 vxpar.setEvx( Evx );
264 //////////////////////////////////////////////////////////////
265
266 VertexFit* vtxfit = VertexFit::instance();
267 vtxfit->init();
268 vtxfit->AddTrack( 0, kap );
269 vtxfit->AddTrack( 1, kam );
270 vtxfit->AddTrack( 2, pip );
271 vtxfit->AddTrack( 3, pim );
272 vtxfit->AddVertex( 0, vxpar, 0, 1, 2, 3 );
273 if ( !vtxfit->Fit( 0 ) ) continue;
274 vtxfit->Swim( 0 );
275
276 WTrackParameter wkap = vtxfit->wtrk( 0 );
277 WTrackParameter wkam = vtxfit->wtrk( 1 );
278 WTrackParameter wpip = vtxfit->wtrk( 2 );
279 WTrackParameter wpim = vtxfit->wtrk( 3 );
280
281 HepVector kap_val = HepVector( 7, 0 );
282 HepVector kam_val = HepVector( 7, 0 );
283 HepVector pip_val = HepVector( 7, 0 );
284 HepVector pim_val = HepVector( 7, 0 );
285 kap_val = wkap.w();
286 kam_val = wkam.w();
287 pip_val = wpip.w();
288 pim_val = wpim.w();
289
290 HepLorentzVector P_KAP( kap_val[0], kap_val[1], kap_val[2], kap_val[3] );
291 HepLorentzVector P_KAM( kam_val[0], kam_val[1], kam_val[2], kam_val[3] );
292 HepLorentzVector P_PIP( pip_val[0], pip_val[1], pip_val[2], pip_val[3] );
293 HepLorentzVector P_PIM( pim_val[0], pim_val[1], pim_val[2], pim_val[3] );
294
295 P_KAP.boost( -0.011, 0, 0 );
296 P_KAM.boost( -0.011, 0, 0 );
297 P_PIP.boost( -0.011, 0, 0 );
298 P_PIM.boost( -0.011, 0, 0 );
299 pddd = P_KAP + P_KAM + P_PIP + P_PIM;
300
301 double pkkpipi = pddd.rho();
302
303 double temp1 = ( ecms / 2 ) * ( ecms / 2 ) - pkkpipi * pkkpipi;
304 if ( temp1 < 0 ) temp1 = 0;
305 double mass_bc_tem = sqrt( temp1 );
306 if ( mass_bc_tem < 1.82 || mass_bc_tem > 1.89 ) continue;
307
308 double delE_tag_tag = ecms / 2 - pddd.e();
309
310 if ( fabs( delE_tag_tag ) < deltaE_tem )
311 {
312 deltaE_tem = fabs( delE_tag_tag );
313 delE_tag_temp = delE_tag_tag;
314 mass_bcgg = mass_bc_tem;
315
316 pddd_temp = pddd;
317
318 ik1_temp = ik1;
319 ik2_temp = ik2;
320 ipi1_temp = ipi1;
321 ipi2_temp = ipi2;
322 ncount1 = 1;
323 }
324 }
325 }
326 }
327 }
328
329 if ( ncount1 == 1 )
330 {
331 tagmode = 20;
332 if ( m_chargetag < 0 ) tagmode = -20;
333 tagmd = tagmode;
334 mass_bc = mass_bcgg;
335 delE_tag = delE_tag_temp;
336 cqtm = 0.0;
337
338 iGoodtag.push_back( ik1_temp );
339 iGoodtag.push_back( ik2_temp );
340 iGoodtag.push_back( ipi1_temp );
341 iGoodtag.push_back( ipi2_temp );
342
343 iGamtag.push_back( 9999 );
344 iGamtag.push_back( 9999 );
345 iGamtag.push_back( 9999 );
346 iGamtag.push_back( 9999 );
347
348 ptag = pddd_temp;
349
350 kkpipimd = true;
351 }
352}
int runNo
Definition DQA_TO_DB.cxx:13
EvtRecTrackCol::iterator EvtRecTrackIterator
const double xmass[5]
Definition Gam4pikp.cxx:35
std::vector< int > Vint
Definition Kkpipi.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 Kkpipi.cxx:32
Kkpipi()
Definition Kkpipi.cxx:28
~Kkpipi()
Definition Kkpipi.cxx:30
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
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
bool Fit()
const double ecms
Definition inclkstar.cxx:26