ATLAS Offline Software
TrackAnalysisPlotsMgr.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "TrackAnalysisPlotsMgr.h"
14 #include "ITrackMatchingLookup.h"
15 
17 #include "GaudiKernel/ISvcLocator.h"
18 #include "GaudiKernel/Service.h"
19 
20 
25  const std::string& dirName,
26  const std::string& anaTag,
27  const std::string& chain,
28  PlotMgr* pParent ) :
29  PlotMgr( dirName, anaTag, pParent ),
30  m_anaTag( anaTag ), m_chain( chain ),
31  m_directory( dirName ), m_trkAnaDefSvc( nullptr ) { }
32 
33 
38 {
39  ATH_MSG_DEBUG( "Initialising in directory: " << m_directory );
40 
42  if( not m_trkAnaDefSvc ) {
43  ISvcLocator* svcLoc = Gaudi::svcLocator();
44  ATH_CHECK( svcLoc->service( "TrkAnaDefSvc"+m_anaTag, m_trkAnaDefSvc ) );
45  }
46 
48  if( m_trkAnaDefSvc->plotTrackParameters() ) {
49  m_plots_trkParam_vsTest = std::make_unique< TrackParametersPlots >(
50  this, "Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->testTag() );
51  m_plots_trkParam_vsRef = std::make_unique< TrackParametersPlots >(
52  this, "Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->referenceTag() );
53  }
54 
56  if( m_trkAnaDefSvc->plotEfficiencies() ) {
57  m_plots_eff_vsTest = std::make_unique< EfficiencyPlots >(
58  this, "Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->testTag() );
59  m_plots_eff_vsRef = std::make_unique< EfficiencyPlots >(
60  this, "Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->referenceTag() );
61  }
62 
64  if( m_trkAnaDefSvc->plotResolutions() ) {
65  m_plots_resolution = std::make_unique< ResolutionPlots >(
66  this, "Tracks/Resolutions", m_anaTag, m_trkAnaDefSvc->referenceTag() );
67  }
68 
70  if( m_trkAnaDefSvc->plotOfflineElectrons() ) {
71  m_plots_offEle = std::make_unique< OfflineElectronPlots >(
72  this, "Tracks/Parameters", m_anaTag );
73  if( m_trkAnaDefSvc->plotEfficiencies() ) {
74  m_plots_eff_vsOffEle = std::make_unique< OfflineElectronPlots >(
75  this, "Tracks/Efficiencies", m_anaTag, true );
76  }
77  }
78 
81 
82  return StatusCode::SUCCESS;
83 }
84 
85 
90  TrackAnalysisCollections& trkAnaColls, float weight )
91 {
93  if( m_trkAnaDefSvc->isTestTruth() ) {
94  ATH_CHECK( fillPlotsTest(
96  trkAnaColls.matches(), weight ) );
97  } else {
98  ATH_CHECK( fillPlotsTest(
100  trkAnaColls.matches(), weight ) );
101  }
102 
104  if( m_trkAnaDefSvc->isReferenceTruth() ) {
105  ATH_CHECK( fillPlotsReference(
107  trkAnaColls.matches(), weight ) );
108  } else {
109  ATH_CHECK( fillPlotsReference(
111  trkAnaColls.matches(), weight ) );
112  }
113 
114  return StatusCode::SUCCESS;
115 }
116 
117 
121 template< typename PARTICLE >
123  const std::vector< const PARTICLE* >& particles,
124  const ITrackMatchingLookup& matches, float weight )
125 {
126  for( const PARTICLE* particle : particles ) {
128  if( m_plots_trkParam_vsTest ) {
129  ATH_CHECK( m_plots_trkParam_vsTest->fillPlots( *particle, weight ) );
130  }
131 
132  bool isMatched = matches.isTestMatched( *particle );
133 
135  if( m_plots_eff_vsTest ) {
136  ATH_CHECK( m_plots_eff_vsTest->fillPlots( *particle, isMatched, weight ) );
137  }
138 
140  if( m_trkAnaDefSvc->isTestOffline() ) {
141  if( m_plots_offEle ) {
142  ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) );
143  }
144  if( m_plots_eff_vsOffEle ) {
145  ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) );
146  }
147  }
148 
149  } // close loop over particles
150 
151  return StatusCode::SUCCESS;
152 }
153 
154 template StatusCode
156  const std::vector< const xAOD::TrackParticle* >& particles,
157  const ITrackMatchingLookup& matches, float weight );
158 
159 template StatusCode
161  const std::vector< const xAOD::TruthParticle* >& particles,
162  const ITrackMatchingLookup& matches, float weight );
163 
164 
168 template< typename PARTICLE >
170  const std::vector< const PARTICLE* >& particles,
171  const ITrackMatchingLookup& matches, float weight )
172 {
173  for( const PARTICLE* particle : particles ) {
175  if( m_plots_trkParam_vsRef ) {
176  ATH_CHECK( m_plots_trkParam_vsRef->fillPlots( *particle, weight ) );
177  }
178 
179  bool isMatched = matches.isRefMatched( *particle );
180 
182  if( m_plots_eff_vsRef ) {
183  ATH_CHECK( m_plots_eff_vsRef->fillPlots( *particle, isMatched, weight ) );
184  }
185 
186  if( m_plots_resolution ) {
187  if( isMatched ) {
188  if( m_trkAnaDefSvc->isTestTruth() ) {
189  ATH_CHECK( m_plots_resolution->fillPlots(
190  *particle, *(matches.getBestMatchedTestTruth( *particle )), weight ) );
191  } else {
192  ATH_CHECK( m_plots_resolution->fillPlots(
193  *particle, *(matches.getBestMatchedTestTrack( *particle )), weight ) );
194  }
195  }
196  }
197 
199  if( m_trkAnaDefSvc->isReferenceOffline() ) {
200  if( m_plots_offEle ) {
201  ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) );
202  }
203  if( m_plots_eff_vsOffEle ) {
204  ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) );
205  }
206  }
207 
208  } // close loop over particles
209 
210  return StatusCode::SUCCESS;
211 }
212 
213 template StatusCode
215  const std::vector< const xAOD::TrackParticle* >& particles,
216  const ITrackMatchingLookup& matches, float weight );
217 
218 template StatusCode
220  const std::vector< const xAOD::TruthParticle* >& particles,
221  const ITrackMatchingLookup& matches, float weight );
IDTPM::TrackAnalysisPlotsMgr::fillPlotsReference
StatusCode fillPlotsReference(const std::vector< const PARTICLE * > &particles, const ITrackMatchingLookup &matches, float weight=1.0)
Fill all plots w.r.t.
Definition: TrackAnalysisPlotsMgr.cxx:169
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
IDTPM::TrackAnalysisCollections
Definition: TrackAnalysisCollections.h:41
IDTPM::TrackAnalysisPlotsMgr::fillPlotsTest
StatusCode fillPlotsTest(const std::vector< const PARTICLE * > &particles, const ITrackMatchingLookup &matches, float weight=1.0)
Fill all plots w.r.t.
Definition: TrackAnalysisPlotsMgr.cxx:122
fillPlotsReference< xAOD::TruthParticle >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsReference< xAOD::TruthParticle >(const std::vector< const xAOD::TruthParticle * > &particles, const ITrackMatchingLookup &matches, float weight)
InDetSecVtxTruthMatchUtils::isMatched
bool isMatched(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:48
fillPlotsTest< xAOD::TrackParticle >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsTest< xAOD::TrackParticle >(const std::vector< const xAOD::TrackParticle * > &particles, const ITrackMatchingLookup &matches, float weight)
TrackAnalysisCollections.h
Class to hold for each event collections needed in the TrkAnalsis.
TrackAnalysisPlotsMgr.h
class to manage (book, fill) all the plots for the processed TrackAnalysis for tracking performance v...
IDTPM::ITrackMatchingLookup::getBestMatchedTestTruth
virtual const xAOD::TruthParticle * getBestMatchedTestTruth(const xAOD::TrackParticle &r) const
best Truth <- Track
Definition: ITrackMatchingLookup.h:91
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
IDTPM::TrackAnalysisCollections::testTrackVec
const std::vector< const xAOD::TrackParticle * > & testTrackVec(Stage stage=FULL)
TEST = Track.
Definition: TrackAnalysisCollections.cxx:439
IDTPM::PlotMgr
Definition: PlotMgr.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
IDTPM::ITrackMatchingLookup::isTestMatched
virtual bool isTestMatched(const xAOD::TrackParticle &t) const =0
return true if test is matched
IDTPM::TrackAnalysisCollections::matches
ITrackMatchingLookup & matches()
return matching information
Definition: TrackAnalysisCollections.h:158
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ITrackMatchingLookup.h
Interace for TrackMatchingLookup objects (templated)
IDTPM::ITrackMatchingLookup::isRefMatched
virtual bool isRefMatched(const xAOD::TrackParticle &r) const =0
return true if reference is matched
IDTPM::ITrackMatchingLookup::getBestMatchedTestTrack
const xAOD::TrackParticle * getBestMatchedTestTrack(const xAOD::TrackParticle &r) const
get best matched test, i.e.
Definition: ITrackMatchingLookup.h:75
fillPlotsTest< xAOD::TruthParticle >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsTest< xAOD::TruthParticle >(const std::vector< const xAOD::TruthParticle * > &particles, const ITrackMatchingLookup &matches, float weight)
IDTPM::TrackAnalysisCollections::refTrackVec
const std::vector< const xAOD::TrackParticle * > & refTrackVec(Stage stage=FULL)
TEST = Track.
Definition: TrackAnalysisCollections.cxx:469
IDTPM::TrackAnalysisPlotsMgr::TrackAnalysisPlotsMgr
TrackAnalysisPlotsMgr(const std::string &dirName, const std::string &anaTag, const std::string &chain, PlotMgr *pParent=nullptr)
Constructor.
Definition: TrackAnalysisPlotsMgr.cxx:24
IDTPM::TrackAnalysisPlotsMgr::fill
StatusCode fill(TrackAnalysisCollections &trkAnaColls, float weight=1.0)
General fill method.
Definition: TrackAnalysisPlotsMgr.cxx:89
IDTPM::TrackAnalysisCollections::InRoI
@ InRoI
Definition: TrackAnalysisCollections.h:49
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
fillPlotsReference< xAOD::TrackParticle >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsReference< xAOD::TrackParticle >(const std::vector< const xAOD::TrackParticle * > &particles, const ITrackMatchingLookup &matches, float weight)
IDTPM::TrackAnalysisCollections::testTruthVec
const std::vector< const xAOD::TruthParticle * > & testTruthVec(Stage stage=FULL)
get TEST track vectors
Definition: TrackAnalysisCollections.cxx:426
IDTPM::TrackAnalysisPlotsMgr::initialize
StatusCode initialize()
initialize
Definition: TrackAnalysisPlotsMgr.cxx:37
IDTPM::PlotMgr::initialize
StatusCode initialize()
initialize
Definition: PlotMgr.cxx:37
IDTPM::ITrackMatchingLookup
Definition: ITrackMatchingLookup.h:30
IDTPM::TrackAnalysisCollections::refTruthVec
const std::vector< const xAOD::TruthParticle * > & refTruthVec(Stage stage=FULL)
get REFERENCE track vectors
Definition: TrackAnalysisCollections.cxx:456