2#ifndef RIVET_ExptResolutionFunctions_HH
3#define RIVET_ExptResolutionFunctions_HH
5#include "Rivet/Tools/ResolutionFunctions.hh"
7#include "YODA/BinnedEstimate.h"
8#include "YODA/Estimate.h"
20 _refFileName =
"ExptResolutionFunctions/ATLAS_RUN2_RES_JET";
27 double resolution(
const double et,
const double abseta)
const {
30 if (
abseta > 4.5 && !_warned) {
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.)");
37 const double et_adj =
max(
min(et, 3000. - 1e-7), 17.);
38 const double abseta_adj =
min(
abseta, 4.5 - 1e-7);
40 return max(_h.at(
"hist_JERMC16EMTopo").binAt(et_adj, abseta_adj).val(),
41 _h.at(
"hist_JERData16EMTopo").binAt(et_adj, abseta_adj).val());
47 return resolution(j.
Et(), j.
abseta());
52 map<string, YODA::Estimate2D> _h;
55 mutable bool _warned =
false;
65 _refFileName =
"ExptResolutionFunctions/ATLAS_RUN2_RES_JET";
66 for (
const string s : {
"20",
"50",
"100"}) {
67 const string histname =
"hist_jetphi" + s;
74 double getRes(
const double pt,
const double eta,
const double phi)
const {
76 if (abs(
eta) > 4.5 && !_warned) {
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.)");
83 const double eta_adj =
max(
min(
eta, 4.5 - 1e-7), -4.5);
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();
101 map<string, YODA::Estimate2D> _h;
104 mutable bool _warned =
false;
113 ATLAS_RUN2_ELECTRON_ET_RES() {
114 _refFileName =
"ExptResolutionFunctions/ATLAS_RUN2_RES_ELECTRON";
116 _h[
"hist_electronNoise90"] =
refData(
"hist_electronNoise90");
117 _h[
"hist_electronConst90"] =
refData(
"hist_electronConst90");
118 _h[
"hist_electronSampling90"] =
refData(
"hist_electronSampling90");
125 const double et_adj =
max(
min(et, 50), 5);
128 if (
abseta > 2.4 && !_warned) {
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.)");
135 const double abseta_adj =
min(
abseta, 2.4 - 1e-7);
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);
154 map<string, YODA::Estimate1D> _h;
157 mutable bool _warned =
false;
168 ATLAS_RUN2_MUON_PT_RES() {
169 _refFileName =
"ExptResolutionFunctions/ATLAS_RUN2_RES_MUON";
170 for (
const string& s : _histosbarrel) {
173 for (
const string& s : _histosendcap) {
184 double resolution(
const double pT2,
const double eta,
const double phi)
const {
186 if (abs(
eta) > 2.9 && !_warned) {
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.)");
193 const double eta_adj =
max(
min(
eta, 2.9 - 1e-7), -2.9);
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();
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));
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",
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"};
220 mutable bool _warned =
false;
229 ATLAS_RUN2_PHOTON_ET_RES() {
230 _refFileName =
"ExptResolutionFunctions/ATLAS_RUN2_RES_PHOTON";
240 if (
abseta > 2.4 && !_warned) {
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.)");
247 const double abseta_adj =
min(
abseta, 2.4 - 1e-7);
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();
253 double sigma2 = rsampling * rsampling /
E + rnoise * rnoise / (
E *
E) + rconst * rconst;
255 double et = std::min(50., std::max(5., pt));
257 double pileupNoiseMeV = sqrt(32.) * (60. + 40. * log(et / 10.) / log(5.));
258 double pileupSigma2 = (pileupNoiseMeV / 1000. / pt) * (pileupNoiseMeV / 1000. / pt);
260 return sqrt(sigma2 + pileupSigma2);
269 map<string, YODA::Estimate1D> _h;
272 mutable bool _warned =
false;
283 ATLAS_RUN2_TAU_1p0n_PT_RES() {
284 _refFileName =
"ExptResolutionFunctions/ATLAS_RUN2_RES_TAU_1p0n";
285 for (
size_t i = 0; i < 5; ++i) {
292 const vector<double> etaEdges = {0.0, 0.3, 0.8, 1.3, 1.6};
296 const double ptMeV = std::max(std::min(1000. * pt, h.xMax() - 1e-7), 15000.);
297 return h.binAt(ptMeV).val();
319 ATLAS_RUN2_MUON_PHI_RES() { }
320 double resolution()
const {
323 double resolution(
const Particle& e)
const override {
332 ATLAS_RUN2_ELECTRON_PHI_RES() { }
333 double resolution()
const {
336 double resolution(
const Particle& e)
const override {
346 ATLAS_RUN2_PHOTON_PHI_RES() { }
347 double resolution()
const {
350 double resolution(
const Particle& e)
const override {
360 ATLAS_RUN2_TAU_PHI_RES() { }
361 double resolution()
const {
364 double resolution(
const Jet& j)
const override {
374 CONST_10_SOFTTERM_PT_RES() { }
375 double resolution()
const {
387 CONST_10_SOFTTERM_PHI_RES() { }
388 double resolution()
const {
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
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