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_SimParticle_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_SimParticle_H
0005 
0006 #include "jana2_tutorial_podio_datamodel/SimParticleObj.h"
0007 
0008 #include <cstdint>
0009 
0010 #include "podio/utilities/MaybeSharedPtr.h"
0011 #include "podio/detail/OrderKey.h"
0012 
0013 #include <ostream>
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 namespace podio::detail {
0025 // Internal function used in less comparison operators of the datatypes and interface types
0026 OrderKey getOrderKey(const ::SimParticle& obj);
0027 };
0028 
0029 
0030 class MutableSimParticle;
0031 class SimParticleCollection;
0032 class SimParticleCollectionData;
0033 
0034 /** @class SimParticle
0035  *  A 'truth' particle, used by a Monte Carlo simulation
0036  *  @author: N. Brei
0037  */
0038 class SimParticle {
0039 
0040   friend class MutableSimParticle;
0041   friend class SimParticleCollection;
0042   friend class SimParticleCollectionData;
0043   friend class SimParticleCollectionIterator;
0044   friend podio::detail::OrderKey podio::detail::getOrderKey(const SimParticle & obj);
0045 
0046 public:
0047   using mutable_type = MutableSimParticle;
0048   using collection_type = SimParticleCollection;
0049 
0050   /// default constructor
0051   SimParticle() = default;
0052 
0053   /// Constructor initializing all members
0054   SimParticle(const double momentum_z, const double momentum_theta, const double momentum_phi, const double energy, const std::uint32_t pdg);
0055 
0056   /// copy constructor
0057   SimParticle(const SimParticle& other) = default;
0058 
0059   /// copy-assignment operator
0060   SimParticle& operator=(SimParticle other) &; // Rebind this to other's internal object
0061   SimParticle& operator=(SimParticle other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0062 
0063   /// create a mutable deep-copy of the object with identical relations
0064   /// if cloneRelations=false, the relations are not cloned and will be empty
0065   MutableSimParticle clone(bool cloneRelations=true) const;
0066 
0067   /// destructor
0068   ~SimParticle() = default;
0069 
0070   /// converting constructor from mutable object
0071   SimParticle(const MutableSimParticle& other);
0072 
0073   static SimParticle makeEmpty();
0074 
0075 public:
0076 
0077   static constexpr std::string_view typeName = "SimParticle";
0078 
0079   /// Access the Momentum in the z direction
0080   double getMomentum_z() const;
0081 
0082   /// Access the Momentum in the theta direction
0083   double getMomentum_theta() const;
0084 
0085   /// Access the Momentum in the phi direction
0086   double getMomentum_phi() const;
0087 
0088   /// Access the Total energy
0089   double getEnergy() const;
0090 
0091   /// Access the PDG particle id
0092   std::uint32_t getPdg() const;
0093 
0094 
0095 
0096 
0097 
0098   /// check whether the object is actually available
0099   bool isAvailable() const;
0100   /// disconnect from SimParticleObj instance
0101   void unlink() { m_obj = podio::utils::MaybeSharedPtr<SimParticleObj>{nullptr}; }
0102 
0103   bool operator==(const SimParticle& other) const { return m_obj == other.m_obj; }
0104   bool operator==(const MutableSimParticle& other) const;
0105 
0106   bool operator!=(const SimParticle& other) const { return !(*this == other); }
0107   bool operator!=(const MutableSimParticle& other) const { return !(*this == other); }
0108 
0109   // less comparison operator, so that objects can be e.g. stored in sets.
0110   bool operator<(const SimParticle& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0111 
0112   podio::ObjectID id() const { return getObjectID(); }
0113 
0114   const podio::ObjectID getObjectID() const;
0115 
0116   friend std::hash<SimParticle>;
0117 
0118   friend void swap(SimParticle& a, SimParticle& b) {
0119     using std::swap;
0120     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0121   }
0122 
0123 private:
0124   /// constructor from existing SimParticleObj
0125   explicit SimParticle(podio::utils::MaybeSharedPtr<SimParticleObj> obj);
0126   SimParticle(SimParticleObj* obj);
0127 
0128   podio::utils::MaybeSharedPtr<SimParticleObj> m_obj{new SimParticleObj{}, podio::utils::MarkOwned};
0129 };
0130 
0131 std::ostream& operator<<(std::ostream& o, const SimParticle& value);
0132 
0133 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0134 void to_json(nlohmann::json& j, const SimParticle& value);
0135 #endif
0136 
0137 
0138 
0139 
0140 
0141 template<>
0142 struct std::hash<SimParticle> {
0143   std::size_t operator()(const SimParticle& obj) const {
0144     return std::hash<SimParticleObj*>{}(obj.m_obj.get());
0145   }
0146 };
0147 
0148 
0149 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0150 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0151 // and https://github.com/AIDASoft/podio/issues/770
0152 #if defined(__clang__)
0153   #pragma clang diagnostic push
0154   #pragma clang diagnostic ignored "-Wunknown-warning-option"
0155   #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0156   #pragma clang diagnostic ignored "-Wdeprecated"
0157 constexpr std::string_view SimParticle::typeName;
0158   #pragma clang diagnostic pop
0159 #elif defined(__GNUC__)
0160   #pragma GCC diagnostic push
0161   #pragma GCC diagnostic ignored "-Wdeprecated"
0162 constexpr std::string_view SimParticle::typeName;
0163   #pragma GCC diagnostic pop
0164 #endif
0165 
0166 
0167 #endif