ATLAS Offline Software
xAODElectronFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 #include "GaudiKernel/ServiceHandle.h"
11 
12 xAODElectronFilter::xAODElectronFilter(const std::string &name, ISvcLocator *pSvcLocator)
13  : GenFilter(name, pSvcLocator)
14 {
15  declareProperty("Ptcut", m_Ptmin = 10000.);
16  declareProperty("Etacut", m_EtaRange = 10.0);
17 }
18 
20  // Retrieve full TruthParticle container
21  const xAOD::TruthParticleContainer *xTruthParticleContainer;
22  if (evtStore()->retrieve(xTruthParticleContainer, "TruthElectrons").isFailure())
23  {
24  ATH_MSG_ERROR("No TruthParticle collection with name "
25  << "TruthElectrons"
26  << " found in StoreGate!");
27  return StatusCode::FAILURE;
28  }
29 
30  unsigned int nParticles = xTruthParticleContainer->size();
31  for (unsigned int iPart = 0; iPart < nParticles; ++iPart)
32  {
33  const xAOD::TruthParticle *part = (*xTruthParticleContainer)[iPart];
34 
35  //electron
36  if (part->pt() >= m_Ptmin && part->abseta() <= m_EtaRange)
37  return StatusCode::SUCCESS;
38  }
39 
40  setFilterPassed(false);
41  return StatusCode::SUCCESS;
42 }
43 
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAODElectronFilter::m_EtaRange
double m_EtaRange
Definition: xAODElectronFilter.h:29
xAODElectronFilter::m_Ptmin
double m_Ptmin
Definition: xAODElectronFilter.h:28
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAODElectronFilter::xAODElectronFilter
xAODElectronFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: xAODElectronFilter.cxx:12
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAODElectronFilter.h
TruthParticle.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAODElectronFilter::filterEvent
virtual StatusCode filterEvent()
Definition: xAODElectronFilter.cxx:19