36{
37
38 int nGood=iGood.size();
39 int nGam=iGam.size();
40
41 iGoodtag.clear();
42 iGamtag.clear();
43
44 double mass_bcgg,delE_tag_temp;
45 int m_chargetag,m_chargepi1,m_chargepi2;
46 int ika_temp,ipi1_temp,ipi2_temp,ipi3_temp, iGam1_temp, iGam2_temp;
47 HepLorentzVector pddd;
48 HepLorentzVector pddd_temp;
49
50 IDataProviderSvc* eventSvc = NULL;
51 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
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 k0pi0md=false;
61 double tagmode=0;
62
63 if((evtRecEvent->totalCharged() < 2||nGam<2)){ return; }
64
66
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 HepSymMatrix xoriginEx(3,0);
76 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
78 {
81 xorigin.setX(dbv[0]);
82 xorigin.setY(dbv[1]);
83 xorigin.setZ(dbv[2]);
84
85 xoriginEx[0][0] = vv[0] * vv[0];
86 xoriginEx[1][1] = vv[1] * vv[1];
87 xoriginEx[2][2] = vv[2] * vv[2];
88
89 }
90
91 double xv=xorigin.x();
92 double yv=xorigin.y();
93 double zv=xorigin.z();
94
96 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
97
98 HepLorentzVector p2gfit;
99 HepLorentzVector p2gg;
100
101 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
103
104 int ipi1= (*itTrk)->trackId();
105
106 if(!(*itTrk)->isMdcKalTrackValid()) continue;
109
110 m_chargepi1=mdcKalTrk1->
charge();
111 if(m_chargepi1 != 1) continue;
112
113
115 HepSymMatrix Ea1 = mdcKalTrk1->
getZError();
116
117 VFHelix helixip3_1(point0,a1,Ea1);
118 helixip3_1.pivot(IP);
119 HepVector vecipa1 = helixip3_1.a();
120
121 double dr1 = fabs(vecipa1[0]);
122 double dz1 = fabs(vecipa1[3]);
123 double costheta1 =
cos(mdcKalTrk1->
theta());
124
125 if ( dr1 >= 15.0) continue;
126 if ( dz1 >= 25.0) continue;
127 if ( fabs(costheta1) >= 0.93) continue;
128
130
131
132
133
134 for(int j = 0; j < evtRecEvent->totalCharged();j++) {
136
137 int ipi2= (*itTrk)->trackId();
138 if(ipi1==ipi2) continue;
139
140 if(!(*itTrk)->isMdcKalTrackValid()) continue;
143
144 m_chargepi2=mdcKalTrk2->
charge();
145 if((m_chargepi1 + m_chargepi2) != 0) continue;
146
147
149 HepSymMatrix Ea2 = mdcKalTrk2->
getZError();
150 VFHelix helixip3_2(point0,a2,Ea2);
151 helixip3_2.pivot(IP);
152 HepVector vecipa2 = helixip3_2.a();
153
154 double dr2 = fabs(vecipa2[0]);
155 double dz2 = fabs(vecipa2[3]);
156 double costheta2 =
cos(mdcKalTrk2->
theta());
157 if ( dr2 >= 15.0) continue;
158 if ( dz2 >= 25.0) continue;
159 if ( fabs(costheta2) >= 0.93) continue;
160
162
163 HepVector pip_val = HepVector(7,0);
164 HepVector pim_val = HepVector(7,0);
165 pip_val = pip.w();
166 pim_val = pim.w();
167 HepLorentzVector ptrktagk0(pip_val[0]+pim_val[0],pip_val[1]+pim_val[1],pip_val[2]+pim_val[2],pip_val[3]+pim_val[3]);
168 double m_xmtagk0_tem = ptrktagk0.mag();
169 if(fabs(ptrktagk0.m()-0.498)>0.1) continue;
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;
177
183 if(!(vtxfit0->
Fit(0)))
continue;
190
197 if(!vtxfit->
Fit())
continue;
198
199 if(vtxfit->
chisq() > 999.)
continue;
201
202 double m_massks1_tem = vtxfit->
p4par().m();
203 if(m_massks1_tem < 0.485 || m_massks1_tem > 0.515) continue;
204 HepLorentzVector p4kstag = vtxfit->
p4par();
205 p4kstag.boost(-0.011,0,0);
207
208 for(int m = 0; m < nGam-1; m++) {
209 if(iGam[m]==-1) continue;
210 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[m]))->emcShower();
211 double eraw1 = g1Trk->
energy();
212 double phi1 = g1Trk->
phi();
213 double the1 = g1Trk->
theta();
214 HepLorentzVector ptrkg1,ptrkg10,ptrkg12;
215 ptrkg1.setPx(eraw1*
sin(the1)*
cos(phi1));
216 ptrkg1.setPy(eraw1*
sin(the1)*
sin(phi1));
217 ptrkg1.setPz(eraw1*
cos(the1));
218 ptrkg1.setE(eraw1);
219 ptrkg10 = ptrkg1;
220 ptrkg12 = ptrkg1.boost(-0.011,0,0);
221
222 for(int n = m+1; n < nGam; n++) {
223 if(iGam[n]==-1) continue;
224 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[n]))->emcShower();
225 double eraw2 = g2Trk->
energy();
226 double phi2 = g2Trk->
phi();
227 double the2 = g2Trk->
theta();
228 HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
229 ptrkg2.setPx(eraw2*
sin(the2)*
cos(phi2));
230 ptrkg2.setPy(eraw2*
sin(the2)*
sin(phi2));
231 ptrkg2.setPz(eraw2*
cos(the2));
232 ptrkg2.setE(eraw2);
233 ptrkg20 = ptrkg2;
234 ptrkg22 = ptrkg2.boost(-0.011,0,0);
235
236
237 HepLorentzVector ptrkpi0;
238 ptrkpi0 = ptrkg12+ptrkg22;
239 double m_xmpi0_tem = ptrkpi0.m();
240 if(m_xmpi0_tem>0.150||m_xmpi0_tem<0.115) continue;
241
242 bool IsEndcap1 = false; bool IsEndcap2 = false;
243 if(fabs(
cos(the1)) > 0.86 && fabs(
cos(the1)) < 0.92) IsEndcap1 =
true;
244 if(fabs(
cos(the2)) > 0.86 && fabs(
cos(the2)) < 0.92) IsEndcap2 =
true;
245 if(IsEndcap1 && IsEndcap2) continue;
246
253
256
257 double pi0_chisq = kmfit->
chisq(0);
258 if ( pi0_chisq >= 2500) continue;
259 HepLorentzVector p2gfit = kmfit->
pfit(0) + kmfit->
pfit(1);
260 p2gfit.boost(-0.011,0,0);
261
262
263 HepVector ksp_val = HepVector(7,0);
264 HepVector ksm_val = HepVector(7,0);
267
268 HepLorentzVector P_KSP(ksp_val[0],ksp_val[1],ksp_val[2],ksp_val[3]);
269 HepLorentzVector P_KSM(ksm_val[0],ksm_val[1],ksm_val[2],ksm_val[3]);
270
271 P_KSP.boost(-0.011,0,0);
272 P_KSM.boost(-0.011,0,0);
273 pddd = p4kstag + p2gfit;
274
275 double pk0pi0=pddd.rho();
276
277 double temp1 = (
ecms/2)*(
ecms/2)-pk0pi0*pk0pi0 ;
278 if(temp1<0) temp1 =0;
279 double mass_bc_tem = sqrt(temp1);
280 if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89) continue;
281
282 double delE_tag_tag =
ecms/2-pddd.e();
283
284 if(fabs(delE_tag_tag)<deltaE_tem){
285 deltaE_tem = fabs(delE_tag_tag);
286 delE_tag_temp = delE_tag_tag;
287 mass_bcgg = mass_bc_tem;
288
289 pddd_temp = pddd;
290
291 ipi1_temp=ipi1;
292 ipi2_temp=ipi2;
293
294 iGam1_temp = iGam[m];
295 iGam2_temp = iGam[n];
296
297 ncount1 = 1;
298 }
299 }
300 }
301 }
302 }
303
304 if(ncount1 == 1){
305 tagmode=18;
306 if(m_chargetag<0) tagmode=-18;
307 tagmd=tagmode;
308 mass_bc = mass_bcgg;
309 delE_tag = delE_tag_temp;
310 cqtm = 0.0;
311
312 iGoodtag.push_back(ipi1_temp);
313 iGoodtag.push_back(ipi2_temp);
314 iGamtag.push_back(iGam1_temp);
315 iGamtag.push_back(iGam2_temp);
316 iGamtag.push_back(9999);
317 iGamtag.push_back(9999);
318
319 ptag = pddd_temp;
320
321 k0pi0md = true;
322
323 }
324}
double sin(const BesAngle a)
double cos(const BesAngle a)
EvtRecTrackCol::iterator EvtRecTrackIterator
const double theta() const
static void setPidType(PidType pidType)
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()
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
HepLorentzVector p4par() const
void setPrimaryVertex(const VertexParameter vpar)
double decayLength() const
static SecondVertexFit * instance()
void setVpar(const VertexParameter vpar)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
WTrackParameter wtrk(int n) const
WTrackParameter wVirtualTrack(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
static VertexFit * instance()
VertexParameter vpar(int n) const
void BuildVirtualParticle(int number)
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
_EXTERN_ std::string EvtRecEvent