rivet is hosted by Hepforge, IPPP Durham
Rivet 4.0.0
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
26
28 inline double JET_EFF_ZERO(const Jet&) { return 0; }
30 inline double JET_EFF_0(const Jet&) { return 0; }
32 inline double JET_FN0(const Jet&) { return 0; }
33
35 inline double JET_EFF_ONE(const Jet&) { return 1; }
37 inline double JET_EFF_1(const Jet&) { return 1; }
39 inline double JET_EFF_PERFECT(const Jet&) { return 1; }
41 inline double JET_FN1(const Jet&) { return 1; }
42
45 JET_EFF_CONST(double eff) : _eff(eff) {}
46 double operator () (const Jet& ) const { return _eff; }
47 double _eff;
48 };
49
50
53 inline double JET_BTAG_PERFECT(const Jet& j) { return j.bTagged() ? 1 : 0; }
54
57 inline double JET_CTAG_PERFECT(const Jet& j) { return j.cTagged() ? 1 : 0; }
58
61 inline double JET_TAUTAG_PERFECT(const Jet& j) { return j.tauTagged() ? 1 : 0; }
62
63
68 JET_BTAG_EFFS(double eff_b, double eff_light=0) : _eff_b(eff_b), _eff_c(-1), _eff_t(-1), _eff_l(eff_light) { }
69 JET_BTAG_EFFS(double eff_b, double eff_c, double eff_light) : _eff_b(eff_b), _eff_c(eff_c), _eff_t(-1), _eff_l(eff_light) { }
70 JET_BTAG_EFFS(double eff_b, double eff_c, double eff_tau, double eff_light) : _eff_b(eff_b), _eff_c(eff_c), _eff_t(eff_tau), _eff_l(eff_light) { }
71 inline double operator () (const Jet& j) {
72 if (j.bTagged()) return _eff_b;
73 if (_eff_c >= 0 && j.cTagged()) return _eff_c;
74 if (_eff_t >= 0 && j.tauTagged()) return _eff_t;
75 return _eff_l;
76 }
77 double _eff_b, _eff_c, _eff_t, _eff_l;
78 };
79
80
84 inline Jet JET_SMEAR_IDENTITY(const Jet& j) { return j; }
86 inline Jet JET_SMEAR_PERFECT(const Jet& j) { return j; }
87
88
95 JetEffSmearFn(const JetSmearFn& s, const JetEffFn& e)
96 : sfn(s), efn(e) { }
97
98 JetEffSmearFn(const JetEffFn& e, const JetSmearFn& s)
99 : sfn(s), efn(e) { }
100
101 JetEffSmearFn(const JetSmearFn& s)
102 : sfn(s), efn(JET_EFF_ONE) { }
103
104 JetEffSmearFn(const JetEffFn& e)
105 : sfn(JET_SMEAR_IDENTITY), efn(e) { }
106
107 JetEffSmearFn(double eff)
108 : JetEffSmearFn(JET_EFF_CONST(eff)) { }
109
111 pair<Jet,double> operator() (const Jet& j) const {
112 return make_pair(sfn(j), efn(j));
113 }
114
116 CmpState cmp(const JetEffSmearFn& other) const {
117 // cout << "Eff hashes = " << get_address(efn) << "," << get_address(other.efn) << "; "
118 // << "smear hashes = " << get_address(sfn) << "," << get_address(other.sfn) << '\n';
119 if (get_address(sfn) == 0 || get_address(other.sfn) == 0) return CmpState::NEQ;
120 if (get_address(efn) == 0 || get_address(other.efn) == 0) return CmpState::NEQ;
121 return Rivet::cmp(get_address(sfn), get_address(other.sfn)) || Rivet::cmp(get_address(efn), get_address(other.efn));
122 }
123
125 operator JetSmearFn () { return sfn; }
128 // operator JetEffFn () { return efn; }
129
130 // Stored functions/functors
132 JetEffFn efn;
133 };
134
135
137 template <typename FN>
138 inline bool efffilt(const Jet& j, FN& feff) {
139 return rand01() < feff(j);
140 }
141
144 template <typename FN>
145 JetEffFilter(const FN& feff) : _feff(feff) {}
146 JetEffFilter(double eff) : JetEffFilter( [&](const Jet&){return eff;} ) {}
147 bool operator () (const Jet& j) const { return efffilt(j, _feff); }
148 private:
149 const JetEffFn _feff;
150 };
152
154
156
157}
158
159#endif
Representation of a clustered jet of particles.
Definition Jet.hh:42
bool cTagged(const Cut &c=Cuts::open()) const
Does this jet have at least one c-tag (that passes an optional Cut)?
Definition Jet.hh:147
bool bTagged(const Cut &c=Cuts::open()) const
Does this jet have at least one b-tag (that passes an optional Cut)?
Definition Jet.hh:134
bool tauTagged(const Cut &c=Cuts::open()) const
Does this jet have at least one tau-tag (that passes an optional Cut)?
Definition Jet.hh:160
double JET_CTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition JetSmearingFunctions.hh:57
double JET_EFF_ONE(const Jet &)
Take a jet and return a constant 1.
Definition JetSmearingFunctions.hh:35
double JET_EFF_0(const Jet &)
Alias for JET_EFF_ZERO.
Definition JetSmearingFunctions.hh:30
double JET_EFF_1(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:37
double JET_TAUTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition JetSmearingFunctions.hh:61
double JET_BTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a b, otherwise 0.
Definition JetSmearingFunctions.hh:53
Jet JET_SMEAR_PERFECT(const Jet &j)
Alias for JET_SMEAR_IDENTITY.
Definition JetSmearingFunctions.hh:86
double JET_FN1(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:41
Jet JET_SMEAR_IDENTITY(const Jet &j)
Definition JetSmearingFunctions.hh:84
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:32
bool efffilt(const Jet &j, FN &feff)
Return true if Jet j is chosen to survive a random efficiency selection.
Definition JetSmearingFunctions.hh:138
double JET_EFF_ZERO(const Jet &)
Take a jet and return a constant 0.
Definition JetSmearingFunctions.hh:28
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:39
Definition MC_CENT_PPB_Projections.hh:10
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:255
uintptr_t get_address(std::function< T(U...)> f)
Get a function pointer / hash integer from an std::function.
Definition RivetSTL.hh:216
b-tagging efficiency functor, for more readable b-tag effs and mistag rates
Definition JetSmearingFunctions.hh:67
Take a Jet and return a constant efficiency.
Definition JetSmearingFunctions.hh:44
A functor to return true if Jet j survives a random efficiency selection.
Definition JetSmearingFunctions.hh:143
Functor for simultaneous efficiency-filtering and smearing of Jets.
Definition JetSmearingFunctions.hh:94
CmpState cmp(const JetEffSmearFn &other) const
Compare to another, for use in the projection system.
Definition JetSmearingFunctions.hh:116
JetSmearFn sfn
Definition JetSmearingFunctions.hh:131
pair< Jet, double > operator()(const Jet &j) const
Smear and calculate an efficiency for the given jet.
Definition JetSmearingFunctions.hh:111