Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:53:32

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 }
0028 
0029 
0030 namespace edm4hep {
0031 
0032 
0033 /** @class MutableParticleID
0034  *  ParticleID
0035  *  @author: EDM4hep authors
0036  */
0037 class MutableParticleID {
0038 
0039   friend class ParticleIDCollection;
0040   friend class ParticleIDMutableCollectionIterator;
0041   friend class ParticleID;
0042 
0043 public:
0044   using object_type = ParticleID;
0045   using collection_type = ParticleIDCollection;
0046 
0047   /// default constructor
0048   MutableParticleID();
0049 
0050   /// Constructor initializing all members
0051   MutableParticleID(const std::int32_t type, const std::int32_t PDG, const std::int32_t algorithmType, const float likelihood);
0052 
0053   /// copy constructor
0054   MutableParticleID(const MutableParticleID& other) = default;
0055 
0056   /// copy-assignment operator
0057   MutableParticleID& operator=(MutableParticleID other) &; // Rebind this to other's internal object
0058   MutableParticleID& 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 
0068 public:
0069 
0070   /// Access the userdefined type
0071   std::int32_t getType() const;
0072 
0073   /// Access the PDG code of this id - ( 999999 ) if unknown
0074   std::int32_t getPDG() const;
0075 
0076   /// Access the type of the algorithm/module that created this hypothesis
0077   std::int32_t getAlgorithmType() const;
0078 
0079   /// Access the likelihood of this hypothesis - in a user defined normalization
0080   float getLikelihood() const;
0081 
0082 
0083   /// Access the the particle from which this PID has been computed
0084   const edm4hep::ReconstructedParticle getParticle() const;
0085 
0086   /// Set the userdefined type
0087   void setType(const std::int32_t type);
0088   /// Get mutable reference to userdefined type
0089   std::int32_t& getType();
0090   /// Get reference to userdefined type
0091   [[deprecated("use getType instead")]]
0092   std::int32_t& type();
0093 
0094   /// Set the PDG code of this id - ( 999999 ) if unknown
0095   void setPDG(const std::int32_t PDG);
0096   /// Get mutable reference to PDG code of this id - ( 999999 ) if unknown
0097   std::int32_t& getPDG();
0098   /// Get reference to PDG code of this id - ( 999999 ) if unknown
0099   [[deprecated("use getPDG instead")]]
0100   std::int32_t& PDG();
0101 
0102   /// Set the type of the algorithm/module that created this hypothesis
0103   void setAlgorithmType(const std::int32_t algorithmType);
0104   /// Get mutable reference to type of the algorithm/module that created this hypothesis
0105   std::int32_t& getAlgorithmType();
0106   /// Get reference to type of the algorithm/module that created this hypothesis
0107   [[deprecated("use getAlgorithmType instead")]]
0108   std::int32_t& algorithmType();
0109 
0110   /// Set the likelihood of this hypothesis - in a user defined normalization
0111   void setLikelihood(const float likelihood);
0112   /// Get mutable reference to likelihood of this hypothesis - in a user defined normalization
0113   float& getLikelihood();
0114   /// Get reference to likelihood of this hypothesis - in a user defined normalization
0115   [[deprecated("use getLikelihood instead")]]
0116   float& likelihood();
0117 
0118 
0119   /// Set the the particle from which this PID has been computed
0120   void setParticle(const edm4hep::ReconstructedParticle& value);
0121 
0122   void addToParameters(const float&);
0123   std::size_t parameters_size() const;
0124   float getParameters(std::size_t) const;
0125   std::vector<float>::const_iterator parameters_begin() const;
0126   std::vector<float>::const_iterator parameters_end() const;
0127   podio::RelationRange<float> getParameters() const;
0128 
0129 
0130 
0131   /// check whether the object is actually available
0132   bool isAvailable() const;
0133   /// disconnect from ParticleIDObj instance
0134   void unlink() { m_obj = podio::utils::MaybeSharedPtr<ParticleIDObj>{nullptr}; }
0135 
0136   bool operator==(const MutableParticleID& other) const { return m_obj == other.m_obj; }
0137   bool operator==(const ParticleID& other) const;
0138 
0139   bool operator!=(const MutableParticleID& other) const { return !(*this == other); }
0140   bool operator!=(const ParticleID& other) const { return !(*this == other); }
0141 
0142   // less comparison operator, so that objects can be e.g. stored in sets.
0143   bool operator<(const MutableParticleID& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0144 
0145   podio::ObjectID id() const { return getObjectID(); }
0146 
0147   const podio::ObjectID getObjectID() const;
0148 
0149   friend std::hash<MutableParticleID>;
0150 
0151   friend void swap(MutableParticleID& a, MutableParticleID& b) {
0152     using std::swap;
0153     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0154   }
0155 
0156 private:
0157   /// constructor from existing ParticleIDObj
0158   explicit MutableParticleID(podio::utils::MaybeSharedPtr<ParticleIDObj> obj);
0159 
0160   podio::utils::MaybeSharedPtr<ParticleIDObj> m_obj{nullptr};
0161 };
0162 
0163 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0164 void to_json(nlohmann::json& j, const MutableParticleID& value);
0165 #endif
0166 
0167 
0168 } // namespace edm4hep
0169 
0170 
0171 
0172 template<>
0173 struct std::hash<edm4hep::MutableParticleID> {
0174   std::size_t operator()(const edm4hep::MutableParticleID& obj) const {
0175     return std::hash<edm4hep::ParticleIDObj*>{}(obj.m_obj.get());
0176   }
0177 };
0178 
0179 
0180 #endif