ATLAS Offline Software
Loading...
Searching...
No Matches
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):
7
8// EDM include(s):
11
12// Local include(s):
15#include <TH1.h>
16
17
18namespace 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
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
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 ) );
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
@ Error
Some error happened during the object correction.
virtual StatusCode execute()
Function executing the algorithm.
std::string m_Track_IP
StoreGate key for the track container to investigate//--->delete in future.
virtual StatusCode initialize()
Function initialising the algorithm.
InDetTrackSmearingToolTester(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
ToolHandle< IInDetTrackSmearingTool > m_smearTool
Connection to the smearing tool.
Primary Vertex Finder.
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition ShallowCopy.h:68
TrackParticle_v1 TrackParticle
Reference the current persistent version:
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".