Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 10:20:46

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef JANA2_TUTORIAL_PODIO_DATAMODEL_MutableSimParticle_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_MutableSimParticle_H
0005 
0006 #include "jana2_tutorial_podio_datamodel/SimParticleObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "jana2_tutorial_podio_datamodel/SimParticle.h"
0009 
0010 #include <cstdint>
0011 
0012 #include "podio/utilities/MaybeSharedPtr.h"
0013 
0014 #include <cstdint>
0015 
0016 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0017 #include "nlohmann/json_fwd.hpp"
0018 #endif
0019 
0020 // forward declarations
0021 class SimParticleCollection;
0022 
0023 
0024 
0025 
0026 /** @class MutableSimParticle
0027  *  A 'truth' particle, used by a Monte Carlo simulation
0028  *  @author: N. Brei
0029  */
0030 class MutableSimParticle {
0031 
0032   friend class SimParticleCollection;
0033   friend class SimParticleMutableCollectionIterator;
0034   friend class SimParticle;
0035 
0036 public:
0037   using object_type = SimParticle;
0038   using collection_type = SimParticleCollection;
0039 
0040   /// default constructor
0041   MutableSimParticle() = default;
0042 
0043   /// Constructor initializing all members
0044   MutableSimParticle(const double momentum_z, const double momentum_theta, const double momentum_phi, const double energy, const std::uint32_t pdg);
0045 
0046   /// copy constructor
0047   MutableSimParticle(const MutableSimParticle& other) = default;
0048 
0049   /// copy-assignment operator
0050   MutableSimParticle& operator=(MutableSimParticle other) &; // Rebind this to other's internal object
0051   MutableSimParticle& operator=(MutableSimParticle other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0052 
0053   /// create a mutable deep-copy of the object with identical relations
0054   /// if cloneRelations=false, the relations are not cloned and will be empty
0055   MutableSimParticle clone(bool cloneRelations=true) const;
0056 
0057   /// destructor
0058   ~MutableSimParticle() = default;
0059 
0060 
0061 public:
0062 
0063   /// Access the Momentum in the z direction
0064   double getMomentum_z() const;
0065 
0066   /// Access the Momentum in the theta direction
0067   double getMomentum_theta() const;
0068 
0069   /// Access the Momentum in the phi direction
0070   double getMomentum_phi() const;
0071 
0072   /// Access the Total energy
0073   double getEnergy() const;
0074 
0075   /// Access the PDG particle id
0076   std::uint32_t getPdg() const;
0077 
0078 
0079 
0080   /// Set the Momentum in the z direction
0081   void setMomentum_z(const double momentum_z);
0082   /// Get mutable reference to Momentum in the z direction
0083   double& getMomentum_z();
0084   /// Get reference to Momentum in the z direction
0085   [[deprecated("use getMomentum_z instead")]]
0086   double& momentum_z();
0087 
0088   /// Set the Momentum in the theta direction
0089   void setMomentum_theta(const double momentum_theta);
0090   /// Get mutable reference to Momentum in the theta direction
0091   double& getMomentum_theta();
0092   /// Get reference to Momentum in the theta direction
0093   [[deprecated("use getMomentum_theta instead")]]
0094   double& momentum_theta();
0095 
0096   /// Set the Momentum in the phi direction
0097   void setMomentum_phi(const double momentum_phi);
0098   /// Get mutable reference to Momentum in the phi direction
0099   double& getMomentum_phi();
0100   /// Get reference to Momentum in the phi direction
0101   [[deprecated("use getMomentum_phi instead")]]
0102   double& momentum_phi();
0103 
0104   /// Set the Total energy
0105   void setEnergy(const double energy);
0106   /// Get mutable reference to Total energy
0107   double& getEnergy();
0108   /// Get reference to Total energy
0109   [[deprecated("use getEnergy instead")]]
0110   double& energy();
0111 
0112   /// Set the PDG particle id
0113   void setPdg(const std::uint32_t pdg);
0114   /// Get mutable reference to PDG particle id
0115   std::uint32_t& getPdg();
0116   /// Get reference to PDG particle id
0117   [[deprecated("use getPdg instead")]]
0118   std::uint32_t& pdg();
0119 
0120 
0121 
0122 
0123 
0124 
0125   /// check whether the object is actually available
0126   bool isAvailable() const;
0127   /// disconnect from SimParticleObj instance
0128   void unlink() { m_obj = podio::utils::MaybeSharedPtr<SimParticleObj>{nullptr}; }
0129 
0130   bool operator==(const MutableSimParticle& other) const { return m_obj == other.m_obj; }
0131   bool operator==(const SimParticle& other) const;
0132 
0133   bool operator!=(const MutableSimParticle& other) const { return !(*this == other); }
0134   bool operator!=(const SimParticle& other) const { return !(*this == other); }
0135 
0136   // less comparison operator, so that objects can be e.g. stored in sets.
0137   bool operator<(const MutableSimParticle& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0138 
0139   podio::ObjectID id() const { return getObjectID(); }
0140 
0141   const podio::ObjectID getObjectID() const;
0142 
0143   friend std::hash<MutableSimParticle>;
0144 
0145   friend void swap(MutableSimParticle& a, MutableSimParticle& b) {
0146     using std::swap;
0147     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0148   }
0149 
0150 private:
0151   /// constructor from existing SimParticleObj
0152   explicit MutableSimParticle(podio::utils::MaybeSharedPtr<SimParticleObj> obj);
0153 
0154   podio::utils::MaybeSharedPtr<SimParticleObj> m_obj{new SimParticleObj{}, podio::utils::MarkOwned};
0155 };
0156 
0157 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0158 void to_json(nlohmann::json& j, const MutableSimParticle& value);
0159 #endif
0160 
0161 
0162 
0163 
0164 
0165 template<>
0166 struct std::hash<MutableSimParticle> {
0167   std::size_t operator()(const MutableSimParticle& obj) const {
0168     return std::hash<SimParticleObj*>{}(obj.m_obj.get());
0169   }
0170 };
0171 
0172 
0173 #endif