ATLAS Offline Software
xAODMultiMuonFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 
11 xAODMultiMuonFilter::xAODMultiMuonFilter(const std::string& name, ISvcLocator* pSvcLocator)
12  : GenFilter(name,pSvcLocator)
13 {
14  declareProperty("Ptcut",m_Ptmin = 10000.);
15  declareProperty("Etacut",m_EtaRange = 10.0);
16  declareProperty("NMuons",m_NMuons = 2);
17 }
18 
19 
21  // Retrieve TruthMuons container
22  const xAOD::TruthParticleContainer* xTruthParticleContainer;
23  if (evtStore()->retrieve(xTruthParticleContainer, "TruthMuons").isFailure()) {
24  ATH_MSG_ERROR("No TruthParticle collection with name " << "TruthMuons" << " found in StoreGate!");
25  return StatusCode::FAILURE;
26  }
27  int numMuons = 0;
28  unsigned int nParticles = xTruthParticleContainer->size();
29  for (unsigned int iPart=0; iPart<nParticles; ++iPart) {
30  const xAOD::TruthParticle* part = (*xTruthParticleContainer)[iPart];
31 
32  if (MC::isStable(part) && MC::isMuon(part)) //muon
33  if( part->pt()>= m_Ptmin && part->abseta() <= m_EtaRange )
34  {
35  numMuons++;
36  if (numMuons >= m_NMuons)
37  {
38  setFilterPassed(true);
39  return StatusCode::SUCCESS;
40  }
41  }
42  }
43 
44  setFilterPassed(false);
45  return StatusCode::SUCCESS;
46 
47 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAODMultiMuonFilter::m_Ptmin
double m_Ptmin
Definition: xAODMultiMuonFilter.h:21
xAODMultiMuonFilter::m_NMuons
int m_NMuons
Definition: xAODMultiMuonFilter.h:23
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TruthParticleContainer.h
TruthParticleAuxContainer.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
xAODMultiMuonFilter.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAODMultiMuonFilter::filterEvent
virtual StatusCode filterEvent()
Definition: xAODMultiMuonFilter.cxx:20
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
xAODMultiMuonFilter::m_EtaRange
double m_EtaRange
Definition: xAODMultiMuonFilter.h:22
TruthParticle.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HepMCHelpers.h
isMuon
bool isMuon(const T &p)
Definition: AtlasPID.h:145
xAODMultiMuonFilter::xAODMultiMuonFilter
xAODMultiMuonFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: xAODMultiMuonFilter.cxx:11