23#include "SD0TagAlg/K3pipi0.h"
24#include "SD0TagAlg/SingleBase.h"
34 iGam,
double Ebeam,
int PID_flag,
int Charge_candidate_D)
37 int nGood=iGood.size();
42 double mass_bcgg, delE_tag_temp;
43 int m_chargetag,m_chargek,m_chargepi1,m_chargepi2,m_chargepi3;
44 int ika_temp,ipi1_temp,ipi2_temp,ipi3_temp,ipi4_temp, iGam1_temp, iGam2_temp;
45 HepLorentzVector kmfit1,kmfit2,kmfit3,kmfit4,pddd;
48 HepLorentzVector pddd_temp;
49 IDataProviderSvc* eventSvc = NULL;
50 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
52 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
54 int runNo=eventHeader->runNumber();
55 int rec=eventHeader->eventNumber();
62 if((evtRecEvent->totalCharged() < 4 || nGam <2)){
return; }
67 Gaudi::svcLocator()->service(
"SimplePIDSvc", simple_pid);
69 double deltaE_tem = 0.20;
72 HepLorentzVector p2gfit;
73 HepLorentzVector p2gg;
75 Hep3Vector xorigin(0,0,0);
77 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
87 double xv=xorigin.x();
88 double yv=xorigin.y();
89 double zv=xorigin.z();
92 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
94 HepLorentzVector ptrk1_temp, ptrk2_temp, ptrk3_temp, ptrk4_temp, ptrk5_temp, ptrk6_temp, ptrk7_temp;
96 for(
int i = 0; i < evtRecEvent->totalCharged(); i++) {
99 int ika= (*itTrk1)->trackId();
101 if(!(*itTrk1)->isMdcKalTrackValid())
continue;
105 m_chargek=mdcKalTrk1->
charge();
106 if(Charge_candidate_D != 0) {
107 if(m_chargek != -Charge_candidate_D)
continue;
109 if(Charge_candidate_D == 0) {
110 if(
abs(m_chargek) != 1)
continue;
115 VFHelix helixip3_1(point0,a1,Ea1);
116 helixip3_1.
pivot(IP);
117 HepVector vecipa1 = helixip3_1.
a();
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;
138 for(
int j = 0; j< evtRecEvent->totalCharged();j++) {
141 int ipi1= (*itTrk2)->trackId();
142 if(ipi1==ika)
continue;
144 if(!(*itTrk2)->isMdcKalTrackValid())
continue;
148 m_chargepi1=mdcKalTrk2->
charge();
149 if((m_chargek + m_chargepi1) != 0)
continue;
152 HepSymMatrix Ea2 = mdcKalTrk2->
getZError();
153 VFHelix helixip3_2(point0,a2,Ea2);
154 helixip3_2.
pivot(IP);
155 HepVector vecipa2 = helixip3_2.
a();
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;
174 for(
int k = 0; k< evtRecEvent->totalCharged(); k++) {
177 int ipi2= (*itTrk3)->trackId();
178 if(ipi2==ika || ipi2==ipi1)
continue;
180 if(!(*itTrk3)->isMdcKalTrackValid())
continue;
184 m_chargepi2=mdcKalTrk3->
charge();
185 if((m_chargek + m_chargepi2) != 0)
continue;
188 HepSymMatrix Ea3 = mdcKalTrk3->
getZError();
189 VFHelix helixip3_3(point0,a3,Ea3);
190 helixip3_3.
pivot(IP);
191 HepVector vecipa3 = helixip3_3.
a();
193 double dr3 = fabs(vecipa3[0]);
194 double dz3 = fabs(vecipa3[3]);
195 double costheta3 =
cos(mdcKalTrk3->
theta());
196 if ( dr3 >= 1.0)
continue;
197 if ( dz3 >= 10.0)
continue;
198 if ( fabs(costheta3) >= 0.93)
continue;
210 for(
int l = 0; l< evtRecEvent->totalCharged();l++) {
213 int ipi3= (*itTrk4)->trackId();
214 if(ipi3==ika || ipi3==ipi1 || ipi3==ipi2 )
continue;
216 if(!(*itTrk4)->isMdcKalTrackValid())
continue;
220 m_chargepi3=mdcKalTrk4->
charge();
221 if((m_chargepi2 + m_chargepi3) != 0)
continue;
224 HepSymMatrix Ea4 = mdcKalTrk4->
getZError();
225 VFHelix helixip3_4(point0,a4,Ea4);
226 helixip3_4.
pivot(IP);
227 HepVector vecipa4 = helixip3_4.
a();
229 double dr4 = fabs(vecipa4[0]);
230 double dz4 = fabs(vecipa4[3]);
231 double costheta4 =
cos(mdcKalTrk4->
theta());
232 if ( dr4 >= 1.0)
continue;
233 if ( dz4 >= 10.0)
continue;
234 if ( fabs(costheta4) >= 0.93)
continue;
244 for(
int m = 0; m < nGam-1; m++) {
245 if(iGam[m]==-1)
continue;
246 RecEmcShower *g1Trk =(*(evtRecTrkCol->begin()+iGam[m]))->emcShower();
247 double eraw1 = g1Trk->
energy();
249 double the1 = g1Trk->
theta();
250 HepLorentzVector ptrkg1,ptrkg10,ptrkg12;
253 ptrkg1.setPz(eraw1*
cos(the1));
256 ptrkg12 = ptrkg1.boost(-0.011,0,0);
258 for(
int n = m+1;
n < nGam;
n++) {
259 if(iGam[
n]==-1)
continue;
260 RecEmcShower *g2Trk =(*(evtRecTrkCol->begin()+iGam[
n]))->emcShower();
261 double eraw2 = g2Trk->
energy();
263 double the2 = g2Trk->
theta();
264 HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
267 ptrkg2.setPz(eraw2*
cos(the2));
270 ptrkg22 = ptrkg2.boost(-0.011,0,0);
273 HepLorentzVector ptrkpi0;
274 ptrkpi0 = ptrkg12+ptrkg22;
275 double m_xmpi0_tem = ptrkpi0.mag();
276 if(m_xmpi0_tem>0.150||m_xmpi0_tem<0.115)
continue;
278 bool IsEndcap1 =
false;
bool IsEndcap2 =
false;
279 if(fabs(
cos(the1)) > 0.86 && fabs(
cos(the1)) < 0.92) IsEndcap1 =
true;
280 if(fabs(
cos(the2)) > 0.86 && fabs(
cos(the2)) < 0.92) IsEndcap2 =
true;
281 if(IsEndcap1 && IsEndcap2)
continue;
294 double pi0_chisq = kmfit->
chisq(0);
295 if ( pi0_chisq >= 2500)
continue;
296 HepLorentzVector p2gfit = kmfit->
pfit(0) + kmfit->
pfit(1);
297 p2gfit.boost(-0.011,0,0);
300 HepPoint3D vx(xorigin.x(), xorigin.y(), xorigin.z());
301 HepSymMatrix Evx(3, 0);
302 double bx = 1E+6; Evx[0][0] = bx*bx;
303 double by = 1E+6; Evx[1][1] = by*by;
304 double bz = 1E+6; Evx[2][2] = bz*bz;
315 if(!vtxfit->
Fit(0))
continue;
323 HepVector kam_val = HepVector(7,0);
324 HepVector pip1_val = HepVector(7,0);
325 HepVector pip2_val = HepVector(7,0);
326 HepVector pip3_val = HepVector(7,0);
328 pip1_val = wpip1.
w();
329 pip2_val = wpip2.
w();
330 pip3_val = wpip3.
w();
332 HepLorentzVector P_KAM(kam_val[0],kam_val[1],kam_val[2],kam_val[3]);
333 HepLorentzVector P_PIP1(pip1_val[0],pip1_val[1],pip1_val[2],pip1_val[3]);
334 HepLorentzVector P_PIP2(pip2_val[0],pip2_val[1],pip2_val[2],pip2_val[3]);
335 HepLorentzVector P_PIP3(pip3_val[0],pip3_val[1],pip3_val[2],pip3_val[3]);
337 P_KAM.boost(-0.011,0,0);
338 P_PIP1.boost(-0.011,0,0);
339 P_PIP2.boost(-0.011,0,0);
340 P_PIP3.boost(-0.011,0,0);
341 pddd = P_KAM + P_PIP1 + P_PIP2 + P_PIP3 + p2gfit;
343 double pk3pipi0=pddd.rho();
345 double temp1 = (
ecms/2)*(
ecms/2)-pk3pipi0*pk3pipi0 ;
346 if(temp1<0) temp1 =0;
347 double mass_bc_tem = sqrt(temp1);
348 if(mass_bc_tem < 1.82 || mass_bc_tem > 1.89)
continue;
350 double delE_tag_tag =
ecms/2-pddd.e();
352 if(fabs(delE_tag_tag)<deltaE_tem) {
353 deltaE_tem = fabs(delE_tag_tag);
354 delE_tag_temp = delE_tag_tag;
355 mass_bcgg = mass_bc_tem;
358 cqtm_temp = m_chargek;
364 iGam1_temp = iGam[m];
365 iGam2_temp = iGam[
n];
379 if(cqtm_temp<0) tagmode=-24;
382 delE_tag = delE_tag_temp;
383 cqtm = -1.0*cqtm_temp;
385 iGoodtag.push_back(ika_temp);
386 iGoodtag.push_back(ipi1_temp);
387 iGoodtag.push_back(ipi2_temp);
388 iGoodtag.push_back(ipi3_temp);
390 iGamtag.push_back(iGam1_temp);
391 iGamtag.push_back(iGam2_temp);
392 iGamtag.push_back(9999);
393 iGamtag.push_back(9999);
EvtRecTrackCol::iterator EvtRecTrackIterator
double sin(const BesAngle a)
double cos(const BesAngle a)
const double theta() const
static void setPidType(PidType pidType)
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)
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
HepSymMatrix & getZErrorK()
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
const HepPoint3D & pivot(void) const
returns pivot position.
const HepVector & a(void) const
returns helix parameters.
WTrackParameter wtrk(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
static VertexFit * instance()
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
_EXTERN_ std::string EvtRecEvent