Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4EIC_MutableJet_H
0004 #define EDM4EIC_MutableJet_H
0005 
0006 #include "edm4eic/JetObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "edm4eic/Jet.h"
0009 
0010 #include "edm4eic/ReconstructedParticle.h"
0011 #include "edm4hep/Vector3f.h"
0012 #include "podio/RelationRange.h"
0013 #include <cstdint>
0014 #include <vector>
0015 
0016 #include "podio/utilities/MaybeSharedPtr.h"
0017 
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 edm4eic {
0031 
0032 
0033 /** @class MutableJet
0034  *  A reconstructed jet, inspired by the FastJet PseudoJet
0035  *  @author: D. Anderson
0036  */
0037 class MutableJet {
0038 
0039   friend class JetCollection;
0040   friend class JetMutableCollectionIterator;
0041   friend class Jet;
0042 
0043 public:
0044   using object_type = Jet;
0045   using collection_type = JetCollection;
0046 
0047   /// default constructor
0048   MutableJet() = default;
0049 
0050   /// Constructor initializing all members
0051   MutableJet(const std::uint32_t type, const float area, const float energy, const float backgroundEnergyDensity, const edm4hep::Vector3f& momentum);
0052 
0053   /// copy constructor
0054   MutableJet(const MutableJet& other) = default;
0055 
0056   /// copy-assignment operator
0057   MutableJet& operator=(MutableJet other) &; // Rebind this to other's internal object
0058   MutableJet& operator=(MutableJet other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0059 
0060   /// create a mutable deep-copy of the object with identical relations
0061   /// if cloneRelations=false, the relations are not cloned and will be empty
0062   MutableJet clone(bool cloneRelations=true) const;
0063 
0064   /// destructor
0065   ~MutableJet() = default;
0066 
0067 
0068 public:
0069 
0070   /// Access the Jet type as enumerated in fastjet::JetAlgorithm
0071   std::uint32_t getType() const;
0072 
0073   /// Access the Jet area
0074   float getArea() const;
0075 
0076   /// Access the Jet energy [GeV]
0077   float getEnergy() const;
0078 
0079   /// Access the Background energy density [GeV/area]
0080   float getBackgroundEnergyDensity() const;
0081 
0082   /// Access the Jet 3-momentum [GeV]
0083   const edm4hep::Vector3f& getMomentum() const;
0084 
0085 
0086 
0087   /// Set the Jet type as enumerated in fastjet::JetAlgorithm
0088   void setType(const std::uint32_t type);
0089   /// Get mutable reference to Jet type as enumerated in fastjet::JetAlgorithm
0090   std::uint32_t& getType();
0091   /// Get reference to Jet type as enumerated in fastjet::JetAlgorithm
0092   [[deprecated("use getType instead")]]
0093   std::uint32_t& type();
0094 
0095   /// Set the Jet area
0096   void setArea(const float area);
0097   /// Get mutable reference to Jet area
0098   float& getArea();
0099   /// Get reference to Jet area
0100   [[deprecated("use getArea instead")]]
0101   float& area();
0102 
0103   /// Set the Jet energy [GeV]
0104   void setEnergy(const float energy);
0105   /// Get mutable reference to Jet energy [GeV]
0106   float& getEnergy();
0107   /// Get reference to Jet energy [GeV]
0108   [[deprecated("use getEnergy instead")]]
0109   float& energy();
0110 
0111   /// Set the Background energy density [GeV/area]
0112   void setBackgroundEnergyDensity(const float backgroundEnergyDensity);
0113   /// Get mutable reference to Background energy density [GeV/area]
0114   float& getBackgroundEnergyDensity();
0115   /// Get reference to Background energy density [GeV/area]
0116   [[deprecated("use getBackgroundEnergyDensity instead")]]
0117   float& backgroundEnergyDensity();
0118 
0119   /// Set the Jet 3-momentum [GeV]
0120   void setMomentum(const edm4hep::Vector3f& momentum);
0121   /// Get mutable reference to Jet 3-momentum [GeV]
0122   edm4hep::Vector3f& getMomentum();
0123   /// Get reference to Jet 3-momentum [GeV]
0124   [[deprecated("use getMomentum instead")]]
0125   edm4hep::Vector3f& momentum();
0126 
0127 
0128 
0129   void addToConstituents(const edm4eic::ReconstructedParticle&);
0130   std::size_t constituents_size() const;
0131   edm4eic::ReconstructedParticle getConstituents(std::size_t) const;
0132   std::vector<edm4eic::ReconstructedParticle>::const_iterator constituents_begin() const;
0133   std::vector<edm4eic::ReconstructedParticle>::const_iterator constituents_end() const;
0134   podio::RelationRange<edm4eic::ReconstructedParticle> getConstituents() const;
0135 
0136  /// Compute the background energy in [GeV]
0137  float getBackgroundEnergy() const { return getArea() * getBackgroundEnergyDensity(); }
0138  
0139 
0140 
0141   /// check whether the object is actually available
0142   bool isAvailable() const;
0143   /// disconnect from JetObj instance
0144   void unlink() { m_obj = podio::utils::MaybeSharedPtr<JetObj>{nullptr}; }
0145 
0146   bool operator==(const MutableJet& other) const { return m_obj == other.m_obj; }
0147   bool operator==(const Jet& other) const;
0148 
0149   bool operator!=(const MutableJet& other) const { return !(*this == other); }
0150   bool operator!=(const Jet& other) const { return !(*this == other); }
0151 
0152   // less comparison operator, so that objects can be e.g. stored in sets.
0153   bool operator<(const MutableJet& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0154 
0155   podio::ObjectID id() const { return getObjectID(); }
0156 
0157   const podio::ObjectID getObjectID() const;
0158 
0159   friend std::hash<MutableJet>;
0160 
0161   friend void swap(MutableJet& a, MutableJet& b) {
0162     using std::swap;
0163     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0164   }
0165 
0166 private:
0167   /// constructor from existing JetObj
0168   explicit MutableJet(podio::utils::MaybeSharedPtr<JetObj> obj);
0169 
0170   podio::utils::MaybeSharedPtr<JetObj> m_obj{new JetObj{}, podio::utils::MarkOwned};
0171 };
0172 
0173 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0174 void to_json(nlohmann::json& j, const MutableJet& value);
0175 #endif
0176 
0177 
0178 } // namespace edm4eic
0179 
0180 
0181 
0182 template<>
0183 struct std::hash<edm4eic::MutableJet> {
0184   std::size_t operator()(const edm4eic::MutableJet& obj) const {
0185     return std::hash<edm4eic::JetObj*>{}(obj.m_obj.get());
0186   }
0187 };
0188 
0189 
0190 #endif