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,
21  bool doGlobalPlots, bool doTruthMuPlots ) :
22  PlotMgr( dirName, anaTag, pParent ),
23  m_trackType( trackType ),
24  m_doGlobalPlots( doGlobalPlots ),
25  m_doTruthMuPlots( doTruthMuPlots ) { }
26 
27 
32 {
33  StatusCode sc = bookPlots();
34  if( sc.isFailure() ) {
35  ATH_MSG_ERROR( "Failed to book duplicate rate plots" );
36  }
37 }
38 
39 
41 {
42  ATH_MSG_DEBUG( "Booking duplicate rate plots in " << getDirectory() );
43 
44  ATH_CHECK( retrieveAndBook( m_duplrate_vs_incl, "duplrate_vs_"+m_trackType+"_inclusive" ) );
45  ATH_CHECK( retrieveAndBook( m_duplrate_vs_pt, "duplrate_vs_"+m_trackType+"_pt" ) );
46  ATH_CHECK( retrieveAndBook( m_duplrate_vs_logPt,"duplrate_vs_"+m_trackType+"_logPt" ) );
47  ATH_CHECK( retrieveAndBook( m_duplrate_vs_eta, "duplrate_vs_"+m_trackType+"_eta" ) );
48  ATH_CHECK( retrieveAndBook( m_duplrate_vs_phi, "duplrate_vs_"+m_trackType+"_phi" ) );
49  ATH_CHECK( retrieveAndBook( m_duplrate_vs_d0, "duplrate_vs_"+m_trackType+"_d0" ) );
50  ATH_CHECK( retrieveAndBook( m_duplrate_vs_z0, "duplrate_vs_"+m_trackType+"_z0" ) );
51 
52  ATH_CHECK( retrieveAndBook( m_duplnum_vs_pt, "duplnum_vs_"+m_trackType+"_pt" ) );
53  ATH_CHECK( retrieveAndBook( m_duplnum_vs_eta, "duplnum_vs_"+m_trackType+"_eta" ) );
54  ATH_CHECK( retrieveAndBook( m_duplnum_vs_phi, "duplnum_vs_"+m_trackType+"_phi" ) );
55  ATH_CHECK( retrieveAndBook( m_duplnum_vs_d0, "duplnum_vs_"+m_trackType+"_d0" ) );
56  ATH_CHECK( retrieveAndBook( m_duplnum_vs_z0, "duplnum_vs_"+m_trackType+"_z0" ) );
57 
58  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_pt, "duplnum_nonzero_vs_"+m_trackType+"_pt" ) );
59  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_eta, "duplnum_nonzero_vs_"+m_trackType+"_eta" ) );
60  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_phi, "duplnum_nonzero_vs_"+m_trackType+"_phi" ) );
61  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_d0, "duplnum_nonzero_vs_"+m_trackType+"_d0" ) );
62  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_z0, "duplnum_nonzero_vs_"+m_trackType+"_z0" ) );
63 
64  if( m_doGlobalPlots ) {
65  ATH_CHECK( retrieveAndBook( m_duplrate_vs_actualMu, "duplrate_vs_actualMu" ) );
66  ATH_CHECK( retrieveAndBook( m_duplnum_vs_actualMu, "duplnum_vs_actualMu" ) );
67  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_actualMu, "duplnum_nonzero_vs_actualMu" ) );
68 
69  if( m_doTruthMuPlots ) {
70  ATH_CHECK( retrieveAndBook( m_duplrate_vs_truthMu, "duplrate_vs_truthMu" ) );
71  ATH_CHECK( retrieveAndBook( m_duplnum_vs_truthMu, "duplnum_vs_truthMu" ) );
72  ATH_CHECK( retrieveAndBook( m_duplnum_nonzero_vs_truthMu, "duplnum_nonzero_vs_truthMu" ) );
73  }
74  }
75 
76  return StatusCode::SUCCESS;
77 }
78 
79 
83 template< typename PARTICLE >
85  const PARTICLE& particle,
86  unsigned int nMatched,
87  float truthMu,
88  float actualMu,
89  float weight )
90 {
92  float ppt = pT( particle ) / Gaudi::Units::GeV;
93  float peta = eta( particle );
94  float pphi = phi( particle );
95  float pd0 = d0( particle );
96  float pz0 = z0( particle );
97 
99  ATH_CHECK( fill( m_duplrate_vs_incl, 1, (nMatched>1), weight ) );
100  ATH_CHECK( fill( m_duplrate_vs_pt, ppt, (nMatched>1), weight ) );
101  ATH_CHECK( fill( m_duplrate_vs_logPt, ppt, (nMatched>1), weight ) );
102  ATH_CHECK( fill( m_duplrate_vs_eta, peta, (nMatched>1), weight ) );
103  ATH_CHECK( fill( m_duplrate_vs_phi, pphi, (nMatched>1), weight ) );
104  ATH_CHECK( fill( m_duplrate_vs_d0, pd0, (nMatched>1), weight ) );
105  ATH_CHECK( fill( m_duplrate_vs_z0, pz0, (nMatched>1), weight ) );
106 
107  ATH_CHECK( fill( m_duplnum_vs_pt, ppt, nMatched, weight ) );
108  ATH_CHECK( fill( m_duplnum_vs_eta, peta, nMatched, weight ) );
109  ATH_CHECK( fill( m_duplnum_vs_phi, pphi, nMatched, weight ) );
110  ATH_CHECK( fill( m_duplnum_vs_d0, pd0, nMatched, weight ) );
111  ATH_CHECK( fill( m_duplnum_vs_z0, pz0, nMatched, weight ) );
112 
113  if( nMatched > 0 ) {
114  ATH_CHECK( fill( m_duplnum_nonzero_vs_pt, ppt, nMatched, weight ) );
115  ATH_CHECK( fill( m_duplnum_nonzero_vs_eta, peta, nMatched, weight ) );
116  ATH_CHECK( fill( m_duplnum_nonzero_vs_phi, pphi, nMatched, weight ) );
117  ATH_CHECK( fill( m_duplnum_nonzero_vs_d0, pd0, nMatched, weight ) );
118  ATH_CHECK( fill( m_duplnum_nonzero_vs_z0, pz0, nMatched, weight ) );
119  }
120 
121  if( m_doGlobalPlots ) {
122  ATH_CHECK( fill( m_duplrate_vs_actualMu, actualMu, (nMatched>1), weight ) );
123  ATH_CHECK( fill( m_duplnum_vs_actualMu, actualMu, nMatched, weight ) );
124  if( nMatched > 0 ) ATH_CHECK( fill( m_duplnum_nonzero_vs_actualMu, actualMu, nMatched, weight ) );
125 
126  if( m_doTruthMuPlots ) {
127  ATH_CHECK( fill( m_duplrate_vs_truthMu, truthMu, (nMatched>1), weight ) );
128  ATH_CHECK( fill( m_duplnum_vs_truthMu, truthMu, nMatched, weight ) );
129  if( nMatched > 0 ) ATH_CHECK( fill( m_duplnum_nonzero_vs_truthMu, truthMu, nMatched, weight ) );
130  }
131  }
132 
133  return StatusCode::SUCCESS;
134 }
135 
137  const xAOD::TrackParticle&, unsigned int nMatched, float truthMu, float actualMu, float weight );
138 
140  const xAOD::TruthParticle&, unsigned int nMatched, float truthMu, float actualMu, float weight );
141 
142 
147 {
148  ATH_MSG_DEBUG( "Finalising duplicate rate plots" );
150 }
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:18
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:79
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:84
IDTPM::DuplicateRatePlots::DuplicateRatePlots
DuplicateRatePlots(PlotMgr *pParent, const std::string &dirName, const std::string &anaTag, const std::string &trackType, bool doGlobalPlots=false, bool doTruthMuPlots=false)
Constructor.
Definition: DuplicateRatePlots.cxx:18
IDTPM::z0
float z0(const U &p)
Definition: TrackParametersHelper.h:72
fillPlots< xAOD::TruthParticle >
template StatusCode IDTPM::DuplicateRatePlots::fillPlots< xAOD::TruthParticle >(const xAOD::TruthParticle &, unsigned int nMatched, float truthMu, float actualMu, float weight)
PrintTrkAnaSummary.dirName
dirName
Definition: PrintTrkAnaSummary.py:275
IDTPM::phi
float phi(const U &p)
Definition: TrackParametersHelper.h:61
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IDTPM::DuplicateRatePlots::finalizePlots
void finalizePlots()
Print out final stats on histograms.
Definition: DuplicateRatePlots.cxx:146
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
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:43
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:40
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:84
IDTPM::pT
float pT(const U &p)
Accessor utility function for getting the value of pT.
Definition: TrackParametersHelper.h:33
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IDTPM::DuplicateRatePlots::initializePlots
void initializePlots()
Book the histograms.
Definition: DuplicateRatePlots.cxx:31
DuplicateRatePlots.h
lumiFormat.fill
fill
Definition: lumiFormat.py:104
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43