Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 #ifndef RIVET_JetFinder_HH
0003 #define RIVET_JetFinder_HH
0004 
0005 #include "Rivet/Projection.hh"
0006 #include "Rivet/Projections/FinalState.hh"
0007 #include "Rivet/Projections/VisibleFinalState.hh"
0008 #include "Rivet/Particle.hh"
0009 #include "Rivet/Jet.hh"
0010 
0011 namespace Rivet {
0012 
0013 
0014   /// Enum for the treatment of muons: whether to include all, some, or none in jet-finding
0015   enum class JetMuons { NONE, DECAY, ALL };
0016 
0017   /// Enum for the treatment of invisible particles: whether to include all, some, or none in jet-finding
0018   enum class JetInvisibles { NONE, DECAY, ALL };
0019 
0020 
0021 
0022   /// Abstract base class for projections which can return a set of {@link Jet}s.
0023   class JetFinder : public Projection {
0024   public:
0025 
0026     /// Constructor
0027     JetFinder(const FinalState& fs,
0028           JetMuons usemuons = JetMuons::ALL,
0029           JetInvisibles useinvis = JetInvisibles::NONE);
0030 
0031     /// Default constructor
0032     JetFinder() = default;
0033 
0034     /// Clone on the heap.
0035     virtual unique_ptr<Projection> clone() const = 0;
0036 
0037     /// Destructor
0038     virtual ~JetFinder() = default;
0039 
0040     /// Import to avoid warnings about overload-hiding
0041     using Projection::operator =;
0042 
0043 
0044     /// @name Control the treatment of muons and invisible particles
0045     ///
0046     /// Since MC-based jet calibration (and/or particle flow) can add back in
0047     /// particles that weren't seen in calorimeters/trackers.
0048     /// @{
0049 
0050     /// @brief Include (some) muons in jet construction.
0051     ///
0052     /// The default behaviour is that jets are only constructed from visible
0053     /// particles. Some jet studies, including those from ATLAS, use a definition
0054     /// in which neutrinos from hadron decays are included via MC-based calibrations.
0055     /// Setting this flag to true avoids the automatic restriction to a VisibleFinalState.
0056     void useMuons(JetMuons usemuons = JetMuons::ALL) {
0057       _useMuons = usemuons;
0058     }
0059 
0060     /// @brief Include (some) invisible particles in jet construction.
0061     ///
0062     /// The default behaviour is that jets are only constructed from visible
0063     /// particles. Some jet studies, including those from ATLAS, use a definition
0064     /// in which neutrinos from hadron decays are included via MC-based calibrations.
0065     /// Setting this flag to true avoids the automatic restriction to a VisibleFinalState.
0066     void useInvisibles(JetInvisibles useinvis = JetInvisibles::DECAY) {
0067       _useInvisibles = useinvis;
0068     }
0069 
0070     /// @}
0071 
0072 
0073     /// @name Access to jet objects
0074     /// @{
0075 
0076     /// Get jets in no guaranteed order, with an optional Cut
0077     /// @note Returns a copy rather than a reference, due to cuts
0078     virtual Jets jets(const Cut& c=Cuts::open()) const {
0079       return select(_jets(), c);
0080     }
0081 
0082     /// Get jets in no guaranteed order, with a selection functor
0083     /// @note Returns a copy rather than a reference, due to cuts
0084     virtual Jets jets(const JetSelector& selector) const {
0085       return select(_jets(), selector);
0086     }
0087 
0088 
0089     /// Get the jets with a Cut applied, and ordered by supplied sorting functor
0090     /// @note Returns a copy rather than a reference, due to cuts and sorting
0091     Jets jets(const Cut& c, const JetSorter& sorter) const {
0092       /// @todo Will the vector be efficiently std::move'd by value through this function chain?
0093       return sortBy(jets(c), sorter);
0094     }
0095 
0096     /// Get the jets, ordered by supplied sorting functor, with an optional Cut
0097     /// @note Returns a copy rather than a reference, due to cuts and sorting
0098     Jets jets(const JetSorter& sorter, const Cut& c=Cuts::open()) const {
0099       /// @todo Will the vector be efficiently std::move'd by value through this function chain?
0100       return jets(c, sorter);
0101     }
0102 
0103     /// Get the jets, ordered by supplied sorting function object, with optional cuts on \f$ p_\perp \f$ and rapidity.
0104     /// @note Returns a copy rather than a reference, due to cuts and sorting
0105     Jets jets(const JetSelector& selector, const JetSorter& sorter) const {
0106       /// @todo Will the vector be efficiently std::move'd by value through this function chain?
0107       return sortBy(jets(selector), sorter);
0108     }
0109 
0110     /// Get the jets, ordered by supplied sorting functor and with a selection functor applied
0111     /// @note Returns a copy rather than a reference, due to cuts and sorting
0112     Jets jets(const JetSorter& sorter, const JetSelector selector) const {
0113       return jets(selector, sorter);
0114     }
0115 
0116 
0117     /// Get the jets, ordered by \f$ p_T \f$, with optional cuts.
0118     ///
0119     /// @note Returns a copy rather than a reference, due to cuts and sorting
0120     ///
0121     /// This is a very common use-case, so is available as syntatic sugar for jets(c, cmpMomByPt).
0122     Jets jetsByPt(const Cut& c=Cuts::open()) const {
0123       return jets(c, cmpMomByPt);
0124     }
0125 
0126     /// Get the jets, ordered by \f$ p_T \f$, with cuts via a selection functor.
0127     ///
0128     /// @note Returns a copy rather than a reference, due to cuts and sorting
0129     ///
0130     /// This is a very common use-case, so is available as syntatic sugar for jets(c, cmpMomByPt).
0131     Jets jetsByPt(const JetSelector& selector) const {
0132       return jets(selector, cmpMomByPt);
0133     }
0134 
0135     /// @}
0136 
0137 
0138   protected:
0139 
0140     /// @brief Internal pure virtual method for getting jets in no guaranteed order.
0141     virtual Jets _jets() const = 0;
0142 
0143 
0144   public:
0145 
0146     /// Count the jets
0147     size_t size() const { return jets().size(); }
0148     /// Count the jets after a Cut is applied.
0149     size_t size(const Cut& c) const { return jets(c).size(); }
0150     /// Count the jets after a selection functor is applied.
0151     size_t size(const JetSelector& s) const { return jets(s).size(); }
0152 
0153     /// Is this jet finder empty?
0154     bool empty() const { return size() == 0; }
0155     /// Is this jet finder empty after a Cut is applied?
0156     bool empty(const Cut& c) const { return size(c) == 0; }
0157     /// Is this jet finder empty after a selection functor is applied?
0158     bool empty(const JetSelector& s) const { return size(s) == 0; }
0159 
0160     /// Clear the projection.
0161     virtual void reset() = 0;
0162 
0163     typedef Jet entity_type;
0164     typedef Jets collection_type;
0165 
0166     /// Template-usable interface common to FinalState.
0167     collection_type entities() const { return jets(); }
0168 
0169     // /// Do the calculation locally (no caching).
0170     // virtual void calc(const Particles& constituents, const Particles& tagparticles=Particles()) = 0;
0171 
0172 
0173   protected:
0174 
0175     /// Perform the projection on the Event.
0176     virtual void project(const Event& e) = 0;
0177 
0178     /// Compare projections.
0179     virtual CmpState compare(const Projection& p) const = 0;
0180 
0181 
0182   protected:
0183 
0184     /// Flag to determine whether or not to exclude (some) muons from the would-be constituents.
0185     JetMuons _useMuons;
0186 
0187     /// Flag to determine whether or not to exclude (some) invisible particles from the would-be constituents.
0188     JetInvisibles _useInvisibles;
0189 
0190 
0191   };
0192 
0193 
0194 }
0195 
0196 #endif