File indexing completed on 2025-09-17 09:13:40
0001
0002 #ifndef RIVET_MomentumSmearingFunctions_HH
0003 #define RIVET_MomentumSmearingFunctions_HH
0004
0005 #include "Rivet/Math/Vector4.hh"
0006 #include "Rivet/Tools/Random.hh"
0007
0008 namespace Rivet {
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct P4SmearParams {
0023 P4SmearParams(const FourMomentum& p4nom, double pres=0.0, double eres=0.0, double phires=0.0, double etares=0.0)
0024 : p4Nominal(p4nom), pResolution(pres), eResolution(pres),
0025 phiResolution(phires), etaResolution(etares) {}
0026 FourMomentum p4Nominal;
0027 double pResolution{0.0}, eResolution{0.0}, phiResolution{0.0}, etaResolution{0.0};
0028 };
0029
0030
0031 typedef std::function<FourMomentum(const FourMomentum&)> P4SmearFn;
0032
0033
0034 typedef std::function<double(const FourMomentum&)> P4EffFn;
0035
0036
0037
0038 inline double P4_EFF_ZERO(const FourMomentum& ) { return 0; }
0039
0040
0041 inline double P4_EFF_ONE(const FourMomentum& ) { return 1; }
0042
0043
0044 struct P4_EFF_CONST {
0045 P4_EFF_CONST(double x) : _x(x) {}
0046 double operator () (const FourMomentum& ) const { return _x; }
0047 double _x;
0048 };
0049
0050
0051
0052 inline FourMomentum P4_SMEAR_IDENTITY(const FourMomentum& p) { return p; }
0053
0054 inline FourMomentum P4_SMEAR_PERFECT(const FourMomentum& p) { return p; }
0055
0056
0057
0058 inline FourMomentum P4_SMEAR_E_GAUSS(const FourMomentum& p, double resolution) {
0059 const double mass = p.mass2() > 0 ? p.mass() : 0;
0060 const double smeared_E = max(randnorm(p.E(), resolution), mass);
0061 return FourMomentum::mkEtaPhiME(p.eta(), p.phi(), mass, smeared_E);
0062 }
0063
0064
0065 inline FourMomentum P4_SMEAR_PT_GAUSS(const FourMomentum& p, double resolution) {
0066 const double smeared_pt = max(randnorm(p.pT(), resolution), 0.);
0067 const double mass = p.mass2() > 0 ? p.mass() : 0;
0068 return FourMomentum::mkEtaPhiMPt(p.eta(), p.phi(), mass, smeared_pt);
0069 }
0070
0071
0072 inline FourMomentum P4_SMEAR_MASS_GAUSS(const FourMomentum& p, double resolution) {
0073 const double smeared_mass = max(randnorm(p.mass(), resolution), 0.);
0074 return FourMomentum::mkEtaPhiMPt(p.eta(), p.phi(), smeared_mass, p.pT());
0075 }
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 inline double P3_EFF_ZERO(const Vector3&) { return 0; }
0086
0087
0088 inline double P3_EFF_ONE(const Vector3&) { return 1; }
0089
0090
0091 struct P3_EFF_CONST {
0092 P3_EFF_CONST(double x) : _x(x) {}
0093 double operator () (const Vector3& ) const { return _x; }
0094 double _x;
0095 };
0096
0097
0098
0099 inline Vector3 P3_SMEAR_IDENTITY(const Vector3& p) { return p; }
0100
0101 inline Vector3 P3_SMEAR_PERFECT(const Vector3& p) { return p; }
0102
0103
0104 inline Vector3 P3_SMEAR_LEN_GAUSS(const Vector3& p, double resolution) {
0105 const double smeared_mod = max(randnorm(p.mod(), resolution), 0.);
0106 return smeared_mod * p.unit();
0107 }
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 struct METSmearParams {
0122 METSmearParams(const Vector3& vmetnom, double pres=0.0, double phires=0.0)
0123 : vmetNominal(vmetnom), pResolution(pres), phiResolution(phires) {}
0124 Vector3 vmetNominal;
0125 double pResolution{0.0}, phiResolution{0.0};
0126 };
0127
0128
0129
0130
0131
0132
0133
0134 typedef function<METSmearParams(const Vector3&, double)> METSmearParamsFn;
0135
0136
0137
0138
0139 typedef function<Vector3(const Vector3&, double)> METSmearFn;
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 inline Vector3 MET_SMEAR_NORM(const METSmearParams& msps) {
0157 const Vector3& vmet = msps.vmetNominal;
0158
0159
0160 const double metsmear = fabs(randnorm(vmet.mod(), msps.pResolution));
0161
0162 const Matrix3 phismear = Matrix3::mkZRotation(randnorm(0.0, msps.phiResolution));
0163
0164 return metsmear * phismear * vmet.unit();
0165 }
0166
0167
0168
0169
0170
0171
0172 inline METSmearParams MET_SMEARPARAMS_IDENTITY(const Vector3& met, double) {
0173 return METSmearParams(met, 0.0, 0.0);
0174 }
0175
0176
0177 inline Vector3 MET_SMEAR_IDENTITY(const Vector3& met, double) {
0178 return met;
0179 }
0180
0181
0182
0183
0184
0185 }
0186
0187 #endif