Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:20:51

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4EIC_Jet_H
0004 #define EDM4EIC_Jet_H
0005 
0006 #include "edm4eic/JetObj.h"
0007 
0008 #include "edm4eic/ReconstructedParticle.h"
0009 #include "edm4hep/Vector3f.h"
0010 #include "podio/RelationRange.h"
0011 #include <cstdint>
0012 #include <vector>
0013 
0014 #include "podio/utilities/MaybeSharedPtr.h"
0015 #include "podio/detail/OrderKey.h"
0016 
0017 #include <ostream>
0018 #include <cstdint>
0019 
0020 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0021 #include "nlohmann/json_fwd.hpp"
0022 #endif
0023 
0024 // forward declarations
0025 namespace edm4eic {
0026 class JetCollection;
0027 }
0028 
0029 
0030 namespace podio::detail {
0031 // Internal function used in less comparison operators of the datatypes and interface types
0032 OrderKey getOrderKey(const edm4eic::Jet& obj);
0033 };
0034 
0035 namespace edm4eic {
0036 
0037 class MutableJet;
0038 class JetCollection;
0039 class JetCollectionData;
0040 
0041 /** @class Jet
0042  *  A reconstructed jet, inspired by the FastJet PseudoJet
0043  *  @author: D. Anderson
0044  */
0045 class Jet {
0046 
0047   friend class MutableJet;
0048   friend class JetCollection;
0049   friend class edm4eic::JetCollectionData;
0050   friend class JetCollectionIterator;
0051   friend podio::detail::OrderKey podio::detail::getOrderKey(const Jet & obj);
0052 
0053 public:
0054   using mutable_type = MutableJet;
0055   using collection_type = JetCollection;
0056 
0057   /// default constructor
0058   Jet() = default;
0059 
0060   /// Constructor initializing all members
0061   Jet(const std::uint32_t type, const float area, const float energy, const float backgroundEnergyDensity, const edm4hep::Vector3f& momentum);
0062 
0063   /// copy constructor
0064   Jet(const Jet& other) = default;
0065 
0066   /// copy-assignment operator
0067   Jet& operator=(Jet other) &; // Rebind this to other's internal object
0068   Jet& operator=(Jet other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0069 
0070   /// create a mutable deep-copy of the object with identical relations
0071   /// if cloneRelations=false, the relations are not cloned and will be empty
0072   MutableJet clone(bool cloneRelations=true) const;
0073 
0074   /// destructor
0075   ~Jet() = default;
0076 
0077   /// converting constructor from mutable object
0078   Jet(const MutableJet& other);
0079 
0080   static Jet makeEmpty();
0081 
0082 public:
0083 
0084   static constexpr std::string_view typeName = "edm4eic::Jet";
0085 
0086   /// Access the Jet type as enumerated in fastjet::JetAlgorithm
0087   std::uint32_t getType() const;
0088 
0089   /// Access the Jet area
0090   float getArea() const;
0091 
0092   /// Access the Jet energy [GeV]
0093   float getEnergy() const;
0094 
0095   /// Access the Background energy density [GeV/area]
0096   float getBackgroundEnergyDensity() const;
0097 
0098   /// Access the Jet 3-momentum [GeV]
0099   const edm4hep::Vector3f& getMomentum() const;
0100 
0101 
0102 
0103   std::size_t constituents_size() const;
0104   edm4eic::ReconstructedParticle getConstituents(std::size_t) const;
0105   std::vector<edm4eic::ReconstructedParticle>::const_iterator constituents_begin() const;
0106   std::vector<edm4eic::ReconstructedParticle>::const_iterator constituents_end() const;
0107   podio::RelationRange<edm4eic::ReconstructedParticle> getConstituents() const;
0108 
0109  /// Compute the background energy in [GeV]
0110  float getBackgroundEnergy() const { return getArea() * getBackgroundEnergyDensity(); }
0111  
0112 
0113   /// check whether the object is actually available
0114   bool isAvailable() const;
0115   /// disconnect from JetObj instance
0116   void unlink() { m_obj = podio::utils::MaybeSharedPtr<JetObj>{nullptr}; }
0117 
0118   bool operator==(const Jet& other) const { return m_obj == other.m_obj; }
0119   bool operator==(const MutableJet& other) const;
0120 
0121   bool operator!=(const Jet& other) const { return !(*this == other); }
0122   bool operator!=(const MutableJet& other) const { return !(*this == other); }
0123 
0124   // less comparison operator, so that objects can be e.g. stored in sets.
0125   bool operator<(const Jet& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0126 
0127   podio::ObjectID id() const { return getObjectID(); }
0128 
0129   const podio::ObjectID getObjectID() const;
0130 
0131   friend std::hash<Jet>;
0132 
0133   friend void swap(Jet& a, Jet& b) {
0134     using std::swap;
0135     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0136   }
0137 
0138 private:
0139   /// constructor from existing JetObj
0140   explicit Jet(podio::utils::MaybeSharedPtr<JetObj> obj);
0141   Jet(JetObj* obj);
0142 
0143   podio::utils::MaybeSharedPtr<JetObj> m_obj{new JetObj{}, podio::utils::MarkOwned};
0144 };
0145 
0146 std::ostream& operator<<(std::ostream& o, const Jet& value);
0147 
0148 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0149 void to_json(nlohmann::json& j, const Jet& value);
0150 #endif
0151 
0152 
0153 } // namespace edm4eic
0154 
0155 
0156 
0157 template<>
0158 struct std::hash<edm4eic::Jet> {
0159   std::size_t operator()(const edm4eic::Jet& obj) const {
0160     return std::hash<edm4eic::JetObj*>{}(obj.m_obj.get());
0161   }
0162 };
0163 
0164 
0165 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0166 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0167 // and https://github.com/AIDASoft/podio/issues/770
0168 #if defined(__clang__)
0169   #pragma clang diagnostic push
0170   #pragma clang diagnostic ignored "-Wunknown-warning-option"
0171   #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0172   #pragma clang diagnostic ignored "-Wdeprecated"
0173 constexpr std::string_view edm4eic::Jet::typeName;
0174   #pragma clang diagnostic pop
0175 #elif defined(__GNUC__)
0176   #pragma GCC diagnostic push
0177   #pragma GCC diagnostic ignored "-Wdeprecated"
0178 constexpr std::string_view edm4eic::Jet::typeName;
0179   #pragma GCC diagnostic pop
0180 #endif
0181 
0182 
0183 #endif