rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.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 
10 namespace Rivet {
11 
12 
14 
15 
17  typedef function<Jet(const Jet&)> JetSmearFn;
18 
20  typedef function<double(const Jet&)> JetEffFn;
21 
22 
23 
25  inline double JET_EFF_ZERO(const Jet& p) { return 0; }
27  inline double JET_EFF_ONE(const Jet& p) { return 1; }
28 
30  struct JET_EFF_CONST {
31  JET_EFF_CONST(double eff) : _eff(eff) {}
32  double operator () (const Jet& ) const { return _eff; }
33  double _eff;
34  };
35 
36 
38  inline double JET_BTAG_PERFECT(const Jet& j) { return j.bTagged() ? 1 : 0; }
39 
41  inline double JET_CTAG_PERFECT(const Jet& j) { return j.cTagged() ? 1 : 0; }
42 
43 
46  struct JET_BTAG_EFFS {
47  JET_BTAG_EFFS(double eff_b, double eff_light=0) : _eff_b(eff_b), _eff_c(-1), _eff_t(-1), _eff_l(eff_light) { }
48  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) { }
49  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) { }
50  inline double operator () (const Jet& j) {
51  if (j.bTagged()) return _eff_b;
52  if (_eff_c >= 0 && j.cTagged()) return _eff_c;
53  if (_eff_t >= 0 && j.tauTagged()) return _eff_t;
54  return _eff_l;
55  }
56  double _eff_b, _eff_c, _eff_t, _eff_l;
57  };
58 
59 
63  inline Jet JET_SMEAR_IDENTITY(const Jet& j) { return j; }
65  inline Jet JET_SMEAR_PERFECT(const Jet& j) { return j; }
66 
67 
73  struct JetEffSmearFn {
74  JetEffSmearFn(const JetSmearFn& s, const JetEffFn& e)
75  : sfn(s), efn(e) { }
76 
77  JetEffSmearFn(const JetEffFn& e, const JetSmearFn& s)
78  : sfn(s), efn(e) { }
79 
80  JetEffSmearFn(const JetSmearFn& s)
81  : sfn(s), efn(JET_EFF_ONE) { }
82 
83  JetEffSmearFn(const JetEffFn& e)
84  : sfn(JET_SMEAR_IDENTITY), efn(e) { }
85 
86  JetEffSmearFn(double eff)
87  : JetEffSmearFn(JET_EFF_CONST(eff)) { }
88 
90  pair<Jet,double> operator() (const Jet& j) const {
91  return make_pair(sfn(j), efn(j));
92  }
93 
95  int cmp(const JetEffSmearFn& other) const {
96  // cout << "Eff hashes = " << get_address(efn) << "," << get_address(other.efn) << "; "
97  // << "smear hashes = " << get_address(sfn) << "," << get_address(other.sfn) << endl;
98  if (get_address(sfn) == 0 || get_address(other.sfn) == 0) return UNDEFINED;
99  if (get_address(efn) == 0 || get_address(other.efn) == 0) return UNDEFINED;
100  return Rivet::cmp(get_address(sfn), get_address(other.sfn)) || Rivet::cmp(get_address(efn), get_address(other.efn));
101  }
102 
104  operator JetSmearFn () { return sfn; }
107  // operator JetEffFn () { return efn; }
108 
109  // Stored functions/functors
110  JetSmearFn sfn;
111  JetEffFn efn;
112  };
113 
114 
116  template <typename FN>
117  inline bool efffilt(const Jet& j, FN& feff) {
118  return rand01() < feff(j);
119  }
120 
122  struct JetEffFilter {
123  template <typename FN>
124  JetEffFilter(const FN& feff) : _feff(feff) {}
125  JetEffFilter(double eff) : JetEffFilter( [&](const Jet& j){return eff;} ) {}
126  bool operator () (const Jet& j) const { return efffilt(j, _feff); }
127  private:
128  const JetEffFn _feff;
129  };
130  using jetEffFilter = JetEffFilter;
131 
133 
134 
135 }
136 
137 #endif
Definition: ALICE_2010_I880049.cc:13
A functor to return true if Jet j survives a random efficiency selection.
Definition: JetSmearingFunctions.hh:122
double JET_EFF_ONE(const Jet &p)
Return a constant 1 given a Jet as argument.
Definition: JetSmearingFunctions.hh:27
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:110
Functor for simultaneous efficiency-filtering and smearing of Jets.
Definition: JetSmearingFunctions.hh:73
double JET_CTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition: JetSmearingFunctions.hh:41
double JET_EFF_ZERO(const Jet &p)
Return a constant 0 given a Jet as argument.
Definition: JetSmearingFunctions.hh:25
JetSmearFn sfn
Definition: JetSmearingFunctions.hh:110
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:136
bool efffilt(const Jet &j, FN &feff)
Return true if Jet j is chosen to survive a random efficiency selection.
Definition: JetSmearingFunctions.hh:117
double JET_BTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a b, otherwise 0.
Definition: JetSmearingFunctions.hh:38
Take a Jet and return a constant efficiency.
Definition: JetSmearingFunctions.hh:30
int cmp(const JetEffSmearFn &other) const
Compare to another, for use in the projection system.
Definition: JetSmearingFunctions.hh:95
Representation of a clustered jet of particles.
Definition: Jet.hh:18
Jet JET_SMEAR_IDENTITY(const Jet &j)
Definition: JetSmearingFunctions.hh:63
b-tagging efficiency functor, for more readable b-tag effs and mistag rates Note several constructors...
Definition: JetSmearingFunctions.hh:46
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:123
double rand01()
Return a uniformly sampled random number between 0 and 1.
Definition: Random.cc:39
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:285
Jet JET_SMEAR_PERFECT(const Jet &j)
Alias for JET_SMEAR_IDENTITY.
Definition: JetSmearingFunctions.hh:65