File indexing completed on 2025-09-18 09:31:17
0001
0002 #ifndef RIVET_JetSmearingFunctions_HH
0003 #define RIVET_JetSmearingFunctions_HH
0004
0005 #include "Rivet/Jet.hh"
0006 #include "Rivet/Tools/MomentumSmearingFunctions.hh"
0007 #include "Rivet/Tools/ParticleSmearingFunctions.hh"
0008 #include "Rivet/Tools/Random.hh"
0009
0010 namespace Rivet {
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 typedef function<Jet(const Jet&)> JetSmearFn;
0021
0022
0023 typedef function<double(const Jet&)> JetEffFn;
0024
0025
0026
0027
0028 inline double JET_EFF_ZERO(const Jet&) { return 0; }
0029
0030 inline double JET_EFF_0(const Jet&) { return 0; }
0031
0032 inline double JET_FN0(const Jet&) { return 0; }
0033
0034
0035 inline double JET_EFF_ONE(const Jet&) { return 1; }
0036
0037 inline double JET_EFF_1(const Jet&) { return 1; }
0038
0039 inline double JET_EFF_PERFECT(const Jet&) { return 1; }
0040
0041 inline double JET_EFF_IDENTITY(const Jet&) { return 1; }
0042
0043 inline double JET_FN1(const Jet&) { return 1; }
0044
0045
0046 struct JET_EFF_CONST {
0047 JET_EFF_CONST(double eff) : _eff(eff) {}
0048 double operator () (const Jet& ) const { return _eff; }
0049 double _eff;
0050 };
0051
0052
0053
0054
0055
0056 inline double JET_BTAG_PERFECT(const Jet& j) { return j.bTagged() ? 1 : 0; }
0057
0058 inline double JET_BTAG_IDENTITY(const Jet& j) { return JET_BTAG_PERFECT(j); }
0059
0060
0061
0062
0063 inline double JET_CTAG_PERFECT(const Jet& j) { return j.cTagged() ? 1 : 0; }
0064
0065 inline double JET_CTAG_IDENTITY(const Jet& j) { return JET_CTAG_PERFECT(j); }
0066
0067
0068
0069
0070 inline double JET_TAUTAG_PERFECT(const Jet& j) { return j.tauTagged() ? 1 : 0; }
0071
0072 inline double JET_TAUTAG_IDENTITY(const Jet& j) { return JET_TAUTAG_PERFECT(j); }
0073
0074
0075
0076
0077
0078 struct JET_BTAG_EFFS {
0079 JET_BTAG_EFFS(double eff_b, double eff_light=0) : _eff_b(eff_b), _eff_c(-1), _eff_t(-1), _eff_l(eff_light) { }
0080 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) { }
0081 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) { }
0082 inline double operator () (const Jet& j) {
0083 if (j.bTagged()) return _eff_b;
0084 if (_eff_c >= 0 && j.cTagged()) return _eff_c;
0085 if (_eff_t >= 0 && j.tauTagged()) return _eff_t;
0086 return _eff_l;
0087 }
0088 double _eff_b, _eff_c, _eff_t, _eff_l;
0089 };
0090
0091
0092
0093
0094
0095 inline Jet JET_SMEAR_IDENTITY(const Jet& j) { return j; }
0096
0097 inline Jet JET_SMEAR_PERFECT(const Jet& j) { return j; }
0098
0099
0100
0101
0102
0103
0104
0105 struct JetEffSmearFn {
0106 JetEffSmearFn(const JetSmearFn& s, const JetEffFn& e)
0107 : sfn(s), efn(e) { }
0108
0109 JetEffSmearFn(const JetEffFn& e, const JetSmearFn& s)
0110 : sfn(s), efn(e) { }
0111
0112 JetEffSmearFn(const JetSmearFn& s)
0113 : sfn(s), efn(JET_EFF_ONE) { }
0114
0115 JetEffSmearFn(const JetEffFn& e)
0116 : sfn(JET_SMEAR_IDENTITY), efn(e) { }
0117
0118 JetEffSmearFn(double eff)
0119 : JetEffSmearFn(JET_EFF_CONST(eff)) { }
0120
0121
0122 pair<Jet,double> operator() (const Jet& j) const {
0123 return make_pair(sfn(j), efn(j));
0124 }
0125
0126
0127 CmpState cmp(const JetEffSmearFn& other) const {
0128
0129
0130 if (get_address(sfn) == 0 || get_address(other.sfn) == 0) return CmpState::NEQ;
0131 if (get_address(efn) == 0 || get_address(other.efn) == 0) return CmpState::NEQ;
0132 return Rivet::cmp(get_address(sfn), get_address(other.sfn)) || Rivet::cmp(get_address(efn), get_address(other.efn));
0133 }
0134
0135
0136 operator JetSmearFn () { return sfn; }
0137
0138
0139
0140
0141
0142 JetSmearFn sfn;
0143 JetEffFn efn;
0144 };
0145
0146
0147
0148 template <typename FN>
0149 inline bool efffilt(const Jet& j, FN& feff) {
0150 return rand01() < feff(j);
0151 }
0152
0153
0154 struct JetEffFilter {
0155 template <typename FN>
0156 JetEffFilter(const FN& feff) : _feff(feff) {}
0157 JetEffFilter(double eff) : JetEffFilter( [&](const Jet&){return eff;} ) {}
0158 bool operator () (const Jet& j) const { return efffilt(j, _feff); }
0159 private:
0160 const JetEffFn _feff;
0161 };
0162 using jetEffFilter = JetEffFilter;
0163
0164
0165
0166
0167
0168 }
0169
0170 #endif