Rivet: /Users/chrisg/software/rivet/include/Rivet/Tools/JetSmearingFunctions.hh Source File

| Rivet 3.1.9

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& p) { return 0; }
30 inline double JET_EFF_0(const Jet& p) { return 0; }
32 inline double JET_FN0(const Jet& p) { return 0; }
33
35 inline double JET_EFF_ONE(const Jet& p) { return 1; }
37 inline double JET_EFF_1(const Jet& p) { return 1; }
39 inline double JET_EFF_PERFECT(const Jet& ) { return 1; }
41 inline double JET_FN1(const Jet& ) { return 1; }
42
44 struct JET_EFF_CONST {
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
67 struct JET_BTAG_EFFS {
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
94 struct JetEffSmearFn {
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
131 JetSmearFn sfn;
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
143 struct JetEffFilter {
144 template <typename FN>
145 JetEffFilter(const FN& feff) : _feff(feff) {}
146 JetEffFilter(double eff) : JetEffFilter( [&](const Jet& j){return eff;} ) {}
147 bool operator () (const Jet& j) const { return efffilt(j, _feff); }
148 private:
149 const JetEffFn _feff;
150 };
151 using jetEffFilter = JetEffFilter;
152
154
156
157}
158
159#endif
Rivet::Jet
Representation of a clustered jet of particles.
Definition Jet.hh:48
Rivet::Jet::cTagged
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:153
Rivet::Jet::bTagged
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:140
Rivet::Jet::tauTagged
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:166
Rivet::Kin::p
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:684
Rivet::JET_CTAG_PERFECT
double JET_CTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition JetSmearingFunctions.hh:57
Rivet::JET_EFF_ONE
double JET_EFF_ONE(const Jet &p)
Take a jet and return a constant 1.
Definition JetSmearingFunctions.hh:35
Rivet::JET_FN0
double JET_FN0(const Jet &p)
Alias for JET_EFF_ZERO.
Definition JetSmearingFunctions.hh:32
Rivet::JET_TAUTAG_PERFECT
double JET_TAUTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition JetSmearingFunctions.hh:61
Rivet::JET_BTAG_PERFECT
double JET_BTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a b, otherwise 0.
Definition JetSmearingFunctions.hh:53
Rivet::JET_SMEAR_PERFECT
Jet JET_SMEAR_PERFECT(const Jet &j)
Alias for JET_SMEAR_IDENTITY.
Definition JetSmearingFunctions.hh:86
Rivet::JET_EFF_1
double JET_EFF_1(const Jet &p)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:37
Rivet::JET_EFF_0
double JET_EFF_0(const Jet &p)
Alias for JET_EFF_ZERO.
Definition JetSmearingFunctions.hh:30
Rivet::JET_FN1
double JET_FN1(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:41
Rivet::JET_EFF_ZERO
double JET_EFF_ZERO(const Jet &p)
Take a jet and return a constant 0.
Definition JetSmearingFunctions.hh:28
Rivet::JET_SMEAR_IDENTITY
Jet JET_SMEAR_IDENTITY(const Jet &j)
Definition JetSmearingFunctions.hh:84
Rivet::JetSmearFn
function< Jet(const Jet &)> JetSmearFn
Typedef for Jet smearing functions/functors.
Definition JetSmearingFunctions.hh:20
Rivet::efffilt
bool efffilt(const Jet &j, FN &feff)
Return true if Jet j is chosen to survive a random efficiency selection.
Definition JetSmearingFunctions.hh:138
Rivet::JetEffFn
function< double(const Jet &)> JetEffFn
Typedef for Jet efficiency functions/functors.
Definition JetSmearingFunctions.hh:23
Rivet::JET_EFF_PERFECT
double JET_EFF_PERFECT(const Jet &)
Alias for JET_EFF_ONE.
Definition JetSmearingFunctions.hh:39
Rivet
Definition MC_Cent_pPb.hh:10
Rivet::rand01
double rand01()
Return a uniformly sampled random number between 0 and 1.
Rivet::cmp
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition Cmp.hh:255
std::get_address
uintptr_t get_address(std::function< T(U...)> f)
Get a function pointer / hash integer from an std::function.
Definition RivetSTL.hh:193
Rivet::JET_BTAG_EFFS
b-tagging efficiency functor, for more readable b-tag effs and mistag rates
Definition JetSmearingFunctions.hh:67
Rivet::JET_EFF_CONST
Take a Jet and return a constant efficiency.
Definition JetSmearingFunctions.hh:44
Rivet::JetEffFilter
A functor to return true if Jet j survives a random efficiency selection.
Definition JetSmearingFunctions.hh:143
Rivet::JetEffSmearFn
Functor for simultaneous efficiency-filtering and smearing of Jets.
Definition JetSmearingFunctions.hh:94
Rivet::JetEffSmearFn::cmp
CmpState cmp(const JetEffSmearFn &other) const
Compare to another, for use in the projection system.
Definition JetSmearingFunctions.hh:116
Rivet::JetEffSmearFn::sfn
JetSmearFn sfn
Definition JetSmearingFunctions.hh:131
Rivet::JetEffSmearFn::operator()
pair< Jet, double > operator()(const Jet &j) const
Smear and calculate an efficiency for the given jet.
Definition JetSmearingFunctions.hh:111