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_MutableADCHit_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_MutableADCHit_H
0005 
0006 #include "jana2_tutorial_podio_datamodel/ADCHitObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "jana2_tutorial_podio_datamodel/ADCHit.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 ADCHitCollection;
0022 
0023 
0024 
0025 
0026 /** @class MutableADCHit
0027  *  The raw hit read off the DAQ, or produced by digitization
0028  *  @author: N. Brei
0029  */
0030 class MutableADCHit {
0031 
0032   friend class ADCHitCollection;
0033   friend class ADCHitMutableCollectionIterator;
0034   friend class ADCHit;
0035 
0036 public:
0037   using object_type = ADCHit;
0038   using collection_type = ADCHitCollection;
0039 
0040   /// default constructor
0041   MutableADCHit() = default;
0042 
0043   /// Constructor initializing all members
0044   MutableADCHit(const std::uint32_t crate, const std::uint32_t slot, const std::uint32_t channel, const std::uint32_t energy, const std::uint32_t timestamp);
0045 
0046   /// copy constructor
0047   MutableADCHit(const MutableADCHit& other) = default;
0048 
0049   /// copy-assignment operator
0050   MutableADCHit& operator=(MutableADCHit other) &; // Rebind this to other's internal object
0051   MutableADCHit& operator=(MutableADCHit 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   MutableADCHit clone(bool cloneRelations=true) const;
0056 
0057   /// destructor
0058   ~MutableADCHit() = default;
0059 
0060 
0061 public:
0062 
0063   /// Access the DAQ crate index
0064   std::uint32_t getCrate() const;
0065 
0066   /// Access the DAQ slot index
0067   std::uint32_t getSlot() const;
0068 
0069   /// Access the DAQ channel index
0070   std::uint32_t getChannel() const;
0071 
0072   /// Access the Energy measured
0073   std::uint32_t getEnergy() const;
0074 
0075   /// Access the Timestamp [ns]
0076   std::uint32_t getTimestamp() const;
0077 
0078 
0079 
0080   /// Set the DAQ crate index
0081   void setCrate(const std::uint32_t crate);
0082   /// Get mutable reference to DAQ crate index
0083   std::uint32_t& getCrate();
0084   /// Get reference to DAQ crate index
0085   [[deprecated("use getCrate instead")]]
0086   std::uint32_t& crate();
0087 
0088   /// Set the DAQ slot index
0089   void setSlot(const std::uint32_t slot);
0090   /// Get mutable reference to DAQ slot index
0091   std::uint32_t& getSlot();
0092   /// Get reference to DAQ slot index
0093   [[deprecated("use getSlot instead")]]
0094   std::uint32_t& slot();
0095 
0096   /// Set the DAQ channel index
0097   void setChannel(const std::uint32_t channel);
0098   /// Get mutable reference to DAQ channel index
0099   std::uint32_t& getChannel();
0100   /// Get reference to DAQ channel index
0101   [[deprecated("use getChannel instead")]]
0102   std::uint32_t& channel();
0103 
0104   /// Set the Energy measured
0105   void setEnergy(const std::uint32_t energy);
0106   /// Get mutable reference to Energy measured
0107   std::uint32_t& getEnergy();
0108   /// Get reference to Energy measured
0109   [[deprecated("use getEnergy instead")]]
0110   std::uint32_t& energy();
0111 
0112   /// Set the Timestamp [ns]
0113   void setTimestamp(const std::uint32_t timestamp);
0114   /// Get mutable reference to Timestamp [ns]
0115   std::uint32_t& getTimestamp();
0116   /// Get reference to Timestamp [ns]
0117   [[deprecated("use getTimestamp instead")]]
0118   std::uint32_t& timestamp();
0119 
0120 
0121 
0122 
0123 
0124 
0125   /// check whether the object is actually available
0126   bool isAvailable() const;
0127   /// disconnect from ADCHitObj instance
0128   void unlink() { m_obj = podio::utils::MaybeSharedPtr<ADCHitObj>{nullptr}; }
0129 
0130   bool operator==(const MutableADCHit& other) const { return m_obj == other.m_obj; }
0131   bool operator==(const ADCHit& other) const;
0132 
0133   bool operator!=(const MutableADCHit& other) const { return !(*this == other); }
0134   bool operator!=(const ADCHit& other) const { return !(*this == other); }
0135 
0136   // less comparison operator, so that objects can be e.g. stored in sets.
0137   bool operator<(const MutableADCHit& 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<MutableADCHit>;
0144 
0145   friend void swap(MutableADCHit& a, MutableADCHit& 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 ADCHitObj
0152   explicit MutableADCHit(podio::utils::MaybeSharedPtr<ADCHitObj> obj);
0153 
0154   podio::utils::MaybeSharedPtr<ADCHitObj> m_obj{new ADCHitObj{}, podio::utils::MarkOwned};
0155 };
0156 
0157 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0158 void to_json(nlohmann::json& j, const MutableADCHit& value);
0159 #endif
0160 
0161 
0162 
0163 
0164 
0165 template<>
0166 struct std::hash<MutableADCHit> {
0167   std::size_t operator()(const MutableADCHit& obj) const {
0168     return std::hash<ADCHitObj*>{}(obj.m_obj.get());
0169   }
0170 };
0171 
0172 
0173 #endif