Rivet  3.1.0
SmearedMET.hh
1 // -*- C++ -*-
2 #ifndef RIVET_SmearedMET_HH
3 #define RIVET_SmearedMET_HH
4 
5 #include "Rivet/Projection.hh"
6 #include "Rivet/Projections/MissingMomentum.hh"
7 #include "Rivet/Tools/SmearingFunctions.hh"
8 #include <functional>
9 
10 namespace Rivet {
11 
12 
14  class SmearedMET : public Projection {
15  public:
16 
18 
19 
23  template <typename V2VFN>
24  SmearedMET(const MissingMomentum& mm, const V2VFN& metSmearFn)
25  : _metSmearFn(metSmearFn)
26  {
27  setName("SmearedMET");
28  declare(mm, "TruthMET");
29  }
30 
32  template <typename V2VFN>
33  SmearedMET(const V2VFN& metSmearFn, const Cut& cut)
34  : _metSmearFn(metSmearFn)
35  {
36  setName("SmearedMET");
37  declare(MissingMomentum(cut), "TruthMET");
38  }
39 
40 
43 
45 
46 
48  CmpState compare(const Projection& p) const {
49  const SmearedMET& other = dynamic_cast<const SmearedMET&>(p);
50  if (get_address(_metSmearFn) == 0) return cmp((size_t)this, (size_t)&p);
51  MSG_TRACE("Smear hashes = " << get_address(_metSmearFn) << "," << get_address(other._metSmearFn));
52  return mkPCmp(other, "TruthMET") || cmp(get_address(_metSmearFn), get_address(other._metSmearFn));
53  }
54 
55 
57  void project(const Event& e) {
58  const auto& mm = apply<MissingMomentum>(e, "TruthMET");
59  _vet = mm.vectorEt();
60  if (_metSmearFn) _vet = _metSmearFn(_vet, mm.scalarEt()); //< smearing
61  }
62 
63 
67 
68 
72  const Vector3& vectorPt() const { return vectorEt(); }
73 
75  const Vector3 vectorMissingPt() const { return -vectorPt(); }
76  // Alias
77  const Vector3 vectorMPT() const { return vectorMissingPt(); }
78 
80  double missingPt() const { return vectorPt().mod(); }
81  // /// Alias for missingPt
82  // double mpt() const { return missingPt(); }
83 
84  // /// The scalar-summed visible transverse momentum in the event.
85  // double scalarPt() const { return _spt; }
86  // // /// Alias for scalarPt
87  // // double spt() const { return scalarPt(); }
88 
90 
91 
95 
96 
99  const Vector3& vectorEt() const { return _vet; }
100 
102  const Vector3 vectorMissingEt() const { return -vectorEt(); }
103  // Alias
104  const Vector3 vectorMET() const { return vectorMissingEt(); }
105 
107  double missingEt() const { return vectorEt().mod(); }
109  double met() const { return missingEt(); }
110 
112 
113 
115  void reset() { }
116 
117 
118  private:
119 
120  Vector3 _vet;
121 
123  std::function<Vector3(const Vector3&, double)> _metSmearFn;
124 
125  };
126 
127 
128 }
129 
130 #endif
void setName(const std::string &name)
Used by derived classes to set their name.
Definition: Projection.hh:142
Definition: MC_Cent_pPb.hh:10
CmpState compare(const Projection &p) const
Compare to another SmearedMET.
Definition: SmearedMET.hh:48
const Vector3 vectorMissingEt() const
Convenience vector MET function.
Definition: SmearedMET.hh:102
void reset()
Reset the projection. Smearing functions will be unchanged.
Definition: SmearedMET.hh:115
const Vector3 & vectorPt() const
Definition: SmearedMET.hh:72
void project(const Event &e)
Perform the MET finding & smearing calculation.
Definition: SmearedMET.hh:57
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
Cmp< Projection > mkPCmp(const Projection &otherparent, const std::string &pname) const
const Vector3 & vectorEt() const
Definition: SmearedMET.hh:99
DEFAULT_RIVET_PROJ_CLONE(SmearedMET)
Clone on the heap.
Wrapper projection for smearing missing (transverse) energy/momentum with detector resolutions...
Definition: SmearedMET.hh:14
const Vector3 vectorMissingPt() const
Convenience vector MPT function.
Definition: SmearedMET.hh:75
SmearedMET(const V2VFN &metSmearFn, const Cut &cut)
Constructor from a Cut (on the particles used to determine missing momentum) and a smearing function...
Definition: SmearedMET.hh:33
Calculate missing , etc.
Definition: MissingMomentum.hh:19
SmearedMET(const MissingMomentum &mm, const V2VFN &metSmearFn)
Constructor from a MissingMomentum projection and a smearing function.
Definition: SmearedMET.hh:24
double met() const
Alias for missingEt.
Definition: SmearedMET.hh:109
const PROJ & declare(const PROJ &proj, const std::string &name)
Register a contained projection (user-facing version)
Definition: ProjectionApplier.hh:160
double missingPt() const
The vector-summed missing transverse momentum in the event.
Definition: SmearedMET.hh:80
double missingEt() const
The vector-summed missing transverse energy in the event.
Definition: SmearedMET.hh:107
Base class for all Rivet projections.
Definition: Projection.hh:29
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:255