ATLAS Offline Software
JetTrackSelectionAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
9 
10 
12  ATH_MSG_DEBUG("Initializing " );
13 
14 
15  StatusCode sc = m_selector.retrieve();
16  if (sc.isFailure()) {ATH_MSG_ERROR("Can't retrieve ITrackSelectorTool "<< m_selector.name() ); return sc;}
17 
20 
21  ATH_CHECK(m_decorDeps.initialize(m_input, m_output));
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 
27 StatusCode JetTrackSelectionAlg::execute(const EventContext& ctx) const {
28  ATH_MSG_DEBUG(" execute() ... ");
29 
30  auto inputTracksH = SG::makeHandle(m_input,ctx);
31  if (! inputTracksH.isValid()){
32  ATH_MSG_ERROR("Can't retrieve input track container "<< m_input.key());
33  return StatusCode::FAILURE;
34  }
35 
36  // create and fill the VIEW container of selected tracks
38  auto selectedTracks = std::make_unique<OutContType>(SG::VIEW_ELEMENTS);
39 
40  for ( const xAOD::TrackParticle* trk : *inputTracksH.cptr() ) {
41  if ( trk != nullptr && m_selector->accept(*trk, nullptr) ) {
42  selectedTracks->push_back(trk);
43  }
44  }
45 
46  ATH_MSG_DEBUG(" ouputing to "<< m_output.key() << " selected size = "<< selectedTracks->size() );
47  // Write out in the event store
48  auto handle_out = SG::makeHandle(m_output, ctx);
49 
50  std::unique_ptr<const xAOD::TrackParticleContainer> selectedTracks_tc(selectedTracks.release()->asDataVector());
51  if (handle_out.put(std::move(selectedTracks_tc))==nullptr ){
52  ATH_MSG_ERROR("Can't record output track container "<< m_output.key());
53  return StatusCode::FAILURE;
54  }
55 
56  ATH_CHECK(m_decorDeps.linkDecors (m_input, ctx));
57  return StatusCode::SUCCESS;
58 }
WriteHandle.h
Handle class for recording to StoreGate.
JetTrackSelectionAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: JetTrackSelectionAlg.cxx:27
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
JetTrackSelectionAlg::m_decorDeps
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
Definition: JetTrackSelectionAlg.h:47
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
JetTrackSelectionAlg::initialize
StatusCode initialize() override
Athena algorithm's Hooks.
Definition: JetTrackSelectionAlg.cxx:11
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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
ReadHandle.h
Handle class for reading from StoreGate.
JetTrackSelectionAlg.h
JetTrackSelectionAlg::m_output
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_output
Definition: JetTrackSelectionAlg.h:44
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
JetTrackSelectionAlg::m_selector
ToolHandle< InDet::IInDetTrackSelectionTool > m_selector
Definition: JetTrackSelectionAlg.h:41
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
JetTrackSelectionAlg::m_input
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_input
Definition: JetTrackSelectionAlg.h:43