ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
TrackingID
InDetTrackSystematicsTools
src
InDetTrackSmearingToolTester.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
#include "
AthContainers/CurrentContext.h
"
11
12
// Local include(s):
13
#include "
InDetTrackSmearingToolTester.h
"
14
#include "
InDetTrackSystematicsTools/InDetTrackSystematics.h
"
15
#include <TH1.h>
16
17
18
namespace
InDet
{
19
InDetTrackSmearingToolTester::InDetTrackSmearingToolTester
(
const
std::string& name, ISvcLocator* svcLoc )
20
:
AthHistogramAlgorithm
( name, svcLoc ),
21
m_smearTool
(
"InDet::InDetTrackSystematicsTools/InDetTrackSmearingTool"
, this ){
22
declareProperty
(
"TrackIP"
,
m_Track_IP
=
"InDetTrackParticles"
);
23
declareProperty
(
"SystematicEffects"
,
m_systematicsNames
);
24
declareProperty
(
"InDetTrackSmearingTool"
,
m_smearTool
);
25
26
}
27
28
StatusCode
InDetTrackSmearingToolTester::initialize
() {
29
30
// Greet the user:
31
ATH_MSG_INFO
(
"Initialising"
);
32
ATH_MSG_DEBUG
(
"InDetTrackSmearingTool = "
<<
m_smearTool
);
33
34
// Retrieve the tools:
35
ATH_CHECK
(
m_smearTool
.retrieve() );
36
37
for
(
const
auto
& name :
m_systematicsNames
) {
38
for
(
const
auto
& systpair : InDet::TrackSystematicMap) {
39
if
(name == systpair.second.name()) {
40
m_systActive
.insert(systpair.second);
41
}
42
}
43
}
44
auto
systCode =
m_smearTool
->applySystematicVariation(
m_systActive
);
45
if
(systCode != StatusCode::SUCCESS) {
46
ATH_MSG_ERROR
(
"Failure to apply systematic variation."
);
47
return
StatusCode::FAILURE;
48
}
49
50
ATH_CHECK
(
book
( TH1F(
"d0_B"
,
"original d0"
, 100, -5.0, 5.0) ) );
51
ATH_CHECK
(
book
( TH1F(
"z0_B"
,
"original z0"
, 100, -200.0, 200.0) ) );
52
ATH_CHECK
(
book
( TH1F(
"d0sm"
,
"d0 after smearing"
, 100, -5.0, 5.0) ) );
53
ATH_CHECK
(
book
( TH1F(
"z0sm"
,
"z0 after smearing"
, 100, -200.0, 200.0) ) );
54
ATH_CHECK
(
book
( TH1F(
"subtraction_d0"
,
"subtraction_d0"
, 100, -0.10, 0.10) ) );
55
ATH_CHECK
(
book
( TH1F(
"subtraction_z0"
,
"subtraction_z0"
, 100,-0.50, 0.50) ) );
56
57
// Return gracefully:
58
return
StatusCode::SUCCESS;
59
}
60
61
StatusCode
InDetTrackSmearingToolTester::execute
(
const
EventContext&
/*ctx*/
) {
62
63
// Create a shallow container copy and then apply the smearingtool to impact parameters:
64
const
xAOD::TrackParticleContainer
*IDParticles =
nullptr
;
65
ATH_CHECK
(
evtStore
()->retrieve( IDParticles ,
m_Track_IP
) );
66
xAOD::ShallowCopyResult_t<xAOD::TrackParticleContainer>
IDParticles_shallowCopy =
67
xAOD::shallowCopy
( *IDParticles );
68
for
(
xAOD::TrackParticle
* track : *IDParticles_shallowCopy.first ) {
69
double
d0_1=0.,d0_2=0.,z0_1=0.,z0_2=0.;
70
d0_1=track->d0();
71
z0_1=track->z0();
72
hist
(
"d0_B"
)->Fill( d0_1 );
73
hist
(
"z0_B"
)->Fill( z0_1 );
74
if
(
m_smearTool
->applyCorrection(*track) ==
CP::CorrectionCode::Error
) {
75
ATH_MSG_ERROR
(
"Could not apply correction."
);
76
}
77
d0_2=track->d0();
78
z0_2=track->z0();
79
hist
(
"d0sm"
)->Fill( d0_2 );
80
hist
(
"z0sm"
)->Fill( z0_2 );
81
hist
(
"subtraction_d0"
)->Fill( d0_2 - d0_1 );
82
hist
(
"subtraction_z0"
)->Fill( z0_2 - z0_1 );
83
}
84
85
// Return gracefully:
86
return
StatusCode::SUCCESS;
87
88
}
// End of the execute()
89
90
}
// namespace InDet
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
CurrentContext.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
TrackParticleContainer.h
InDetTrackSmearingToolTester.h
InDetTrackSystematics.h
ShallowCopy.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
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::InDetTrackSmearingToolTester::m_Track_IP
std::string m_Track_IP
StoreGate key for the track container to investigate//--->delete in future.
Definition
InDetTrackSmearingToolTester.h:35
InDet::InDetTrackSmearingToolTester::initialize
virtual StatusCode initialize()
Function initialising the algorithm.
Definition
InDetTrackSmearingToolTester.cxx:28
InDet::InDetTrackSmearingToolTester::InDetTrackSmearingToolTester
InDetTrackSmearingToolTester(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition
InDetTrackSmearingToolTester.cxx:19
InDet::InDetTrackSmearingToolTester::execute
virtual StatusCode execute(const EventContext &ctx)
Function executing the algorithm.
Definition
InDetTrackSmearingToolTester.cxx:61
InDet::InDetTrackSmearingToolTester::m_smearTool
ToolHandle< IInDetTrackSmearingTool > m_smearTool
Connection to the smearing tool.
Definition
InDetTrackSmearingToolTester.h:38
InDet::InDetTrackSmearingToolTester::m_systematicsNames
std::vector< std::string > m_systematicsNames
Definition
InDetTrackSmearingToolTester.h:40
InDet::InDetTrackSmearingToolTester::m_systActive
CP::SystematicSet m_systActive
Definition
InDetTrackSmearingToolTester.h:41
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
xAOD::ShallowCopyResult_t
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition
ShallowCopy.h:68
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.
xAOD::TrackParticleContainer
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticleContainer.h:14
Generated on
for ATLAS Offline Software by
1.17.0