ATLAS Offline Software
Loading...
Searching...
No Matches
InDetTrackBiasingToolTester.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Framework include(s):
7
8// EDM include(s):
10
11// Local include(s):
13#include <TH1.h>
14
15
16namespace 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
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
47
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::shallowCopyContainer( *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 delete nominalCopy.first;
68 delete nominalCopy.second;
69
70 // --- Systematic: all biasing systematics active, correction should be undone ---
71 ATH_CHECK( m_biasTool->applySystematicVariation( m_biasTool->affectingSystematics() ) );
72 auto systematicCopy = xAOD::shallowCopyContainer( *IDParticles );
73 for ( xAOD::TrackParticle* track : *systematicCopy.first ) {
74 const double d0_orig = track->d0();
75 const double z0_orig = track->z0();
76 if ( m_biasTool->applyCorrection(*track) == CP::CorrectionCode::Error ) {
77 ATH_MSG_ERROR( "Could not apply systematic correction." );
78 }
79 hist("d0_systematic")->Fill( track->d0() );
80 hist("z0_systematic")->Fill( track->z0() );
81 hist("d0_systematic_delta")->Fill( track->d0() - d0_orig );
82 hist("z0_systematic_delta")->Fill( track->z0() - z0_orig );
83 }
84 delete systematicCopy.first;
85 delete systematicCopy.second;
86
87 return StatusCode::SUCCESS;
88
89 } // End of execute()
90
91} // namespace InDet
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(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 initialize()
Function initialising the algorithm.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
StoreGate key for the track container.
InDetTrackBiasingToolTester(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
ToolHandle< IInDetTrackBiasingTool > m_biasTool
Connection to the biasing tool.
virtual StatusCode execute()
Function executing the algorithm.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Primary Vertex Finder.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.
TrackParticle_v1 TrackParticle
Reference the current persistent version: