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/ITHistSvc.h"
20#include "GaudiKernel/Bootstrap.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 mpi = 0.13957;
44const double mk = 0.493677;
46const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
48const double velc = 299.792458;
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;
69 declareProperty(
"Vr0cut", m_vr0cut=5.0);
70 declareProperty(
"Vz0cut", m_vz0cut=10.0);
71 declareProperty(
"CheckDedx", m_checkDedx = 1);
72 declareProperty(
"CheckTof", m_checkTof = 1);
77 MsgStream log(
msgSvc(), name());
79 log << MSG::INFO <<
"in initialize()" << endmsg;
83 if(service(
"THistSvc", m_thsvc).isFailure()) {
84 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
85 return StatusCode::FAILURE;
88 TH1F* inclkstar_mass =
new TH1F(
"InclKstar_mass",
"INCLUSIVE_Kstar_MASS",65,0.65,1.3);
89 inclkstar_mass->GetXaxis()->SetTitle(
"M_{K#pi} (GeV)");
90 inclkstar_mass->GetYaxis()->SetTitle(
"Nentries/10MeV/c^{2}");
92 if(m_thsvc->regHist(
"/DQAHist/InclKstar/InclKstar_mass", inclkstar_mass).isFailure()) {
93 log << MSG::ERROR <<
"Couldn't register InclKstar_mass" << endreq;
97 NTuplePtr nt2(
ntupleSvc(),
"DQAFILE/InclKstar");
98 if ( nt2 ) m_tuple2 = nt2;
100 m_tuple2 =
ntupleSvc()->book (
"DQAFILE/InclKstar", CLID_ColumnWiseTuple,
"inclkstar Ntuple");
102 status = m_tuple2->addItem (
"nkaonm", m_nkm);
103 status = m_tuple2->addItem (
"nkaonp", m_nkp);
104 status = m_tuple2->addItem (
"npionp", m_npip);
105 status = m_tuple2->addItem (
"npionm", m_npim);
106 status = m_tuple2->addItem (
"ncharge", m_ncharge);
107 status = m_tuple2->addItem (
"difchikp", m_difchikp);
108 status = m_tuple2->addItem (
"difchikm", m_difchikm);
109 status = m_tuple2->addItem (
"mkstarkp", m_kstarkp);
110 status = m_tuple2->addItem (
"mkstarkm", m_kstarkm);
111 status = m_tuple2->addItem (
"mkstar", m_mkstar);
112 status = m_tuple2->addItem (
"pkstar", m_pkstar);
115 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple2) << endmsg;
116 return StatusCode::FAILURE;
123 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
124 return StatusCode::SUCCESS;
130 StatusCode sc = StatusCode::SUCCESS;
132 MsgStream log(
msgSvc(), name());
133 log << MSG::INFO <<
"in execute()" << endreq;
138 setFilterPassed(
false);
142 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
146 Vint iGood, ikm, ikp, ipip, ipim, iGam;
154 Vp4 ppip, ppim, pkm, pkp;
161 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
163 if(!(*itTrk)->isMdcTrackValid())
continue;
165 if(fabs(mdcTrk->
z()) >= m_vz0cut)
continue;
166 if(mdcTrk->
r() >= m_vr0cut)
continue;
168 TotCharge += mdcTrk->
charge();
173 int nGood = iGood.size();
179 if((nGood < 2) || (TotCharge!=0))
return sc;
187 for(
int i = 0; i < nGood; i++) {
201 if(!(*itTrk)->isMdcKalTrackValid()) continue ;
205 HepLorentzVector ptrk;
206 ptrk.setPx(mdcKalTrk->
px());
207 ptrk.setPy(mdcKalTrk->
py());
208 ptrk.setPz(mdcKalTrk->
pz());
209 double p3 = ptrk.mag();
210 ptrk.setE(sqrt(p3*p3+
mk*
mk));
211 if(mdcKalTrk->
charge() >0) {
212 ikp.push_back(iGood[i]);
215 ikm.push_back(iGood[i]);
222 HepLorentzVector ptrk;
223 ptrk.setPx(mdcKalTrk->
px());
224 ptrk.setPy(mdcKalTrk->
py());
225 ptrk.setPz(mdcKalTrk->
pz());
226 double p3 = ptrk.mag();
227 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
228 if(mdcKalTrk->
charge() >0) {
229 ipip.push_back(iGood[i]);
230 ppip.push_back(ptrk);
232 ipim.push_back(iGood[i]);
233 ppim.push_back(ptrk);
237 int npip = ipip.size();
238 int npim = ipim.size();
239 int nkm = ikm.size();
240 int nkp = ikp.size();
249 if(npip < 1 && npim < 1)
return sc;
250 if(nkp < 1 && nkm < 1)
return sc;
258 HepLorentzVector pkstar, pkstar1, ppi1, ppi2, pTot;
262 double difchi0=99999.0;
266 for (
int i = 0; i < npim; i++) {
267 for (
int j = 0; j < nkp; j++) {
268 pkstar = ppim[i] + pkp[j];
269 double difchi =fabs(pkstar.m()-
mkstar0);
270 if(difchi < difchi0){
278 m_difchikp = difchi0;
280 if(ixpim != -1) m_kstarkp=(ppim[ixpim] + pkp[ixkp]).m();
282 double difchi1=99999.0;
286 for (
int ii = 0; ii < npip; ii++) {
287 for (
int jj = 0; jj < nkm; jj++) {
288 pkstar1 = ppip[ii] + pkm[jj];
289 double difchi2 =fabs(pkstar1.m()-
mkstar0);
290 if(difchi2 < difchi1){
298 m_difchikm = difchi1;
300 if(ixpip != -1) m_kstarkm=(ppip[ixpip] + pkm[ixkm]).m();
303 if(ixpip == -1 && ixpim == -1)
return sc;
305 if(difchi0 < difchi1){
306 pTot = ppim[ixpim] + pkp[ixkp];
309 pTot = ppip[ixpip] + pkm[ixkm];
313 m_pkstar = pTot.rho();
317 if (m_thsvc->getHist(
"/DQAHist/InclKstar/InclKstar_mass", h).isSuccess()) {
320 log << MSG::ERROR <<
"Couldn't retrieve InclKstar_mass" << endreq;
330 (*(evtRecTrkCol->begin()+ipim[ixpim]))->tagPion();
331 (*(evtRecTrkCol->begin()+ikp[ixkp]))->tagKaon();
332 (*(evtRecTrkCol->begin()+ipim[ixpim]))->setQuality(3);
333 (*(evtRecTrkCol->begin()+ikp[ixkp]))->setQuality(3);
337 (*(evtRecTrkCol->begin()+ipip[ixpip]))->tagPion();
338 (*(evtRecTrkCol->begin()+ikm[ixkm]))->tagKaon();
339 (*(evtRecTrkCol->begin()+ipip[ixpip]))->setQuality(3);
340 (*(evtRecTrkCol->begin()+ikm[ixkm]))->setQuality(3);
345 setFilterPassed(
true);
348 return StatusCode::SUCCESS;
354 MsgStream log(
msgSvc(), name());
355 log << MSG::INFO <<
"in finalize()" << endmsg;
356 log << MSG::INFO <<
"Total Entries : " << m_pass[0] << endreq;
357 log << MSG::INFO <<
"TOF,dEdx: " << m_pass[1] << endreq;
358 log << MSG::INFO <<
"Ncharge Cut : " << m_pass[2] << endreq;
359 log << MSG::INFO <<
"PID : " << m_pass[3] << endreq;
360 log << MSG::INFO <<
"Npi and Nk Cut : " << m_pass[4] << endreq;
361 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
inclkstar(const std::string &name, ISvcLocator *pSvcLocator)
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol