BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Kkpi0.cxx
Go to the documentation of this file.
1//
2// Kkpi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 through the final states
3// of Kkpi0 from D0 decays. Kkpi0.cxx was transfered from the Fortran routine "Kkpi0.f" which
4// 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 "Kkpi0.f" used at the BES-II experiment was coded by H.L. Ma
8// and G. Rong in 2003.
9//
10// Kkpi0.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/Kkpi0.h"
27
29
31
32void Kkpi0::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;
43 int ik1_temp, ik2_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 kkpi0md = 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 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
90 HepLorentzVector p2gfit;
91 HepLorentzVector p2gg;
92
93 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
94 {
95 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
96
97 int ik1 = ( *itTrk )->trackId();
98
99 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
100 RecMdcKalTrack* mdcKalTrk1 = ( *itTrk )->mdcKalTrack();
102
103 m_chargek1 = mdcKalTrk1->charge();
104 if ( abs( m_chargek1 ) != 1 ) continue;
105
106 /////////////////////////////////////////
107 HepVector a1 = mdcKalTrk1->getZHelixK();
108 HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
109
110 VFHelix helixip3_1( point0, a1, Ea1 );
111 helixip3_1.pivot( IP );
112 HepVector vecipa1 = helixip3_1.a();
113
114 double dr1 = fabs( vecipa1[0] );
115 double dz1 = fabs( vecipa1[3] );
116 double costheta1 = cos( mdcKalTrk1->theta() );
117
118 if ( dr1 >= 1.0 ) continue;
119 if ( dz1 >= 10.0 ) continue;
120 if ( fabs( costheta1 ) >= 0.93 ) continue;
121 /////////////////////////////////////////
122 if ( PID_flag == 5 )
123 {
124 simple_pid->preparePID( *itTrk );
125 if ( simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion() )
126 continue;
127 }
128 /////////////////////////////////////////
129 WTrackParameter kap( xmass[3], mdcKalTrk1->getZHelixK(), mdcKalTrk1->getZErrorK() );
130
131 //
132 // select K2
133 //
134 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
135 {
136 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
137
138 int ik2 = ( *itTrk )->trackId();
139 if ( ik2 == ik1 ) continue;
140
141 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
142 RecMdcKalTrack* mdcKalTrk2 = ( *itTrk )->mdcKalTrack();
144
145 m_chargek2 = mdcKalTrk2->charge();
146 if ( ( m_chargek1 + m_chargek2 ) != 0 ) continue;
147
148 /////////////////////////////////////////
149 HepVector a2 = mdcKalTrk2->getZHelixK();
150 HepSymMatrix Ea2 = mdcKalTrk2->getZErrorK();
151 VFHelix helixip3_2( point0, a2, Ea2 );
152 helixip3_2.pivot( IP );
153 HepVector vecipa2 = helixip3_2.a();
154
155 double dr2 = fabs( vecipa2[0] );
156 double dz2 = fabs( vecipa2[3] );
157 double costheta2 = cos( mdcKalTrk2->theta() );
158 if ( dr2 >= 1.0 ) continue;
159 if ( dz2 >= 10.0 ) continue;
160 if ( fabs( costheta2 ) >= 0.93 ) continue;
161 /////////////////////////////////////////
162 if ( PID_flag == 5 )
163 {
164 simple_pid->preparePID( *itTrk );
165 if ( simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion() )
166 continue;
167 }
168 /////////////////////////////////////////
169 WTrackParameter kam( xmass[3], mdcKalTrk2->getZHelixK(), mdcKalTrk2->getZErrorK() );
170
171 for ( int m = 0; m < nGam - 1; m++ )
172 {
173 if ( iGam[m] == -1 ) continue;
174 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + iGam[m] ) )->emcShower();
175 double eraw1 = g1Trk->energy();
176 double phi1 = g1Trk->phi();
177 double the1 = g1Trk->theta();
178 HepLorentzVector ptrkg1, ptrkg10, ptrkg12;
179 ptrkg1.setPx( eraw1 * sin( the1 ) * cos( phi1 ) );
180 ptrkg1.setPy( eraw1 * sin( the1 ) * sin( phi1 ) );
181 ptrkg1.setPz( eraw1 * cos( the1 ) );
182 ptrkg1.setE( eraw1 );
183 ptrkg10 = ptrkg1;
184 ptrkg12 = ptrkg1.boost( -0.011, 0, 0 );
185
186 for ( int n = m + 1; n < nGam; n++ )
187 {
188 if ( iGam[n] == -1 ) continue;
189 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + iGam[n] ) )->emcShower();
190 double eraw2 = g2Trk->energy();
191 double phi2 = g2Trk->phi();
192 double the2 = g2Trk->theta();
193 HepLorentzVector ptrkg2, ptrkg20, ptrkg22;
194 ptrkg2.setPx( eraw2 * sin( the2 ) * cos( phi2 ) );
195 ptrkg2.setPy( eraw2 * sin( the2 ) * sin( phi2 ) );
196 ptrkg2.setPz( eraw2 * cos( the2 ) );
197 ptrkg2.setE( eraw2 );
198 ptrkg20 = ptrkg2;
199 ptrkg22 = ptrkg2.boost( -0.011, 0, 0 );
200
201 /////////////////////////////////////////////////////////////
202 HepLorentzVector ptrkpi0;
203 ptrkpi0 = ptrkg12 + ptrkg22;
204 double m_xmpi0_tem = ptrkpi0.m();
205 if ( m_xmpi0_tem > 0.150 || m_xmpi0_tem < 0.115 ) continue;
206 /////////////////////////////////////////////////////////////
207 bool IsEndcap1 = false;
208 bool IsEndcap2 = false;
209 if ( fabs( cos( the1 ) ) > 0.86 && fabs( cos( the1 ) ) < 0.92 ) IsEndcap1 = true;
210 if ( fabs( cos( the2 ) ) > 0.86 && fabs( cos( the2 ) ) < 0.92 ) IsEndcap2 = true;
211 if ( IsEndcap1 && IsEndcap2 ) continue;
212 /////////////////////////////////////////////////////////////
214 kmfit->init();
215 kmfit->setChisqCut( 2500 );
216 kmfit->AddTrack( 0, 0.0, g1Trk );
217 kmfit->AddTrack( 1, 0.0, g2Trk );
218 kmfit->AddResonance( 0, mpi0, 0, 1 );
219
220 kmfit->Fit( 0 ); // Perform fit
221 kmfit->BuildVirtualParticle( 0 );
222
223 double pi0_chisq = kmfit->chisq( 0 );
224 if ( pi0_chisq >= 2500 ) continue;
225 HepLorentzVector p2gfit = kmfit->pfit( 0 ) + kmfit->pfit( 1 );
226 p2gfit.boost( -0.011, 0, 0 );
227
228 //////////////////////////////////////////////////////////////
229 HepPoint3D vx( xorigin.x(), xorigin.y(), xorigin.z() );
230 HepSymMatrix Evx( 3, 0 );
231 double bx = 1E+6;
232 Evx[0][0] = bx * bx;
233 double by = 1E+6;
234 Evx[1][1] = by * by;
235 double bz = 1E+6;
236 Evx[2][2] = bz * bz;
237 VertexParameter vxpar;
238 vxpar.setVx( vx );
239 vxpar.setEvx( Evx );
240 //////////////////////////////////////////////////////////////
241
242 VertexFit* vtxfit = VertexFit::instance();
243 vtxfit->init();
244 vtxfit->AddTrack( 0, kam );
245 vtxfit->AddTrack( 1, kap );
246 vtxfit->AddVertex( 0, vxpar, 0, 1 );
247 if ( !vtxfit->Fit( 0 ) ) continue;
248 vtxfit->Swim( 0 );
249
250 WTrackParameter wkam = vtxfit->wtrk( 0 );
251 WTrackParameter wkap = vtxfit->wtrk( 1 );
252
253 HepVector kam_val = HepVector( 7, 0 );
254 kam_val = wkam.w();
255 HepVector kap_val = HepVector( 7, 0 );
256 kap_val = wkap.w();
257
258 HepLorentzVector P_KAM( kam_val[0], kam_val[1], kam_val[2], kam_val[3] );
259 HepLorentzVector P_KAP( kap_val[0], kap_val[1], kap_val[2], kap_val[3] );
260
261 P_KAM.boost( -0.011, 0, 0 );
262 P_KAP.boost( -0.011, 0, 0 );
263 pddd = P_KAM + P_KAP + p2gfit;
264
265 double pkkpi0 = pddd.rho();
266
267 double temp1 = ( ecms / 2 ) * ( ecms / 2 ) - pkkpi0 * pkkpi0;
268 if ( temp1 < 0 ) temp1 = 0;
269 double mass_bc_tem = sqrt( temp1 );
270 if ( mass_bc_tem < 1.82 || mass_bc_tem > 1.89 ) continue;
271
272 double delE_tag_tag = ecms / 2 - pddd.e();
273
274 if ( fabs( delE_tag_tag ) < deltaE_tem )
275 {
276 deltaE_tem = fabs( delE_tag_tag );
277 delE_tag_temp = delE_tag_tag;
278 mass_bcgg = mass_bc_tem;
279
280 pddd_temp = pddd;
281
282 ik1_temp = ik1;
283 ik2_temp = ik2;
284 iGam1_temp = iGam[m];
285 iGam2_temp = iGam[n];
286 ncount1 = 1;
287 }
288 }
289 }
290 }
291 }
292
293 if ( ncount1 == 1 )
294 {
295 tagmode = 23;
296 if ( m_chargetag < 0 ) tagmode = -23;
297 tagmd = tagmode;
298 mass_bc = mass_bcgg;
299 delE_tag = delE_tag_temp;
300 cqtm = 0.0;
301
302 iGoodtag.push_back( ik1_temp );
303 iGoodtag.push_back( ik2_temp );
304
305 iGamtag.push_back( iGam1_temp );
306 iGamtag.push_back( iGam2_temp );
307 iGamtag.push_back( 9999 );
308 iGamtag.push_back( 9999 );
309
310 ptag = pddd_temp;
311
312 kkpi0md = true;
313 }
314}
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 Kkpi0.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 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 MTotal(double event, SmartDataPtr< EvtRecTrackCol > evtRecTrkCol, Vint iGood, Vint iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
Definition Kkpi0.cxx:32
~Kkpi0()
Definition Kkpi0.cxx:30
Kkpi0()
Definition Kkpi0.cxx:28
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