ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkInDet
src
InDetTrackSelectionToolWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// InDetTrackSelectionToolWrapper.cxx
8
9
#include "
DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h
"
10
#include "
xAODTracking/TrackParticleContainer.h
"
11
#include "
StoreGate/ReadHandle.h
"
12
#include "
StoreGate/WriteDecorHandle.h
"
13
#include <vector>
14
#include <string>
15
#include <string_view>
16
17
namespace
DerivationFramework
{
18
19
StatusCode
InDetTrackSelectionToolWrapper::initialize
()
20
{
21
if
(
m_decorationKey
.empty()) {
22
ATH_MSG_ERROR
(
"No decoration prefix name provided for the output of InDetTrackSelectionToolWrapper!"
);
23
return
StatusCode::FAILURE;
24
}
25
26
ATH_CHECK
(
m_tracksKey
.initialize() );
27
std::string::size_type pos =
m_tracksKey
.key().find(
'+'
);
28
pos = (pos != std::string::npos) ? pos+1 : 0;
29
std::string_view container_name( &(
m_tracksKey
.key()[pos]),
m_tracksKey
.key().size() - pos);
30
std::string_view decor_name(
m_decorationKey
.key());
31
if
(!(decor_name.compare(0,
m_tracksKey
.key().size(),std::string_view(
m_tracksKey
.key()))==0 && decor_name.compare(0,container_name.size(),container_name)==0)) {
32
m_decorationKey
= std::string(container_name) +
"."
+
m_decorationKey
.key();
33
}
34
std::cout <<
"DEBUG "
<< name() <<
" InDetTrackSelectionToolWrapper::initialize container key "
<<
m_tracksKey
.key() <<
" -> "
<< container_name <<
" decor="
<<
m_decorationKey
.key() << std::endl;
35
ATH_CHECK
(
m_decorationKey
.initialize());
36
ATH_MSG_INFO
(
"Using "
<<
m_tracksKey
<<
"as the source collection for inner detector track particles"
);
37
ATH_CHECK
(
m_tool
.retrieve());
38
ATH_MSG_INFO
(
" InDetTrackSelectionToolWrapper::initialize i: "
<< inputHandles().
size
() <<
" o:"
<< outputHandles().
size
() );
39
return
StatusCode::SUCCESS;
40
}
41
42
43
StatusCode
InDetTrackSelectionToolWrapper::addBranches
(
const
EventContext& ctx)
const
44
{
45
46
// retrieve track container
47
SG::ReadHandle<xAOD::TrackParticleContainer>
tracks(
m_tracksKey
, ctx);
48
if
(!tracks.
isValid
()) {
49
//if( ! tracks ) {
50
ATH_MSG_ERROR
(
"Couldn't retrieve TrackParticles with key: "
<< tracks.
key
() );
51
return
StatusCode::FAILURE;
52
}
53
// Run tool for each element and decorate with the decision
54
SG::WriteDecorHandle<xAOD::TrackParticleContainer,bool >
accept(
m_decorationKey
, ctx);
55
for
(
const
auto
*trItr : *tracks) {
56
accept( *trItr ) =
m_tool
->accept(trItr).getCutResult(0);
57
}
// end of loop over tracks
58
59
return
StatusCode::SUCCESS;
60
}
61
62
}
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_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
TrackParticleContainer.h
InDetTrackSelectionToolWrapper.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
size
size_t size() const
Number of registered mappings.
DerivationFramework::InDetTrackSelectionToolWrapper::m_tracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksKey
Definition
InDetTrackSelectionToolWrapper.h:36
DerivationFramework::InDetTrackSelectionToolWrapper::initialize
virtual StatusCode initialize() override final
Definition
InDetTrackSelectionToolWrapper.cxx:19
DerivationFramework::InDetTrackSelectionToolWrapper::m_tool
ToolHandle< InDet::IInDetTrackSelectionTool > m_tool
Definition
InDetTrackSelectionToolWrapper.h:33
DerivationFramework::InDetTrackSelectionToolWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
InDetTrackSelectionToolWrapper.cxx:43
DerivationFramework::InDetTrackSelectionToolWrapper::m_decorationKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decorationKey
Definition
InDetTrackSelectionToolWrapper.h:39
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
Generated on
for ATLAS Offline Software by
1.17.0