ATLAS Offline Software
Loading...
Searching...
No Matches
MomentumTruthPullPlots.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <utility>
8
10#ifndef XAOD_ANALYSIS
12#endif // not XAOD_ANALYSIS
13
14namespace Muon {
15
17 const std::string& sDir,
18 std::string sType)
19 : PlotBase(pParent, sDir), m_sType(std::move(sType)) {}
20
22
25 Book1D("dp_CB_truthIP_" + m_sType,
26 m_sType + " pCB-ptruthIP;#Delta p;Entries", 200, -10, 10);
28 Book1D("dp_ME_truthIP_" + m_sType,
29 m_sType + " pME-ptruthIP;#Delta p;Entries", 200, -10, 10);
31 Book1D("dp_ME_truthIP_MS_truthMS_" + m_sType,
32 m_sType + " (pME-ptruthIP) - (pMS-ptruthMS);#Delta p;Entries",
33 200, -10, 10);
34 dp_eloss = Book1D("dp_eloss_" + m_sType,
35 m_sType + " dp_eloss;#Delta p;Entries", 200, -10, 10);
36
37 Double_t ptBins[] = {5, 10, 25, 60, 100, 200, 1000};
38 Double_t etaBins[] = {-2.7, -2.5, -1.7, -1.05, -0.1,
39 0.1, 1.05, 1.7, 2.5, 2.7};
40 // Double_t phiBins[] = {-3.15, -2.4, -1.6, -0.8, 0, 0.8, 1.6, 2.4, 3.15};
41
42 const unsigned int nptBins = sizeof(ptBins) / sizeof(ptBins[0]) - 1;
43 const unsigned int netaBins = sizeof(etaBins) / sizeof(etaBins[0]) - 1;
44
45 dp_CB_truthIP_vs_pt = Book2D("dp_CB_truthIP_vs_pt_" + m_sType,
46 m_sType + " pCB-ptruthIP vs pt;pt;#Delta p",
47 nptBins, ptBins, 100, -10., 10.);
48 dp_ME_truthIP_vs_pt = Book2D("dp_ME_truthIP_vs_pt_" + m_sType,
49 m_sType + " pME-ptruthIP vs pt;pt;#Delta p",
50 nptBins, ptBins, 100, -10., 10.);
52 Book2D("dp_ME_truthIP_MS_truthMS_vs_pt_" + m_sType,
53 m_sType + " (pME-ptruthIP) - (pMS-ptruthMS) vs pt;pt;#Delta p",
54 nptBins, ptBins, 200, -10., 10.);
55 dp_eloss_vs_pt = Book2D("dp_eloss_vs_pt_" + m_sType,
56 m_sType + " dp_eloss vs pt;pt [GeV]; #Delta p",
57 nptBins, ptBins, 100, -10., 10.);
58
59 dp_CB_truthIP_vs_eta = Book2D("dp_CB_truthIP_vs_eta_" + m_sType,
60 m_sType + " pCB-ptruthIP vs eta;eta;#Delta p",
61 netaBins, etaBins, 100, -10., 10.);
62 dp_ME_truthIP_vs_eta = Book2D("dp_ME_truthIP_vs_eta_" + m_sType,
63 m_sType + " pME-ptruthIP vs eta;eta;#Delta p",
64 netaBins, etaBins, 100, -10., 10.);
66 Book2D("dp_ME_truthIP_MS_truthMS_vs_eta_" + m_sType,
67 m_sType + " (pME-ptruthIP) - (pMS-ptruthMS) vs eta;eta;#Delta p",
68 netaBins, etaBins, 200, -10., 10.);
69 dp_eloss_vs_eta = Book2D("dp_eloss_vs_eta_" + m_sType,
70 m_sType + " dp_eloss vs eta;eta; #Delta p",
71 netaBins, etaBins, 100, -10., 10.);
72}
73
75 const xAOD::TrackParticle* msTrk,
76 const xAOD::TruthParticle& truthMu,
77 float weight) {
78 if (!(muon.muonType() == xAOD::Muon::MuonType::Combined ||
79 muon.muonType() == xAOD::Muon::MuonType::SegmentTagged ||
80 muon.muonType() == xAOD::Muon::MuonType::MuonStandAlone)) {
81 return;
82 }
83
84 using enum xAOD::Muon::TrackParticleType;
85 const xAOD::TrackParticle* muPrimaryTrk = muon.trackParticle(Primary);
86
87 const xAOD::TrackParticle* msExtrapTrk = muon.trackParticle(ExtrapolatedMuonSpectrometerTrackParticle);
88 if (!msExtrapTrk) {
89 msExtrapTrk = muon.trackParticle(MuonSpectrometerTrackParticle);
90 }
91
92 float eta = truthMu.eta();
93 float pt = 0.001 * truthMu.pt();
94
95 float pTruth = truthMu.p4().P();
96 float pCB = muPrimaryTrk->p4().P();
97 float pME = 0;
98 if (msExtrapTrk) {
99 pME = msExtrapTrk->p4().P(); // muon extrapolated
100 }
101 float pMS = 0;
102 if (msTrk) {
103 pMS = msTrk->p4().P(); // at muon spectrometer entry//@@@
104 }
105
106 float eloss = 0;
107 if (muon.parameter(eloss, xAOD::Muon::ParamDef::MeasEnergyLoss)) {
108 ;
109 }
110 float pTruthMS = 0; // p truth at MS entry
111 static const SG::ConstAccessor<float> entpxAcc("MuonEntryLayer_px");
112 static const SG::ConstAccessor<float> entpyAcc("MuonEntryLayer_py");
113 static const SG::ConstAccessor<float> entpzAcc("MuonEntryLayer_pz");
114 if (entpxAcc.isAvailable(truthMu) && entpyAcc.isAvailable(truthMu) &&
115 entpzAcc.isAvailable(truthMu)) {
116 Amg::Vector3D pvecTruthMS{entpxAcc(truthMu), entpyAcc(truthMu),
117 entpzAcc(truthMu)};
118 pTruthMS = pvecTruthMS.mag();
119 }
120
121 if (muon.muonType() != xAOD::Muon::MuonType::SegmentTagged) {
122 if (pTruth) {
123 float dpCB = 0.001 * (pCB - pTruth);
124 dp_CB_truthIP->Fill(dpCB, weight);
125 dp_CB_truthIP_vs_pt->Fill(pt, dpCB, weight);
126 dp_CB_truthIP_vs_eta->Fill(eta, dpCB, weight);
127 if (pME) {
128 float dpME = 0.001 * (pME - pTruth);
129 dp_ME_truthIP->Fill(dpME, weight);
130 dp_ME_truthIP_vs_pt->Fill(pt, dpME, weight);
131 dp_ME_truthIP_vs_eta->Fill(eta, dpME, weight);
132 if (pMS && pTruthMS) {
133 float dpMS = 0.001 * (pME - pMS - pTruth + pTruthMS);
134 dp_ME_truthIP_MS_truthMS->Fill(dpMS, weight);
135 dp_ME_truthIP_MS_truthMS_vs_pt->Fill(pt, dpMS, weight);
136 dp_ME_truthIP_MS_truthMS_vs_eta->Fill(eta, dpMS, weight);
137 }
138 }
139 }
140 }
141
142 if (eloss > 2000 && pTruthMS && pTruth) {
143 float dpEloss = 0.001 * (pTruth - pTruthMS - eloss);
144 dp_eloss->Fill(dpEloss, weight);
145 dp_eloss_vs_pt->Fill(pt, dpEloss, weight);
146 dp_eloss_vs_eta->Fill(eta, dpEloss, weight);
147 }
148}
149
150} // namespace Muon
Scalar eta() const
pseudorapidity method
Helper class to provide constant type-safe access to aux data.
MomentumTruthPullPlots(PlotBase *pParent, const std::string &sDir, std::string sType)
void fill(const xAOD::Muon &muon, const xAOD::TrackParticle *muontpIP, const xAOD::TruthParticle &truthprt, float weight=1.0)
TH1D * Book1D(std::string_view name, std::string_view labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
Definition PlotBase.cxx:94
PlotBase(PlotBase *parent, std::string_view sDir)
Definition PlotBase.cxx:29
TH2F * Book2D(std::string_view name, std::string_view labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir=true)
Book a TH2F histogram.
Definition PlotBase.cxx:123
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Eigen::Matrix< double, 3, 1 > Vector3D
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
STL namespace.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version: