ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
TrackingID
InDetTrackSystematicsTools
src
TrackSystematicsAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "GaudiKernel/ServiceHandle.h"
6
7
#include "
TrackSystematicsAlg.h
"
8
#include "
xAODTracking/TrackingPrimitives.h
"
9
10
namespace
InDet
{
11
TrackSystematicsAlg::TrackSystematicsAlg
(
const
std::string& name, ISvcLocator* pSvcLocator ) :
12
AthReentrantAlgorithm
( name, pSvcLocator ){}
13
14
StatusCode
TrackSystematicsAlg::initialize
() {
15
16
ATH_CHECK
(
m_inTrackKey
.initialize());
17
ATH_CHECK
(
m_outTrackKey
.initialize());
18
ATH_CHECK
(
m_decorDeps
.initialize(
m_inTrackKey
,
m_outTrackKey
));
19
20
// Retrieve the tools:
21
ATH_CHECK
(
m_trackFilterToolLRT
.retrieve());
22
ATH_CHECK
(
m_trackFilterToolSTD
.retrieve());
23
24
if
(
m_systematicVariationSTD
.value().empty() &&
m_systematicVariationLRT
.value().empty()) {
25
ATH_MSG_ERROR
(
"No track filter systematic configured (SystematicVariationSTD, SystematicVariationLRT)"
);
26
return
StatusCode::FAILURE;
27
}
28
29
// The tools silently ignore unknown systematics, so reject them here
30
auto
makeSet = [
this
](
const
std::string& name,
const
CP::ISystematicsTool
& tool,
31
const
char
*
type
,
CP::SystematicSet
& systSet) -> StatusCode {
32
if
(name.empty())
return
StatusCode::SUCCESS;
33
const
CP::SystematicVariation
var(name);
34
if
(!tool.isAffectedBySystematic(var)) {
35
ATH_MSG_ERROR
(
"Systematic '"
<< name <<
"' is not known to the "
<<
type
<<
" track filter tool"
);
36
return
StatusCode::FAILURE;
37
}
38
systSet.insert(var);
39
return
StatusCode::SUCCESS;
40
};
41
CP::SystematicSet
systSetSTD, systSetLRT;
42
ATH_CHECK
(makeSet(
m_systematicVariationSTD
, *
m_trackFilterToolSTD
,
"STD"
, systSetSTD));
43
ATH_CHECK
(makeSet(
m_systematicVariationLRT
, *
m_trackFilterToolLRT
,
"LRT"
, systSetLRT));
44
45
ATH_CHECK
(
m_trackFilterToolLRT
->applySystematicVariation(systSetLRT));
46
ATH_CHECK
(
m_trackFilterToolSTD
->applySystematicVariation(systSetSTD));
47
48
return
StatusCode::SUCCESS;
49
}
50
51
StatusCode
TrackSystematicsAlg::execute
(
const
EventContext& ctx)
const
{
52
53
//Retrieve the tracks:
54
SG::ReadHandle<xAOD::TrackParticleContainer>
inTracks(
m_inTrackKey
, ctx);
55
56
auto
selectedTracks = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer> >(
SG::VIEW_ELEMENTS
);
57
58
for
(
const
xAOD::TrackParticle
* track : *inTracks) {
59
60
const
std::bitset<xAOD::NumberOfTrackRecoInfo> patternReco = track->patternRecoInfo();
61
bool
passFilter =
false
;
62
63
// LRT track
64
if
(patternReco.test(
xAOD::SiSpacePointsSeedMaker_LargeD0
)) {
65
passFilter =
m_trackFilterToolLRT
->accept(track);
66
}
67
// standard track
68
else
{
69
passFilter =
m_trackFilterToolSTD
->accept(track);
70
}
71
if
(passFilter) {
72
ATH_MSG_DEBUG
(
"Track accepted!"
);
73
selectedTracks->push_back( track );
74
}
75
else
{
76
ATH_MSG_DEBUG
(
"Track rejected!"
);
77
}
78
}
79
80
std::unique_ptr<const xAOD::TrackParticleContainer> outTracks(selectedTracks.release()->asDataVector());
81
SG::WriteHandle<xAOD::TrackParticleContainer>
outTrackHandle(
m_outTrackKey
, ctx);
82
83
ATH_MSG_DEBUG
(
"Initial number of tracks: "
<< inTracks->size() );
84
ATH_MSG_DEBUG
(
"Selected number of tracks: "
<< outTracks->size() );
85
86
if
(not outTrackHandle.
put
(std::move(outTracks))){
87
ATH_MSG_ERROR
(
"Failed to record "
<<
m_outTrackKey
.key() <<
" as const xAOD::TrackParticleContainer!"
);
88
return
StatusCode::FAILURE;
89
}
90
ATH_CHECK
(
m_decorDeps
.linkDecors (
m_inTrackKey
, ctx));
91
92
93
return
StatusCode::SUCCESS;
94
}
95
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
TrackSystematicsAlg.h
TrackingPrimitives.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CP::ISystematicsTool
Interface for all CP tools supporting systematic variations.
Definition
ISystematicsTool.h:32
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition
SystematicSet.h:31
CP::SystematicVariation
Definition
SystematicVariation.h:47
InDet::TrackSystematicsAlg::initialize
StatusCode initialize() override
Definition
TrackSystematicsAlg.cxx:14
InDet::TrackSystematicsAlg::TrackSystematicsAlg
TrackSystematicsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TrackSystematicsAlg.cxx:11
InDet::TrackSystematicsAlg::m_outTrackKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outTrackKey
Definition
TrackSystematicsAlg.h:50
InDet::TrackSystematicsAlg::m_inTrackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inTrackKey
Definition
TrackSystematicsAlg.h:49
InDet::TrackSystematicsAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition
TrackSystematicsAlg.cxx:51
InDet::TrackSystematicsAlg::m_systematicVariationSTD
Gaudi::Property< std::string > m_systematicVariationSTD
Definition
TrackSystematicsAlg.h:44
InDet::TrackSystematicsAlg::m_trackFilterToolLRT
ToolHandle< InDet::InclusiveTrackFilterTool > m_trackFilterToolLRT
Definition
TrackSystematicsAlg.h:37
InDet::TrackSystematicsAlg::m_decorDeps
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
Definition
TrackSystematicsAlg.h:51
InDet::TrackSystematicsAlg::m_trackFilterToolSTD
ToolHandle< InDet::InDetTrackTruthFilterTool > m_trackFilterToolSTD
Definition
TrackSystematicsAlg.h:39
InDet::TrackSystematicsAlg::m_systematicVariationLRT
Gaudi::Property< std::string > m_systematicVariationLRT
Definition
TrackSystematicsAlg.h:46
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:71
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::SiSpacePointsSeedMaker_LargeD0
@ SiSpacePointsSeedMaker_LargeD0
Definition
TrackingPrimitives.h:179
type
Generated on
for ATLAS Offline Software by
1.17.0