BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
K0pi0.cxx
Go to the documentation of this file.
1//
2// K0pi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 meson through the final
3// states of K0pi0 from D0 or anti-D0 meson decays. K0pi0.cxx was transfered from the Fortran
4// routine "K0pi0.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 "K0pi0.f" used at the BES-II experiment was coded by G. Rong in
8// 2002.
9//
10// K0pi0.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/K0pi0.h"
27
29
31
32void K0pi0::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;
43 int ika_temp, ipi1_temp, ipi2_temp, ipi3_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 k0pi0md = false;
58 double tagmode = 0;
59
60 if ( ( evtRecEvent->totalCharged() < 2 || 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 HepLorentzVector p2gfit;
95 HepLorentzVector p2gg;
96
97 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
98 {
99 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
100
101 int ipi1 = ( *itTrk )->trackId();
102
103 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
104 RecMdcKalTrack* mdcKalTrk1 = ( *itTrk )->mdcKalTrack();
106
107 m_chargepi1 = mdcKalTrk1->charge();
108 if ( m_chargepi1 != 1 ) continue;
109
110 /////////////////////////////////////////
111 HepVector a1 = mdcKalTrk1->getZHelix();
112 HepSymMatrix Ea1 = mdcKalTrk1->getZError();
113
114 VFHelix helixip3_1( point0, a1, Ea1 );
115 helixip3_1.pivot( IP );
116 HepVector vecipa1 = helixip3_1.a();
117
118 double dr1 = fabs( vecipa1[0] );
119 double dz1 = fabs( vecipa1[3] );
120 double costheta1 = cos( mdcKalTrk1->theta() );
121
122 if ( dr1 >= 15.0 ) continue;
123 if ( dz1 >= 25.0 ) continue;
124 if ( fabs( costheta1 ) >= 0.93 ) continue;
125 /////////////////////////////////////////
126 WTrackParameter pip( xmass[2], mdcKalTrk1->getZHelix(), mdcKalTrk1->getZError() );
127
128 //
129 // select pi
130 //
131 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
132 {
133 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
134
135 int ipi2 = ( *itTrk )->trackId();
136 if ( ipi1 == ipi2 ) continue;
137
138 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
139 RecMdcKalTrack* mdcKalTrk2 = ( *itTrk )->mdcKalTrack();
141
142 m_chargepi2 = mdcKalTrk2->charge();
143 if ( ( m_chargepi1 + m_chargepi2 ) != 0 ) continue;
144
145 /////////////////////////////////////////
146 HepVector a2 = mdcKalTrk2->getZHelix();
147 HepSymMatrix Ea2 = mdcKalTrk2->getZError();
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 >= 15.0 ) continue;
156 if ( dz2 >= 25.0 ) continue;
157 if ( fabs( costheta2 ) >= 0.93 ) continue;
158 /////////////////////////////////////////
159 WTrackParameter pim( xmass[2], mdcKalTrk2->getZHelix(), mdcKalTrk2->getZError() );
160
161 HepVector pip_val = HepVector( 7, 0 );
162 HepVector pim_val = HepVector( 7, 0 );
163 pip_val = pip.w();
164 pim_val = pim.w();
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;
169
170 HepPoint3D vx( xorigin.x(), xorigin.y(), xorigin.z() );
171 HepSymMatrix Evx( 3, 0 );
172 double bx = 1E+6;
173 Evx[0][0] = bx * bx;
174 double by = 1E+6;
175 Evx[1][1] = by * by;
176 double bz = 1E+6;
177 Evx[2][2] = bz * bz;
178 VertexParameter vxpar;
179 vxpar.setVx( vx );
180 vxpar.setEvx( Evx );
181
182 VertexFit* vtxfit0 = VertexFit::instance();
183 vtxfit0->init();
184 vtxfit0->AddTrack( 0, pip );
185 vtxfit0->AddTrack( 1, pim );
186 vtxfit0->AddVertex( 0, vxpar, 0, 1 );
187 if ( !( vtxfit0->Fit( 0 ) ) ) continue;
188 vtxfit0->Swim( 0 );
189 vtxfit0->BuildVirtualParticle( 0 );
190 WTrackParameter wksp = vtxfit0->wtrk( 0 );
191 WTrackParameter wksm = vtxfit0->wtrk( 1 );
192 WTrackParameter wks_Trk = vtxfit0->wVirtualTrack( 0 );
193 VertexParameter wks_var = vtxfit0->vpar( 0 );
194
196 vtxfit->init();
197 vxpar.setEvx( xoriginEx );
198 vtxfit->setPrimaryVertex( vxpar );
199 vtxfit->AddTrack( 0, wks_Trk );
200 vtxfit->setVpar( wks_var );
201 if ( !vtxfit->Fit() ) continue;
202
203 if ( vtxfit->chisq() > 999. ) continue;
204 if ( vtxfit->decayLength() < 0.0 ) continue;
205
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 );
210 WTrackParameter para_ks = vtxfit0->wVirtualTrack( 0 );
211
212 for ( int m = 0; m < nGam - 1; m++ )
213 {
214 if ( iGam[m] == -1 ) continue;
215 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + iGam[m] ) )->emcShower();
216 double eraw1 = g1Trk->energy();
217 double phi1 = g1Trk->phi();
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 );
224 ptrkg10 = ptrkg1;
225 ptrkg12 = ptrkg1.boost( -0.011, 0, 0 );
226
227 for ( int n = m + 1; n < nGam; n++ )
228 {
229 if ( iGam[n] == -1 ) continue;
230 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + iGam[n] ) )->emcShower();
231 double eraw2 = g2Trk->energy();
232 double phi2 = g2Trk->phi();
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 );
239 ptrkg20 = ptrkg2;
240 ptrkg22 = ptrkg2.boost( -0.011, 0, 0 );
241
242 /////////////////////////////////////////////////////////////
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;
247 /////////////////////////////////////////////////////////////
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;
253 /////////////////////////////////////////////////////////////
255 kmfit->init();
256 kmfit->setChisqCut( 2500 );
257 kmfit->AddTrack( 0, 0.0, g1Trk );
258 kmfit->AddTrack( 1, 0.0, g2Trk );
259 kmfit->AddResonance( 0, mpi0, 0, 1 );
260
261 kmfit->Fit( 0 ); // Perform fit
262 kmfit->BuildVirtualParticle( 0 );
263
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 );
268 /////////////////////////////////////////////////////////////
269
270 HepVector ksp_val = HepVector( 7, 0 );
271 HepVector ksm_val = HepVector( 7, 0 );
272 ksp_val = wksp.w();
273 ksm_val = wksm.w();
274
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] );
277
278 P_KSP.boost( -0.011, 0, 0 );
279 P_KSM.boost( -0.011, 0, 0 );
280 pddd = p4kstag + p2gfit;
281
282 double pk0pi0 = pddd.rho();
283
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;
288
289 double delE_tag_tag = ecms / 2 - pddd.e();
290
291 if ( fabs( delE_tag_tag ) < deltaE_tem )
292 {
293 deltaE_tem = fabs( delE_tag_tag );
294 delE_tag_temp = delE_tag_tag;
295 mass_bcgg = mass_bc_tem;
296
297 pddd_temp = pddd;
298
299 ipi1_temp = ipi1;
300 ipi2_temp = ipi2;
301
302 iGam1_temp = iGam[m];
303 iGam2_temp = iGam[n];
304
305 ncount1 = 1;
306 }
307 }
308 }
309 }
310 }
311
312 if ( ncount1 == 1 )
313 {
314 tagmode = 18;
315 if ( m_chargetag < 0 ) tagmode = -18;
316 tagmd = tagmode;
317 mass_bc = mass_bcgg;
318 delE_tag = delE_tag_temp;
319 cqtm = 0.0;
320
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 );
327
328 ptag = pddd_temp;
329
330 k0pi0md = true;
331 }
332}
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 K0pi0.h:16
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 K0pi0.cxx:32
K0pi0()
Definition K0pi0.cxx:28
~K0pi0()
Definition K0pi0.cxx:30
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