ATLAS Offline Software
Loading...
Searching...
No Matches
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
18 ATH_CHECK(m_input.initialize());
19 ATH_CHECK(m_output.initialize());
20
22
23 return StatusCode::SUCCESS;
24}
25
26
27StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
static Double_t sc
DataVector adapter that acts like it holds const pointers.
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_output
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_input
StatusCode initialize() override
Athena algorithm's Hooks.
StatusCode execute(const EventContext &ctx) const override
ToolHandle< InDet::IInDetTrackSelectionTool > m_selector
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
TrackParticle_v1 TrackParticle
Reference the current persistent version: