CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
Kpi.cxx
Go to the documentation of this file.
1//
2// Kpi.cxx is the single D0 tag code to reconstruct D0 or anti-D0 through the final states of
3// Kpi from D0 decays. Kpi.cxx was transfered from the Fortran routine "Kpi.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 "Kpi.f" used at the BES-II experiment was coded by G. Rong in 2001.
8//
9// Kpi.cxx was transfered by G. Rong and J. Liu in December, 2005.
10//
11// Since 2008, G. Rong and L.L. Jiang have been working on developing this code to analyze of
12// the data taken at 3.773 GeV with the BES-III detector at the BEPC-II collider.
13//
14// During developing this code, many People made significant contributions to this code. These are
15// G. Rong, L.L. Jiang, J. Liu, H.L. Ma, J.C. Chen, D.H. Zhang,
16// M.G. Zhao, B. Zheng, L. Li, Y. Fang, Z.Y. Yi, H.H. Liu, Z.Q. Liu et al.
17//
18// By G. Rong and L.L. Jiang
19// March, 2009
20//
21// ==========================================================================================
22//
23#include "SD0TagAlg/Kpi.h"
24#include "SD0TagAlg/SingleBase.h"
25
26
28{}
29
31{}
32
33void Kpi::MTotal(double event,SmartDataPtr<EvtRecTrackCol> evtRecTrkCol, Vint iGood,Vint
34 iGam, double Ebeam, int PID_flag, int Charge_candidate_D)
35{
36
37 int nGood=iGood.size();
38 int nGam=iGam.size();
39
40 iGoodtag.clear();
41 iGamtag.clear();
42
43 double mass_bcgg, delE_tag_temp;
44 int m_chargetag, m_chargek,m_chargepi;
45 int ika_temp,ipi_temp,ipi2_temp,ipi3_temp;
46 HepLorentzVector kmfit1,kmfit2,kmfit3,kmfit4,pddd;
47
48 int cqtm_temp;
49 HepLorentzVector pddd_temp;
50 IDataProviderSvc* eventSvc = NULL;
51 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
52 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc,EventModel::EvtRec::EvtRecEvent);
53 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
54
55 int runNo=eventHeader->runNumber();
56 int rec=eventHeader->eventNumber();
57
58 double xecm=2*Ebeam;
59
60 kpimd = false;
61 double tagmode=0;
62
63 if((evtRecEvent->totalCharged() < 2)){ return; }
64
65 double ecms = xecm; ;
66
67 ISimplePIDSvc* simple_pid;
68 Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
69
70 double deltaE_tem = 0.20;
71 int ncount1 = 0;
72
73 Hep3Vector xorigin(0,0,0);
74 IVertexDbSvc* vtxsvc;
75 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
76 if(vtxsvc->isVertexValid())
77 {
78 double* dbv = vtxsvc->PrimaryVertex();
79 double* vv = vtxsvc->SigmaPrimaryVertex();
80 xorigin.setX(dbv[0]);
81 xorigin.setY(dbv[1]);
82 xorigin.setZ(dbv[2]);
83 }
84
85 double xv=xorigin.x();
86 double yv=xorigin.y();
87 double zv=xorigin.z();
88
89 HepPoint3D point0(0.,0.,0.);
90 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
91
92 HepLorentzVector ptrk1_temp, ptrk2_temp;
93 //////////////////////////////////////////////////////////////////
94 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
95 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
96
97 int ika= (*itTrk)->trackId();
98
99 if(!(*itTrk)->isMdcKalTrackValid()) continue;
100 RecMdcKalTrack* mdcKalTrk1 = (*itTrk)->mdcKalTrack();
102 /////////////////////////////////////////
103 m_chargek=mdcKalTrk1->charge();
104 if(Charge_candidate_D != 0) {
105 if(m_chargek != -Charge_candidate_D) continue;
106 }
107 if(Charge_candidate_D == 0) {
108 if(abs(m_chargek) != 1) continue;
109 }
110 /////////////////////////////////////////
111 HepVector a1 = mdcKalTrk1->getZHelixK();
112 HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
113 VFHelix helixip3_1(point0,a1,Ea1);
114 helixip3_1.pivot(IP);
115 HepVector vecipa1 = helixip3_1.a();
116
117 double dr1 = fabs(vecipa1[0]);
118 double dz1 = fabs(vecipa1[3]);
119 double costheta1 = cos(mdcKalTrk1->theta());
120 if ( dr1 >= 1.0) continue;
121 if ( dz1 >= 10.0) continue;
122 if ( fabs(costheta1) >= 0.93) continue;
123 /////////////////////////////////////////
124 if(PID_flag == 5) {
125 simple_pid->preparePID(*itTrk);
126 if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;
127 }
128 /////////////////////////////////////////
129
130 WTrackParameter kam(xmass[3],mdcKalTrk1->getZHelixK(),mdcKalTrk1->getZErrorK() );
131
132 //
133 // select pi
134 //
135 for(int j = 0; j< evtRecEvent->totalCharged();j++) {
136 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
137
138 int ipi= (*itTrk)->trackId();
139 if(ipi==ika) continue;
140
141 if(!(*itTrk)->isMdcKalTrackValid()) continue;
142 RecMdcKalTrack* mdcKalTrk2 = (*itTrk)->mdcKalTrack();
144
145 /////////////////////////////////////////
146 m_chargepi=mdcKalTrk2->charge();
147 if((m_chargek + m_chargepi) != 0) continue;
148 /////////////////////////////////////////
149 HepVector a2 = mdcKalTrk2->getZHelix();
150 HepSymMatrix Ea2 = mdcKalTrk2->getZError();
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 simple_pid->preparePID(*itTrk);
164 if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;
165 }
166 /////////////////////////////////////////
167
168 WTrackParameter pip(xmass[2], mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
169
170 //////////////////////////////////////////////////////////////
171 HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
172 HepSymMatrix Evx(3, 0);
173 double bx = 1E+6; Evx[0][0] = bx*bx;
174 double by = 1E+6; Evx[1][1] = by*by;
175 double bz = 1E+6; Evx[2][2] = bz*bz;
176 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
177 //////////////////////////////////////////////////////////////
178
179 VertexFit* vtxfit = VertexFit::instance();
180 vtxfit->init();
181 vtxfit->AddTrack(0, kam);
182 vtxfit->AddTrack(1, pip);
183 vtxfit->AddVertex(0, vxpar, 0, 1);
184 if(!vtxfit->Fit(0)) continue;
185 vtxfit->Swim(0);
186
187 WTrackParameter wkam = vtxfit->wtrk(0);
188 WTrackParameter wpip = vtxfit->wtrk(1);
189
190 HepVector kam_val = HepVector(7,0);
191 kam_val = wkam.w();
192 HepVector pip_val = HepVector(7,0);
193 pip_val = wpip.w();
194
195 HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
196 HepLorentzVector P_PIP(pip_val[0],pip_val[1],pip_val[2],pip_val[3]);
197
198 P_KAM.boost(-0.011,0,0);
199 P_PIP.boost(-0.011,0,0);
200 pddd = P_KAM + P_PIP;
201
202 double pkpi=pddd.rho();
203
204 double temp1 = (ecms/2)*(ecms/2)-pkpi*pkpi;
205 if(temp1<0) temp1 =0;
206 double mass_bc_tem = sqrt(temp1);
207
208 if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
209
210 double delE_tag_tag = ecms/2-pddd.e();
211
212
213 if(fabs(delE_tag_tag)<deltaE_tem) {
214 deltaE_tem = fabs(delE_tag_tag);
215 delE_tag_temp = delE_tag_tag;
216 mass_bcgg = mass_bc_tem;
217
218 pddd_temp = pddd;
219 cqtm_temp = m_chargek;
220 ika_temp=ika;
221 ipi_temp=ipi;
222 ncount1 = 1;
223 }
224 }
225 }
226
227 if(ncount1 == 1){
228 tagmode = 11;
229 if(cqtm_temp<0) tagmode=-11;
230 tagmd = tagmode;
231 mass_bc = mass_bcgg;
232 delE_tag = delE_tag_temp;
233 cqtm = -1.0*cqtm_temp;
234
235 // cqtm = +1 for D0-->K-Pi+; cqtm = -1 for D0-bar-->K+Pi-;
236 // cqtm = 0 for D0-->K+K- ect. ...; cqtm = 0 means that we do not
237 // know whether it s D0 or D0-bar decays;
238
239 iGoodtag.push_back(ika_temp);
240 iGoodtag.push_back(ipi_temp);
241
242 iGamtag.push_back(9999);
243 iGamtag.push_back(9999);
244 iGamtag.push_back(9999);
245 iGamtag.push_back(9999);
246
247 ptag = pddd_temp;
248
249 kpimd = true;
250
251 }
252}
int runNo
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
const double xmass[5]
Definition: Gam4pikp.cxx:50
double cos(const BesAngle a)
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: Kpi.cxx:33
~Kpi()
Definition: Kpi.cxx:30
Kpi()
Definition: Kpi.cxx:27
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition: TrackPool.cxx:22
const HepPoint3D & pivot(void) const
returns pivot position.
const HepVector & a(void) const
returns helix parameters.
void init()
Definition: VertexFit.cxx:29
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
Definition: VertexFit.cxx:89
static VertexFit * instance()
Definition: VertexFit.cxx:15
bool Fit()
Definition: VertexFit.cxx:301
const double ecms
Definition: inclkstar.cxx:42