Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-05 09:39:06

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