Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-24 10:16:52

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_MutableCluster_H
0004 #define EDM4HEP_MutableCluster_H
0005 
0006 #include "edm4hep/ClusterObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "edm4hep/Cluster.h"
0009 
0010 #include "edm4hep/CalorimeterHit.h"
0011 #include "edm4hep/CovMatrix3f.h"
0012 #include "edm4hep/Vector3f.h"
0013 #include "podio/RelationRange.h"
0014 #include <cstdint>
0015 #include <edm4hep/Constants.h>
0016 #include <vector>
0017 
0018 #include "podio/utilities/MaybeSharedPtr.h"
0019 
0020 #include <cstdint>
0021 
0022 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0023 #include "nlohmann/json_fwd.hpp"
0024 #endif
0025 
0026 // forward declarations
0027 namespace edm4hep {
0028 class ClusterCollection;
0029 }
0030 
0031 namespace edm4hep {
0032 
0033 /** @class MutableCluster
0034  *  Calorimeter Hit Cluster
0035  *  @author: EDM4hep authors
0036  */
0037 class MutableCluster {
0038 
0039   friend class ClusterCollection;
0040   friend class ClusterMutableCollectionIterator;
0041   friend class Cluster;
0042 
0043 public:
0044   using object_type = Cluster;
0045   using collection_type = ClusterCollection;
0046 
0047   /// default constructor
0048   MutableCluster() = default;
0049 
0050   /// Constructor initializing all members
0051   MutableCluster(const std::int32_t type, const float energy, const float energyError,
0052                  const edm4hep::Vector3f& position, const edm4hep::CovMatrix3f& positionError, const float iTheta,
0053                  const float iPhi, const edm4hep::Vector3f& directionError);
0054 
0055   /// copy constructor
0056   MutableCluster(const MutableCluster& other) noexcept = default;
0057 
0058   /// move constructor
0059   MutableCluster(MutableCluster&& other) noexcept = default;
0060 
0061   /// copy-assignment operator
0062   MutableCluster& operator=(MutableCluster other) &; // Rebind this to other's internal object
0063   MutableCluster&
0064   operator=(MutableCluster other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0065 
0066   /// create a mutable deep-copy of the object with identical relations
0067   /// if cloneRelations=false, the relations are not cloned and will be empty
0068   MutableCluster clone(bool cloneRelations = true) const;
0069 
0070   /// destructor
0071   ~MutableCluster() = default;
0072 
0073 public:
0074   /// Access the flagword that defines the type of cluster
0075   std::int32_t getType() const;
0076 
0077   /// Access the energy of the cluster [GeV]
0078   float getEnergy() const;
0079 
0080   /// Access the error on the energy [GeV]
0081   float getEnergyError() const;
0082 
0083   /// Access the position of the cluster [mm]
0084   const edm4hep::Vector3f& getPosition() const;
0085 
0086   /// Access the covariance matrix of the position [mm^2]
0087   const edm4hep::CovMatrix3f& getPositionError() const;
0088 
0089   /// Access the Polar angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be confused with the
0090   /// cluster position seen from IP [rad]
0091   float getITheta() const;
0092 
0093   /// Access the Azimuthal angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be confused with
0094   /// the cluster position seen from IP [rad]
0095   float getIPhi() const;
0096 
0097   /// Access the covariance matrix of the direction [rad^2]
0098   const edm4hep::Vector3f& getDirectionError() const;
0099 
0100   /// Set the flagword that defines the type of cluster
0101   void setType(const std::int32_t type);
0102   /// Get mutable reference to flagword that defines the type of cluster
0103   std::int32_t& getType();
0104 
0105   /// Set the energy of the cluster [GeV]
0106   void setEnergy(const float energy);
0107   /// Get mutable reference to energy of the cluster [GeV]
0108   float& getEnergy();
0109 
0110   /// Set the error on the energy [GeV]
0111   void setEnergyError(const float energyError);
0112   /// Get mutable reference to error on the energy [GeV]
0113   float& getEnergyError();
0114 
0115   /// Set the position of the cluster [mm]
0116   void setPosition(const edm4hep::Vector3f& position);
0117   /// Get mutable reference to position of the cluster [mm]
0118   edm4hep::Vector3f& getPosition();
0119 
0120   /// Set the covariance matrix of the position [mm^2]
0121   void setPositionError(const edm4hep::CovMatrix3f& positionError);
0122   /// Get mutable reference to covariance matrix of the position [mm^2]
0123   edm4hep::CovMatrix3f& getPositionError();
0124 
0125   /// Set the Polar angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be confused with the
0126   /// cluster position seen from IP [rad]
0127   void setITheta(const float iTheta);
0128   /// Get mutable reference to Polar angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be
0129   /// confused with the cluster position seen from IP [rad]
0130   float& getITheta();
0131 
0132   /// Set the Azimuthal angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be confused with
0133   /// the cluster position seen from IP [rad]
0134   void setIPhi(const float iPhi);
0135   /// Get mutable reference to Azimuthal angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be
0136   /// confused with the cluster position seen from IP [rad]
0137   float& getIPhi();
0138 
0139   /// Set the covariance matrix of the direction [rad^2]
0140   void setDirectionError(const edm4hep::Vector3f& directionError);
0141   /// Get mutable reference to covariance matrix of the direction [rad^2]
0142   edm4hep::Vector3f& getDirectionError();
0143 
0144   void addToClusters(const edm4hep::Cluster&);
0145   std::size_t clusters_size() const;
0146   edm4hep::Cluster getClusters(std::size_t) const;
0147   std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0148   std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0149   podio::RelationRange<edm4hep::Cluster> getClusters() const;
0150   void addToHits(const edm4hep::CalorimeterHit&);
0151   std::size_t hits_size() const;
0152   edm4hep::CalorimeterHit getHits(std::size_t) const;
0153   std::vector<edm4hep::CalorimeterHit>::const_iterator hits_begin() const;
0154   std::vector<edm4hep::CalorimeterHit>::const_iterator hits_end() const;
0155   podio::RelationRange<edm4hep::CalorimeterHit> getHits() const;
0156   void addToShapeParameters(const float&);
0157   std::size_t shapeParameters_size() const;
0158   float getShapeParameters(std::size_t) const;
0159   std::vector<float>::const_iterator shapeParameters_begin() const;
0160   std::vector<float>::const_iterator shapeParameters_end() const;
0161   podio::RelationRange<float> getShapeParameters() const;
0162   void addToSubdetectorEnergies(const float&);
0163   std::size_t subdetectorEnergies_size() const;
0164   float getSubdetectorEnergies(std::size_t) const;
0165   std::vector<float>::const_iterator subdetectorEnergies_begin() const;
0166   std::vector<float>::const_iterator subdetectorEnergies_end() const;
0167   podio::RelationRange<float> getSubdetectorEnergies() const;
0168 
0169   /// Get the position error value for the two passed dimensions
0170   float getPositionError(edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) const {
0171     return getPositionError().getValue(dimI, dimJ);
0172   }
0173   /// Get the Azimuthal angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be confused with
0174   /// the cluster position seen from IP
0175   [[deprecated("Use getIPhi instead")]] float getPhi() const { return getIPhi(); }
0176 
0177   /// Set the position error value for the two passed dimensions
0178   void setPositionError(float value, edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) {
0179     return getPositionError().setValue(value, dimI, dimJ);
0180   }
0181   /// Set the Azimuthal angle of the cluster's intrinsic direction (used e.g. for vertexing). Not to be confused with
0182   /// the cluster position seen from IP
0183   [[deprecated("Use setIPhi instead")]] void setPhi(float value) { setIPhi(value); }
0184 
0185   /// check whether the object is actually available
0186   bool isAvailable() const;
0187   /// disconnect from ClusterObj instance
0188   void unlink() { m_obj = podio::utils::MaybeSharedPtr<ClusterObj>{nullptr}; }
0189 
0190   constexpr bool operator==(const MutableCluster& other) const { return m_obj == other.m_obj; }
0191   bool operator==(const Cluster& other) const;
0192 
0193   constexpr bool operator!=(const MutableCluster& other) const { return !(*this == other); }
0194   bool operator!=(const Cluster& other) const { return !(*this == other); }
0195 
0196   // less comparison operator, so that objects can be e.g. stored in sets.
0197   bool operator<(const MutableCluster& other) const {
0198     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0199   }
0200 
0201   podio::ObjectID id() const { return getObjectID(); }
0202 
0203   const podio::ObjectID getObjectID() const;
0204 
0205   friend std::hash<MutableCluster>;
0206 
0207   friend void swap(MutableCluster& a, MutableCluster& b) {
0208     using std::swap;
0209     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0210   }
0211 
0212 private:
0213   /// constructor from existing ClusterObj
0214   explicit MutableCluster(podio::utils::MaybeSharedPtr<ClusterObj> obj);
0215 
0216   podio::utils::MaybeSharedPtr<ClusterObj> m_obj{new ClusterObj{}, podio::utils::MarkOwned};
0217 };
0218 
0219 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0220 void to_json(nlohmann::json& j, const MutableCluster& value);
0221 #endif
0222 
0223 } // namespace edm4hep
0224 
0225 template <>
0226 struct std::hash<edm4hep::MutableCluster> {
0227   std::size_t operator()(const edm4hep::MutableCluster& obj) const {
0228     return std::hash<edm4hep::ClusterObj*>{}(obj.m_obj.get());
0229   }
0230 };
0231 
0232 #endif