ATLAS Offline Software
PFTrackPreselAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "PFTrackPreselAlg.h"
6 #include "StoreGate/ReadHandle.h"
9 #include <memory>
10 
11 namespace {
12  const SG::AuxElement::Decorator<char> decPass("passPFTrackPresel");
13 }
14 
15 PFTrackPreselAlg::PFTrackPreselAlg(const std::string& name, ISvcLocator* pSvcLocator)
16  : AthReentrantAlgorithm(name, pSvcLocator)
17 {
18 }
19 
21 
23 {
26  ATH_CHECK( m_trackSelTool.retrieve() );
27  return StatusCode::SUCCESS;
28 }
29 
30 StatusCode PFTrackPreselAlg::execute(const EventContext &ctx) const
31 {
33  if (!input.isValid())
34  {
35  ATH_MSG_ERROR("Failed to retrieve " << m_inputTracksKey);
36  return StatusCode::FAILURE;
37  }
38  auto output = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer>>(SG::VIEW_ELEMENTS);
39  for (const xAOD::TrackParticle* itrk : *input)
40  {
41  if (itrk->pt() > m_upperPtCut || !m_trackSelTool->accept(*itrk))
42  {
43  decPass(*itrk) = false;
44  continue;
45  }
46  decPass(*itrk) = true;
47  output->push_back(itrk);
48  }
49  auto outputHandle = SG::makeHandle(m_outputTracksKey, ctx);
50  ATH_CHECK(outputHandle.put(std::move(output)) != nullptr);
51  return StatusCode::SUCCESS;
52 }
PFTrackPreselAlg::initialize
virtual StatusCode initialize() override
Definition: PFTrackPreselAlg.cxx:22
PFTrackPreselAlg::m_inputTracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTracksKey
Definition: PFTrackPreselAlg.h:30
PFTrackPreselAlg::m_outputTracksKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputTracksKey
Definition: PFTrackPreselAlg.h:32
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:30
PFTrackPreselAlg::PFTrackPreselAlg
PFTrackPreselAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PFTrackPreselAlg.cxx:15
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
WriteHandle.h
Handle class for recording to StoreGate.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
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
merge.output
output
Definition: merge.py:17
PFTrackPreselAlg::~PFTrackPreselAlg
~PFTrackPreselAlg()
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PFTrackPreselAlg.h
PFTrackPreselAlg::m_trackSelTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelTool
Definition: PFTrackPreselAlg.h:34
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:36