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 "VertexFit/SecondVertexFit.h"
37#include "ParticleID/ParticleID.h"
39#include "DQAinclLamda/incllambda.h"
44const double mpi = 0.13957;
45const double mp = 0.93827203;
46const double mlam = 1.115683;
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=20.0);
69 declareProperty(
"Vz0cut", m_vz0cut=50.0);
70 declareProperty(
"CheckDedx", m_checkDedx = 1);
71 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* incllambda_mass =
new TH1F(
"InclLam_mass",
"INCLUSIVE_LAMBDA_MASS",150,1.11,1.125);
89 incllambda_mass->GetXaxis()->SetTitle(
"M_{p#pi} (GeV)");
90 incllambda_mass->GetYaxis()->SetTitle(
"Nentries/0.1MeV/c^{2}");
91 if(m_thsvc->regHist(
"/DQAHist/InclLam/InclLam_mass", incllambda_mass).isFailure()) {
92 log << MSG::ERROR <<
"Couldn't register incllambda_mass" << endreq;
97 NTuplePtr nt1(
ntupleSvc(),
"DQAFILE/InclLam");
98 if ( nt1 ) m_tuple1 = nt1;
100 m_tuple1 =
ntupleSvc()->book (
"DQAFILE/InclLam", CLID_ColumnWiseTuple,
"incllam Ntuple");
102 status = m_tuple1->addItem (
"npi", m_npi);
103 status = m_tuple1->addItem (
"np", m_np);
104 status = m_tuple1->addItem (
"lxyz", m_lxyz);
105 status = m_tuple1->addItem (
"ctau", m_ctau);
106 status = m_tuple1->addItem (
"elxyz", m_elxyz);
107 status = m_tuple1->addItem (
"lamchi", m_chis);
108 status = m_tuple1->addItem (
"mlamraw", m_lamRawMass);
109 status = m_tuple1->addItem (
"plam", m_plam);
112 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
113 return StatusCode::FAILURE;
120 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
121 return StatusCode::SUCCESS;
127 StatusCode sc = StatusCode::SUCCESS;
129 MsgStream log(
msgSvc(), name());
130 log << MSG::INFO <<
"in execute()" << endreq;
135 setFilterPassed(
false);
139 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
143 Vint ilam, ip, ipi, iGood;
154 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
156 if(!(*itTrk)->isMdcTrackValid())
continue;
158 if(fabs(mdcTrk->
z()) >= m_vz0cut)
continue;
159 if(mdcTrk->
r() >= m_vr0cut)
continue;
161 TotCharge += mdcTrk->
charge();
166 int nGood = iGood.size();
172 if((nGood < 2) || (TotCharge!=0))
return sc;
179 for(
int i = 0; i < nGood; i++) {
191 if(!(*itTrk)->isMdcKalTrackValid()) continue ;
194 if(mdcKalTrk->
charge() == 0)
continue;
198 ipi.push_back(iGood[i]);
199 HepLorentzVector
ptrk;
200 ptrk.setPx(mdcKalTrk->
px());
201 ptrk.setPy(mdcKalTrk->
py());
202 ptrk.setPz(mdcKalTrk->
pz());
203 double p3 =
ptrk.mag();
209 ip.push_back(iGood[i]);
210 HepLorentzVector
ptrk;
211 ptrk.setPx(mdcKalTrk->
px());
212 ptrk.setPy(mdcKalTrk->
py());
213 ptrk.setPz(mdcKalTrk->
pz());
214 double p3 =
ptrk.mag();
222 int npi = ipi.size();
226 if(npi < 1 || np <1)
return sc;
236 HepSymMatrix Evx(3, 0);
247 int ipion=-1, iproton=-1;
252 for(
unsigned int i1 = 0; i1 < ipi.size(); i1++) {
253 RecMdcKalTrack *piTrk = (*(evtRecTrkCol->begin()+ipi[i1]))->mdcKalTrack();
257 for(
unsigned int i2 = 0; i2 < ip.size(); i2++) {
258 RecMdcKalTrack *protonTrk = (*(evtRecTrkCol->begin()+ip[i2]))->mdcKalTrack();
267 if(NCharge != 0)
continue;
273 if(!(vtxfit0->
Fit(0)))
continue;
280 if(!vtxfit->
Fit())
continue;
285 if(vtxfit->
chisq() > chi)
continue;
288 chi = vtxfit->
chisq();
296 if(ipion==-1 || iproton==-1)
return sc;
299 RecMdcKalTrack *pionTrk = (*(evtRecTrkCol->begin()+ipion))->mdcKalTrack();
303 RecMdcKalTrack *protonTrk = (*(evtRecTrkCol->begin()+iproton))->mdcKalTrack();
310 if(!(vtxfit0->
Fit(0)))
return sc;
317 if(!vtxfit->
Fit())
return sc;
319 m_lamRawMass = vtxfit->
p4par().m();
320 m_ctau = vtxfit->
ctau();
323 m_chis = vtxfit->
chisq();
324 m_plam = vtxfit->
p4par().rho();
329 if (m_thsvc->getHist(
"/DQAHist/InclLam/InclLam_mass", h).isSuccess()) {
330 h->Fill(m_lamRawMass);
332 log << MSG::ERROR <<
"Couldn't retrieve incllam_mass" << endreq;
343 (*(evtRecTrkCol->begin()+ipion))->tagPion();
344 (*(evtRecTrkCol->begin()+iproton))->tagProton();
350 (*(evtRecTrkCol->begin()+ipion))->setQuality(1);
351 (*(evtRecTrkCol->begin()+iproton))->setQuality(1);
356 setFilterPassed(
true);
358 return StatusCode::SUCCESS;
364 MsgStream log(
msgSvc(), name());
365 log << MSG::INFO <<
"in finalize()" << endmsg;
366 log << MSG::INFO <<
"Total Entries : " << m_pass[0] << endreq;
367 log << MSG::INFO <<
"Qtot Cut : " << m_pass[1] << endreq;
368 log << MSG::INFO <<
"Nks : " << m_pass[2] << endreq;
369 log << MSG::INFO <<
"Good Ks cut : " << m_pass[3] << endreq;
370 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
double probProton() 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)
incllambda(const std::string &name, ISvcLocator *pSvcLocator)
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol