ATLAS Offline Software
Loading...
Searching...
No Matches
MuonParamElossPlots.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
9
10namespace Muon {
11
13 const std::string& sDir)
14 : PlotBase(pParent, sDir) {}
15
18 "msInnerMatchChi2",
19 "inner match #chi^{2};inner match #chi^{2};;Entries", 100, 0., 100.);
21 "msOuterMatchChi2",
22 "outer match #chi^{2};outer match #chi^{2};;Entries", 100, 0., 100.);
23
24 ELoss = Book1D("ELoss", "ELoss;ELoss [GeV];Entries", 50, 0, 10);
26 "ELossDiffTruth",
27 "Difference ELoss to truth ELoss);#Delta(fitted - truth) [GeV];Entries",
28 100, -10., 10.);
30 Book1D("ELossDiffTruthEta0_1p35",
31 "Difference ELoss to truth ELoss for "
32 "0<|#eta|<1.35;#Delta(fitted - truth) [GeV];Entries",
33 100, -10., 10.);
35 Book1D("ELossDiffTruthEta1p35_1p55",
36 "Difference ELoss to truth ELoss for "
37 "1.35<|#eta|<1.55;#Delta(fitted - truth) [GeV];Entries",
38 100, -10., 10.);
40 Book1D("ELossDiffTruthEta1p55_end",
41 "Difference ELoss to truth ELoss for 1.55<|#eta|;#Delta(fitted "
42 "- truth) [GeV];Entries",
43 100, -10., 10.);
45 Book1D("ELossSigma", "ELossSigma;ELossSgima [GeV];Entries", 50, 0, 5);
46
48 Book1D("paramELoss", "paramELoss;paramELoss [GeV];Entries", 50, 0, 10);
49 paramELossDiff = Book1D("paramELossDiff",
50 "Difference paramELoss to fitted "
51 "ELoss;#Delta(param-fitted) [GeV];Entries",
52 100, -3., 1.);
53 paramELossDiffTruth = Book1D("paramELossDiffTruth",
54 "Difference paramELoss to truth "
55 "ELoss;#Delta(param-truth) [GeV];Entries",
56 100, -10., 10.);
58 Book1D("paramELossDiffTruthEta0_1p35",
59 "Difference paramELoss to truth ELoss for "
60 "0<|#eta|<1.35;#Delta(param-truth) [GeV];Entries",
61 100, -10., 10.);
63 Book1D("paramELossDiffTruthEta1p35_1p55",
64 "Difference paramELoss to truth ELoss for "
65 "1.35<|#eta|<1.55;#Delta(param-truth) [GeV];Entries",
66 100, -10., 10.);
68 Book1D("paramELossDiffTruthhEta1p55_end",
69 "Difference paramELoss to truth ELoss for "
70 "1.55<|#eta|;#Delta(param-truth) [GeV];Entries",
71 100, -10., 10.);
72
73 measELoss =
74 Book1D("measELoss", "measELoss;measELoss [GeV];Entries", 50, 0, 10);
75 measELossDiff = Book1D("measELossDiff",
76 "Difference measELoss to fitted ELoss);#Delta(meas- "
77 "fitted) [GeV];Entries",
78 100, -3., 1.);
79 measELossDiffTruth = Book1D("measELossDiffTruth",
80 "Difference measELoss to truth "
81 "ELoss);#Delta(meas- truth) [GeV];Entries",
82 100, -10., 10.);
84 Book1D("measELossDiffTruthEta0_1p35",
85 "Difference measELoss to truth ELoss for "
86 "0<|#eta|<1.35;#Delta(meas- truth) [GeV];Entries",
87 100, -10., 10.);
89 Book1D("measELossDiffTruthEta1p35_1p55",
90 "Difference measELoss to truth ELoss for "
91 "1.35<|#eta|<1.55;#Delta(meas- truth) [GeV];Entries",
92 100, -10., 10.);
94 Book1D("measELossDiffTruthEta1p55_end",
95 "Difference measELoss to truth ELoss for "
96 "1.55<|#eta|;#Delta(meas- truth) [GeV];Entries",
97 100, -10., 10.);
98
99 ELossType = Book1D("ELossType", "ELossType;Type;Entries", 5, -0.5, 4.5);
101 Book1D("ELossTypeParametrPt",
102 "ELossType:Parametrized Pt;Pt [GeV];Entries", 50, 0, 500);
104 Book1D("ELossTypeNotIsoPt", "ELossType:NotIsolated Pt;Pt [GeV];Entries",
105 50, 0, 500);
106 ELossTypeTailPt = Book1D("ELossTypeTailPt",
107 "ELossType:Tail Pt;Pt [GeV];Entries", 50, 0, 500);
108 ELossTypeAllPt = Book1D("ELossTypeAllPt",
109 "All ELossTypes Pt;Pt [GeV];Entries", 50, 0, 500);
110}
111
113 const xAOD::Muon& mu, float weight) {
114 FillPlot(msInnerMatchChi2, mu, xAOD::Muon::ParamDef::msInnerMatchChi2, weight);
115 FillPlot(msOuterMatchChi2, mu, xAOD::Muon::ParamDef::msOuterMatchChi2, weight);
116#ifndef XAOD_ANALYSIS
119 xAOD::Muon::ParamDef::EnergyLoss, 0.001, weight);
122 truthmu, mu, xAOD::Muon::ParamDef::MeasEnergyLoss, 0.001, weight);
123 FillPlot(ELossSigma, mu, xAOD::Muon::ParamDef::EnergyLossSigma, 0.001, weight);
126 truthmu, mu, xAOD::Muon::ParamDef::ParamEnergyLoss, 0.001, weight);
127 FillPlotELossType(ELossType, mu, 0.001, weight);
128 FillPlotELossType(ELossTypeNotIsoPt, mu, xAOD::Muon::EnergyLossType::NotIsolated, 0.001,
129 weight);
130 FillPlotELossType(ELossTypeParametrPt, mu, xAOD::Muon::EnergyLossType::Parametrized, 0.001,
131 weight);
132 FillPlotELossType(ELossTypeTailPt, mu, xAOD::Muon::EnergyLossType::Tail, 0.001, weight);
133#endif // not XAOD_ANALYSIS
134}
136 const xAOD::Muon::ParamDef paramDef,
137 float scale, float weight) {
138 if (mu.muonType() == xAOD::Muon::MuonType::CaloTagged) {
139 return; // protection
140 }
141 float fpar = 0;
142 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
143 if (elossAcc.isAvailable(mu)) {
144 if (mu.parameter(fpar, paramDef)) {
145 hist->Fill(scale * fpar, weight); // scale to GeV, if needed
146 }
147 }
148 return;
149}
151 TH1* hist, TH1* hist_DiffTruth, TH1* hist_DiffTruthEta0_1p35,
152 TH1* hist_DiffTruthEta1p35_1p55, TH1* hist_DiffTruthEta1p55_end,
153 const xAOD::TruthParticle& truthprt, const xAOD::Muon& mu,
154 const xAOD::Muon::ParamDef paramDef, float scale, float weight) {
155 if (mu.muonType() == xAOD::Muon::MuonType::CaloTagged) {
156 return; // protection
157 }
158 float fpar = 0;
159 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
160 if (elossAcc.isAvailable(mu)) {
161 if (mu.parameter(fpar, paramDef)) {
162 hist->Fill(scale * fpar, weight); // scale to GeV, if needed
163 }
164
165 // get true energy loss
166 static const SG::ConstAccessor<float> pxAcc("px");
167 static const SG::ConstAccessor<float> pyAcc("py");
168 static const SG::ConstAccessor<float> pzAcc("pz");
169 static const SG::ConstAccessor<float> muonEnt_pxAcc(
170 "MuonEntryLayer_px");
171 static const SG::ConstAccessor<float> muonEnt_pyAcc(
172 "MuonEntryLayer_py");
173 static const SG::ConstAccessor<float> muonEnt_pzAcc(
174 "MuonEntryLayer_pz");
175 if (!pxAcc.isAvailable(truthprt) || !pyAcc.isAvailable(truthprt) ||
176 !pzAcc.isAvailable(truthprt) ||
177 !muonEnt_pxAcc.isAvailable(truthprt) ||
178 !muonEnt_pyAcc.isAvailable(truthprt) ||
179 !muonEnt_pzAcc.isAvailable(truthprt)) {
180 return;
181 }
182
183 // workaround for missing caloentry
184 Amg::Vector3D vecCaloEntry{pxAcc(truthprt), pyAcc(truthprt),
185 pzAcc(truthprt)};
186
187 Amg::Vector3D vecMuonExit{muonEnt_pxAcc(truthprt),
188 muonEnt_pyAcc(truthprt),
189 muonEnt_pzAcc(truthprt)};
190 float dpTruth = vecCaloEntry.mag() - vecMuonExit.mag();
191 hist_DiffTruth->Fill(scale * (fpar - dpTruth),
192 weight); // scale to GeV, if needed
193 // again in eta ranges
194 if (std::abs(mu.eta()) < 1.35) {
195 hist_DiffTruthEta0_1p35->Fill(scale * (fpar - dpTruth), weight);
196 } else {
197 if (std::abs(mu.eta()) < 1.55) {
198 hist_DiffTruthEta1p35_1p55->Fill(scale * (fpar - dpTruth),
199 weight);
200 } else {
201 hist_DiffTruthEta1p55_end->Fill(scale * (fpar - dpTruth),
202 weight);
203 }
204 }
205 }
206 return;
207}
209 float scale, float weight) {
210 if (mu.muonType() == xAOD::Muon::MuonType::CaloTagged) {
211 return; // protection
212 }
213 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
214 if (elossAcc.isAvailable(mu)) {
215 hist->Fill(static_cast<int>(mu.energyLossType()), weight);
216 ELossTypeAllPt->Fill(mu.pt() * scale, weight);
217 float used = 0;
218 float meas = -100000;
219 float param = -100000;
220 if (mu.parameter(used, xAOD::Muon::ParamDef::EnergyLoss) &&
221 mu.parameter(param, xAOD::Muon::ParamDef::ParamEnergyLoss) &&
222 mu.parameter(meas, xAOD::Muon::ParamDef::MeasEnergyLoss)) {
223 // fill diff plots
224 if (mu.energyLossType() == xAOD::Muon::EnergyLossType::Parametrized) {
225 paramELossDiff->Fill((param - used) * scale, weight);
226 }
227 if (mu.energyLossType() == xAOD::Muon::EnergyLossType::Tail) {
228 measELossDiff->Fill((meas - used) * scale, weight);
229 }
230 }
231 }
232 return;
233}
235 TH1* hist, const xAOD::Muon& mu, const xAOD::Muon::EnergyLossType type,
236 float scale, float weight) {
237 if (mu.muonType() == xAOD::Muon::MuonType::CaloTagged) {
238 return; // protection
239 }
240 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
241 if (elossAcc.isAvailable(mu)) {
242 if (mu.energyLossType() == type) {
243 hist->Fill(mu.pt() * scale, weight); // scale to GeV, if needed
244 }
245 }
246 return;
247}
248} // namespace Muon
Helper class to provide constant type-safe access to aux data.
void FillPlotELossType(TH1 *hist, const xAOD::Muon &mu, float scale=1, float weight=1.0)
MuonParamElossPlots(PlotBase *pParent, const std::string &sDir)
void FillPlot(TH1 *hist, const xAOD::Muon &mu, const xAOD::Muon::ParamDef paramDef, float scale=1, float weight=1.0)
void fill(const xAOD::TruthParticle &truthMu, const xAOD::Muon &mu, 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
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.
holding In fact this class is here in order to allow STL container for all features This class is sho...
Eigen::Matrix< double, 3, 1 > Vector3D
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version: