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::msInnerMatchChi2, weight);
115 FillPlot(msOuterMatchChi2, mu, xAOD::Muon::msOuterMatchChi2, weight);
116#ifndef XAOD_ANALYSIS
119 xAOD::Muon::EnergyLoss, 0.001, weight);
122 truthmu, mu, xAOD::Muon::MeasEnergyLoss, 0.001, weight);
123 FillPlot(ELossSigma, mu, xAOD::Muon::EnergyLossSigma, 0.001, weight);
126 truthmu, mu, xAOD::Muon::ParamEnergyLoss, 0.001, weight);
127 FillPlotELossType(ELossType, mu, 0.001, weight);
128 FillPlotELossType(ELossTypeNotIsoPt, mu, xAOD::Muon::NotIsolated, 0.001,
129 weight);
130 FillPlotELossType(ELossTypeParametrPt, mu, xAOD::Muon::Parametrized, 0.001,
131 weight);
132 FillPlotELossType(ELossTypeTailPt, mu, xAOD::Muon::Tail, 0.001, weight);
133#endif // not XAOD_ANALYSIS
134}
136 const xAOD::Muon::ParamDef paramDef,
137 float scale, float weight) {
138 if (mu.author() == xAOD::Muon::CaloTag ||
139 mu.author() == xAOD::Muon::CaloLikelihood ||
140 mu.author() == xAOD::Muon::ExtrapolateMuonToIP) {
141 return; // protection
142 }
143 float fpar = 0;
144 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
145 if (elossAcc.isAvailable(mu)) {
146 if (mu.parameter(fpar, paramDef)) {
147 hist->Fill(scale * fpar, weight); // scale to GeV, if needed
148 }
149 }
150 return;
151}
153 TH1* hist, TH1* hist_DiffTruth, TH1* hist_DiffTruthEta0_1p35,
154 TH1* hist_DiffTruthEta1p35_1p55, TH1* hist_DiffTruthEta1p55_end,
155 const xAOD::TruthParticle& truthprt, const xAOD::Muon& mu,
156 const xAOD::Muon::ParamDef paramDef, float scale, float weight) {
157 if (mu.author() == xAOD::Muon::CaloTag ||
158 mu.author() == xAOD::Muon::CaloLikelihood ||
159 mu.author() == xAOD::Muon::ExtrapolateMuonToIP) {
160 return; // protection
161 }
162 float fpar = 0;
163 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
164 if (elossAcc.isAvailable(mu)) {
165 if (mu.parameter(fpar, paramDef)) {
166 hist->Fill(scale * fpar, weight); // scale to GeV, if needed
167 }
168
169 // get true energy loss
170 static const SG::ConstAccessor<float> pxAcc("px");
171 static const SG::ConstAccessor<float> pyAcc("py");
172 static const SG::ConstAccessor<float> pzAcc("pz");
173 static const SG::ConstAccessor<float> muonEnt_pxAcc(
174 "MuonEntryLayer_px");
175 static const SG::ConstAccessor<float> muonEnt_pyAcc(
176 "MuonEntryLayer_py");
177 static const SG::ConstAccessor<float> muonEnt_pzAcc(
178 "MuonEntryLayer_pz");
179 if (!pxAcc.isAvailable(truthprt) || !pyAcc.isAvailable(truthprt) ||
180 !pzAcc.isAvailable(truthprt) ||
181 !muonEnt_pxAcc.isAvailable(truthprt) ||
182 !muonEnt_pyAcc.isAvailable(truthprt) ||
183 !muonEnt_pzAcc.isAvailable(truthprt)) {
184 return;
185 }
186
187 // workaround for missing caloentry
188 Amg::Vector3D vecCaloEntry{pxAcc(truthprt), pyAcc(truthprt),
189 pzAcc(truthprt)};
190
191 Amg::Vector3D vecMuonExit{muonEnt_pxAcc(truthprt),
192 muonEnt_pyAcc(truthprt),
193 muonEnt_pzAcc(truthprt)};
194 float dpTruth = vecCaloEntry.mag() - vecMuonExit.mag();
195 hist_DiffTruth->Fill(scale * (fpar - dpTruth),
196 weight); // scale to GeV, if needed
197 // again in eta ranges
198 if (std::abs(mu.eta()) < 1.35) {
199 hist_DiffTruthEta0_1p35->Fill(scale * (fpar - dpTruth), weight);
200 } else {
201 if (std::abs(mu.eta()) < 1.55) {
202 hist_DiffTruthEta1p35_1p55->Fill(scale * (fpar - dpTruth),
203 weight);
204 } else {
205 hist_DiffTruthEta1p55_end->Fill(scale * (fpar - dpTruth),
206 weight);
207 }
208 }
209 }
210 return;
211}
213 float scale, float weight) {
214 if (mu.author() == xAOD::Muon::CaloTag ||
215 mu.author() == xAOD::Muon::CaloLikelihood ||
216 mu.author() == xAOD::Muon::ExtrapolateMuonToIP) {
217 return; // protection
218 }
219 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
220 if (elossAcc.isAvailable(mu)) {
221 hist->Fill(mu.energyLossType(), weight);
222 ELossTypeAllPt->Fill(mu.pt() * scale, weight);
223 float used = 0;
224 float meas = -100000;
225 float param = -100000;
226 if (mu.parameter(used, xAOD::Muon::EnergyLoss) &&
227 mu.parameter(param, xAOD::Muon::ParamEnergyLoss) &&
228 mu.parameter(meas, xAOD::Muon::MeasEnergyLoss)) {
229 // fill diff plots
230 if (mu.energyLossType() == xAOD::Muon::Parametrized) {
231 paramELossDiff->Fill((param - used) * scale, weight);
232 }
233 if (mu.energyLossType() == xAOD::Muon::Tail) {
234 measELossDiff->Fill((meas - used) * scale, weight);
235 }
236 }
237 }
238 return;
239}
241 TH1* hist, const xAOD::Muon& mu, const xAOD::Muon::EnergyLossType type,
242 float scale, float weight) {
243 if (mu.author() == xAOD::Muon::CaloTag ||
244 mu.author() == xAOD::Muon::CaloLikelihood ||
245 mu.author() == xAOD::Muon::ExtrapolateMuonToIP) {
246 return; // protection
247 }
248 static const SG::ConstAccessor<float> elossAcc("EnergyLoss");
249 if (elossAcc.isAvailable(mu)) {
250 if (mu.energyLossType() == type) {
251 hist->Fill(mu.pt() * scale, weight); // scale to GeV, if needed
252 }
253 }
254 return;
255}
256} // 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: