ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
TrackingID
InDetTrackSystematicsTools
src
InDetTrackBiasingToolTester.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
// Framework include(s):
6
#include "
xAODCore/ShallowCopy.h
"
7
8
// EDM include(s):
9
#include "
xAODTracking/TrackParticleContainer.h
"
10
11
// Local include(s):
12
#include "
InDetTrackBiasingToolTester.h
"
13
#include <TH1.h>
14
15
16
namespace
InDet
{
17
InDetTrackBiasingToolTester::InDetTrackBiasingToolTester
(
const
std::string& name, ISvcLocator* svcLoc )
18
:
AthHistogramAlgorithm
( name, svcLoc ),
19
m_biasTool
(
"InDet::InDetTrackSystematicsTools/InDetTrackBiasingTool"
, this ){
20
declareProperty
(
"InDetTrackBiasingTool"
,
m_biasTool
);
21
}
22
23
StatusCode
InDetTrackBiasingToolTester::initialize
() {
24
25
ATH_MSG_INFO
(
"Initialising"
);
26
ATH_CHECK
(
m_trackKey
.initialize() );
27
ATH_CHECK
(
m_biasTool
.retrieve() );
28
29
// Nominal: correction is applied, tracks should differ from original
30
ATH_CHECK
(
book
( TH1F(
"d0_original"
,
"original d0"
, 100, -5.0, 5.0) ) );
31
ATH_CHECK
(
book
( TH1F(
"z0_original"
,
"original z0"
, 100, -200., 200.) ) );
32
ATH_CHECK
(
book
( TH1F(
"d0_nominal"
,
"d0 after nominal correction"
, 100, -5.0, 5.0) ) );
33
ATH_CHECK
(
book
( TH1F(
"z0_nominal"
,
"z0 after nominal correction"
, 100, -200., 200.) ) );
34
ATH_CHECK
(
book
( TH1F(
"d0_nominal_delta"
,
"d0 nominal - original (expect nonzero)"
, 100, -0.10, 0.10) ) );
35
ATH_CHECK
(
book
( TH1F(
"z0_nominal_delta"
,
"z0 nominal - original (expect nonzero)"
, 100, -0.50, 0.50) ) );
36
37
// Systematic: correction is undone, tracks should be identical to original
38
ATH_CHECK
(
book
( TH1F(
"d0_systematic"
,
"d0 after systematic variation"
, 100, -5.0, 5.0) ) );
39
ATH_CHECK
(
book
( TH1F(
"z0_systematic"
,
"z0 after systematic variation"
, 100, -200., 200.) ) );
40
ATH_CHECK
(
book
( TH1F(
"d0_systematic_delta"
,
"d0 systematic - original (expect zero)"
, 100, -0.10, 0.10) ) );
41
ATH_CHECK
(
book
( TH1F(
"z0_systematic_delta"
,
"z0 systematic - original (expect zero)"
, 100, -0.50, 0.50) ) );
42
43
return
StatusCode::SUCCESS;
44
}
45
46
StatusCode
InDetTrackBiasingToolTester::execute
(
const
EventContext& ctx) {
47
48
SG::ReadHandle<xAOD::TrackParticleContainer>
IDParticles(
m_trackKey
, ctx);
49
ATH_CHECK
( IDParticles.
isValid
() );
50
51
// --- Nominal: no systematics active, correction should be applied ---
52
ATH_CHECK
(
m_biasTool
->applySystematicVariation( {} ) );
53
auto
nominalCopy =
xAOD::shallowCopy
( *IDParticles );
54
for
(
xAOD::TrackParticle
* track : *nominalCopy.first ) {
55
const
double
d0_orig = track->d0();
56
const
double
z0_orig = track->z0();
57
hist
(
"d0_original"
)->Fill( d0_orig );
58
hist
(
"z0_original"
)->Fill( z0_orig );
59
if
(
m_biasTool
->applyCorrection(*track) ==
CP::CorrectionCode::Error
) {
60
ATH_MSG_ERROR
(
"Could not apply nominal correction."
);
61
}
62
hist
(
"d0_nominal"
)->Fill( track->d0() );
63
hist
(
"z0_nominal"
)->Fill( track->z0() );
64
hist
(
"d0_nominal_delta"
)->Fill( track->d0() - d0_orig );
65
hist
(
"z0_nominal_delta"
)->Fill( track->z0() - z0_orig );
66
}
67
68
// --- Systematic: all biasing systematics active, correction should be undone ---
69
ATH_CHECK
(
m_biasTool
->applySystematicVariation(
m_biasTool
->affectingSystematics() ) );
70
auto
systematicCopy =
xAOD::shallowCopy
( *IDParticles );
71
for
(
xAOD::TrackParticle
* track : *systematicCopy.first ) {
72
const
double
d0_orig = track->d0();
73
const
double
z0_orig = track->z0();
74
if
(
m_biasTool
->applyCorrection(*track) ==
CP::CorrectionCode::Error
) {
75
ATH_MSG_ERROR
(
"Could not apply systematic correction."
);
76
}
77
hist
(
"d0_systematic"
)->Fill( track->d0() );
78
hist
(
"z0_systematic"
)->Fill( track->z0() );
79
hist
(
"d0_systematic_delta"
)->Fill( track->d0() - d0_orig );
80
hist
(
"z0_systematic_delta"
)->Fill( track->z0() - z0_orig );
81
}
82
83
return
StatusCode::SUCCESS;
84
85
}
// End of execute()
86
87
}
// namespace InDet
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
InDetTrackBiasingToolTester.h
ShallowCopy.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthHistogramAlgorithm::AthHistogramAlgorithm
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition
AthHistogramAlgorithm.cxx:31
AthHistogramming::book
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
Definition
AthHistogramming.h:305
AthHistogramming::hist
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
Definition
AthHistogramming.cxx:164
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition
CorrectionCode.h:36
InDet::InDetTrackBiasingToolTester::initialize
virtual StatusCode initialize()
Function initialising the algorithm.
Definition
InDetTrackBiasingToolTester.cxx:23
InDet::InDetTrackBiasingToolTester::m_trackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
StoreGate key for the track container.
Definition
InDetTrackBiasingToolTester.h:38
InDet::InDetTrackBiasingToolTester::InDetTrackBiasingToolTester
InDetTrackBiasingToolTester(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition
InDetTrackBiasingToolTester.cxx:17
InDet::InDetTrackBiasingToolTester::m_biasTool
ToolHandle< IInDetTrackBiasingTool > m_biasTool
Connection to the biasing tool.
Definition
InDetTrackBiasingToolTester.h:41
InDet::InDetTrackBiasingToolTester::execute
virtual StatusCode execute(const EventContext &ctx)
Function executing the algorithm.
Definition
InDetTrackBiasingToolTester.cxx:46
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
Generated on
for ATLAS Offline Software by
1.17.0