Rivet API documentation

Rivet 4.1.3
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/IO.h"
8#include "YODA/Estimate.h"
9#include "YODA/BinnedEstimate.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 const double et_adj = max(min(et, 3000), 17);
29 const double abseta_adj = min(abseta, 4.5);
30
31 return max(_h.at("hist_JERMC16EMTopo").binAt(et_adj, abseta_adj).val(),
32 _h.at("hist_JERData16EMTopo").binAt(et_adj, abseta_adj).val());
33 }
34
37 double resolution(const Jet &j) const override {
38 return resolution(j.Et(), j.abseta());
39 }
40
41 private:
42 map<string, YODA::Estimate2D> _h;
43 };
44
46 public:
47
52 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_JET";
53 for (const string s : {"20", "50", "100"}){
54 const string histname = "hist_jetphi"+s;
55 _h[histname] = refData<YODA::Estimate2D>(histname);
56 }
57 }
58
61 double getRes(const double pt, const double eta, const double phi) const {
62 if (pt < 20*GeV)
63 return 0.;
64 else if (pt < 50*GeV)
65 return _h.at("hist_jetphi20").binAt(eta, phi).val();
66 else if (pt < 100*GeV)
67 return _h.at("hist_jetphi50").binAt(eta, phi).val();
68 return _h.at("hist_jetphi100").binAt(eta, phi).val();
69 }
70
72 double resolution(const Jet &j) const override {
73 return getRes(j.pt(), j.eta(), j.phi(MINUSPI_PLUSPI));
74 }
75
76 private:
77 map<string, YODA::Estimate2D> _h;
78 };
79
83 class ATLAS_RUN2_ELECTRON_ET_RES : public ResolutionFunctor<Particle> {
84 public:
85 ATLAS_RUN2_ELECTRON_ET_RES(){
86 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_ELECTRON";
87 // TODO: These histograms are small enough (17 bins IIRC) that we could hardcode them if preferred.
88 _h["hist_electronNoise90"] = refData("hist_electronNoise90");
89 _h["hist_electronConst90"] = refData("hist_electronConst90");
90 _h["hist_electronSampling90"] = refData("hist_electronSampling90");
91 }
92
95 double resolution(const double et, const double e, const double abseta) const {
96 // This et range seems almost pointlessly small but hey ho.
97 const double et_adj = max(min(abseta, 50), 5);
98
99 const double rsampling = _h.at("hist_electronSampling90").binAt(abseta).val();
100 const double rnoise = _h.at("hist_electronNoise90").binAt(abseta).val();
101 const double rconst = _h.at("hist_electronConst90").binAt(abseta).val();
102 const double sigma2 = rsampling*rsampling / e + rnoise*rnoise / e / e + rconst*rconst;
103 const double pileupNoiseMeV = sqrt(32.) * (60. + 40. * log(et_adj/10.)/log(5.));
104 const double pileupSigma2 = (pileupNoiseMeV/1000./et_adj)*(pileupNoiseMeV/1000./et_adj);
105 return sqrt(sigma2+pileupSigma2);
106 }
107
109 double resolution(const Particle &e) const override {
110 // TODO: In typical ATLAS fashion, there's a good chance they mean pT
111 return resolution(e.Et(), e.E(), e.abseta());
112 }
113
114 private:
115 map<string, YODA::Estimate1D> _h;
116 };
117
123 class ATLAS_RUN2_MUON_PT_RES : public ResolutionFunctor<Particle> {
124 public:
125 ATLAS_RUN2_MUON_PT_RES(){
126 _refFileName="ExptResolutionFunctions/ATLAS_RUN2_RES_MUON";
127 for (const string & s : _histosbarrel){
128 _h[s] = refData<YODA::Estimate2D>("hist_"+s);
129 }
130 for (const string & s : _histosendcap){
131 _h[s] = refData<YODA::Estimate2D>("hist_"+s);
132 }
133 }
134
140 double resolution(const double pT2, const double eta, const double phi) const {
141 vector<string> whichhistos = abs(eta) < 1.05 ? _histosbarrel : _histosendcap;
142 vector<double> pars = {0.,0.,0.,0.,0.};
143 for (size_t i=0; i < 5; ++i){
144 pars[i] = _h.at(whichhistos[i]).binAt(phi, eta).val();
145 }
146 double IDResSq = pars[0]*pars[0] + pars[1]*pars[1] * pT2;
147 double MSResSq = pars[2]*pars[2] / pT2 + pars[3]*pars[3] + pars[4]*pars[4]*pT2;
148 return sqrt(IDResSq * MSResSq / (IDResSq + MSResSq));
149 }
150
152 double resolution(const Particle & mu) const override {
153 return resolution(mu.pt2(), mu.eta(), mu.phi());
154 }
155
156 private:
157 map<string, YODA::Estimate2D> _h;
158 std::vector<string> _histosbarrel = {
159 "r1_ID_MC_BARREL", "r2_ID_MC_BARREL",
160 "r0_MS_MC_BARREL",
161 "r1_MS_MC_BARREL", "r2_MS_MC_BARREL",
162 };
163 std::vector<string> _histosendcap = {
164 "r1_ID_MC_ENDCAP", "r2_ID_MC_ENDCAP",
165 "r0_MS_MC_ENDCAP", "r1_MS_MC_ENDCAP",
166 "r2_MS_MC_ENDCAP"
167 };
168 };
169
173 class ATLAS_RUN2_PHOTON_ET_RES : public ResolutionFunctor<Particle> {
174 public:
175 ATLAS_RUN2_PHOTON_ET_RES(){
176 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_PHOTON";
177 _h["hist_photonConst90"] = refData<YODA::Estimate1D>("hist_photonConst90");
178 _h["hist_photonNoise90"] = refData<YODA::Estimate1D>("hist_photonNoise90");
179 _h["hist_photonSampling90"] = refData<YODA::Estimate1D>("hist_photonSampling90");
180 }
181
184 double resolution(const double E, const double pt, const double abseta) const {
185 const double rsampling = abseta < 2.4 ? _h.at("hist_photonSampling90").binAt(abseta).val() : 0;
186 const double rnoise = abseta < 2.4 ? _h.at("hist_photonNoise90").binAt(abseta).val() : 0;
187 const double rconst = abseta < 2.4 ? _h.at("hist_photonConst90").binAt(abseta).val() : 0;
188
189 double sigma2 = rsampling * rsampling / E +
190 rnoise * rnoise / (E * E) + rconst * rconst;
191
192 double et = std::min(50., std::max(5., pt)); // constraint 5-50 GeV
193
194 double pileupNoiseMeV = sqrt(32.) * (60. + 40. * log(et / 10.) / log(5.));
195 double pileupSigma2 = (pileupNoiseMeV / 1000. / pt)*(pileupNoiseMeV / 1000. / pt);
196 // not clear why Egamma group uses Et and not E here? (comment left in from SA code)
197 return sqrt(sigma2 + pileupSigma2);
198 }
199
200 double resolution(const Particle &gamma) const override {
201 return resolution(gamma.E(), gamma.pt(), gamma.abseta());
202 }
203
204 private:
205 map<string, YODA::Estimate1D> _h;
206 };
207
208
213 class ATLAS_RUN2_TAU_1p0n_PT_RES : public ResolutionFunctor<Jet> {
214 public:
215 ATLAS_RUN2_TAU_1p0n_PT_RES(){
216 _refFileName = "ExptResolutionFunctions/ATLAS_RUN2_RES_TAU_1p0n";
217 for (size_t i = 0; i < 5; ++i){
218 _h[i] = refData<YODA::Estimate1D>("hist_tauRes1p0nBin"s+to_string(i));
219 }
220 }
221
223 double resolution(const double pt, const double abseta) const {
224 const double ptMeV = 1000.*std::min(499., std::max(15., pt)); // only defined for 15-499 GeV
225 const vector<double> etaEdges = {0.0, 0.3, 0.8, 1.3, 1.6};
226 const double res = _h[binIndex(abseta, etaEdges, true)].binAt(ptMeV).val();
227 return res;
228 }
229
230 double resolution(const Jet &hadTau) const override {
231 // TODO: Should we consider an extra check to make sure it is a 1p0n decay?
232 // And maybe a tau-tag check?
233 return resolution(hadTau.pt(), hadTau.abseta());
234 }
235
236 private:
238 };
239
240
243
245 class ATLAS_RUN2_MUON_PHI_RES : public ResolutionFunctor<Particle>{
246 public:
247 ATLAS_RUN2_MUON_PHI_RES(){}
248 double resolution() const { return 0.001; }
249 double resolution(const Particle &e) const override { return resolution(); }
250 };
251
253 class ATLAS_RUN2_ELECTRON_PHI_RES : public ResolutionFunctor<Particle>{
254 public:
255 ATLAS_RUN2_ELECTRON_PHI_RES(){}
256 double resolution() const { return 0.004; }
257 double resolution(const Particle &e) const override { return resolution(); }
258 };
259
260
262 class ATLAS_RUN2_PHOTON_PHI_RES : public ResolutionFunctor<Particle> {
263 public:
264 ATLAS_RUN2_PHOTON_PHI_RES(){}
265 double resolution() const { return 0.004; }
266 double resolution(const Particle &e) const override { return resolution(); }
267 };
268
271 class ATLAS_RUN2_TAU_PHI_RES : public ResolutionFunctor<Jet> {
272 public:
273 ATLAS_RUN2_TAU_PHI_RES(){}
274 double resolution() const { return 0.01; }
275 double resolution(const Jet &j) const override { return resolution(); }
276 };
277
278
279}
280
281#endif
double resolution(const double et, const double e, const double abseta) const
Definition ExptResolutionFunctions.hh:95
double resolution(const Particle &e) const override
Get electron pt/et resolution given a Particle (hopefully an electron).
Definition ExptResolutionFunctions.hh:109
ATLAS_RUN2_EMTOPO_PT_RES()
Definition ExptResolutionFunctions.hh:19
double resolution(const Jet &j) const override
Definition ExptResolutionFunctions.hh:37
double resolution(const Jet &j) const override
Get jet phi resolution given a jet.
Definition ExptResolutionFunctions.hh:72
ATLAS_RUN2_JET_PHI_RES()
Definition ExptResolutionFunctions.hh:51
double getRes(const double pt, const double eta, const double phi) const
Definition ExptResolutionFunctions.hh:61
double resolution(const double pT2, const double eta, const double phi) const
Definition ExptResolutionFunctions.hh:140
double resolution(const Particle &mu) const override
Get muon pt resolution given a Particle.
Definition ExptResolutionFunctions.hh:152
double resolution(const double E, const double pt, const double abseta) const
Definition ExptResolutionFunctions.hh:184
double resolution(const double pt, const double abseta) const
Get hadronic tau pt resolution given pt and abseta.
Definition ExptResolutionFunctions.hh:223
Representation of a clustered jet of particles.
Definition Jet.hh:42
double phi(const PhiMapping mapping=ZERO_2PI) const
Get the directly.
Definition ParticleBase.hh:107
double abseta() const
Get the directly (alias).
Definition ParticleBase.hh:93
double pt2() const
Get the directly.
Definition ParticleBase.hh:70
double pt() const
Get the directly.
Definition ParticleBase.hh:63
double eta() const
Get the directly (alias).
Definition ParticleBase.hh:89
double Et() const
Get the directly.
Definition ParticleBase.hh:77
double E() const
Get the energy directly.
Definition ParticleBase.hh:53
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:45
Definition ResolutionFunctions.hh:20
STL class.
const T2 & refData(const string &hname) const
Definition ResolutionFunctions.hh:49
double E(const ParticleBase &p)
Unbound function access to E.
Definition ParticleBaseUtils.hh:659
double eta(const ParticleBase &p)
Unbound function access to eta.
Definition ParticleBaseUtils.hh:665
double abseta(const ParticleBase &p)
Unbound function access to abseta.
Definition ParticleBaseUtils.hh:668
Definition MC_CENT_PPB_Projections.hh:10
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:115
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:104
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:465