ATLAS Offline Software
InDetPerfPlot_TRTExtension.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 
15 
16 #include <cmath>
17 
18 using namespace IDPVM;
19 
21  InDetPlotBase(pParent, sDir),
22  m_resolutionMethod(IDPVM::ResolutionHelper::iterRMS_convergence),
23  m_fracTRTExtensions_vs_eta{},
24  m_fracTRTExtensions_vs_pt{},
25  m_fracTRTExtensions_vs_mu{},
26  m_fracTRTExtensions_vs_nvertices{},
27  m_fracTRTExtensions_matched_vs_eta{},
28  m_fracTRTExtensions_matched_vs_pt{},
29  m_chi2ndofTRTExtensions{},
30  m_chi2ndofNoTRTExtensions{},
31  m_ptresTRTExtensions_vs_eta{},
32  m_ptresTRTExtensions_vs_pt{},
33  m_ptresNoTRTExtensions_vs_eta{},
34  m_ptresNoTRTExtensions_vs_pt{},
35  m_reswidthTRTExtensions_vs_eta{},
36  m_resmeanTRTExtensions_vs_eta{},
37  m_reswidthTRTExtensions_vs_pt{},
38  m_resmeanTRTExtensions_vs_pt{},
39  m_reswidthNoTRTExtensions_vs_eta{},
40  m_resmeanNoTRTExtensions_vs_eta{},
41  m_reswidthNoTRTExtensions_vs_pt{},
42  m_resmeanNoTRTExtensions_vs_pt{},
43  m_ptpullTRTExtensions_vs_eta{},
44  m_ptpullTRTExtensions_vs_pt{},
45  m_ptpullNoTRTExtensions_vs_eta{},
46  m_ptpullNoTRTExtensions_vs_pt{},
47  m_pullwidthTRTExtensions_vs_eta{},
48  m_pullmeanTRTExtensions_vs_eta{},
49  m_pullwidthTRTExtensions_vs_pt{},
50  m_pullmeanTRTExtensions_vs_pt{},
51  m_pullwidthNoTRTExtensions_vs_eta{},
52  m_pullmeanNoTRTExtensions_vs_eta{},
53  m_pullwidthNoTRTExtensions_vs_pt{},
54  m_pullmeanNoTRTExtensions_vs_pt{}
55 
56 
57  {
58 }
59 
60 void
62 
63  book(m_fracTRTExtensions_vs_eta, "fracTRTExtensions_vs_eta");
64  book(m_fracTRTExtensions_vs_pt, "fracTRTExtensions_vs_pt");
65  book(m_fracTRTExtensions_vs_mu, "fracTRTExtensions_vs_mu");
66  book(m_fracTRTExtensions_vs_nvertices, "fracTRTExtensions_vs_nvertices");
67 
68  book(m_fracTRTExtensions_matched_vs_eta, "fracTRTExtensions_matched_vs_eta");
69  book(m_fracTRTExtensions_matched_vs_pt, "fracTRTExtensions_matched_vs_pt");
70 
71  book(m_chi2ndofTRTExtensions, "chi2ndofTRTExtensions");
72  book(m_chi2ndofNoTRTExtensions, "chi2ndofNoTRTExtensions");
73 
74  book(m_ptresTRTExtensions_vs_eta, "ptresTRTExtensions_vs_eta");
75  book(m_ptresTRTExtensions_vs_pt, "ptresTRTExtensions_vs_pt");
76  book(m_ptresNoTRTExtensions_vs_eta, "ptresNoTRTExtensions_vs_eta");
77  book(m_ptresNoTRTExtensions_vs_pt, "ptresNoTRTExtensions_vs_pt");
78 
79  book(m_reswidthTRTExtensions_vs_eta, "ptresolutionTRTExtensions_vs_eta");
80  book(m_resmeanTRTExtensions_vs_eta, "ptresmeanTRTExtensions_vs_eta");
81  book(m_reswidthTRTExtensions_vs_pt, "ptresolutionTRTExtensions_vs_pt");
82  book(m_resmeanTRTExtensions_vs_pt, "ptresmeanTRTExtensions_vs_pt");
83 
84  book(m_reswidthNoTRTExtensions_vs_eta, "ptresolutionNoTRTExtensions_vs_eta");
85  book(m_resmeanNoTRTExtensions_vs_eta, "ptresmeanNoTRTExtensions_vs_eta");
86  book(m_reswidthNoTRTExtensions_vs_pt, "ptresolutionNoTRTExtensions_vs_pt");
87  book(m_resmeanNoTRTExtensions_vs_pt, "ptresmeanNoTRTExtensions_vs_pt");
88 
89 
90  book(m_ptpullTRTExtensions_vs_eta, "ptpullTRTExtensions_vs_eta");
91  book(m_ptpullTRTExtensions_vs_pt, "ptpullTRTExtensions_vs_pt");
92  book(m_ptpullNoTRTExtensions_vs_eta, "ptpullNoTRTExtensions_vs_eta");
93  book(m_ptpullNoTRTExtensions_vs_pt, "ptpullNoTRTExtensions_vs_pt");
94 
95  book(m_pullwidthTRTExtensions_vs_eta, "ptpullwidthTRTExtensions_vs_eta");
96  book(m_pullmeanTRTExtensions_vs_eta, "ptpullmeanTRTExtensions_vs_eta");
97  book(m_pullwidthTRTExtensions_vs_pt, "ptpullwidthTRTExtensions_vs_pt");
98  book(m_pullmeanTRTExtensions_vs_pt, "ptpullmeanTRTExtensions_vs_pt");
99 
100  book(m_pullwidthNoTRTExtensions_vs_eta, "ptpullwidthNoTRTExtensions_vs_eta");
101  book(m_pullmeanNoTRTExtensions_vs_eta, "ptpullmeanNoTRTExtensions_vs_eta");
102  book(m_pullwidthNoTRTExtensions_vs_pt, "ptpullwidthNoTRTExtensions_vs_pt");
103  book(m_pullmeanNoTRTExtensions_vs_pt, "ptpullmeanNoTRTExtensions_vs_pt");
104 
105 }
106 
107 void
109 
110  double eta = particle.eta();
111  double pt = particle.pt() / Gaudi::Units::GeV;
112  float chi2 = particle.chiSquared();
113  float ndof = particle.numberDoF();
114  float chi2Overndof = ndof > 0 ? chi2 / ndof : 0;
115 
116  uint8_t iTrtHits = 0;
117  particle.summaryValue(iTrtHits, xAOD::numberOfTRTHits);
118 
119  std::bitset<xAOD::TrackPatternRecoInfo::NumberOfTrackRecoInfo> patternInfo = particle.patternRecoInfo();
120  bool isTRTExtension = patternInfo.test(xAOD::TrackPatternRecoInfo::InDetExtensionProcessor) or iTrtHits > 0;
121 
122  fillHisto(m_fracTRTExtensions_vs_eta, eta, isTRTExtension, weight);
123  fillHisto(m_fracTRTExtensions_vs_pt, pt, isTRTExtension, weight);
124 
125  if(isTRTExtension) fillHisto(m_chi2ndofTRTExtensions, chi2Overndof, weight);
126  else { fillHisto(m_chi2ndofNoTRTExtensions, chi2Overndof, weight); }
127 
128 }
129 
130 void
131 InDetPerfPlot_TRTExtension::fill(const xAOD::TrackParticle& particle, const float mu, const unsigned int nvertices, float weight) {
132 
133  uint8_t iTrtHits = 0;
134  particle.summaryValue(iTrtHits, xAOD::numberOfTRTHits);
135 
136  std::bitset<xAOD::TrackPatternRecoInfo::NumberOfTrackRecoInfo> patternInfo = particle.patternRecoInfo();
137  bool isTRTExtension = patternInfo.test(xAOD::TrackPatternRecoInfo::InDetExtensionProcessor) or iTrtHits > 0;
138 
139  fillHisto(m_fracTRTExtensions_vs_mu, mu, isTRTExtension, weight);
140  fillHisto(m_fracTRTExtensions_vs_nvertices, nvertices, isTRTExtension, weight);
141 
142 }
143 
144 void
146 
147  //Fraction of extended for truth matched tracks
148 
149  uint8_t iTrtHits = 0;
150  particle.summaryValue(iTrtHits, xAOD::numberOfTRTHits);
151 
152  std::bitset<xAOD::TrackPatternRecoInfo::NumberOfTrackRecoInfo> patternInfo = particle.patternRecoInfo();
153  bool isTRTExtension = patternInfo.test(3) or iTrtHits > 0;
154 
155  //Get pT resolution for TRT extensions versus without
156  const float undefinedValue = -9999;
157  const float smallestAllowableTan = 1e-8;
158  const float sinTheta{std::sin(particle.theta())};
159  const bool saneSineValue = (std::abs(sinTheta) > 1e-8);
160  const float inverseSinTheta = saneSineValue ? 1./sinTheta : undefinedValue;
161  float track_qopt = saneSineValue ? particle.qOverP()*inverseSinTheta : undefinedValue;
162  const float qopterr = std::sqrt(particle.definingParametersCovMatrix()(4, 4)) * inverseSinTheta;
163 
164  static const SG::ConstAccessor<float> qOverPAcc("qOverP");
165  static const SG::ConstAccessor<float> thetaAcc("theta");
166  const float truth_qop = qOverPAcc.isAvailable(truthParticle) ? qOverPAcc(truthParticle) : undefinedValue;
167  const float truth_theta = thetaAcc.isAvailable(truthParticle) ? thetaAcc(truthParticle) : undefinedValue;
168  float truth_qopt = std::abs(truth_theta) > 0 ? truth_qop * 1/(std::sin(truth_theta)) : undefinedValue;
169 
170  float ptres = (track_qopt - truth_qopt) * ( 1 / truth_qopt);
171  float ptpull = qopterr > smallestAllowableTan ? (track_qopt - truth_qopt) / qopterr : undefinedValue;
172  float pt = truthParticle.pt() / Gaudi::Units::GeV;
173  const float tanHalfTheta = std::tan(truth_theta * 0.5);
174  const bool tanThetaIsSane = std::abs(tanHalfTheta) > smallestAllowableTan;
175  float eta = undefinedValue;
176  if (tanThetaIsSane) eta = -std::log(tanHalfTheta);
177 
178 
179  if(isTRTExtension){
182 
185  } else {
188 
191  }
192 
195 
196 
197 }
198 
199 
200 void
202 
207 
208 
213 
214 }
IDPVM
Class to retrieve associated truth from a track, implementing a cached response.
Definition: InDetPhysValMonitoringTool.h:55
InDetPerfPlot_TRTExtension::m_ptresTRTExtensions_vs_pt
TH2 * m_ptresTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:50
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
IDTPM::ndof
float ndof(const U &p)
Definition: TrackParametersHelper.h:132
InDetPerfPlot_TRTExtension::m_chi2ndofTRTExtensions
TH1 * m_chi2ndofTRTExtensions
Definition: InDetPerfPlot_TRTExtension.h:46
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
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.
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
InDetPerfPlot_TRTExtension::m_pullmeanTRTExtensions_vs_eta
TH1 * m_pullmeanTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:70
IDPVM::ResolutionHelper::makeResolutions
void makeResolutions(const TH2 *h_input2D, TH1 *hwidth, TH1 *hmean, TH1 *hproj[], bool saveProjections, IDPVM::ResolutionHelper::methods theMethod=IDPVM::ResolutionHelper::iterRMS_convergence)
extract 1D resolution plots from a 2D "residual vs observable" histogram.
Definition: InnerDetector/InDetValidation/InDetPhysValMonitoring/src/ResolutionHelper.cxx:288
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
InDetPerfPlot_TRTExtension::m_resmeanTRTExtensions_vs_pt
TH1 * m_resmeanTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:57
InDetPerfPlot_TRTExtension::m_ptresNoTRTExtensions_vs_pt
TH2 * m_ptresNoTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:52
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:60
InDetPerfPlot_TRTExtension::m_fracTRTExtensions_vs_nvertices
TEfficiency * m_fracTRTExtensions_vs_nvertices
Definition: InDetPerfPlot_TRTExtension.h:41
InDetPhysValMonitoringUtilities.h
InDetPerfPlot_TRTExtension::m_resolutionHelper
IDPVM::ResolutionHelper m_resolutionHelper
Definition: InDetPerfPlot_TRTExtension.h:34
test_pyathena.pt
pt
Definition: test_pyathena.py:11
xAOD::numberOfTRTHits
@ numberOfTRTHits
number of TRT hits [unit8_t].
Definition: TrackingPrimitives.h:275
SG::ConstAccessor< float >
InDetPerfPlot_TRTExtension::m_ptpullTRTExtensions_vs_eta
TH2 * m_ptpullTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:64
InDetPerfPlot_TRTExtension::m_resmeanNoTRTExtensions_vs_pt
TH1 * m_resmeanNoTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:62
InDetPerfPlot_TRTExtension::m_pullmeanNoTRTExtensions_vs_eta
TH1 * m_pullmeanNoTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:75
InDetPerfPlot_TRTExtension.h
InDetPerfPlot_TRTExtension::m_pullwidthNoTRTExtensions_vs_pt
TH1 * m_pullwidthNoTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:76
InDetPerfPlot_TRTExtension::m_chi2ndofNoTRTExtensions
TH1 * m_chi2ndofNoTRTExtensions
Definition: InDetPerfPlot_TRTExtension.h:47
IDPVM::ResolutionHelper
Definition: InnerDetector/InDetValidation/InDetPhysValMonitoring/InDetPhysValMonitoring/ResolutionHelper.h:28
InDetPerfPlot_TRTExtension::m_resmeanNoTRTExtensions_vs_eta
TH1 * m_resmeanNoTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:60
InDetPerfPlot_TRTExtension::m_fracTRTExtensions_matched_vs_pt
TEfficiency * m_fracTRTExtensions_matched_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:44
InDetPerfPlot_TRTExtension::m_reswidthNoTRTExtensions_vs_pt
TH1 * m_reswidthNoTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:61
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
InDetPerfPlot_TRTExtension::m_ptpullNoTRTExtensions_vs_eta
TH2 * m_ptpullNoTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:66
InDetPerfPlot_TRTExtension::m_ptpullTRTExtensions_vs_pt
TH2 * m_ptpullTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:65
InDetPerfPlot_TRTExtension::fill
void fill(const xAOD::TrackParticle &particle, float weight)
Definition: InDetPerfPlot_TRTExtension.cxx:108
InDetPerfPlot_TRTExtension::m_reswidthNoTRTExtensions_vs_eta
TH1 * m_reswidthNoTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:59
InDetPlotBase
Mixin class to give extra capabilities to plots such as ATH_MSG and an easier booking interface,...
Definition: InDetPlotBase.h:33
InDetPerfPlot_TRTExtension::m_fracTRTExtensions_vs_pt
TEfficiency * m_fracTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:39
InDetPerfPlot_TRTExtension::m_ptresTRTExtensions_vs_eta
TH2 * m_ptresTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:49
InDetPerfPlot_TRTExtension::m_pullwidthTRTExtensions_vs_eta
TH1 * m_pullwidthTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:69
InDetPerfPlot_TRTExtension::m_pullwidthNoTRTExtensions_vs_eta
TH1 * m_pullwidthNoTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:74
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
InDetPerfPlot_TRTExtension::finalizePlots
void finalizePlots()
Definition: InDetPerfPlot_TRTExtension.cxx:201
InDetPerfPlot_TRTExtension::InDetPerfPlot_TRTExtension
InDetPerfPlot_TRTExtension(InDetPlotBase *pParent, const std::string &dirName)
Definition: InDetPerfPlot_TRTExtension.cxx:20
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
InDetPerfPlot_TRTExtension::m_fracTRTExtensions_vs_eta
TEfficiency * m_fracTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:38
InDetPerfPlot_TRTExtension::m_pullmeanTRTExtensions_vs_pt
TH1 * m_pullmeanTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:72
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
InDetPerfPlot_TRTExtension::m_reswidthTRTExtensions_vs_pt
TH1 * m_reswidthTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:56
InDetPerfPlot_TRTExtension::m_pullmeanNoTRTExtensions_vs_pt
TH1 * m_pullmeanNoTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:77
InDetPerfPlot_TRTExtension::m_fracTRTExtensions_vs_mu
TEfficiency * m_fracTRTExtensions_vs_mu
Definition: InDetPerfPlot_TRTExtension.h:40
InDetPerfPlot_TRTExtension::initializePlots
void initializePlots()
Definition: InDetPerfPlot_TRTExtension.cxx:61
InDetPerfPlot_TRTExtension::m_fracTRTExtensions_matched_vs_eta
TEfficiency * m_fracTRTExtensions_matched_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:43
InDetPerfPlot_TRTExtension::m_ptpullNoTRTExtensions_vs_pt
TH2 * m_ptpullNoTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:67
InDetPerfPlot_TRTExtension::m_reswidthTRTExtensions_vs_eta
TH1 * m_reswidthTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:54
InDetPerfPlot_TRTExtension::m_pullwidthTRTExtensions_vs_pt
TH1 * m_pullwidthTRTExtensions_vs_pt
Definition: InDetPerfPlot_TRTExtension.h:71
InDetPerfPlot_TRTExtension::m_resmeanTRTExtensions_vs_eta
TH1 * m_resmeanTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:55
InDetPerfPlot_TRTExtension::m_ptresNoTRTExtensions_vs_eta
TH2 * m_ptresNoTRTExtensions_vs_eta
Definition: InDetPerfPlot_TRTExtension.h:51
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TruthParticle_v1.cxx:166
xAOD::InDetExtensionProcessor
@ InDetExtensionProcessor
Tracks with InDetExtensionProcessor used.
Definition: TrackingPrimitives.h:91
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
InDetPlotBase::fillHisto
static void fillHisto(TProfile *pTprofile, const float bin, const float weight, const float weight2=1.0)
Definition: InDetPlotBase.cxx:82
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
InDetPerfPlot_TRTExtension::m_resolutionMethod
IDPVM::ResolutionHelper::methods m_resolutionMethod
Definition: InDetPerfPlot_TRTExtension.h:35