Rivet API documentation

Rivet 4.1.5
ExptResolutionFunctions.hh
1// -*- C++ -*-
2#ifndef RIVET_ExptResolutionFunctions_HH
3#define RIVET_ExptResolutionFunctions_HH
4
5#include "Rivet/Tools/ResolutionFunctions.hh"
6
7#include "YODA/BinnedEstimate.h"
8#include "YODA/Estimate.h"
9#include "YODA/IO.h"
10
11namespace Rivet {
12
14 public:
15
20 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_JET";
21 _h["hist_JERMC16EMTopo"] = refData<YODA::Estimate2D>("hist_JERMC16EMTopo");
22 _h["hist_JERData16EMTopo"] = refData<YODA::Estimate2D>("hist_JERData16EMTopo");
23 }
24
25 // Get resolution based on jet et, abseta.
26 // Return max of MC/Data results.
27 double resolution(const double et, const double abseta) const {
28 // Only defined for 17 < E_T < 3000 GeV and |eta| < 4.5: use the nearest bin outside that.
29 // As in SA, E_T is clamped silently.
30 if (abseta > 4.5 && !_warned) {
31 MSG_WARNING("Jet |eta| = " << abseta
32 << " is outside the range of the ATLAS Run 2 JER tables"
33 " (|eta| < 4.5): using the last bin."
34 " Treat with care. (This warning is only printed once.)");
35 _warned = true;
36 }
37 const double et_adj = max(min(et, 3000. - 1e-7), 17.);
38 const double abseta_adj = min(abseta, 4.5 - 1e-7);
39
40 return max(_h.at("hist_JERMC16EMTopo").binAt(et_adj, abseta_adj).val(),
41 _h.at("hist_JERData16EMTopo").binAt(et_adj, abseta_adj).val());
42 }
43
46 double resolution(const Jet& j) const override {
47 return resolution(j.Et(), j.abseta());
48 }
49
50 private:
51
52 map<string, YODA::Estimate2D> _h;
53
55 mutable bool _warned = false;
56 };
57
59 public:
60
65 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_JET";
66 for (const string s : {"20", "50", "100"}) {
67 const string histname = "hist_jetphi" + s;
68 _h[histname] = refData<YODA::Estimate2D>(histname);
69 }
70 }
71
74 double getRes(const double pt, const double eta, const double phi) const {
75 // Only defined for |eta| < 4.5: use the nearest bin outside that.
76 if (abs(eta) > 4.5 && !_warned) {
77 MSG_WARNING("Jet eta = " << eta
78 << " is outside the range of the ATLAS Run 2 jet phi resolution"
79 " tables (|eta| < 4.5): using the nearest bin."
80 " Treat with care. (This warning is only printed once.)");
81 _warned = true;
82 }
83 const double eta_adj = max(min(eta, 4.5 - 1e-7), -4.5);
84
85 if (pt < 20*GeV)
86 return 0.;
87 else if (pt < 50*GeV)
88 return _h.at("hist_jetphi20").binAt(eta_adj, phi).val();
89 else if (pt < 100*GeV)
90 return _h.at("hist_jetphi50").binAt(eta_adj, phi).val();
91 return _h.at("hist_jetphi100").binAt(eta_adj, phi).val();
92 }
93
95 double resolution(const Jet& j) const override {
96 return getRes(j.pt(), j.eta(), j.phi(MINUSPI_PLUSPI));
97 }
98
99 private:
100
101 map<string, YODA::Estimate2D> _h;
102
104 mutable bool _warned = false;
105 };
106
110 class ATLAS_RUN2_ELECTRON_ET_RES : public ResolutionFunctor<Particle> {
111 public:
112
113 ATLAS_RUN2_ELECTRON_ET_RES() {
114 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_ELECTRON";
115 // TODO: These histograms are small enough (17 bins IIRC) that we could hardcode them if preferred.
116 _h["hist_electronNoise90"] = refData("hist_electronNoise90");
117 _h["hist_electronConst90"] = refData("hist_electronConst90");
118 _h["hist_electronSampling90"] = refData("hist_electronSampling90");
119 }
120
123 double resolution(const double et, const double e, const double abseta) const {
124 // As in ATLAS's egammaEnergyCorrectionTool, E_T is clamped to 5-50 GeV only inside the pile-up noise
125 const double et_adj = max(min(et, 50), 5);
126
127 // Only defined for |eta| < 2.4: use the last bin beyond that.
128 if (abseta > 2.4 && !_warned) {
129 MSG_WARNING("Electron |eta| = " << abseta
130 << " is outside the range of the ATLAS Run 2 electron"
131 " resolution tables (|eta| < 2.4): using the last bin."
132 " Treat with care. (This warning is only printed once.)");
133 _warned = true;
134 }
135 const double abseta_adj = min(abseta, 2.4 - 1e-7);
136
137 const double rsampling = _h.at("hist_electronSampling90").binAt(abseta_adj).val();
138 const double rnoise = _h.at("hist_electronNoise90").binAt(abseta_adj).val();
139 const double rconst = _h.at("hist_electronConst90").binAt(abseta_adj).val();
140 const double sigma2 = rsampling * rsampling / e + rnoise * rnoise / e / e + rconst * rconst;
141 const double pileupNoiseMeV = sqrt(32.) * (60. + 40. * log(et_adj / 10.) / log(5.));
142 const double pileupSigma2 = (pileupNoiseMeV / 1000. / et) * (pileupNoiseMeV / 1000. / et);
143 return sqrt(sigma2 + pileupSigma2);
144 }
145
147 double resolution(const Particle& e) const override {
148 // TODO: In typical ATLAS fashion, there's a good chance they mean pT
149 return resolution(e.Et(), e.E(), e.abseta());
150 }
151
152 private:
153
154 map<string, YODA::Estimate1D> _h;
155
157 mutable bool _warned = false;
158 };
159
165 class ATLAS_RUN2_MUON_PT_RES : public ResolutionFunctor<Particle> {
166 public:
167
168 ATLAS_RUN2_MUON_PT_RES() {
169 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_MUON";
170 for (const string& s : _histosbarrel) {
171 _h[s] = refData<YODA::Estimate2D>("hist_" + s);
172 }
173 for (const string& s : _histosendcap) {
174 _h[s] = refData<YODA::Estimate2D>("hist_" + s);
175 }
176 }
177
184 double resolution(const double pT2, const double eta, const double phi) const {
185 // Only defined for |eta| < 2.9: use the nearest bin outside that.
186 if (abs(eta) > 2.9 && !_warned) {
187 MSG_WARNING("Muon eta = " << eta
188 << " is outside the range of the ATLAS Run 2 muon resolution"
189 " tables (|eta| < 2.9): using the nearest bin."
190 " Treat with care. (This warning is only printed once.)");
191 _warned = true;
192 }
193 const double eta_adj = max(min(eta, 2.9 - 1e-7), -2.9);
194
195 const vector<string>& whichhistos = abs(eta) < 1.05 ? _histosbarrel : _histosendcap;
196 vector<double> pars = {0., 0., 0., 0., 0.};
197 for (size_t i = 0; i < 5; ++i) {
198 pars[i] = _h.at(whichhistos[i]).binAt(phi, eta_adj).val();
199 }
200 double IDResSq = pars[0] * pars[0] + pars[1] * pars[1] * pT2;
201 double MSResSq = pars[2] * pars[2] / pT2 + pars[3] * pars[3] + pars[4] * pars[4] * pT2;
202 return sqrt(IDResSq * MSResSq / (IDResSq + MSResSq));
203 }
204
206 double resolution(const Particle& mu) const override {
207 return resolution(mu.pt2(), mu.eta(), mu.phi(MINUSPI_PLUSPI));
208 }
209
210 private:
211
212 map<string, YODA::Estimate2D> _h;
213 std::vector<string> _histosbarrel = {
214 "r1_ID_MC_BARREL", "r2_ID_MC_BARREL", "r0_MS_MC_BARREL", "r1_MS_MC_BARREL", "r2_MS_MC_BARREL",
215 };
216 std::vector<string> _histosendcap = {"r1_ID_MC_ENDCAP", "r2_ID_MC_ENDCAP", "r0_MS_MC_ENDCAP",
217 "r1_MS_MC_ENDCAP", "r2_MS_MC_ENDCAP"};
218
220 mutable bool _warned = false;
221 };
222
226 class ATLAS_RUN2_PHOTON_ET_RES : public ResolutionFunctor<Particle> {
227 public:
228
229 ATLAS_RUN2_PHOTON_ET_RES() {
230 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_PHOTON";
231 _h["hist_photonConst90"] = refData<YODA::Estimate1D>("hist_photonConst90");
232 _h["hist_photonNoise90"] = refData<YODA::Estimate1D>("hist_photonNoise90");
233 _h["hist_photonSampling90"] = refData<YODA::Estimate1D>("hist_photonSampling90");
234 }
235
238 double resolution(const double E, const double pt, const double abseta) const {
239 // Only defined for |eta| < 2.4: use the last bin beyond that, as SA does.
240 if (abseta > 2.4 && !_warned) {
241 MSG_WARNING("Photon |eta| = " << abseta
242 << " is outside the range of the ATLAS Run 2 photon"
243 " resolution tables (|eta| < 2.4): using the last bin."
244 " Treat with care. (This warning is only printed once.)");
245 _warned = true;
246 }
247 const double abseta_adj = min(abseta, 2.4 - 1e-7);
248
249 const double rsampling = _h.at("hist_photonSampling90").binAt(abseta_adj).val();
250 const double rnoise = _h.at("hist_photonNoise90").binAt(abseta_adj).val();
251 const double rconst = _h.at("hist_photonConst90").binAt(abseta_adj).val();
252
253 double sigma2 = rsampling * rsampling / E + rnoise * rnoise / (E * E) + rconst * rconst;
254
255 double et = std::min(50., std::max(5., pt)); // constraint 5-50 GeV
256
257 double pileupNoiseMeV = sqrt(32.) * (60. + 40. * log(et / 10.) / log(5.));
258 double pileupSigma2 = (pileupNoiseMeV / 1000. / pt) * (pileupNoiseMeV / 1000. / pt);
259 // not clear why Egamma group uses Et and not E here? (comment left in from SA code)
260 return sqrt(sigma2 + pileupSigma2);
261 }
262
263 double resolution(const Particle& gamma) const override {
264 return resolution(gamma.E(), gamma.pt(), gamma.abseta());
265 }
266
267 private:
268
269 map<string, YODA::Estimate1D> _h;
270
272 mutable bool _warned = false;
273 };
274
275
280 class ATLAS_RUN2_TAU_1p0n_PT_RES : public ResolutionFunctor<Jet> {
281 public:
282
283 ATLAS_RUN2_TAU_1p0n_PT_RES() {
284 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_TAU_1p0n";
285 for (size_t i = 0; i < 5; ++i) {
286 _h.push_back(refData<YODA::Estimate1D>("hist_tauRes1p0nBin"s + to_string(i)));
287 }
288 }
289
291 double resolution(const double pt, const double abseta) const {
292 const vector<double> etaEdges = {0.0, 0.3, 0.8, 1.3, 1.6};
293 const YODA::Estimate1D& h = _h[binIndex(abseta, etaEdges, true)];
294 // Only defined from 15 GeV up to the end of each table (303-499 GeV): use the nearest bin outside that.
295 // As in SA, pT is clamped silently.
296 const double ptMeV = std::max(std::min(1000. * pt, h.xMax() - 1e-7), 15000.);
297 return h.binAt(ptMeV).val();
298 }
299
300 double resolution(const Jet& hadTau) const override {
301 // TODO: Should we consider an extra check to make sure it is a 1p0n decay?
302 // And maybe a tau-tag check?
303 return resolution(hadTau.pt(), hadTau.abseta());
304 }
305
306 private:
307
309 };
310
311
314
316 class ATLAS_RUN2_MUON_PHI_RES : public ResolutionFunctor<Particle> {
317 public:
318
319 ATLAS_RUN2_MUON_PHI_RES() { }
320 double resolution() const {
321 return 0.001;
322 }
323 double resolution(const Particle& e) const override {
324 return resolution();
325 }
326 };
327
329 class ATLAS_RUN2_ELECTRON_PHI_RES : public ResolutionFunctor<Particle> {
330 public:
331
332 ATLAS_RUN2_ELECTRON_PHI_RES() { }
333 double resolution() const {
334 return 0.004;
335 }
336 double resolution(const Particle& e) const override {
337 return resolution();
338 }
339 };
340
341
343 class ATLAS_RUN2_PHOTON_PHI_RES : public ResolutionFunctor<Particle> {
344 public:
345
346 ATLAS_RUN2_PHOTON_PHI_RES() { }
347 double resolution() const {
348 return 0.004;
349 }
350 double resolution(const Particle& e) const override {
351 return resolution();
352 }
353 };
354
357 class ATLAS_RUN2_TAU_PHI_RES : public ResolutionFunctor<Jet> {
358 public:
359
360 ATLAS_RUN2_TAU_PHI_RES() { }
361 double resolution() const {
362 return 0.01;
363 }
364 double resolution(const Jet& j) const override {
365 return resolution();
366 }
367 };
368
369
371 class CONST_10_SOFTTERM_PT_RES : public ResolutionFunctor<ThreeMomentum> {
372 public:
373
374 CONST_10_SOFTTERM_PT_RES() { }
375 double resolution() const {
376 return 10;
377 }
378 double resolution(const ThreeMomentum& p3) const override {
379 return resolution();
380 }
381 };
382
384 class CONST_10_SOFTTERM_PHI_RES : public ResolutionFunctor<ThreeMomentum> {
385 public:
386
387 CONST_10_SOFTTERM_PHI_RES() { }
388 double resolution() const {
389 return 10;
390 }
391 double resolution(const ThreeMomentum& p3) const override {
392 return resolution();
393 }
394 };
395
396
397}
398
399#endif
double resolution(const double et, const double e, const double abseta) const
Definition ExptResolutionFunctions.hh:123
double resolution(const Particle &e) const override
Get electron pt/et resolution given a Particle (hopefully an electron).
Definition ExptResolutionFunctions.hh:147
ATLAS_RUN2_EMTOPO_PT_RES()
Definition ExptResolutionFunctions.hh:19
double resolution(const Jet &j) const override
Definition ExptResolutionFunctions.hh:46
double resolution(const Jet &j) const override
Get jet phi resolution given a jet.
Definition ExptResolutionFunctions.hh:95
ATLAS_RUN2_JET_PHI_RES()
Definition ExptResolutionFunctions.hh:64
double getRes(const double pt, const double eta, const double phi) const
Definition ExptResolutionFunctions.hh:74
double resolution(const double pT2, const double eta, const double phi) const
Definition ExptResolutionFunctions.hh:184
double resolution(const Particle &mu) const override
Get muon pt resolution given a Particle.
Definition ExptResolutionFunctions.hh:206
double resolution(const double E, const double pt, const double abseta) const
Definition ExptResolutionFunctions.hh:238
double resolution(const double pt, const double abseta) const
Get hadronic tau pt resolution given pt and abseta.
Definition ExptResolutionFunctions.hh:291
Representation of a clustered jet of particles.
Definition Jet.hh:47
double phi(const PhiMapping mapping=ZERO_2PI) const
Get the directly.
Definition ParticleBase.hh:159
double abseta() const
Get the directly (alias).
Definition ParticleBase.hh:133
double pt2() const
Get the directly.
Definition ParticleBase.hh:90
double pt() const
Get the directly.
Definition ParticleBase.hh:77
double eta() const
Get the directly (alias).
Definition ParticleBase.hh:125
double Et() const
Get the directly.
Definition ParticleBase.hh:103
double E() const
Get the energy directly.
Definition ParticleBase.hh:59
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:50
Definition ResolutionFunctions.hh:20
Specialized version of the ThreeVector with momentum functionality.
Definition Vector3.hh:377
STL class.
const T2 & refData(const string &hname) const
Definition ResolutionFunctions.hh:50
#define MSG_WARNING(x)
Warning messages for non-fatal bad things, using MSG_LVL.
Definition Logging.hh:200
Vector3 p3(const ParticleBase &p)
Unbound function access to p3.
Definition ParticleBaseUtils.hh:809
double E(const ParticleBase &p)
Unbound function access to E.
Definition ParticleBaseUtils.hh:829
double eta(const ParticleBase &p)
Unbound function access to eta.
Definition ParticleBaseUtils.hh:839
double abseta(const ParticleBase &p)
Unbound function access to abseta.
Definition ParticleBaseUtils.hh:844
Definition LHCbCommon.hh:9
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, signed_if_mixed_t< N1, N2 > > max(N1 a, N2 b)
Get the maximum of two numbers.
Definition MathUtils.hh:124
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, signed_if_mixed_t< N1, N2 > > min(N1 a, N2 b)
Get the minimum of two numbers.
Definition MathUtils.hh:113
std::enable_if_t< std::is_arithmetic_v< NUM1 > &&std::is_arithmetic_v< NUM2 >, int > binIndex(NUM1 val, std::initializer_list< NUM2 > binedges, bool allow_overflow=false)
Return the bin index of the given value, val, given a vector of bin edges.
Definition MathUtils.hh:503