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"
8#include "EventModel/EventModel.h"
9#include "EventModel/Event.h"
11#include "EvtRecEvent/EvtRecEvent.h"
12#include "EvtRecEvent/EvtRecTrack.h"
13#include "DstEvent/TofHitStatus.h"
14#include "EventModel/EventHeader.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
34#include "VertexFit/KinematicFit.h"
35#include "VertexFit/VertexFit.h"
36#include "ParticleID/ParticleID.h"
38#include "DQAinclPhi/inclphi.h"
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;
60 Algorithm(name, pSvcLocator) {
64 for(
int i = 0; i < 10; i++) m_pass[i] = 0;
67 declareProperty(
"Vr0cut", m_vr0cut=5.0);
68 declareProperty(
"Vz0cut", m_vz0cut=10.0);
69 declareProperty(
"CheckDedx", m_checkDedx = 1);
70 declareProperty(
"CheckTof", m_checkTof = 1);
75 MsgStream log(
msgSvc(), name());
77 log << MSG::INFO <<
"in initialize()" << endmsg;
81 if(service(
"THistSvc", m_thsvc).isFailure()) {
82 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
83 return StatusCode::FAILURE;
86 TH1F* inclphi_mass =
new TH1F(
"InclPhi_mass",
"INCLUSIVE_PHI_MASS",80,1.01,1.05);
87 inclphi_mass->GetXaxis()->SetTitle(
"M_{KK} (GeV)");
88 inclphi_mass->GetYaxis()->SetTitle(
"Nentries/0.5MeV/c^{2}");
89 if(m_thsvc->regHist(
"/DQAHist/InclPhi/InclPhi_mass", inclphi_mass).isFailure()) {
90 log << MSG::ERROR <<
"Couldn't register inclphi_mass" << endreq;
95 NTuplePtr nt1(
ntupleSvc(),
"DQAFILE/InclPhi");
96 if ( nt1 ) m_tuple1 = nt1;
98 m_tuple1 =
ntupleSvc()->book (
"DQAFILE/InclPhi1", CLID_ColumnWiseTuple,
"inclphi Ntuple");
100 status = m_tuple1->addItem (
"mphiall", m_mphiall);
101 status = m_tuple1->addItem (
"mpphiall", m_pphiall);
104 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
105 return StatusCode::FAILURE;
108 NTuplePtr nt2(
ntupleSvc(),
"DQAFILE/InclPhi2");
109 if ( nt2 ) m_tuple2 = nt2;
111 m_tuple2 =
ntupleSvc()->book (
"DQAFILE/InclPhi2", CLID_ColumnWiseTuple,
"inclphi Ntuple");
113 status = m_tuple2->addItem (
"nkp", m_nkp);
114 status = m_tuple2->addItem (
"nkm", m_nkm);
115 status = m_tuple2->addItem (
"ncharge", m_ncharge);
116 status = m_tuple2->addItem (
"difchi0", m_difchi);
117 status = m_tuple2->addItem (
"mmphi", m_mphi);
118 status = m_tuple2->addItem (
"pphi", m_pphi);
119 status = m_tuple2->addItem (
"pk1", m_pk1);
122 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple2) << endmsg;
123 return StatusCode::FAILURE;
130 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
131 return StatusCode::SUCCESS;
137 StatusCode sc = StatusCode::SUCCESS;
139 MsgStream log(
msgSvc(), name());
140 log << MSG::INFO <<
"in execute()" << endreq;
145 setFilterPassed(
false);
149 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
150 int run=eventHeader->runNumber();
151 int event=eventHeader->eventNumber();
158 Vint ikp, ikm, iGood;
168 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
170 if(!(*itTrk)->isMdcTrackValid())
continue;
172 if(fabs(mdcTrk->
z()) >= m_vz0cut)
continue;
173 if(mdcTrk->
r() >= m_vr0cut)
continue;
175 TotCharge += mdcTrk->
charge();
180 int nGood = iGood.size();
186 if((nGood < 2) || (TotCharge!=0))
return sc;
194 for(
int i = 0; i < nGood; i++) {
205 if(!(*itTrk)->isMdcKalTrackValid()) continue ;
212 HepLorentzVector ptrk;
213 ptrk.setPx(mdcKalTrk->
px());
214 ptrk.setPy(mdcKalTrk->
py());
215 ptrk.setPz(mdcKalTrk->
pz());
216 double p3 = ptrk.mag();
217 ptrk.setE(sqrt(p3*p3+
mk*
mk));
218 if(mdcKalTrk->
charge() >0) {
219 ikp.push_back(iGood[i]);
222 ikm.push_back(iGood[i]);
228 int nkp = ikp.size();
229 int nkm = ikm.size();
236 if(nkp < 1 || nkm <1)
return sc;
245 HepLorentzVector pphi, pTot;
249 double difchi0=99999.0;
253 for (
int i = 0; i < nkm; i++) {
254 for (
int j = 0; j < nkp; j++) {
256 pphi = pkm[i] + pkp[j];
257 m_mphiall = pphi.m();
258 m_pphiall = pphi.rho();
261 double difchi =fabs(pphi.m()-
mphi);
262 if(difchi < difchi0){
272 if (ixk1 == -1)
return sc;
276 pTot = pkm[ixk1] + pkp[ixk2];
278 m_pk1 = pkm[ixk1].m();
283 if (m_thsvc->getHist(
"/DQAHist/InclPhi/InclPhi_mass", h).isSuccess()) {
286 log << MSG::ERROR <<
"Couldn't retrieve inclphi_mass" << endreq;
295 (*(evtRecTrkCol->begin()+ikm[ixk1]))->tagKaon();
296 (*(evtRecTrkCol->begin()+ikp[ixk2]))->tagKaon();
302 (*(evtRecTrkCol->begin()+ikm[ixk1]))->setQuality(3);
303 (*(evtRecTrkCol->begin()+ikp[ixk2]))->setQuality(3);
307 setFilterPassed(
true);
309 return StatusCode::SUCCESS;
315 MsgStream log(
msgSvc(), name());
316 log << MSG::INFO <<
"in finalize()" << endmsg;
317 log << MSG::INFO <<
"Total Entries : " << m_pass[0] << endreq;
318 log << MSG::INFO <<
"dstCol, trkCol: " << m_pass[1] << endreq;
319 log << MSG::INFO <<
"Ncharge Cut : " << m_pass[2] << endreq;
320 log << MSG::INFO <<
"TOF dEdx : " << m_pass[3] << endreq;
321 log << MSG::INFO <<
"PID : " << m_pass[4] << endreq;
322 log << MSG::INFO <<
"NK Cut : " << m_pass[5] << endreq;
323 log << MSG::INFO <<
"Nphi select : " << m_pass[6] << endreq;
324 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
inclphi(const std::string &name, ISvcLocator *pSvcLocator)
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol