3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/PropertyMgr.h"
9#include "GaudiKernel/Bootstrap.h"
10#include "GaudiKernel/ISvcLocator.h"
12#include "GaudiKernel/INTupleSvc.h"
13#include "GaudiKernel/NTuple.h"
14#include "GaudiKernel/ITHistSvc.h"
17#include "EventModel/EventModel.h"
18#include "EventModel/Event.h"
20#include "EvtRecEvent/EvtRecEvent.h"
21#include "EvtRecEvent/EvtRecTrack.h"
22#include "DstEvent/TofHitStatus.h"
23#include "EventModel/EventHeader.h"
27#include "CLHEP/Vector/ThreeVector.h"
28#include "CLHEP/Vector/LorentzVector.h"
29#include "CLHEP/Vector/TwoVector.h"
31using CLHEP::Hep3Vector;
32using CLHEP::Hep2Vector;
33using CLHEP::HepLorentzVector;
34#include "CLHEP/Geometry/Point3D.h"
36#include "VertexFit/IVertexDbSvc.h"
37#include "VertexFit/KinematicFit.h"
38#include "VertexFit/VertexFit.h"
39#include "VertexFit/SecondVertexFit.h"
40#include "ParticleID/ParticleID.h"
43#include "JsiLL/JsiLL.h"
45#ifndef ENABLE_BACKWARDS_COMPATIBILITY
48using CLHEP::HepLorentzVector;
50const double mpi = 0.13957;
51const double mk = 0.493677;
53const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
54const double velc = 299.792458;
55typedef std::vector<int>
Vint;
56typedef std::vector<HepLorentzVector>
Vp4;
61 Algorithm(name, pSvcLocator) {
64 declareProperty(
"Vr0cut", m_vr0cut=5.0);
65 declareProperty(
"Vz0cut", m_vz0cut=20.0);
66 declareProperty(
"Vr1cut", m_vr1cut=1.0);
67 declareProperty(
"Vz1cut", m_vz1cut=5.0);
68 declareProperty(
"Vctcut", m_cthcut=0.93);
69 declareProperty(
"EnergyThreshold", m_energyThreshold=0.04);
70 declareProperty(
"GammaAngCut", m_gammaAngCut=20.0);
76 MsgStream log(
msgSvc(), name());
78 log << MSG::INFO <<
"in initialize()" << endmsg;
84 NTuplePtr nt(
ntupleSvc(),
"DQAFILE/JsiLL");
85 if ( nt ) m_tuple = nt;
87 m_tuple =
ntupleSvc()->book(
"DQAFILE/JsiLL", CLID_ColumnWiseTuple,
"JsiLL ntuple");
89 status = m_tuple->addItem(
"runNo", m_runNo);
90 status = m_tuple->addItem(
"event", m_event);
91 status = m_tuple->addItem(
"chisq", m_chisq);
92 status = m_tuple->addItem(
"mLambda", m_mLambda);
93 status = m_tuple->addItem(
"mLambdabar", m_mLambdabar);
94 status = m_tuple->addItem(
"pLambda", m_pLambda);
95 status = m_tuple->addItem(
"pLambdabar", m_pLambdabar);
98 log << MSG::ERROR <<
"Can not book N-tuple:" << long(m_tuple) << endreq;
102 if(service(
"THistSvc", m_thsvc).isFailure()) {
103 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
104 return StatusCode::FAILURE;
109 TH1F* hrxy =
new TH1F(
"Rxy",
"Rxy distribution", 110, -1., 10.);
110 if(m_thsvc->regHist(
"/DQAHist/JsiLL/hrxy", hrxy).isFailure()) {
111 log << MSG::ERROR <<
"Couldn't register Rxy" << endreq;
113 TH1F* hz =
new TH1F(
"z",
"z distribution", 200, -100., 100.);
114 if(m_thsvc->regHist(
"/DQAHist/JsiLL/hz", hz).isFailure()) {
115 log << MSG::ERROR <<
"Couldn't register z" << endreq;
118 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
119 return StatusCode::SUCCESS;
127 MsgStream log(
msgSvc(), name());
128 log << MSG::INFO <<
"in execute()" << endreq;
133 setFilterPassed(
false);
135 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
136 m_runNo=eventHeader->runNumber();
137 m_event=eventHeader->eventNumber();
138 log << MSG::DEBUG <<
"run, evtnum = "
144 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
145 << evtRecEvent->totalCharged() <<
" , "
146 << evtRecEvent->totalNeutral() <<
" , "
147 << evtRecEvent->totalTracks() <<endreq;
151 if(evtRecEvent->totalNeutral()>100) {
152 return StatusCode::SUCCESS;
155 Vint iGood, iplus, iminus;
163 Hep3Vector xorigin(0,0,0);
166 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
170 xorigin.setX(dbv[0]);
171 xorigin.setY(dbv[1]);
172 xorigin.setZ(dbv[2]);
176 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
178 if(!(*itTrk)->isMdcTrackValid())
continue;
179 if (!(*itTrk)->isMdcKalTrackValid())
continue;
182 double pch =mdcTrk->
p();
183 double x0 =mdcTrk->
x();
184 double y0 =mdcTrk->
y();
185 double z0 =mdcTrk->
z();
186 double phi0=mdcTrk->
helix(1);
187 double xv=xorigin.x();
188 double yv=xorigin.y();
189 double Rxy=fabs((x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0));
191 if(fabs(z0) >= m_vz0cut)
continue;
192 if(Rxy >= m_vr0cut)
continue;
197 if (m_thsvc->getHist(
"/DQAHist/JsiLL/hrxy", h).isSuccess()) {
200 log << MSG::ERROR <<
"Couldn't retrieve hrxy" << endreq;
202 if (m_thsvc->getHist(
"/DQAHist/JsiLL/hz", h).isSuccess()) {
205 log << MSG::ERROR <<
"Couldn't retrieve hz" << endreq;
210 nCharge += mdcTrk->
charge();
211 if (mdcTrk->
charge() > 0) {
221 int nGood = iGood.size();
222 log << MSG::DEBUG <<
"ngood, totcharge = " << nGood <<
" , " << nCharge << endreq;
223 if((nGood != 4)||(nCharge!=0)){
224 return StatusCode::SUCCESS;
234 int pidp0 = 5, pidp1 = 3, pidm0 = 5, pidm1 = 3;
236 RecMdcKalTrack *itTrkp = (*(evtRecTrkCol->begin() + iplus[0]))->mdcKalTrack();
237 RecMdcKalTrack *itTrkpip = (*(evtRecTrkCol->begin() + iplus[1]))->mdcKalTrack();
238 RecMdcKalTrack *itTrkpb = (*(evtRecTrkCol->begin() + iminus[0]))->mdcKalTrack();
239 RecMdcKalTrack *itTrkpim = (*(evtRecTrkCol->begin() + iminus[1]))->mdcKalTrack();
242 double tmppp, tmpppb, tmpppip, tmpppim;
243 tmppp = sqrt(itTrkp->
px()*itTrkp->
px() + itTrkp->
py()*itTrkp->
py() + itTrkp->
pz()*itTrkp->
pz());
244 tmpppb = sqrt(itTrkpb->
px()*itTrkpb->
px() + itTrkpb->
py()*itTrkpb->
py() + itTrkpb->
pz()*itTrkpb->
pz());
245 tmpppip = sqrt(itTrkpip->
px()*itTrkpip->
px() + itTrkpip->
py()*itTrkpip->
py() + itTrkpip->
pz()*itTrkpip->
pz());
246 tmpppim = sqrt(itTrkpim->
px()*itTrkpim->
px() + itTrkpim->
py()*itTrkpim->
py() + itTrkpim->
pz()*itTrkpim->
pz());
249 if ( tmppp < tmpppip ) {
250 itTrkp = (*(evtRecTrkCol->begin() + iplus[1]))->mdcKalTrack();
251 itTrkpip = (*(evtRecTrkCol->begin() + iplus[0]))->mdcKalTrack();
259 if ( tmpppb < tmpppim ) {
260 itTrkpb = (*(evtRecTrkCol->begin() + iminus[1]))->mdcKalTrack();
261 itTrkpim = (*(evtRecTrkCol->begin() + iminus[0]))->mdcKalTrack();
270 if ( tmppp < 0.7 || tmppp >1.1)
return StatusCode::SUCCESS;
271 if ( tmpppb < 0.7 || tmpppb >1.1)
return StatusCode::SUCCESS;
272 if ( tmpppip > 0.35)
return StatusCode::SUCCESS;
273 if ( tmpppim > 0.35)
return StatusCode::SUCCESS;
286 HepSymMatrix Evx(3, 0);
313 if(!vtxfita0->
Fit(0))
return StatusCode::SUCCESS;
319 if(!vtxfita->
Fit())
return StatusCode::SUCCESS;
327 if(!vtxfitb0->
Fit(0))
return StatusCode::SUCCESS;
334 if(!vtxfitb->
Fit())
return StatusCode::SUCCESS;
342 if(!vtxfit->
Fit(0))
return StatusCode::SUCCESS;
353 HepLorentzVector
ecms(0.034065,0.0,0.0,3.0969);
354 const Hep3Vector
u_cms = -
ecms.boostVector();
361 if(!kmfit->
Fit())
return StatusCode::SUCCESS;
362 m_chisq = kmfit->
chisq();
363 if(m_chisq > 50)
return StatusCode::SUCCESS;
364 HepLorentzVector kmf_pLambda = kmfit->
pfit(0);
365 HepLorentzVector kmf_pLambdabar = kmfit->
pfit(1);
367 kmf_pLambda.boost(
u_cms);
368 kmf_pLambdabar.boost(
u_cms);
369 m_mLambda = kmf_pLambda.m();
370 m_mLambdabar = kmf_pLambdabar.m();
371 m_pLambda = kmf_pLambda.rho();
372 m_pLambdabar = kmf_pLambdabar.rho();
374 if(fabs(m_mLambda-1.1157)>0.003||fabs(m_mLambdabar-1.1157)>0.003)
return StatusCode::SUCCESS;
385 (*(evtRecTrkCol->begin()+iplus[0]))->setPartId(pidp0);
386 (*(evtRecTrkCol->begin()+iplus[1]))->setPartId(pidp1);
387 (*(evtRecTrkCol->begin()+iminus[0]))->setPartId(pidm0);
388 (*(evtRecTrkCol->begin()+iminus[1]))->setPartId(pidm1);
394 (*(evtRecTrkCol->begin()+iplus[0]))->setQuality(0);
395 (*(evtRecTrkCol->begin()+iplus[1]))->setQuality(0);
396 (*(evtRecTrkCol->begin()+iminus[0]))->setQuality(0);
397 (*(evtRecTrkCol->begin()+iminus[1]))->setQuality(0);
402 setFilterPassed(
true);
405 return StatusCode::SUCCESS;
412 MsgStream log(
msgSvc(), name());
413 log << MSG::INFO <<
"in finalize()" << endmsg;
414 return StatusCode::SUCCESS;
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
double sin(const BesAngle a)
double cos(const BesAngle a)
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
static void setPidType(PidType pidType)
const HepVector helix() const
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
JsiLL(const std::string &name, ISvcLocator *pSvcLocator)
static KinematicFit * instance()
void AddFourMomentum(int number, HepLorentzVector p4)
HepLorentzVector pfit(int n) const
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
HepSymMatrix & getZErrorP()
static SecondVertexFit * instance()
void setVpar(const VertexParameter vpar)
WTrackParameter wpar() const
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
_EXTERN_ std::string EvtRecTrackCol