Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:06:52

0001 // -*- C++ -*-
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   /// @ingroup smearing
0012   /// @{
0013 
0014   /// @defgroup smearing_mom Generic 4-momentum filtering, efficiency and smearing utils
0015   /// @{
0016 
0017   /// Typedef for FourMomentum smearing functions/functors
0018   typedef std::function<FourMomentum(const FourMomentum&)> P4SmearFn;
0019 
0020   /// Typedef for FourMomentum efficiency functions/functors
0021   typedef std::function<double(const FourMomentum&)> P4EffFn;
0022 
0023 
0024   /// Take a FourMomentum and return 0
0025   inline double P4_EFF_ZERO(const FourMomentum& ) { return 0; }
0026 
0027   /// Take a FourMomentum and return 1
0028   inline double P4_EFF_ONE(const FourMomentum& ) { return 1; }
0029 
0030   /// Take a FourMomentum and return a constant number
0031   struct P4_EFF_CONST {
0032     P4_EFF_CONST(double x) : _x(x) {}
0033     double operator () (const FourMomentum& )  const { return _x; }
0034     double _x;
0035   };
0036 
0037 
0038   /// Take a FourMomentum and return it unmodified
0039   inline FourMomentum P4_SMEAR_IDENTITY(const FourMomentum& p) { return p; }
0040   /// Alias for P4_SMEAR_IDENTITY
0041   inline FourMomentum P4_SMEAR_PERFECT(const FourMomentum& p) { return p; }
0042 
0043   /// Smear a FourMomentum's energy using a Gaussian of absolute width @a resolution
0044   /// @todo Also make jet versions that update/smear constituents?
0045   inline FourMomentum P4_SMEAR_E_GAUSS(const FourMomentum& p, double resolution) {
0046     const double mass = p.mass2() > 0 ? p.mass() : 0; //< numerical carefulness...
0047     const double smeared_E = max(randnorm(p.E(), resolution), mass); //< can't let the energy go below the mass!
0048     return FourMomentum::mkEtaPhiME(p.eta(), p.phi(), mass, smeared_E);
0049   }
0050 
0051   /// Smear a FourMomentum's transverse momentum using a Gaussian of absolute width @a resolution
0052   inline FourMomentum P4_SMEAR_PT_GAUSS(const FourMomentum& p, double resolution) {
0053     const double smeared_pt = max(randnorm(p.pT(), resolution), 0.);
0054     const double mass = p.mass2() > 0 ? p.mass() : 0; //< numerical carefulness...
0055     return FourMomentum::mkEtaPhiMPt(p.eta(), p.phi(), mass, smeared_pt);
0056   }
0057 
0058   /// Smear a FourMomentum's mass using a Gaussian of absolute width @a resolution
0059   inline FourMomentum P4_SMEAR_MASS_GAUSS(const FourMomentum& p, double resolution) {
0060     const double smeared_mass = max(randnorm(p.mass(), resolution), 0.);
0061     return FourMomentum::mkEtaPhiMPt(p.eta(), p.phi(), smeared_mass, p.pT());
0062   }
0063 
0064   /// @}
0065 
0066 
0067 
0068   /// @defgroup smearing_mom Generic 3-momentum filtering, efficiency and smearing utils
0069   /// @{
0070 
0071   /// Take a Vector3 and return 0
0072   inline double P3_EFF_ZERO(const Vector3&) { return 0; }
0073 
0074   /// Take a Vector3 and return 1
0075   inline double P3_EFF_ONE(const Vector3&) { return 1; }
0076 
0077   /// Take a Vector3 and return a constant number
0078   struct P3_EFF_CONST {
0079     P3_EFF_CONST(double x) : _x(x) {}
0080     double operator () (const Vector3& )  const { return _x; }
0081     double _x;
0082   };
0083 
0084 
0085   /// Take a Vector3 and return it unmodified
0086   inline Vector3 P3_SMEAR_IDENTITY(const Vector3& p) { return p; }
0087   /// Alias for P3_SMEAR_IDENTITY
0088   inline Vector3 P3_SMEAR_PERFECT(const Vector3& p) { return p; }
0089 
0090   /// Smear a Vector3's length using a Gaussian of absolute width @a resolution
0091   inline Vector3 P3_SMEAR_LEN_GAUSS(const Vector3& p, double resolution) {
0092     const double smeared_mod = max(randnorm(p.mod(), resolution), 0.); //< can't let the energy go below the mass!
0093     return smeared_mod * p.unit();
0094   }
0095 
0096   /// @}
0097 
0098   /// @}
0099 
0100 }
0101 
0102 #endif