ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRecTools
Root
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
6
#include "
JetRecTools/JetTrackSelectionAlg.h
"
7
#include "
AsgDataHandles/ReadHandle.h
"
8
#include "
AsgDataHandles/WriteHandle.h
"
9
10
11
StatusCode
JetTrackSelectionAlg::initialize
() {
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
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
37
using
OutContType =
ConstDataVector<xAOD::TrackParticleContainer>
;
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
JetTrackSelectionAlg.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
JetTrackSelectionAlg::m_output
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_output
Definition
JetTrackSelectionAlg.h:44
JetTrackSelectionAlg::m_input
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_input
Definition
JetTrackSelectionAlg.h:43
JetTrackSelectionAlg::initialize
StatusCode initialize() override
Athena algorithm's Hooks.
Definition
JetTrackSelectionAlg.cxx:11
JetTrackSelectionAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition
JetTrackSelectionAlg.cxx:27
JetTrackSelectionAlg::m_selector
ToolHandle< InDet::IInDetTrackSelectionTool > m_selector
Definition
JetTrackSelectionAlg.h:41
JetTrackSelectionAlg::m_decorDeps
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
Definition
JetTrackSelectionAlg.h:47
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
Generated on
for ATLAS Offline Software by
1.17.0