Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-23 09:45:13

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_MutableParticleID_H
0004 #define EDM4HEP_MutableParticleID_H
0005 
0006 #include "edm4hep/ParticleIDObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "edm4hep/ParticleID.h"
0009 
0010 #include "podio/RelationRange.h"
0011 #include <cstdint>
0012 #include <vector>
0013 
0014 #include "podio/utilities/MaybeSharedPtr.h"
0015 
0016 #include <cstdint>
0017 
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021 
0022 // forward declarations
0023 namespace edm4hep {
0024 class ParticleIDCollection;
0025 class ReconstructedParticle;
0026 class MutableReconstructedParticle;
0027 } // namespace edm4hep
0028 
0029 namespace edm4hep {
0030 
0031 /** @class MutableParticleID
0032  *  ParticleID
0033  *  @author: EDM4hep authors
0034  */
0035 class MutableParticleID {
0036 
0037   friend class ParticleIDCollection;
0038   friend class ParticleIDMutableCollectionIterator;
0039   friend class ParticleID;
0040 
0041 public:
0042   using object_type = ParticleID;
0043   using collection_type = ParticleIDCollection;
0044 
0045   /// default constructor
0046   MutableParticleID() = default;
0047 
0048   /// Constructor initializing all members
0049   MutableParticleID(const std::int32_t type, const std::int32_t PDG, const std::int32_t algorithmType,
0050                     const float likelihood);
0051 
0052   /// copy constructor
0053   MutableParticleID(const MutableParticleID& other) = default;
0054 
0055   /// copy-assignment operator
0056   MutableParticleID& operator=(MutableParticleID other) &; // Rebind this to other's internal object
0057   MutableParticleID&
0058   operator=(MutableParticleID 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   MutableParticleID clone(bool cloneRelations = true) const;
0063 
0064   /// destructor
0065   ~MutableParticleID() = default;
0066 
0067 public:
0068   /// Access the userdefined type
0069   std::int32_t getType() const;
0070 
0071   /// Access the PDG code of this id - ( 999999 ) if unknown
0072   std::int32_t getPDG() const;
0073 
0074   /// Access the type of the algorithm/module that created this hypothesis
0075   std::int32_t getAlgorithmType() const;
0076 
0077   /// Access the likelihood of this hypothesis - in a user defined normalization
0078   float getLikelihood() const;
0079 
0080   /// Access the the particle from which this PID has been computed
0081   const edm4hep::ReconstructedParticle getParticle() const;
0082 
0083   /// Set the userdefined type
0084   void setType(const std::int32_t type);
0085   /// Get mutable reference to userdefined type
0086   std::int32_t& getType();
0087   /// Get reference to userdefined type
0088   [[deprecated("use getType instead")]] std::int32_t& type();
0089 
0090   /// Set the PDG code of this id - ( 999999 ) if unknown
0091   void setPDG(const std::int32_t PDG);
0092   /// Get mutable reference to PDG code of this id - ( 999999 ) if unknown
0093   std::int32_t& getPDG();
0094   /// Get reference to PDG code of this id - ( 999999 ) if unknown
0095   [[deprecated("use getPDG instead")]] std::int32_t& PDG();
0096 
0097   /// Set the type of the algorithm/module that created this hypothesis
0098   void setAlgorithmType(const std::int32_t algorithmType);
0099   /// Get mutable reference to type of the algorithm/module that created this hypothesis
0100   std::int32_t& getAlgorithmType();
0101   /// Get reference to type of the algorithm/module that created this hypothesis
0102   [[deprecated("use getAlgorithmType instead")]] std::int32_t& algorithmType();
0103 
0104   /// Set the likelihood of this hypothesis - in a user defined normalization
0105   void setLikelihood(const float likelihood);
0106   /// Get mutable reference to likelihood of this hypothesis - in a user defined normalization
0107   float& getLikelihood();
0108   /// Get reference to likelihood of this hypothesis - in a user defined normalization
0109   [[deprecated("use getLikelihood instead")]] float& likelihood();
0110 
0111   /// Set the the particle from which this PID has been computed
0112   void setParticle(const edm4hep::ReconstructedParticle& value);
0113 
0114   void addToParameters(const float&);
0115   std::size_t parameters_size() const;
0116   float getParameters(std::size_t) const;
0117   std::vector<float>::const_iterator parameters_begin() const;
0118   std::vector<float>::const_iterator parameters_end() const;
0119   podio::RelationRange<float> getParameters() const;
0120 
0121   /// check whether the object is actually available
0122   bool isAvailable() const;
0123   /// disconnect from ParticleIDObj instance
0124   void unlink() { m_obj = podio::utils::MaybeSharedPtr<ParticleIDObj>{nullptr}; }
0125 
0126   bool operator==(const MutableParticleID& other) const { return m_obj == other.m_obj; }
0127   bool operator==(const ParticleID& other) const;
0128 
0129   bool operator!=(const MutableParticleID& other) const { return !(*this == other); }
0130   bool operator!=(const ParticleID& other) const { return !(*this == other); }
0131 
0132   // less comparison operator, so that objects can be e.g. stored in sets.
0133   bool operator<(const MutableParticleID& other) const {
0134     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0135   }
0136 
0137   podio::ObjectID id() const { return getObjectID(); }
0138 
0139   const podio::ObjectID getObjectID() const;
0140 
0141   friend std::hash<MutableParticleID>;
0142 
0143   friend void swap(MutableParticleID& a, MutableParticleID& b) {
0144     using std::swap;
0145     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0146   }
0147 
0148 private:
0149   /// constructor from existing ParticleIDObj
0150   explicit MutableParticleID(podio::utils::MaybeSharedPtr<ParticleIDObj> obj);
0151 
0152   podio::utils::MaybeSharedPtr<ParticleIDObj> m_obj{new ParticleIDObj{}, podio::utils::MarkOwned};
0153 };
0154 
0155 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0156 void to_json(nlohmann::json& j, const MutableParticleID& value);
0157 #endif
0158 
0159 } // namespace edm4hep
0160 
0161 template <>
0162 struct std::hash<edm4hep::MutableParticleID> {
0163   std::size_t operator()(const edm4hep::MutableParticleID& obj) const {
0164     return std::hash<edm4hep::ParticleIDObj*>{}(obj.m_obj.get());
0165   }
0166 };
0167 
0168 #endif