ATLAS Offline Software
PFTrackPreselAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "PFTrackPreselAlg.h"
6 #include "StoreGate/ReadHandle.h"
10 #include <memory>
11 
12 PFTrackPreselAlg::PFTrackPreselAlg(const std::string& name, ISvcLocator* pSvcLocator)
13  : AthReentrantAlgorithm(name, pSvcLocator)
14 {
15 }
16 
18 
20 {
23 
26 
27  ATH_CHECK( m_trackSelTool.retrieve() );
28 
29  return StatusCode::SUCCESS;
30 }
31 
32 StatusCode PFTrackPreselAlg::execute(const EventContext &ctx) const
33 {
35  if (!input.isValid())
36  {
37  ATH_MSG_ERROR("Failed to retrieve " << m_inputTracksKey);
38  return StatusCode::FAILURE;
39  }
40 
42 
43  auto output = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer>>(SG::VIEW_ELEMENTS);
44  for (const xAOD::TrackParticle* itrk : *input)
45  {
46  if (itrk->pt() > m_upperPtCut || !m_trackSelTool->accept(*itrk))
47  {
48  decPass(*itrk) = false;
49  continue;
50  }
51  decPass(*itrk) = true;
52  output->push_back(itrk);
53  }
54  auto outputHandle = SG::makeHandle(m_outputTracksKey, ctx);
55  ATH_CHECK(outputHandle.put(std::move(output)) != nullptr);
56 
57  return StatusCode::SUCCESS;
58 }
PFTrackPreselAlg::initialize
virtual StatusCode initialize() override
Definition: PFTrackPreselAlg.cxx:19
PFTrackPreselAlg::m_inputTracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTracksKey
Definition: PFTrackPreselAlg.h:31
PFTrackPreselAlg::m_outputTracksKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputTracksKey
Definition: PFTrackPreselAlg.h:33
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
PFTrackPreselAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: PFTrackPreselAlg.cxx:32
PFTrackPreselAlg::PFTrackPreselAlg
PFTrackPreselAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PFTrackPreselAlg.cxx:12
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
WriteHandle.h
Handle class for recording to StoreGate.
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
PFTrackPreselAlg::m_outputDecorKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_outputDecorKey
Definition: PFTrackPreselAlg.h:35
merge.output
output
Definition: merge.py:16
PFTrackPreselAlg::~PFTrackPreselAlg
~PFTrackPreselAlg()
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
PFTrackPreselAlg.h
PFTrackPreselAlg::m_trackSelTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelTool
Definition: PFTrackPreselAlg.h:37
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ReadHandle.h
Handle class for reading from StoreGate.
PFTrackPreselAlg::m_upperPtCut
Gaudi::Property< float > m_upperPtCut
Definition: PFTrackPreselAlg.h:39