ATLAS Offline Software
InDetPerfPlot_Efficiency.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include "logLinearBinning.h"
9 #include "GaudiKernel/SystemOfUnits.h" //for Gaudi::Units
10 using namespace IDPVM;
11 
13  InDetPlotBase(pParent, sDir){
14  // nop
15 }
16 
17 void
19 
20  book(m_efficiency_vs_pteta, "efficiency_vs_pteta");
21  book(m_efficiency_vs_ptTruthMu, "efficiency_vs_ptTruthMu");
22  book(m_efficiency_vs_ptActualMu, "efficiency_vs_ptActualMu");
23 
24  book(m_efficiency_vs_etaTruthMu, "efficiency_vs_absEtaTruthMu");
25  book(m_efficiency_vs_etaActualMu, "efficiency_vs_absEtaActualMu");
26 
27  for(unsigned int i=0; i<m_eta_bins.size()-1; i++){
28  m_efficiency_vs_truthMu_eta_bin.emplace_back();
29  m_efficiency_vs_actualMu_eta_bin.emplace_back();
30 
31  std::string bin_low = std::to_string(m_eta_bins[i]);
32  size_t dotPos = bin_low.find('.');
33  bin_low.resize(dotPos+2);
34  bin_low.replace(dotPos, 1, 1, 'p');
35  std::string bin_up = std::to_string(m_eta_bins[i+1]);
36  dotPos = bin_up.find('.');
37  bin_up.resize(dotPos+2);
38  bin_up.replace(dotPos, 1, 1, 'p');
39 
41  "efficiency_vs_truthMu_absEta_"+bin_low+"_"+bin_up);
43  "efficiency_vs_actualMu_absEta_"+bin_low+"_"+bin_up);
44  }
45 
46  book(m_efficiency_vs_eta, "efficiency_vs_eta");
47  book(m_efficiency_vs_pt, "efficiency_vs_pt");
48  book(m_efficiency_vs_pt_low, "efficiency_vs_pt_low");
49  book(m_efficiency_vs_pt_high, "efficiency_vs_pt_high");
50  book(m_efficiency_vs_lowpt, "efficiency_vs_lowpt");
51  book(m_efficiency_vs_phi, "efficiency_vs_phi");
52  book(m_efficiency_vs_d0, "efficiency_vs_d0");
53  book(m_efficiency_vs_d0_abs, "efficiency_vs_d0_abs");
54  book(m_efficiency_vs_z0, "efficiency_vs_z0");
55  book(m_efficiency_vs_z0_abs, "efficiency_vs_z0_abs");
56  book(m_efficiency_vs_R, "efficiency_vs_R");
57  book(m_efficiency_vs_Z, "efficiency_vs_Z");
58  book(m_efficiency_vs_truthMu, "efficiency_vs_truthMu");
59  book(m_efficiency_vs_actualMu, "efficiency_vs_actualMu");
60 
61  book(m_technical_efficiency_vs_pteta, "technical_efficiency_vs_pteta");
62  book(m_technical_efficiency_vs_eta, "technical_efficiency_vs_eta");
63  book(m_technical_efficiency_vs_pt, "technical_efficiency_vs_pt");
64  book(m_technical_efficiency_vs_phi, "technical_efficiency_vs_phi");
65  book(m_technical_efficiency_vs_d0, "technical_efficiency_vs_d0");
66  book(m_technical_efficiency_vs_z0, "technical_efficiency_vs_z0");
67  book(m_technical_efficiency_vs_truthMu, "technical_efficiency_vs_truthMu");
68  book(m_technical_efficiency_vs_actualMu, "technical_efficiency_vs_actualMu");
69 
70  book(m_extended_efficiency_vs_d0, "extended_efficiency_vs_d0");
71  book(m_extended_efficiency_vs_d0_abs, "extended_efficiency_vs_d0_abs");
72  book(m_extended_efficiency_vs_z0, "extended_efficiency_vs_z0");
73  book(m_extended_efficiency_vs_z0_abs, "extended_efficiency_vs_z0_abs");
74  book(m_efficiency_vs_prodR, "efficiency_vs_prodR");
75  book(m_efficiency_vs_prodR_extended, "efficiency_vs_prodR_extended");
76  book(m_efficiency_vs_prodZ, "efficiency_vs_prodZ");
77  book(m_efficiency_vs_prodZ_extended, "efficiency_vs_prodZ_extended");
78 
79  book(m_TrkRec_eta, "TrkRec_eta");
80  book(m_TrkRec_d0, "TrkRec_d0");
81  book(m_TrkRec_prodR, "TrkRec_prodR");
82  book(m_TrkRec_pT, "TrkRec_pT");
83  book(m_TrkRec_truthMu, "TrkRec_truthMu");
84  book(m_TrkRec_actualMu, "TrkRec_actualMu");
85  book(m_TrkRec_eta_d0, "TrkRec_eta_d0");
86  book(m_TrkRec_eta_prodR, "TrkRec_eta_prodR");
87  book(m_TrkRec_eta_pT, "TrkRec_eta_pT");
88 
89  book(m_efficiency_vs_pt_log, "efficiency_vs_pt_log");
90  const TH1* h = m_efficiency_vs_pt_log->GetTotalHistogram();
91  int nbins = h->GetNbinsX();
92  std::vector<double> logptbins = IDPVM::logLinearBinning(nbins, h->GetBinLowEdge(1), h->GetBinLowEdge(nbins + 1), false);
93  m_efficiency_vs_pt_log->SetBins(nbins, logptbins.data());
94 }
95 
96 void
97 InDetPerfPlot_Efficiency::fill(const xAOD::TruthParticle& truth, const bool isGood, unsigned int truthMu, float actualMu, float weight) {
98  double eta = truth.eta();
99  double pt = truth.pt() / Gaudi::Units::GeV; // convert MeV to GeV
100  double phi = truth.phi();
101 
103  fillHisto(m_efficiency_vs_ptTruthMu, pt, truthMu, isGood, weight);
104  fillHisto(m_efficiency_vs_ptActualMu, pt, actualMu, isGood, weight);
105 
106  fillHisto(m_efficiency_vs_etaTruthMu, std::abs(eta), truthMu, isGood, weight);
107  fillHisto(m_efficiency_vs_etaActualMu, std::abs(eta), actualMu, isGood, weight);
108 
109  const auto pVal = std::lower_bound(m_eta_bins.begin(), m_eta_bins.end(), std::abs(eta));
110  const int bin = std::distance(m_eta_bins.begin(), pVal) - 1;
113 
121 
122  static const SG::ConstAccessor<float> d0Acc("d0");
123  static const SG::ConstAccessor<float> z0Acc("z0");
124  static const SG::ConstAccessor<float> prodRAcc("prodR");
125  static const SG::ConstAccessor<float> prodZAcc("prodZ");
126  double d0 = d0Acc(truth);
127  double z0 = z0Acc(truth);
128  double R = prodRAcc(truth);
129  double Z = prodZAcc(truth);
131  fillHisto(m_efficiency_vs_d0_abs, std::abs(d0), isGood, weight);
133  fillHisto(m_efficiency_vs_z0_abs, std::abs(z0), isGood, weight);
134  fillHisto(m_efficiency_vs_R, R, isGood, weight);
135  fillHisto(m_efficiency_vs_Z, Z, isGood, weight);
136 
138  fillHisto(m_extended_efficiency_vs_d0_abs, std::abs(d0), isGood, weight);
140  fillHisto(m_extended_efficiency_vs_z0_abs, std::abs(z0), isGood, weight);
141  fillHisto(m_efficiency_vs_truthMu, truthMu, isGood, weight);
142  fillHisto(m_efficiency_vs_actualMu, actualMu, isGood, weight);
143 
144  fillHisto(m_TrkRec_eta, eta, isGood, weight);
145  fillHisto(m_TrkRec_d0, d0, isGood, weight);
146  fillHisto(m_TrkRec_pT, pt, isGood, weight);
147  fillHisto(m_TrkRec_truthMu, truthMu, isGood, weight);
148  fillHisto(m_TrkRec_actualMu, actualMu, isGood, weight);
149 
150  fillHisto(m_TrkRec_eta_d0, eta, d0, isGood, weight);
151  fillHisto(m_TrkRec_eta_pT, eta, pt, isGood, weight);
152 
153  if (truth.hasProdVtx()) {
154  const xAOD::TruthVertex* vtx = truth.prodVtx();
155  double prod_rad = vtx->perp();
156  double prod_z = vtx->z();
157  fillHisto(m_efficiency_vs_prodR, prod_rad, isGood, weight);
158  fillHisto(m_efficiency_vs_prodR_extended, prod_rad, isGood, weight);
159  fillHisto(m_efficiency_vs_prodZ, prod_z, isGood, weight);
161 
162  fillHisto(m_TrkRec_prodR, prod_rad, isGood, weight);
163 
164  fillHisto(m_TrkRec_eta_prodR, eta, prod_rad, isGood, weight);
165  }
166 }
167 
168 void
169 InDetPerfPlot_Efficiency::fillTechnicalEfficiency(const xAOD::TruthParticle& truth, const bool isGood, unsigned int truthMu, float actualMu, float weight) {
170  double eta = truth.eta();
171  double pt = truth.pt() / Gaudi::Units::GeV; // convert MeV to GeV
172  double phi = truth.phi();
177 
178  static const SG::ConstAccessor<float> d0Acc("d0");
179  static const SG::ConstAccessor<float> z0Acc("z0");
180  double d0 = d0Acc(truth);
181  double z0 = z0Acc(truth);
186 }
187 
188 
189 void
191 }
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_actualMu
TEfficiency * m_technical_efficiency_vs_actualMu
Definition: InDetPerfPlot_Efficiency.h:72
IDPVM
Class to retrieve associated truth from a track, implementing a cached response.
Definition: InDetPhysValMonitoringTool.h:55
InDetPerfPlot_Efficiency::m_efficiency_vs_pt_log
TEfficiency * m_efficiency_vs_pt_log
Definition: InDetPerfPlot_Efficiency.h:53
InDetPerfPlot_Efficiency::m_efficiency_vs_actualMu_eta_bin
std::vector< TEfficiency * > m_efficiency_vs_actualMu_eta_bin
Definition: InDetPerfPlot_Efficiency.h:43
InDetPerfPlot_Efficiency::m_efficiency_vs_prodR
TEfficiency * m_efficiency_vs_prodR
Definition: InDetPerfPlot_Efficiency.h:78
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
InDetPerfPlot_Efficiency::m_efficiency_vs_ptTruthMu
TEfficiency * m_efficiency_vs_ptTruthMu
Definition: InDetPerfPlot_Efficiency.h:37
InDetPerfPlot_Efficiency::m_extended_efficiency_vs_z0
TEfficiency * m_extended_efficiency_vs_z0
Definition: InDetPerfPlot_Efficiency.h:76
InDetPerfPlot_Efficiency.h
InDetPerfPlot_Efficiency::m_TrkRec_pT
TEfficiency * m_TrkRec_pT
Definition: InDetPerfPlot_Efficiency.h:86
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
InDetPlotBase::book
void book(Htype *&pHisto, const std::string &histoIdentifier, const std::string &nameOverride="", const std::string &folder="default")
Helper method to book histograms using an identifier string.
InDetPerfPlot_Efficiency::m_efficiency_vs_eta
TEfficiency * m_efficiency_vs_eta
Definition: InDetPerfPlot_Efficiency.h:49
InDetPerfPlot_Efficiency::m_efficiency_vs_truthMu
TEfficiency * m_efficiency_vs_truthMu
Definition: InDetPerfPlot_Efficiency.h:62
InDetPerfPlot_Efficiency::m_efficiency_vs_prodZ
TEfficiency * m_efficiency_vs_prodZ
Definition: InDetPerfPlot_Efficiency.h:80
InDetPerfPlot_Efficiency::m_efficiency_vs_etaActualMu
TEfficiency * m_efficiency_vs_etaActualMu
Definition: InDetPerfPlot_Efficiency.h:41
InDetPerfPlot_Efficiency::InDetPerfPlot_Efficiency
InDetPerfPlot_Efficiency(InDetPlotBase *pParent, const std::string &dirName)
Definition: InDetPerfPlot_Efficiency.cxx:12
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_eta
TEfficiency * m_technical_efficiency_vs_eta
Definition: InDetPerfPlot_Efficiency.h:66
InDetPerfPlot_Efficiency::initializePlots
void initializePlots()
Definition: InDetPerfPlot_Efficiency.cxx:18
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
InDetPerfPlot_Efficiency::finalizePlots
void finalizePlots()
Definition: InDetPerfPlot_Efficiency.cxx:190
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:60
InDetPerfPlot_Efficiency::m_efficiency_vs_z0
TEfficiency * m_efficiency_vs_z0
Definition: InDetPerfPlot_Efficiency.h:58
InDetPerfPlot_Efficiency::m_TrkRec_eta
TEfficiency * m_TrkRec_eta
Definition: InDetPerfPlot_Efficiency.h:83
InDetPerfPlot_Efficiency::m_TrkRec_actualMu
TEfficiency * m_TrkRec_actualMu
Definition: InDetPerfPlot_Efficiency.h:88
test_pyathena.pt
pt
Definition: test_pyathena.py:11
bin
Definition: BinsDiffFromStripMedian.h:43
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_z0
TEfficiency * m_technical_efficiency_vs_z0
Definition: InDetPerfPlot_Efficiency.h:70
InDetPerfPlot_Efficiency::m_extended_efficiency_vs_d0
TEfficiency * m_extended_efficiency_vs_d0
Definition: InDetPerfPlot_Efficiency.h:74
InDetPerfPlot_Efficiency::m_efficiency_vs_prodZ_extended
TEfficiency * m_efficiency_vs_prodZ_extended
Definition: InDetPerfPlot_Efficiency.h:81
SG::ConstAccessor< float >
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_pteta
TEfficiency * m_technical_efficiency_vs_pteta
Definition: InDetPerfPlot_Efficiency.h:65
InDetPerfPlot_Efficiency::m_TrkRec_truthMu
TEfficiency * m_TrkRec_truthMu
Definition: InDetPerfPlot_Efficiency.h:87
InDetPerfPlot_Efficiency::m_extended_efficiency_vs_d0_abs
TEfficiency * m_extended_efficiency_vs_d0_abs
Definition: InDetPerfPlot_Efficiency.h:75
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
InDetPerfPlot_Efficiency::m_efficiency_vs_pt_high
TEfficiency * m_efficiency_vs_pt_high
Definition: InDetPerfPlot_Efficiency.h:52
InDetPerfPlot_Efficiency::m_efficiency_vs_pteta
TEfficiency * m_efficiency_vs_pteta
Definition: InDetPerfPlot_Efficiency.h:36
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
IDPVM::logLinearBinning
std::vector< double > logLinearBinning(const unsigned int nBins, const double absXmin, const double absXmax, const bool symmetriseAroundZero)
Definition: logLinearBinning.cxx:16
InDetPerfPlot_Efficiency::m_efficiency_vs_R
TEfficiency * m_efficiency_vs_R
Definition: InDetPerfPlot_Efficiency.h:60
InDetPerfPlot_Efficiency::m_efficiency_vs_ptActualMu
TEfficiency * m_efficiency_vs_ptActualMu
Definition: InDetPerfPlot_Efficiency.h:38
InDetPlotBase
Mixin class to give extra capabilities to plots such as ATH_MSG and an easier booking interface,...
Definition: InDetPlotBase.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
h
InDetPerfPlot_Efficiency::m_TrkRec_prodR
TEfficiency * m_TrkRec_prodR
Definition: InDetPerfPlot_Efficiency.h:85
logLinearBinning.h
InDetPerfPlot_Efficiency::fillTechnicalEfficiency
void fillTechnicalEfficiency(const xAOD::TruthParticle &truth, const bool isGood, unsigned int truthMu, float actualMu, float weight)
Definition: InDetPerfPlot_Efficiency.cxx:169
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
xAOD::TruthVertex_v1::perp
float perp() const
Vertex transverse distance from the beam line.
Definition: TruthVertex_v1.cxx:163
xAOD::TruthParticle_v1::hasProdVtx
bool hasProdVtx() const
Check for a production vertex on this particle.
Definition: TruthParticle_v1.cxx:74
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
InDetPerfPlot_Efficiency::m_eta_bins
std::vector< float > m_eta_bins
Definition: InDetPerfPlot_Efficiency.h:44
InDetPerfPlot_Efficiency::m_efficiency_vs_truthMu_eta_bin
std::vector< TEfficiency * > m_efficiency_vs_truthMu_eta_bin
Definition: InDetPerfPlot_Efficiency.h:42
AnalysisUtils::Delta::R
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Definition: AnalysisMisc.h:49
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
InDetPerfPlot_Efficiency::m_TrkRec_d0
TEfficiency * m_TrkRec_d0
Definition: InDetPerfPlot_Efficiency.h:84
InDetPerfPlot_Efficiency::m_efficiency_vs_z0_abs
TEfficiency * m_efficiency_vs_z0_abs
Definition: InDetPerfPlot_Efficiency.h:59
TruthVertex.h
InDetPerfPlot_Efficiency::fill
void fill(const xAOD::TruthParticle &truth, const bool isGood, unsigned int truthMu, float actualMu, float weight)
Definition: InDetPerfPlot_Efficiency.cxx:97
xAOD::TruthParticle_v1::prodVtx
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
Definition: TruthParticle_v1.cxx:80
InDetPerfPlot_Efficiency::m_TrkRec_eta_d0
TEfficiency * m_TrkRec_eta_d0
Definition: InDetPerfPlot_Efficiency.h:89
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
InDetPerfPlot_Efficiency::m_TrkRec_eta_prodR
TEfficiency * m_TrkRec_eta_prodR
Definition: InDetPerfPlot_Efficiency.h:90
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InDetPerfPlot_Efficiency::m_efficiency_vs_d0
TEfficiency * m_efficiency_vs_d0
Definition: InDetPerfPlot_Efficiency.h:56
xAOD::TruthParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TruthParticle_v1.cxx:174
InDetPerfPlot_Efficiency::m_efficiency_vs_Z
TEfficiency * m_efficiency_vs_Z
Definition: InDetPerfPlot_Efficiency.h:61
InDetPerfPlot_Efficiency::m_efficiency_vs_etaTruthMu
TEfficiency * m_efficiency_vs_etaTruthMu
Definition: InDetPerfPlot_Efficiency.h:40
InDetPerfPlot_Efficiency::m_efficiency_vs_d0_abs
TEfficiency * m_efficiency_vs_d0_abs
Definition: InDetPerfPlot_Efficiency.h:57
xAOD::TruthParticle_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
Definition: TruthParticle_v1.cxx:181
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_pt
TEfficiency * m_technical_efficiency_vs_pt
Definition: InDetPerfPlot_Efficiency.h:67
InDetPerfPlot_Efficiency::m_TrkRec_eta_pT
TEfficiency * m_TrkRec_eta_pT
Definition: InDetPerfPlot_Efficiency.h:91
InDetPerfPlot_Efficiency::m_efficiency_vs_prodR_extended
TEfficiency * m_efficiency_vs_prodR_extended
Definition: InDetPerfPlot_Efficiency.h:79
xAOD::TruthVertex_v1::z
float z() const
Vertex longitudinal distance along the beam line form the origin.
InDetPerfPlot_Efficiency::m_efficiency_vs_pt_low
TEfficiency * m_efficiency_vs_pt_low
Definition: InDetPerfPlot_Efficiency.h:51
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_truthMu
TEfficiency * m_technical_efficiency_vs_truthMu
Definition: InDetPerfPlot_Efficiency.h:71
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TruthParticle_v1.cxx:166
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_d0
TEfficiency * m_technical_efficiency_vs_d0
Definition: InDetPerfPlot_Efficiency.h:69
InDetPerfPlot_Efficiency::m_extended_efficiency_vs_z0_abs
TEfficiency * m_extended_efficiency_vs_z0_abs
Definition: InDetPerfPlot_Efficiency.h:77
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
InDetPlotBase::fillHisto
static void fillHisto(TProfile *pTprofile, const float bin, const float weight, const float weight2=1.0)
Definition: InDetPlotBase.cxx:82
InDetPerfPlot_Efficiency::m_technical_efficiency_vs_phi
TEfficiency * m_technical_efficiency_vs_phi
Definition: InDetPerfPlot_Efficiency.h:68
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
InDetPerfPlot_Efficiency::m_efficiency_vs_phi
TEfficiency * m_efficiency_vs_phi
Definition: InDetPerfPlot_Efficiency.h:55
InDetPerfPlot_Efficiency::m_efficiency_vs_actualMu
TEfficiency * m_efficiency_vs_actualMu
Definition: InDetPerfPlot_Efficiency.h:63
InDetPerfPlot_Efficiency::m_efficiency_vs_lowpt
TEfficiency * m_efficiency_vs_lowpt
Definition: InDetPerfPlot_Efficiency.h:54
InDetPerfPlot_Efficiency::m_efficiency_vs_pt
TEfficiency * m_efficiency_vs_pt
Definition: InDetPerfPlot_Efficiency.h:50