rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
MomentumSmearingFunctions.hh
1 // -*- C++ -*-
2 #ifndef RIVET_MomentumSmearingFunctions_HH
3 #define RIVET_MomentumSmearingFunctions_HH
4 
5 #include "Rivet/Math/Vector4.hh"
6 #include "Rivet/Tools/Random.hh"
7 
8 namespace Rivet {
9 
10 
12 
13 
15  typedef std::function<FourMomentum(const FourMomentum&)> P4SmearFn;
16 
18  typedef std::function<double(const FourMomentum&)> P4EffFn;
19 
20 
22  inline double P4_EFF_ZERO(const FourMomentum& ) { return 0; }
24  inline double P4_FN0(const FourMomentum& ) { return 0; }
25 
27  inline double P4_EFF_ONE(const FourMomentum& ) { return 1; }
29  inline double P4_FN1(const FourMomentum& ) { return 1; }
30 
32  struct P4_EFF_CONST {
33  P4_EFF_CONST(double x) : _x(x) {}
34  double operator () (const FourMomentum& ) const { return _x; }
35  double _x;
36  };
37 
38 
40  inline FourMomentum P4_SMEAR_IDENTITY(const FourMomentum& p) { return p; }
42  inline FourMomentum P4_SMEAR_PERFECT(const FourMomentum& p) { return p; }
43 
46  inline FourMomentum P4_SMEAR_E_GAUSS(const FourMomentum& p, double resolution) {
47  const double mass = p.mass2() > 0 ? p.mass() : 0; //< numerical carefulness...
48  const double smeared_E = max(randnorm(p.E(), resolution), mass); //< can't let the energy go below the mass!
49  return FourMomentum::mkEtaPhiME(p.eta(), p.phi(), mass, smeared_E);
50  }
51 
53  inline FourMomentum P4_SMEAR_PT_GAUSS(const FourMomentum& p, double resolution) {
54  const double smeared_pt = max(randnorm(p.pT(), resolution), 0.);
55  const double mass = p.mass2() > 0 ? p.mass() : 0; //< numerical carefulness...
56  return FourMomentum::mkEtaPhiMPt(p.eta(), p.phi(), mass, smeared_pt);
57  }
58 
60  inline FourMomentum P4_SMEAR_MASS_GAUSS(const FourMomentum& p, double resolution) {
61  const double smeared_mass = max(randnorm(p.mass(), resolution), 0.);
62  return FourMomentum::mkEtaPhiMPt(p.eta(), p.phi(), smeared_mass, p.pT());
63  }
64 
66 
67 
68 
70 
71 
73  inline double P3_EFF_ZERO(const Vector3& p) { return 0; }
75  inline double P3_FN0(const Vector3& p) { return 0; }
76 
78  inline double P3_EFF_ONE(const Vector3& p) { return 1; }
80  inline double P3_FN1(const Vector3& p) { return 1; }
81 
83  struct P3_EFF_CONST {
84  P3_EFF_CONST(double x) : _x(x) {}
85  double operator () (const Vector3& ) const { return _x; }
86  double _x;
87  };
88 
89 
91  inline Vector3 P3_SMEAR_IDENTITY(const Vector3& p) { return p; }
93  inline Vector3 P3_SMEAR_PERFECT(const Vector3& p) { return p; }
94 
96  inline Vector3 P3_SMEAR_LEN_GAUSS(const Vector3& p, double resolution) {
97  const double smeared_mod = max(randnorm(p.mod(), resolution), 0.); //< can't let the energy go below the mass!
98  return smeared_mod * p.unit();
99  }
100 
102 
103 
104 }
105 
106 #endif
Vector3 P3_SMEAR_PERFECT(const Vector3 &p)
Alias for P3_SMEAR_IDENTITY.
Definition: MomentumSmearingFunctions.hh:93
Definition: ALICE_2010_I880049.cc:13
FourMomentum P4_SMEAR_E_GAUSS(const FourMomentum &p, double resolution)
Definition: MomentumSmearingFunctions.hh:46
double P3_FN1(const Vector3 &p)
Definition: MomentumSmearingFunctions.hh:80
double pT() const
Calculate the transverse momentum .
Definition: Vector4.hh:628
FourMomentum P4_SMEAR_IDENTITY(const FourMomentum &p)
Take a FourMomentum and return it unmodified.
Definition: MomentumSmearingFunctions.hh:40
Take a Vector3 and return a constant number.
Definition: MomentumSmearingFunctions.hh:83
double eta() const
Synonym for pseudorapidity.
Definition: Vector4.hh:152
double P4_EFF_ZERO(const FourMomentum &)
Take a FourMomentum and return 0.
Definition: MomentumSmearingFunctions.hh:22
Vector3 P3_SMEAR_LEN_GAUSS(const Vector3 &p, double resolution)
Smear a Vector3&#39;s length using a Gaussian of absolute width resolution.
Definition: MomentumSmearingFunctions.hh:96
static FourMomentum mkEtaPhiMPt(double eta, double phi, double mass, double pt)
Make a vector from (eta,phi,pT) coordinates and the mass.
Definition: Vector4.hh:786
static FourMomentum mkEtaPhiME(double eta, double phi, double mass, double E)
Make a vector from (eta,phi,energy) coordinates and the mass.
Definition: Vector4.hh:781
double mass2() const
Get the squared mass (the Lorentz self-invariant).
Definition: Vector4.hh:572
Take a FourMomentum and return a constant number.
Definition: MomentumSmearingFunctions.hh:32
double P4_FN1(const FourMomentum &)
Definition: MomentumSmearingFunctions.hh:29
double P3_EFF_ONE(const Vector3 &p)
Take a Vector3 and return 1.
Definition: MomentumSmearingFunctions.hh:78
FourMomentum P4_SMEAR_PERFECT(const FourMomentum &p)
Alias for P4_SMEAR_IDENTITY.
Definition: MomentumSmearingFunctions.hh:42
double mass() const
Get the mass (the Lorentz self-invariant).
Definition: Vector4.hh:561
double P4_EFF_ONE(const FourMomentum &)
Take a FourMomentum and return 1.
Definition: MomentumSmearingFunctions.hh:27
FourMomentum P4_SMEAR_MASS_GAUSS(const FourMomentum &p, double resolution)
Smear a FourMomentum&#39;s mass using a Gaussian of absolute width resolution.
Definition: MomentumSmearingFunctions.hh:60
double P3_FN0(const Vector3 &p)
Definition: MomentumSmearingFunctions.hh:75
double E() const
Get energy (time component of momentum).
Definition: Vector4.hh:538
double P4_FN0(const FourMomentum &)
Definition: MomentumSmearingFunctions.hh:24
double max(const vector< double > &in, double errval=DBL_NAN)
Find the maximum value in the vector.
Definition: Utils.hh:465
Vector3 unit() const
Synonym for unitVec.
Definition: Vector3.hh:105
Vector3 P3_SMEAR_IDENTITY(const Vector3 &p)
Take a Vector3 and return it unmodified.
Definition: MomentumSmearingFunctions.hh:91
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector4.hh:134
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
double P3_EFF_ZERO(const Vector3 &p)
Take a Vector3 and return 0.
Definition: MomentumSmearingFunctions.hh:73
Specialized version of the FourVector with momentum/energy functionality.
Definition: Vector4.hh:301
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95
FourMomentum P4_SMEAR_PT_GAUSS(const FourMomentum &p, double resolution)
Smear a FourMomentum&#39;s transverse momentum using a Gaussian of absolute width resolution.
Definition: MomentumSmearingFunctions.hh:53
double randnorm(double loc, double scale)
Return a Gaussian/normal sampled random number with the given mean and width.
Definition: Random.cc:47