File indexing completed on 2025-05-12 09:05:03
0001
0002 #ifndef RIVET_SmearedMET_HH
0003 #define RIVET_SmearedMET_HH
0004
0005 #include "Rivet/Projection.hh"
0006 #include "Rivet/Projections/METFinder.hh"
0007 #include "Rivet/Projections/MissingMomentum.hh"
0008 #include "Rivet/Tools/SmearingFunctions.hh"
0009 #include <functional>
0010
0011 namespace Rivet {
0012
0013
0014
0015 class SmearedMET : public METFinder {
0016 public:
0017
0018
0019
0020
0021
0022
0023
0024 template <typename V2VFN>
0025 SmearedMET(const MissingMomentum& mm, const V2VFN& metSmearFn)
0026 : _metSmearFn(metSmearFn)
0027 {
0028 setName("SmearedMET");
0029 declare(mm, "TruthMET");
0030 }
0031
0032
0033 template <typename V2VFN>
0034 SmearedMET(const V2VFN& metSmearFn, const Cut& cut)
0035 : _metSmearFn(metSmearFn)
0036 {
0037 setName("SmearedMET");
0038 declare(MissingMomentum(cut), "TruthMET");
0039 }
0040
0041
0042
0043 RIVET_DEFAULT_PROJ_CLONE(SmearedMET);
0044
0045
0046
0047
0048 using Projection::operator =;
0049
0050
0051
0052 CmpState compare(const Projection& p) const {
0053 const SmearedMET& other = dynamic_cast<const SmearedMET&>(p);
0054 if (get_address(_metSmearFn) == 0) return cmp((size_t)this, (size_t)&p);
0055 MSG_TRACE("Smear hashes = " << get_address(_metSmearFn) << "," << get_address(other._metSmearFn));
0056 return mkPCmp(other, "TruthMET") || cmp(get_address(_metSmearFn), get_address(other._metSmearFn));
0057 }
0058
0059
0060
0061 void project(const Event& e) {
0062 const auto& mm = apply<MissingMomentum>(e, "TruthMET");
0063 _vet = mm.vectorEt();
0064 if (_metSmearFn) _vet = _metSmearFn(_vet, mm.scalarEt());
0065 }
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 const Vector3& vectorPt() const { return vectorEt(); }
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 const Vector3& vectorEt() const { return _vet; }
0091
0092
0093
0094
0095
0096 void reset() { }
0097
0098
0099 protected:
0100
0101 Vector3 _vet;
0102
0103
0104 std::function<Vector3(const Vector3&, double)> _metSmearFn;
0105
0106 };
0107
0108
0109 }
0110
0111 #endif