ATLAS Offline Software
DuplicateRatePlots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #include "DuplicateRatePlots.h"
12 #include "../TrackParametersHelper.h"
13 
14 
19  PlotMgr* pParent, const std::string& dirName,
20  const std::string& anaTag, const std::string& trackType, bool doGlobalPlots ) :
21  PlotMgr( dirName, anaTag, pParent ),
22  m_trackType( trackType ),
23  m_doGlobalPlots( doGlobalPlots ) { }
24 
25 
30 {
31  StatusCode sc = bookPlots();
32  if( sc.isFailure() ) {
33  ATH_MSG_ERROR( "Failed to book duplicate rate plots" );
34  }
35 }
36 
37 
39 {
40  ATH_MSG_DEBUG( "Booking duplicate rate plots in " << getDirectory() );
41 
42  ATH_CHECK( retrieveAndBook( m_duplrate_vs_pt, "duplrate_vs_"+m_trackType+"_pt" ) );
43  ATH_CHECK( retrieveAndBook( m_duplrate_vs_eta, "duplrate_vs_"+m_trackType+"_eta" ) );
44  ATH_CHECK( retrieveAndBook( m_duplrate_vs_phi, "duplrate_vs_"+m_trackType+"_phi" ) );
45  ATH_CHECK( retrieveAndBook( m_duplrate_vs_d0, "duplrate_vs_"+m_trackType+"_d0" ) );
46  ATH_CHECK( retrieveAndBook( m_duplrate_vs_z0, "duplrate_vs_"+m_trackType+"_z0" ) );
47 
48  ATH_CHECK( retrieveAndBook( m_duplnum_vs_pt, "duplnum_vs_"+m_trackType+"_pt" ) );
49  ATH_CHECK( retrieveAndBook( m_duplnum_vs_eta, "duplnum_vs_"+m_trackType+"_eta" ) );
50  ATH_CHECK( retrieveAndBook( m_duplnum_vs_phi, "duplnum_vs_"+m_trackType+"_phi" ) );
51  ATH_CHECK( retrieveAndBook( m_duplnum_vs_d0, "duplnum_vs_"+m_trackType+"_d0" ) );
52  ATH_CHECK( retrieveAndBook( m_duplnum_vs_z0, "duplnum_vs_"+m_trackType+"_z0" ) );
53 
54  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_pt, "duplnum_nonzero_vs_"+m_trackType+"_pt" ) );
55  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_eta, "duplnum_nonzero_vs_"+m_trackType+"_eta" ) );
56  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_phi, "duplnum_nonzero_vs_"+m_trackType+"_phi" ) );
57  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_d0, "duplnum_nonzero_vs_"+m_trackType+"_d0" ) );
58  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_z0, "duplnum_nonzero_vs_"+m_trackType+"_z0" ) );
59 
60  if( m_doGlobalPlots ) {
61  ATH_CHECK( retrieveAndBook( m_duplrate_vs_truthMu, "duplrate_vs_truthMu" ) );
62  ATH_CHECK( retrieveAndBook( m_duplrate_vs_actualMu, "duplrate_vs_actualMu" ) );
63 
64  ATH_CHECK( retrieveAndBook( m_duplnum_vs_truthMu, "duplnum_vs_truthMu" ) );
65  ATH_CHECK( retrieveAndBook( m_duplnum_vs_actualMu, "duplnum_vs_actualMu" ) );
66 
67  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_truthMu, "duplnum_nonzero_vs_truthMu" ) );
68  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_actualMu, "duplnum_nonzero_vs_actualMu" ) );
69  }
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 
78 template< typename PARTICLE >
80  const PARTICLE& particle,
81  unsigned int nMatched,
82  float truthMu,
83  float actualMu,
84  float weight )
85 {
87  float ppt = pT( particle ) / Gaudi::Units::GeV;
88  float peta = eta( particle );
89  float pphi = phi( particle );
90  float pd0 = d0( particle );
91  float pz0 = z0( particle );
92 
94  ATH_CHECK( fill( m_duplrate_vs_pt, ppt, (nMatched>1), weight ) );
95  ATH_CHECK( fill( m_duplrate_vs_eta, peta, (nMatched>1), weight ) );
96  ATH_CHECK( fill( m_duplrate_vs_phi, pphi, (nMatched>1), weight ) );
97  ATH_CHECK( fill( m_duplrate_vs_d0, pd0, (nMatched>1), weight ) );
98  ATH_CHECK( fill( m_duplrate_vs_z0, pz0, (nMatched>1), weight ) );
99 
100  ATH_CHECK( fill( m_duplnum_vs_pt, ppt, nMatched, weight ) );
101  ATH_CHECK( fill( m_duplnum_vs_eta, peta, nMatched, weight ) );
102  ATH_CHECK( fill( m_duplnum_vs_phi, pphi, nMatched, weight ) );
103  ATH_CHECK( fill( m_duplnum_vs_d0, pd0, nMatched, weight ) );
104  ATH_CHECK( fill( m_duplnum_vs_z0, pz0, nMatched, weight ) );
105 
106  if( nMatched > 0 ) {
107  ATH_CHECK( fill( m_duplnum_nonzero_vs_pt, ppt, nMatched, weight ) );
108  ATH_CHECK( fill( m_duplnum_nonzero_vs_eta, peta, nMatched, weight ) );
109  ATH_CHECK( fill( m_duplnum_nonzero_vs_phi, pphi, nMatched, weight ) );
110  ATH_CHECK( fill( m_duplnum_nonzero_vs_d0, pd0, nMatched, weight ) );
111  ATH_CHECK( fill( m_duplnum_nonzero_vs_z0, pz0, nMatched, weight ) );
112  }
113 
114  if( m_doGlobalPlots ) {
115  ATH_CHECK( fill( m_duplrate_vs_truthMu, truthMu, (nMatched>1), weight ) );
116  ATH_CHECK( fill( m_duplrate_vs_actualMu, actualMu, (nMatched>1), weight ) );
117 
118  ATH_CHECK( fill( m_duplnum_vs_truthMu, truthMu, nMatched, weight ) );
119  ATH_CHECK( fill( m_duplnum_vs_actualMu, actualMu, nMatched, weight ) );
120 
121  if( nMatched > 0 ) {
122  ATH_CHECK( fill( m_duplnum_nonzero_vs_truthMu, truthMu, nMatched, weight ) );
123  ATH_CHECK( fill( m_duplnum_nonzero_vs_actualMu, actualMu, nMatched, weight ) );
124  }
125  }
126 
127  return StatusCode::SUCCESS;
128 }
129 
131  const xAOD::TrackParticle&, unsigned int nMatched, float truthMu, float actualMu, float weight );
132 
134  const xAOD::TruthParticle&, unsigned int nMatched, float truthMu, float actualMu, float weight );
135 
136 
141 {
142  ATH_MSG_DEBUG( "Finalising duplicate rate plots" );
144 }
fillPlots< xAOD::TrackParticle >
template StatusCode IDTPM::DuplicateRatePlots::fillPlots< xAOD::TrackParticle >(const xAOD::TrackParticle &, unsigned int nMatched, float truthMu, float actualMu, float weight)
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
IDTPM::DuplicateRatePlots::fillPlots
StatusCode fillPlots(const PARTICLE &particle, unsigned int nMatched, float truthMu, float actualMu, float weight)
Dedicated fill method (for tracks and/or truth particles)
Definition: DuplicateRatePlots.cxx:79
IDTPM::z0
float z0(const U &p)
Definition: TrackParametersHelper.h:70
fillPlots< xAOD::TruthParticle >
template StatusCode IDTPM::DuplicateRatePlots::fillPlots< xAOD::TruthParticle >(const xAOD::TruthParticle &, unsigned int nMatched, float truthMu, float actualMu, float weight)
IDTPM::phi
float phi(const U &p)
Definition: TrackParametersHelper.h:59
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IDTPM::DuplicateRatePlots::finalizePlots
void finalizePlots()
Print out final stats on histograms.
Definition: DuplicateRatePlots.cxx:140
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
IDTPM::PlotMgr
Definition: PlotMgr.h:33
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IDTPM::eta
float eta(const U &p)
Accessor utility function for getting the value of eta.
Definition: TrackParametersHelper.h:41
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::DuplicateRatePlots::bookPlots
StatusCode bookPlots()
Definition: DuplicateRatePlots.cxx:38
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
IDTPM::d0
float d0(const U &p)
Definition: TrackParametersHelper.h:82
IDTPM::pT
float pT(const U &p)
Accessor utility function for getting the value of pT.
Definition: TrackParametersHelper.h:31
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IDTPM::DuplicateRatePlots::initializePlots
void initializePlots()
Book the histograms.
Definition: DuplicateRatePlots.cxx:29
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
IDTPM::DuplicateRatePlots::DuplicateRatePlots
DuplicateRatePlots(PlotMgr *pParent, const std::string &dirName, const std::string &anaTag, const std::string &trackType, bool doGlobalPlots=false)
Constructor.
Definition: DuplicateRatePlots.cxx:18
DuplicateRatePlots.h
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43