Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-12 09:05:03

0001 // -*- C++ -*-
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   /// Wrapper projection for smearing missing (transverse) energy/momentum with detector resolutions
0015   class SmearedMET : public METFinder {
0016   public:
0017 
0018     /// @name Constructors etc.
0019     /// @{
0020 
0021     /// @brief Constructor from a MissingMomentum projection and a smearing function
0022     ///
0023     /// Smearing function maps a 3-vector MET and scalar SET to a new MET 3-vector: f(V3, double) -> V3
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     /// @brief Constructor from a Cut (on the particles used to determine missing momentum) and a smearing function
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     /// Clone on the heap.
0043     RIVET_DEFAULT_PROJ_CLONE(SmearedMET);
0044 
0045     /// @}
0046 
0047     /// Import to avoid warnings about overload-hiding
0048     using Projection::operator =;
0049 
0050 
0051     /// Compare to another SmearedMET
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     /// Perform the MET finding & smearing calculation
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()); //< smearing
0065     }
0066 
0067 
0068     /// @name Transverse momentum functions
0069     ///
0070     /// @note This may be what you want, even if the paper calls it "missing Et"!
0071     /// @{
0072 
0073     /// The vector-summed visible transverse momentum in the event, as a 3-vector with z=0
0074     ///
0075     /// @note Reverse this vector with operator- to get the missing pT vector.
0076     /// @todo Currently equivalent to vectorEt
0077     const Vector3& vectorPt() const { return vectorEt(); }
0078 
0079     /// @}
0080 
0081 
0082     /// @name Transverse energy functions
0083     ///
0084     /// @warning Despite the common names "MET" and "SET", what's often meant is the pT functions above!
0085     /// @{
0086 
0087     /// The vector-summed visible transverse energy in the event, as a 3-vector with z=0
0088     ///
0089     /// @note Reverse this vector with operator- to get the missing ET vector.
0090     const Vector3& vectorEt() const { return _vet; }
0091 
0092     /// @}
0093 
0094 
0095     /// Reset the projection. Smearing functions will be unchanged.
0096     void reset() {  }
0097 
0098 
0099   protected:
0100 
0101     Vector3 _vet;
0102 
0103     /// Stored smearing function
0104     std::function<Vector3(const Vector3&, double)> _metSmearFn;
0105 
0106   };
0107 
0108 
0109 }
0110 
0111 #endif