23#include "SD0TagAlg/Kpipi0.h"
24#include "SD0TagAlg/SingleBase.h"
34 iGam,
double Ebeam,
int PID_flag,
int Charge_candidate_D)
37 int nGood=iGood.size();
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;
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() < 2||nGam<2)){
return; }
67 Gaudi::svcLocator()->service(
"SimplePIDSvc", simple_pid);
69 double deltaE_tem = 0.20;
72 Hep3Vector xorigin(0,0,0);
74 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
85 double xv=xorigin.x();
86 double yv=xorigin.y();
87 double zv=xorigin.z();
90 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
92 HepLorentzVector ptrk1_temp, ptrk2_temp, ptrk3_temp, ptrk4_temp, ptrk5_temp;
94 HepLorentzVector p2gfit;
95 HepLorentzVector p2gg;
96 for(
int i = 0; i < evtRecEvent->totalCharged(); i++) {
99 int ika= (*itTrk)->trackId();
101 if(!(*itTrk)->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 ipi= (*itTrk)->trackId();
142 if(ipi==ika)
continue;
144 if(!(*itTrk)->isMdcKalTrackValid())
continue;
148 m_chargepi=mdcKalTrk2->
charge();
149 if((m_chargek + m_chargepi) != 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;
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();
177 double the1 = g1Trk->
theta();
178 HepLorentzVector ptrkg1,ptrkg10,ptrkg12;
181 ptrkg1.setPz(eraw1*
cos(the1));
184 ptrkg12 = ptrkg1.boost(-0.011,0,0);
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();
191 double the2 = g2Trk->
theta();
192 HepLorentzVector ptrkg2,ptrkg20,ptrkg22;
195 ptrkg2.setPz(eraw2*
cos(the2));
198 ptrkg22 = ptrkg2.boost(-0.011,0,0);
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;
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;
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);
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;
240 if(!vtxfit->
Fit(0))
continue;
246 HepVector kam_val = HepVector(7,0);
248 HepVector pip_val = HepVector(7,0);
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]);
254 P_KAM.boost(-0.011,0,0);
255 P_PIP.boost(-0.011,0,0);
256 pddd = P_KAM + P_PIP + p2gfit;
258 double pkpipi0=pddd.rho();
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;
265 double delE_tag_tag =
ecms/2-pddd.e();
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;
274 cqtm_temp = m_chargek;
279 iGam1_temp = iGam[m];
280 iGam2_temp = iGam[
n];
291 if(cqtm_temp <0) tagmode=-12;
294 delE_tag = delE_tag_temp;
295 cqtm = -1.0*cqtm_temp;
297 iGoodtag.push_back(ipi_temp);
298 iGoodtag.push_back(ika_temp);
300 iGamtag.push_back(iGam1_temp);
301 iGamtag.push_back(iGam2_temp);
302 iGamtag.push_back(9999);
303 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 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)
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