1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
7#include "GaudiKernel/Bootstrap.h"
9#include "GaudiKernel/INTupleSvc.h"
10#include "GaudiKernel/NTuple.h"
11#include "GaudiKernel/ITHistSvc.h"
23#include "CLHEP/Vector/ThreeVector.h"
24#include "CLHEP/Vector/LorentzVector.h"
25#include "CLHEP/Vector/TwoVector.h"
27using CLHEP::Hep3Vector;
28using CLHEP::Hep2Vector;
29using CLHEP::HepLorentzVector;
30#include "CLHEP/Geometry/Point3D.h"
31#ifndef ENABLE_BACKWARDS_COMPATIBILITY
46const double mk0 = 0.497648;
47const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
50typedef std::vector<int>
Vint;
51typedef std::vector<HepLorentzVector>
Vp4;
62 Algorithm(name, pSvcLocator) {
65 for(
int i = 0; i < 10; i++) m_pass[i] = 0;
68 declareProperty(
"Vr0cut", m_vr0cut=10.0);
69 declareProperty(
"Vz0cut", m_vz0cut=50.0);
70 declareProperty(
"CheckDedx", m_checkDedx = 1);
71 declareProperty(
"CheckTof", m_checkTof = 1);
76 MsgStream log(
msgSvc(), name());
78 log << MSG::INFO <<
"in initialize()" << endmsg;
82 if(service(
"THistSvc", m_thsvc).isFailure()) {
83 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
84 return StatusCode::FAILURE;
87 TH1F* inclks_mass =
new TH1F(
"InclKs_mass",
"INCLUSIVE_Ks_MASS",70,0.46,0.53);
88 inclks_mass->GetXaxis()->SetTitle(
"M_{#pi#pi} (GeV)");
89 inclks_mass->GetYaxis()->SetTitle(
"Nentries/0.1MeV/c^{2}");
90 if(m_thsvc->regHist(
"/DQAHist/InclKs/InclKs_mass", inclks_mass).isFailure()) {
91 log << MSG::ERROR <<
"Couldn't register inclks_mass" << endreq;
96 NTuplePtr nt1(
ntupleSvc(),
"DQAFILE/InclKs");
97 if ( nt1 ) m_tuple1 = nt1;
99 m_tuple1 =
ntupleSvc()->book (
"DQAFILE/InclKs", CLID_ColumnWiseTuple,
"ksklx Ntuple");
101 status = m_tuple1->addItem (
"npip", m_npip);
102 status = m_tuple1->addItem (
"npim", m_npim);
103 status = m_tuple1->addItem (
"ctau", m_ctau);
104 status = m_tuple1->addItem (
"lxyz", m_lxyz);
105 status = m_tuple1->addItem (
"elxyz", m_elxyz);
106 status = m_tuple1->addItem (
"kschi", m_chis);
107 status = m_tuple1->addItem (
"mksraw", m_ksRawMass);
108 status = m_tuple1->addItem (
"pk0", m_pk0);
112 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
113 return StatusCode::FAILURE;
121 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
122 return StatusCode::SUCCESS;
128 StatusCode sc = StatusCode::SUCCESS;
130 MsgStream log(
msgSvc(), name());
131 log << MSG::INFO <<
"in execute()" << endreq;
136 setFilterPassed(
false);
140 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
144 Vint iks, ipip, ipim, iGood;
155 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
157 if(!(*itTrk)->isMdcTrackValid())
continue;
159 if(fabs(mdcTrk->
z()) >= m_vz0cut)
continue;
160 if(mdcTrk->
r() >= m_vr0cut)
continue;
162 TotCharge += mdcTrk->
charge();
167 int nGood = iGood.size();
173 if((nGood < 2) || (TotCharge!=0))
return sc;
180 for(
int i = 0; i < nGood; i++) {
193 if(!(*itTrk)->isMdcKalTrackValid()) continue ;
200 HepLorentzVector
ptrk;
201 ptrk.setPx(mdcKalTrk->
px());
202 ptrk.setPy(mdcKalTrk->
py());
203 ptrk.setPz(mdcKalTrk->
pz());
207 if(mdcKalTrk->
charge() >0) {
208 ipip.push_back(iGood[i]);
209 ppip.push_back(
ptrk);
211 ipim.push_back(iGood[i]);
212 ppim.push_back(
ptrk);
217 int npip = ipip.size();
218 int npim = ipim.size();
222 if(npip < 1 || npim <1)
return sc;
234 HepSymMatrix Evx(3, 0);
259 for(
int i1 = 0; i1 < ipip.size(); i1++) {
260 RecMdcKalTrack *pipTrk = (*(evtRecTrkCol->begin()+ipip[i1]))->mdcKalTrack();
264 for(
int i2 = 0; i2 < ipim.size(); i2++) {
265 RecMdcKalTrack *pimTrk = (*(evtRecTrkCol->begin()+ipim[i2]))->mdcKalTrack();
273 if(!(vtxfit0->
Fit(0)))
continue;
279 if(!vtxfit->
Fit())
continue;
280 chi = vtxfit->
chisq();
283 if(chi > chisq)
continue;
284 delm = fabs((vtxfit->
p4par().m())-
mk0);
293 if(ip1==-1 || ip2==-1)
return sc;
296 RecMdcKalTrack *pi1Trk = (*(evtRecTrkCol->begin()+ip1))->mdcKalTrack();
300 RecMdcKalTrack *pi2Trk = (*(evtRecTrkCol->begin()+ip2))->mdcKalTrack();
307 if(!(vtxfit0->
Fit(0)))
return sc;
313 if(!vtxfit->
Fit())
return sc;
315 m_ksRawMass = vtxfit->
p4par().m();
316 m_ctau = vtxfit->
ctau();
319 m_chis = vtxfit->
chisq();
320 m_pk0 = vtxfit->
p4par().rho();
323 if(m_lxyz>0.4 && m_chis<20.){
326 if (m_thsvc->getHist(
"/DQAHist/InclKs/InclKs_mass", h).isSuccess()) {
327 h->Fill(m_ksRawMass);
329 log << MSG::ERROR <<
"Couldn't retrieve inclks_mass" << endreq;
340 (*(evtRecTrkCol->begin()+ip1))->tagPion();
341 (*(evtRecTrkCol->begin()+ip2))->tagPion();
347 (*(evtRecTrkCol->begin()+ip1))->setQuality(2);
348 (*(evtRecTrkCol->begin()+ip2))->setQuality(2);
352 setFilterPassed(
true);
354 return StatusCode::SUCCESS;
360 MsgStream log(
msgSvc(), name());
361 log << MSG::INFO <<
"in finalize()" << endmsg;
362 log << MSG::INFO <<
"Total Entries : " << m_pass[0] << endreq;
363 log << MSG::INFO <<
"Qtot Cut : " << m_pass[1] << endreq;
364 log << MSG::INFO <<
"PID : " << m_pass[2] << endreq;
365 log << MSG::INFO <<
"NPI : " << m_pass[3] << endreq;
366 log << MSG::INFO <<
"Second Vertex Cut : " << m_pass[4] << endreq;
367 return StatusCode::SUCCESS;
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
const HepVector & helix() const
static void setPidType(PidType pidType)
const HepSymMatrix & err() const
int methodProbability() const
void setChiMinCut(const double chi=4)
void setRecTrack(EvtRecTrack *trk)
void setMethod(const int method)
void identify(const int pidcase)
void usePidSys(const int pidsys)
static ParticleID * instance()
bool IsPidInfoValid() const
HepLorentzVector p4par() const
double decayLength() const
double decayLengthError() const
static SecondVertexFit * instance()
void setVpar(const VertexParameter vpar)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
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)
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol