Rivet API documentation

Rivet 4.1.3
JetSmearingFunctions.hh
1// -*- C++ -*-
2#ifndef RIVET_JetSmearingFunctions_HH
3#define RIVET_JetSmearingFunctions_HH
4
5#include "Rivet/Jet.hh"
6#include "Rivet/Tools/MomentumSmearingFunctions.hh"
7#include "Rivet/Tools/ParticleSmearingFunctions.hh"
8#include "Rivet/Tools/Random.hh"
9
10namespace Rivet {
11
12
15
18
20 typedef function<Jet(const Jet&)> JetSmearFn;
21
23 typedef function<double(const Jet&)> JetEffFn;
24
25
27 inline double JET_EFF_ZERO(const Jet&) {
28 return 0;
29 }
30
31 inline double JET_EFF_0(const Jet&) {
32 return 0;
33 }
34
35 inline double JET_FN0(const Jet&) {
36 return 0;
37 }
38
40 inline double JET_EFF_ONE(const Jet&) {
41 return 1;
42 }
43
44 inline double JET_EFF_1(const Jet&) {
45 return 1;
46 }
47
48 inline double JET_EFF_PERFECT(const Jet&) {
49 return 1;
50 }
51
52 inline double JET_EFF_IDENTITY(const Jet&) {
53 return 1;
54 }
55
56 inline double JET_FN1(const Jet&) {
57 return 1;
58 }
59
61 struct JET_EFF_CONST {
62 JET_EFF_CONST(double eff)
63 : _eff(eff) { }
64 double operator()(const Jet&) const {
65 return _eff;
66 }
67 double _eff;
68 };
69
70
74 inline double JET_BTAG_PERFECT(const Jet& j) {
75 return j.bTagged() ? 1 : 0;
76 }
77
78 inline double JET_BTAG_IDENTITY(const Jet& j) {
79 return JET_BTAG_PERFECT(j);
80 }
81
85 inline double JET_CTAG_PERFECT(const Jet& j) {
86 return j.cTagged() ? 1 : 0;
87 }
88
89 inline double JET_CTAG_IDENTITY(const Jet& j) {
90 return JET_CTAG_PERFECT(j);
91 }
92
96 inline double JET_TAUTAG_PERFECT(const Jet& j) {
97 return j.tauTagged() ? 1 : 0;
98 }
99
100 inline double JET_TAUTAG_IDENTITY(const Jet& j) {
101 return JET_TAUTAG_PERFECT(j);
102 }
103
104
108 struct JET_BTAG_EFFS {
109 JET_BTAG_EFFS(double eff_b, double eff_light = 0)
110 : _eff_b(eff_b), _eff_c(-1), _eff_t(-1), _eff_l(eff_light) { }
111 JET_BTAG_EFFS(double eff_b, double eff_c, double eff_light)
112 : _eff_b(eff_b), _eff_c(eff_c), _eff_t(-1), _eff_l(eff_light) { }
113 JET_BTAG_EFFS(double eff_b, double eff_c, double eff_tau, double eff_light)
114 : _eff_b(eff_b), _eff_c(eff_c), _eff_t(eff_tau), _eff_l(eff_light) { }
115 inline double operator()(const Jet& j) {
116 if (j.bTagged()) return _eff_b;
117 if (_eff_c >= 0 && j.cTagged()) return _eff_c;
118 if (_eff_t >= 0 && j.tauTagged()) return _eff_t;
119 return _eff_l;
120 }
121 double _eff_b, _eff_c, _eff_t, _eff_l;
122 };
123
124
128 inline Jet JET_SMEAR_IDENTITY(const Jet& j) {
129 return j;
130 }
131
132 inline Jet JET_SMEAR_PERFECT(const Jet& j) {
133 return j;
134 }
135
136
142 struct JetEffSmearFn {
143 JetEffSmearFn(const JetSmearFn& s, const JetEffFn& e)
144 : sfn(s), efn(e) { }
145
146 JetEffSmearFn(const JetEffFn& e, const JetSmearFn& s)
147 : sfn(s), efn(e) { }
148
149 JetEffSmearFn(const JetSmearFn& s)
150 : sfn(s), efn(JET_EFF_ONE) { }
151
152 JetEffSmearFn(const JetEffFn& e)
153 : sfn(JET_SMEAR_IDENTITY), efn(e) { }
154
155 JetEffSmearFn(double eff)
156 : JetEffSmearFn(JET_EFF_CONST(eff)) { }
157
159 pair<Jet, double> operator()(const Jet& j) const {
160 return make_pair(sfn(j), efn(j));
161 }
162
164 CmpState cmp(const JetEffSmearFn& other) const {
165 // cout << "Eff hashes = " << get_address(efn) << "," << get_address(other.efn) << "; "
166 // << "smear hashes = " << get_address(sfn) << "," << get_address(other.sfn) << '\n';
167 if (get_address(sfn) == 0 || get_address(other.sfn) == 0) return CmpState::NEQ;
168 if (get_address(efn) == 0 || get_address(other.efn) == 0) return CmpState::NEQ;
169 return Rivet::cmp(get_address(sfn), get_address(other.sfn))
170 || Rivet::cmp(get_address(efn), get_address(other.efn));
171 }
172
174 operator JetSmearFn() {
175 return sfn;
176 }
177
179 // operator JetEffFn () { return efn; }
180
181 // Stored functions/functors
183 JetEffFn efn;
184 };
185
186
188 template <typename FN>
189 inline bool efffilt(const Jet& j, FN& feff) {
190 return rand01() < feff(j);
191 }
192
194 struct JetEffFilter {
195 template <typename FN>
196 JetEffFilter(const FN& feff)
197 : _feff(feff) { }
198 JetEffFilter(double eff)
199 : JetEffFilter([&](const Jet&) { return eff; }) { }
200 bool operator()(const Jet& j) const {
201 return efffilt(j, _feff);
202 }
203
204 private:
205
206 const JetEffFn _feff;
207 };
208 using jetEffFilter = JetEffFilter;
209
211
213
214}
215
216#endif
Representation of a clustered jet of particles.
Definition Jet.hh:47
bool cTagged(const Cut &c=Cuts::open(), double dRmax=-1) const
Does this jet have at least one c-tag? (with optional Cut and dR restriction).
Definition Jet.hh:217
bool tauTagged(const Cut &c=Cuts::open(), double dRmax=-1) const
Does this jet have at least one tau-tag (with optional Cut and dR restriction).
Definition Jet.hh:246
bool bTagged(const Cut &c=Cuts::open(), double dRmax=-1) const
Does this jet have at least one b-tag? (with optional Cut and dR restriction).
Definition Jet.hh:188
double JET_CTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition JetSmearingFunctions.hh:85
double JET_EFF_ONE(const Jet &)
Take a jet and return a constant 1.
Definition JetSmearingFunctions.hh:40
double JET_EFF_0(const Jet &)
Alias for JET_EFF_ZERO.
Definition JetSmearingFunctions.hh:31
double JET_EFF_1(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:44
double JET_TAUTAG_IDENTITY(const Jet &j)
Alias for JET_TAUTAG_PERFECT.
Definition JetSmearingFunctions.hh:100
double JET_TAUTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition JetSmearingFunctions.hh:96
double JET_BTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a b, otherwise 0.
Definition JetSmearingFunctions.hh:74
Jet JET_SMEAR_PERFECT(const Jet &j)
Alias for JET_SMEAR_IDENTITY.
Definition JetSmearingFunctions.hh:132
double JET_CTAG_IDENTITY(const Jet &j)
Alias for JET_CTAG_PERFECT.
Definition JetSmearingFunctions.hh:89
double JET_BTAG_IDENTITY(const Jet &j)
Alias for JET_BTAG_PERFECT.
Definition JetSmearingFunctions.hh:78
double JET_FN1(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:56
Jet JET_SMEAR_IDENTITY(const Jet &j)
Definition JetSmearingFunctions.hh:128
function< Jet(const Jet &)> JetSmearFn
Typedef for Jet smearing functions/functors.
Definition JetSmearingFunctions.hh:20
double JET_FN0(const Jet &)
Alias for JET_EFF_ZERO.
Definition JetSmearingFunctions.hh:35
double JET_EFF_IDENTITY(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:52
bool efffilt(const Jet &j, FN &feff)
Return true if Jet j is chosen to survive a random efficiency selection.
Definition JetSmearingFunctions.hh:189
double JET_EFF_ZERO(const Jet &)
Take a jet and return a constant 0.
Definition JetSmearingFunctions.hh:27
function< double(const Jet &)> JetEffFn
Typedef for Jet efficiency functions/functors.
Definition JetSmearingFunctions.hh:23
double JET_EFF_PERFECT(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:48
Definition LHCbCommon.hh:9
double rand01()
Return a uniformly sampled random number between 0 and 1.
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition Cmp.hh:253
uintptr_t get_address(std::function< T(U...)> f)
Get a function pointer / hash integer from an std::function.
Definition RivetSTL.hh:338
Take a Jet and return a constant efficiency.
Definition JetSmearingFunctions.hh:61
A functor to return true if Jet j survives a random efficiency selection.
Definition JetSmearingFunctions.hh:194
CmpState cmp(const JetEffSmearFn &other) const
Compare to another, for use in the projection system.
Definition JetSmearingFunctions.hh:164
JetSmearFn sfn
Definition JetSmearingFunctions.hh:182
pair< Jet, double > operator()(const Jet &j) const
Smear and calculate an efficiency for the given jet.
Definition JetSmearingFunctions.hh:159