CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
Kpipi0.cxx
Go to the documentation of this file.
1//
2// Kpipi0.cxx is the single D0 tag code to reconstruct D0 or anti-D0 through the final states of
3// kpipi0 from D0 decays. Kpipi0.cxx was transfered from the Fortran routine "Kpipi0.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 "Kpipi0.f" used at the BES-II experiment was coded by G. Rong in 2003.
8//
9// Kpipi0.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/Kpipi0.h"
25
27{}
28
30{}
31
32
33void Kpipi0::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, iGam1_temp, iGam2_temp;
46 HepLorentzVector pddd, pddd_temp;
47
48 int cqtm_temp;
49 IDataProviderSvc* eventSvc = NULL;
50 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
51 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc,EventModel::EvtRec::EvtRecEvent);
52 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
53
54 int runNo=eventHeader->runNumber();
55 int rec=eventHeader->eventNumber();
56
57 double xecm=2*Ebeam;
58
59 kpipi0md=false;
60 double tagmode=0;
61
62 if((evtRecEvent->totalCharged() < 2||nGam<2)){ return; }
63
64 double ecms = xecm;
65
66 ISimplePIDSvc* simple_pid;
67 Gaudi::svcLocator()->service("SimplePIDSvc", simple_pid);
68
69 double deltaE_tem = 0.20;
70 int ncount1 = 0;
71
72 Hep3Vector xorigin(0,0,0);
73 IVertexDbSvc* vtxsvc;
74 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
75 if(vtxsvc->isVertexValid())
76 {
77 double* dbv = vtxsvc->PrimaryVertex();
78 double* vv = vtxsvc->SigmaPrimaryVertex();
79 xorigin.setX(dbv[0]);
80 xorigin.setY(dbv[1]);
81 xorigin.setZ(dbv[2]);
82 }
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, ptrk3_temp, ptrk4_temp, ptrk5_temp;
93 //////////////////////////////////////////////////////////////////
94 HepLorentzVector p2gfit;
95 HepLorentzVector p2gg;
96 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
97 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
98
99 int ika= (*itTrk)->trackId();
100
101 if(!(*itTrk)->isMdcKalTrackValid()) continue;
102 RecMdcKalTrack* mdcKalTrk1 = (*itTrk)->mdcKalTrack();
104 /////////////////////////////////////////
105 m_chargek=mdcKalTrk1->charge();
106 if(Charge_candidate_D != 0) {
107 if(m_chargek != -Charge_candidate_D) continue;
108 }
109 if(Charge_candidate_D == 0) {
110 if(abs(m_chargek) != 1) continue;
111 }
112 /////////////////////////////////////////
113 HepVector a1 = mdcKalTrk1->getZHelixK();
114 HepSymMatrix Ea1 = mdcKalTrk1->getZErrorK();
115 VFHelix helixip3_1(point0,a1,Ea1);
116 helixip3_1.pivot(IP);
117 HepVector vecipa1 = helixip3_1.a();
118
119 double dr1 = fabs(vecipa1[0]);
120 double dz1 = fabs(vecipa1[3]);
121 double costheta1 = cos(mdcKalTrk1->theta());
122 if ( dr1 >= 1.0) continue;
123 if ( dz1 >= 10.0) continue;
124 if ( fabs(costheta1) >= 0.93) continue;
125
126 /////////////////////////////////////////
127 if(PID_flag == 5) {
128 simple_pid->preparePID(*itTrk);
129 if(simple_pid->probKaon() < 0.0 || simple_pid->probKaon() < simple_pid->probPion()) continue;
130 }
131 /////////////////////////////////////////
132
133 WTrackParameter kam(xmass[3],mdcKalTrk1->getZHelixK(),mdcKalTrk1->getZErrorK() );
134
135 //
136 // select pi
137 //
138 for(int j = 0; j< evtRecEvent->totalCharged();j++) {
139 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + j;
140
141 int ipi= (*itTrk)->trackId();
142 if(ipi==ika) continue;
143
144 if(!(*itTrk)->isMdcKalTrackValid()) continue;
145 RecMdcKalTrack* mdcKalTrk2 = (*itTrk)->mdcKalTrack();
147 /////////////////////////////////////////
148 m_chargepi=mdcKalTrk2->charge();
149 if((m_chargek + m_chargepi) != 0) continue;
150 /////////////////////////////////////////
151 HepVector a2 = mdcKalTrk2->getZHelix();
152 HepSymMatrix Ea2 = mdcKalTrk2->getZError();
153 VFHelix helixip3_2(point0,a2,Ea2);
154 helixip3_2.pivot(IP);
155 HepVector vecipa2 = helixip3_2.a();
156
157 double dr2 = fabs(vecipa2[0]);
158 double dz2 = fabs(vecipa2[3]);
159 double costheta2 = cos(mdcKalTrk2->theta());
160 if ( dr2 >= 1.0) continue;
161 if ( dz2 >= 10.0) continue;
162 if ( fabs(costheta2) >= 0.93) continue;
163 /////////////////////////////////////////
164 if(PID_flag == 5) {
165 simple_pid->preparePID(*itTrk);
166 if(simple_pid->probPion() < 0.0 || simple_pid->probPion() < simple_pid->probKaon()) continue;
167 }
168 /////////////////////////////////////////
169
170 WTrackParameter pip(xmass[2],mdcKalTrk2->getZHelix(),mdcKalTrk2->getZError() );
171
172 for(int m = 0; m < nGam-1; m++) {
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 if(iGam[n]==-1) continue;
188 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[n]))->emcShower();
189 double eraw2 = g2Trk->energy();
190 double phi2 = g2Trk->phi();
191 double the2 = g2Trk->theta();
192 HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
193 ptrkg2.setPx(eraw2*sin(the2)*cos(phi2));
194 ptrkg2.setPy(eraw2*sin(the2)*sin(phi2));
195 ptrkg2.setPz(eraw2*cos(the2));
196 ptrkg2.setE(eraw2);
197 ptrkg20 = ptrkg2;
198 ptrkg22 = ptrkg2.boost(-0.011,0,0);
199
200 /////////////////////////////////////////////////////////////
201 HepLorentzVector ptrkpi0;
202 ptrkpi0 = ptrkg12+ptrkg22;
203 double m_xmpi0_tem = ptrkpi0.m();
204 if(m_xmpi0_tem>0.150||m_xmpi0_tem<0.115) continue;
205 /////////////////////////////////////////////////////////////
206 bool IsEndcap1 = false; bool IsEndcap2 = false;
207 if(fabs(cos(the1)) > 0.86 && fabs(cos(the1)) < 0.92) IsEndcap1 = true;
208 if(fabs(cos(the2)) > 0.86 && fabs(cos(the2)) < 0.92) IsEndcap2 = true;
209 if(IsEndcap1 && IsEndcap2) continue;
210 /////////////////////////////////////////////////////////////
212 kmfit->init();
213 kmfit->setChisqCut(2500);
214 kmfit->AddTrack(0, 0.0, g1Trk);
215 kmfit->AddTrack(1, 0.0, g2Trk);
216 kmfit->AddResonance(0, mpi0, 0, 1);
217
218 kmfit->Fit(0); // Perform fit
219 kmfit->BuildVirtualParticle(0);
220
221 double pi0_chisq = kmfit->chisq(0);
222 if ( pi0_chisq >= 2500) continue;
223 HepLorentzVector p2gfit = kmfit->pfit(0) + kmfit->pfit(1);
224 p2gfit.boost(-0.011,0,0);
225
226 ////////////////////////////////////////////////////////////////
227 HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
228 HepSymMatrix Evx(3, 0);
229 double bx = 1E+6; Evx[0][0] = bx*bx;
230 double by = 1E+6; Evx[1][1] = by*by;
231 double bz = 1E+6; Evx[2][2] = bz*bz;
232 VertexParameter vxpar; vxpar.setVx(vx); vxpar.setEvx(Evx);
233 //////////////////////////////////////////////////////////////
234
235 VertexFit* vtxfit = VertexFit::instance();
236 vtxfit->init();
237 vtxfit->AddTrack(0, kam);
238 vtxfit->AddTrack(1, pip);
239 vtxfit->AddVertex(0, vxpar, 0, 1);
240 if(!vtxfit->Fit(0)) continue;
241 vtxfit->Swim(0);
242
243 WTrackParameter wkam = vtxfit->wtrk(0);
244 WTrackParameter wpip = vtxfit->wtrk(1);
245
246 HepVector kam_val = HepVector(7,0);
247 kam_val = wkam.w();
248 HepVector pip_val = HepVector(7,0);
249 pip_val = wpip.w();
250
251 HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
252 HepLorentzVector P_PIP(pip_val[0],pip_val[1],pip_val[2],pip_val[3]);
253
254 P_KAM.boost(-0.011,0,0);
255 P_PIP.boost(-0.011,0,0);
256 pddd = P_KAM + P_PIP + p2gfit;
257
258 double pkpipi0=pddd.rho();
259
260 double temp1 = (ecms/2)*(ecms/2)-pkpipi0*pkpipi0 ;
261 if(temp1<0) temp1 =0;
262 double mass_bc_tem = sqrt(temp1);
263 if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
264
265 double delE_tag_tag = ecms/2-pddd.e();
266
267
268 if(fabs(delE_tag_tag)<deltaE_tem) {
269 deltaE_tem = fabs(delE_tag_tag);
270 delE_tag_temp = delE_tag_tag;
271 mass_bcgg = mass_bc_tem;
272
273 pddd_temp = pddd;
274 cqtm_temp = m_chargek;
275
276 ika_temp=ika;
277 ipi_temp=ipi;
278
279 iGam1_temp = iGam[m];
280 iGam2_temp = iGam[n];
281 ncount1 = 1;
282
283 }
284 }
285 }
286 }
287 }
288
289 if(ncount1 == 1){
290 tagmode=12;
291 if(cqtm_temp <0) tagmode=-12;
292 tagmd=tagmode;
293 mass_bc = mass_bcgg;
294 delE_tag = delE_tag_temp;
295 cqtm = -1.0*cqtm_temp;
296
297 iGoodtag.push_back(ipi_temp);
298 iGoodtag.push_back(ika_temp);
299
300 iGamtag.push_back(iGam1_temp);
301 iGamtag.push_back(iGam2_temp);
302 iGamtag.push_back(9999);
303 iGamtag.push_back(9999);
304
305 ptag = pddd_temp;
306
307 kpipi0md = true;
308
309 }
310}
311
312
313
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
const double mpi0
const Int_t n
Double_t phi2
Double_t phi1
int runNo
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
EvtRecTrackCol::iterator EvtRecTrackIterator
Definition: EvtRecTrack.h:131
const double xmass[5]
Definition: Gam4pikp.cxx:50
std::vector< int > Vint
Definition: Kpipi0.h:16
double theta() const
Definition: DstEmcShower.h:38
double phi() const
Definition: DstEmcShower.h:39
double energy() const
Definition: DstEmcShower.h:45
const double theta() const
static void setPidType(PidType pidType)
const int charge() const
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)
HepLorentzVector pfit(int n) const
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: Kpipi0.cxx:33
Kpipi0()
Definition: Kpipi0.cxx:26
~Kpipi0()
Definition: Kpipi0.cxx:29
const HepVector & getZHelix() const
HepVector & getZHelixK()
const HepSymMatrix & getZError() const
HepSymMatrix & getZErrorK()
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.
WTrackParameter wtrk(int n) const
Definition: VertexFit.h:78
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
void Swim(int n)
Definition: VertexFit.h:58
bool Fit()
Definition: VertexFit.cxx:301
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
HepVector w() const
const double ecms
Definition: inclkstar.cxx:42
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:134