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"
17#include "GaudiKernel/INTupleSvc.h"
18#include "GaudiKernel/NTuple.h"
19#include "GaudiKernel/Bootstrap.h"
21#include "GaudiKernel/ITHistSvc.h"
23#include "CLHEP/Vector/ThreeVector.h"
24#include "CLHEP/Vector/LorentzVector.h"
25#include "CLHEP/Vector/TwoVector.h"
26using CLHEP::Hep3Vector;
27using CLHEP::Hep2Vector;
28using CLHEP::HepLorentzVector;
29#include "CLHEP/Geometry/Point3D.h"
30#ifndef ENABLE_BACKWARDS_COMPATIBILITY
43const double mk = 0.493677;
44const double mphi = 1.01946;
45const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
46const double velc = 299.792458;
49typedef std::vector<int>
Vint;
50typedef std::vector<HepLorentzVector>
Vp4;
61 Algorithm(name, pSvcLocator) {
65 for(
int i = 0; i < 10; i++) m_pass[i] = 0;
68 declareProperty(
"Vr0cut", m_vr0cut=5.0);
69 declareProperty(
"Vz0cut", m_vz0cut=10.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* inclphi_mass =
new TH1F(
"InclPhi_mass",
"INCLUSIVE_PHI_MASS",80,1.01,1.05);
88 inclphi_mass->GetXaxis()->SetTitle(
"M_{KK} (GeV)");
89 inclphi_mass->GetYaxis()->SetTitle(
"Nentries/0.5MeV/c^{2}");
90 if(m_thsvc->regHist(
"/DQAHist/InclPhi/InclPhi_mass", inclphi_mass).isFailure()) {
91 log << MSG::ERROR <<
"Couldn't register inclphi_mass" << endreq;
96 NTuplePtr nt1(
ntupleSvc(),
"DQAFILE/InclPhi");
97 if ( nt1 ) m_tuple1 = nt1;
99 m_tuple1 =
ntupleSvc()->book (
"DQAFILE/InclPhi1", CLID_ColumnWiseTuple,
"inclphi Ntuple");
101 status = m_tuple1->addItem (
"mphiall", m_mphiall);
102 status = m_tuple1->addItem (
"mpphiall", m_pphiall);
105 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
106 return StatusCode::FAILURE;
109 NTuplePtr nt2(
ntupleSvc(),
"DQAFILE/InclPhi2");
110 if ( nt2 ) m_tuple2 = nt2;
112 m_tuple2 =
ntupleSvc()->book (
"DQAFILE/InclPhi2", CLID_ColumnWiseTuple,
"inclphi Ntuple");
114 status = m_tuple2->addItem (
"nkp", m_nkp);
115 status = m_tuple2->addItem (
"nkm", m_nkm);
116 status = m_tuple2->addItem (
"ncharge", m_ncharge);
117 status = m_tuple2->addItem (
"difchi0", m_difchi);
118 status = m_tuple2->addItem (
"mmphi", m_mphi);
119 status = m_tuple2->addItem (
"pphi", m_pphi);
120 status = m_tuple2->addItem (
"pk1", m_pk1);
123 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple2) << endmsg;
124 return StatusCode::FAILURE;
131 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
132 return StatusCode::SUCCESS;
138 StatusCode sc = StatusCode::SUCCESS;
140 MsgStream log(
msgSvc(), name());
141 log << MSG::INFO <<
"in execute()" << endreq;
146 setFilterPassed(
false);
150 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
151 int run=eventHeader->runNumber();
152 int event=eventHeader->eventNumber();
159 Vint ikp, ikm, iGood;
169 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
171 if(!(*itTrk)->isMdcTrackValid())
continue;
173 if(fabs(mdcTrk->
z()) >= m_vz0cut)
continue;
174 if(mdcTrk->
r() >= m_vr0cut)
continue;
176 TotCharge += mdcTrk->
charge();
181 int nGood = iGood.size();
187 if((nGood < 2) || (TotCharge!=0))
return sc;
195 for(
int i = 0; i < nGood; i++) {
206 if(!(*itTrk)->isMdcKalTrackValid()) continue ;
213 HepLorentzVector
ptrk;
214 ptrk.setPx(mdcKalTrk->
px());
215 ptrk.setPy(mdcKalTrk->
py());
216 ptrk.setPz(mdcKalTrk->
pz());
219 if(mdcKalTrk->
charge() >0) {
220 ikp.push_back(iGood[i]);
223 ikm.push_back(iGood[i]);
229 int nkp = ikp.size();
230 int nkm = ikm.size();
237 if(nkp < 1 || nkm <1)
return sc;
246 HepLorentzVector pphi, pTot;
250 double difchi0=99999.0;
254 for (
int i = 0; i < nkm; i++) {
255 for (
int j = 0; j < nkp; j++) {
257 pphi = pkm[i] + pkp[j];
258 m_mphiall = pphi.m();
259 m_pphiall = pphi.rho();
262 double difchi =fabs(pphi.m()-
mphi);
263 if(difchi < difchi0){
273 if (ixk1 == -1)
return sc;
277 pTot = pkm[ixk1] + pkp[ixk2];
279 m_pk1 = pkm[ixk1].m();
284 if (m_thsvc->getHist(
"/DQAHist/InclPhi/InclPhi_mass", h).isSuccess()) {
287 log << MSG::ERROR <<
"Couldn't retrieve inclphi_mass" << endreq;
296 (*(evtRecTrkCol->begin()+ikm[ixk1]))->tagKaon();
297 (*(evtRecTrkCol->begin()+ikp[ixk2]))->tagKaon();
303 (*(evtRecTrkCol->begin()+ikm[ixk1]))->setQuality(3);
304 (*(evtRecTrkCol->begin()+ikp[ixk2]))->setQuality(3);
308 setFilterPassed(
true);
310 return StatusCode::SUCCESS;
316 MsgStream log(
msgSvc(), name());
317 log << MSG::INFO <<
"in finalize()" << endmsg;
318 log << MSG::INFO <<
"Total Entries : " << m_pass[0] << endreq;
319 log << MSG::INFO <<
"dstCol, trkCol: " << m_pass[1] << endreq;
320 log << MSG::INFO <<
"Ncharge Cut : " << m_pass[2] << endreq;
321 log << MSG::INFO <<
"TOF dEdx : " << m_pass[3] << endreq;
322 log << MSG::INFO <<
"PID : " << m_pass[4] << endreq;
323 log << MSG::INFO <<
"NK Cut : " << m_pass[5] << endreq;
324 log << MSG::INFO <<
"Nphi select : " << m_pass[6] << endreq;
325 return StatusCode::SUCCESS;
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
static void setPidType(PidType pidType)
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
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol