File indexing completed on 2025-12-22 10:09:01
0001
0002
0003 #ifndef EDM4HEP_EventHeader_H
0004 #define EDM4HEP_EventHeader_H
0005
0006 #include "edm4hep/EventHeaderObj.h"
0007
0008 #include "podio/RelationRange.h"
0009 #include <cstdint>
0010 #include <vector>
0011
0012 #include "podio/detail/OrderKey.h"
0013 #include "podio/utilities/MaybeSharedPtr.h"
0014
0015 #include <cstdint>
0016 #include <ostream>
0017
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021
0022
0023 namespace edm4hep {
0024 class EventHeaderCollection;
0025 }
0026
0027 namespace podio::detail {
0028
0029 OrderKey getOrderKey(const edm4hep::EventHeader& obj);
0030 };
0031
0032 namespace edm4hep {
0033
0034 class MutableEventHeader;
0035 class EventHeaderCollection;
0036 class EventHeaderCollectionData;
0037
0038
0039
0040
0041
0042 class EventHeader {
0043
0044 friend class MutableEventHeader;
0045 friend class EventHeaderCollection;
0046 friend class edm4hep::EventHeaderCollectionData;
0047 friend class EventHeaderCollectionIterator;
0048 friend podio::detail::OrderKey podio::detail::getOrderKey(const EventHeader& obj);
0049
0050 public:
0051 using mutable_type = MutableEventHeader;
0052 using collection_type = EventHeaderCollection;
0053
0054
0055 EventHeader() = default;
0056
0057
0058 EventHeader(const std::uint64_t eventNumber, const std::uint32_t runNumber, const std::uint64_t timeStamp,
0059 const double weight);
0060
0061
0062 EventHeader(const EventHeader& other) = default;
0063
0064
0065 EventHeader& operator=(EventHeader other) &;
0066 EventHeader& operator=(EventHeader other) && = delete;
0067
0068
0069
0070 MutableEventHeader clone(bool cloneRelations = true) const;
0071
0072
0073 ~EventHeader() = default;
0074
0075
0076 EventHeader(const MutableEventHeader& other);
0077
0078 static EventHeader makeEmpty();
0079
0080 public:
0081 static constexpr std::string_view typeName = "edm4hep::EventHeader";
0082
0083
0084 std::uint64_t getEventNumber() const;
0085
0086
0087 std::uint32_t getRunNumber() const;
0088
0089
0090 std::uint64_t getTimeStamp() const;
0091
0092
0093 double getWeight() const;
0094
0095 std::size_t weights_size() const;
0096 double getWeights(std::size_t) const;
0097 std::vector<double>::const_iterator weights_begin() const;
0098 std::vector<double>::const_iterator weights_end() const;
0099 podio::RelationRange<double> getWeights() const;
0100
0101
0102 bool isAvailable() const;
0103
0104 void unlink() { m_obj = podio::utils::MaybeSharedPtr<EventHeaderObj>{nullptr}; }
0105
0106 bool operator==(const EventHeader& other) const { return m_obj == other.m_obj; }
0107 bool operator==(const MutableEventHeader& other) const;
0108
0109 bool operator!=(const EventHeader& other) const { return !(*this == other); }
0110 bool operator!=(const MutableEventHeader& other) const { return !(*this == other); }
0111
0112
0113 bool operator<(const EventHeader& other) const {
0114 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0115 }
0116
0117 podio::ObjectID id() const { return getObjectID(); }
0118
0119 const podio::ObjectID getObjectID() const;
0120
0121 friend std::hash<EventHeader>;
0122
0123 friend void swap(EventHeader& a, EventHeader& b) {
0124 using std::swap;
0125 swap(a.m_obj, b.m_obj);
0126 }
0127
0128 private:
0129
0130 explicit EventHeader(podio::utils::MaybeSharedPtr<EventHeaderObj> obj);
0131 EventHeader(EventHeaderObj* obj);
0132
0133 podio::utils::MaybeSharedPtr<EventHeaderObj> m_obj{new EventHeaderObj{}, podio::utils::MarkOwned};
0134 };
0135
0136 std::ostream& operator<<(std::ostream& o, const EventHeader& value);
0137
0138 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0139 void to_json(nlohmann::json& j, const EventHeader& value);
0140 #endif
0141
0142 }
0143
0144 template <>
0145 struct std::hash<edm4hep::EventHeader> {
0146 std::size_t operator()(const edm4hep::EventHeader& obj) const {
0147 return std::hash<edm4hep::EventHeaderObj*>{}(obj.m_obj.get());
0148 }
0149 };
0150
0151
0152
0153
0154 #if defined(__clang__)
0155 #pragma clang diagnostic push
0156 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0157 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0158 #pragma clang diagnostic ignored "-Wdeprecated"
0159 constexpr std::string_view edm4hep::EventHeader::typeName;
0160 #pragma clang diagnostic pop
0161 #elif defined(__GNUC__)
0162 #pragma GCC diagnostic push
0163 #pragma GCC diagnostic ignored "-Wdeprecated"
0164 constexpr std::string_view edm4hep::EventHeader::typeName;
0165 #pragma GCC diagnostic pop
0166 #endif
0167
0168 #endif