BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Kk.cxx
Go to the documentation of this file.
1//
2// Kk.cxx is the single D0 tag code to reconstruct D0 or anti-D0 through the final states of
3// KK from D0 decays. Kk.cxx was transfered from the Fortran routine "Kk.f" which was
4// 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 "Kk.f" used at the BES-II experiment was coded by G. Rong in
8// 2002.
9//
10// Kk.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/Kk.h"
27
29
31
32void Kk::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 ika1_temp, ika2_temp, ipi2_temp, ipi3_temp;
44 HepLorentzVector kmfit1, kmfit2, kmfit3, kmfit4, pddd;
45
46 HepLorentzVector pddd_temp;
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 kkmd = false;
58 double tagmode = 0;
59
60 if ( ( evtRecEvent->totalCharged() < 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 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
91 {
92 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
93
94 int ika1 = ( *itTrk )->trackId();
95
96 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
97 RecMdcKalTrack* mdcKalTrk1 = ( *itTrk )->mdcKalTrack();
99
100 m_chargek1 = mdcKalTrk1->charge();
101 if ( m_chargek1 != 1 ) continue;
102
103 /////////////////////////////////////////
104 HepVector a1 = mdcKalTrk1->getZHelixK();
105 HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
106
107 VFHelix helixip3_1( point0, a1, Ea1 );
108 helixip3_1.pivot( IP );
109 HepVector vecipa1 = helixip3_1.a();
110
111 double dr1 = fabs( vecipa1[0] );
112 double dz1 = fabs( vecipa1[3] );
113 double costheta1 = cos( mdcKalTrk1->theta() );
114
115 if ( dr1 >= 1.0 ) continue;
116 if ( dz1 >= 10.0 ) continue;
117 if ( fabs( costheta1 ) >= 0.93 ) continue;
118 /////////////////////////////////////////
119 if ( PID_flag == 5 )
120 {
121 simple_pid->preparePID( *itTrk );
122 if ( simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion() )
123 continue;
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 ika2 = ( *itTrk )->trackId();
136 if ( ika1 == ika2 ) 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.0 || simple_pid->probKaon() < simple_pid->probPion() )
163 continue;
164 }
165 /////////////////////////////////////////
166 WTrackParameter kam( xmass[3], mdcKalTrk2->getZHelixK(), mdcKalTrk2->getZErrorK() );
167
168 // all loop for the charged tracks overed here !!!!!!!
169
170 //////////////////////////////////////////////////////////////
171 HepPoint3D vx( xorigin.x(), xorigin.y(), xorigin.z() );
172 HepSymMatrix Evx( 3, 0 );
173 double bx = 1E+6;
174 Evx[0][0] = bx * bx;
175 double by = 1E+6;
176 Evx[1][1] = by * by;
177 double bz = 1E+6;
178 Evx[2][2] = bz * bz;
179 VertexParameter vxpar;
180 vxpar.setVx( vx );
181 vxpar.setEvx( Evx );
182 //////////////////////////////////////////////////////////////
183
184 VertexFit* vtxfit = VertexFit::instance();
185 vtxfit->init();
186 vtxfit->AddTrack( 0, kap );
187 vtxfit->AddTrack( 1, kam );
188 vtxfit->AddVertex( 0, vxpar, 0, 1 );
189 if ( !vtxfit->Fit( 0 ) ) continue;
190 vtxfit->Swim( 0 );
191
192 WTrackParameter wkap = vtxfit->wtrk( 0 );
193 WTrackParameter wkam = vtxfit->wtrk( 1 );
194
195 HepVector kap_val = HepVector( 7, 0 );
196 kap_val = wkap.w();
197 HepVector kam_val = HepVector( 7, 0 );
198 kam_val = wkam.w();
199
200 HepLorentzVector P_KAP( kap_val[0], kap_val[1], kap_val[2], kap_val[3] );
201 HepLorentzVector P_KAM( kam_val[0], kam_val[1], kam_val[2], kam_val[3] );
202
203 P_KAP.boost( -0.011, 0, 0 );
204 P_KAM.boost( -0.011, 0, 0 );
205 pddd = P_KAP + P_KAM;
206
207 double pkk = pddd.rho();
208
209 double temp1 = ( ecms / 2 ) * ( ecms / 2 ) - pkk * pkk;
210 if ( temp1 < 0 ) temp1 = 0;
211 double mass_bc_tem = sqrt( temp1 );
212 if ( mass_bc_tem < 1.82 || mass_bc_tem > 1.89 ) continue;
213
214 double delE_tag_tag = ecms / 2 - pddd.e();
215
216 if ( fabs( delE_tag_tag ) < deltaE_tem )
217 {
218 deltaE_tem = fabs( delE_tag_tag );
219 delE_tag_temp = delE_tag_tag;
220 mass_bcgg = mass_bc_tem;
221
222 pddd_temp = pddd;
223 ika1_temp = ika1;
224 ika2_temp = ika2;
225 ncount1 = 1;
226 }
227 }
228 }
229
230 if ( ncount1 == 1 )
231 {
232 tagmode = 15;
233 if ( m_chargetag < 0 ) tagmode = -15;
234 tagmd = tagmode;
235 mass_bc = mass_bcgg;
236 delE_tag = delE_tag_temp;
237 cqtm = -0.0;
238
239 iGoodtag.push_back( ika1_temp );
240 iGoodtag.push_back( ika2_temp );
241 iGamtag.push_back( 9999 );
242 iGamtag.push_back( 9999 );
243 iGamtag.push_back( 9999 );
244 iGamtag.push_back( 9999 );
245
246 ptag = pddd_temp;
247
248 kkmd = true;
249 }
250}
int runNo
Definition DQA_TO_DB.cxx:13
EvtRecTrackCol::iterator EvtRecTrackIterator
const double xmass[5]
Definition Gam4pikp.cxx:35
std::vector< int > Vint
Definition Kk.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
~Kk()
Definition Kk.cxx:30
void MTotal(double event, SmartDataPtr< EvtRecTrackCol > evtRecTrkCol, Vint iGood, Vint iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
Definition Kk.cxx:32
Kk()
Definition Kk.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