File indexing completed on 2025-12-12 09:51:34
0001
0002
0003 #ifndef EDM4EIC_MutableTruthiness_H
0004 #define EDM4EIC_MutableTruthiness_H
0005
0006 #include "edm4eic/TruthinessObj.h"
0007
0008 #include "edm4eic/Truthiness.h"
0009
0010 #include "edm4eic/MCRecoParticleAssociation.h"
0011 #include "edm4eic/ReconstructedParticle.h"
0012 #include "edm4eic/TruthinessContribution.h"
0013 #include "edm4hep/MCParticle.h"
0014 #include "podio/RelationRange.h"
0015 #include <vector>
0016
0017 #include "podio/utilities/MaybeSharedPtr.h"
0018
0019 #include <cstdint>
0020
0021 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0022 #include "nlohmann/json_fwd.hpp"
0023 #endif
0024
0025
0026 namespace edm4eic {
0027 class TruthinessCollection;
0028 }
0029
0030
0031 namespace edm4eic {
0032
0033
0034
0035
0036
0037
0038 class MutableTruthiness {
0039
0040 friend class TruthinessCollection;
0041 friend class TruthinessMutableCollectionIterator;
0042 friend class Truthiness;
0043
0044 public:
0045 using object_type = Truthiness;
0046 using collection_type = TruthinessCollection;
0047
0048
0049 MutableTruthiness() = default;
0050
0051
0052 MutableTruthiness(const float truthiness, const edm4eic::TruthinessContribution& associationContribution, const float unassociatedMCParticlesContribution, const float unassociatedRecoParticlesContribution);
0053
0054
0055 MutableTruthiness(const MutableTruthiness& other) = default;
0056
0057
0058 MutableTruthiness& operator=(MutableTruthiness other) &;
0059 MutableTruthiness& operator=(MutableTruthiness other) && = delete;
0060
0061
0062
0063 MutableTruthiness clone(bool cloneRelations=true) const;
0064
0065
0066 ~MutableTruthiness() = default;
0067
0068
0069 public:
0070
0071
0072 float getTruthiness() const;
0073
0074
0075 const edm4eic::TruthinessContribution& getAssociationContribution() const;
0076
0077
0078 float getUnassociatedMCParticlesContribution() const;
0079
0080
0081 float getUnassociatedRecoParticlesContribution() const;
0082
0083
0084
0085
0086 void setTruthiness(const float truthiness);
0087
0088 float& getTruthiness();
0089
0090 [[deprecated("use getTruthiness instead")]]
0091 float& truthiness();
0092
0093
0094 void setAssociationContribution(const edm4eic::TruthinessContribution& associationContribution);
0095
0096 edm4eic::TruthinessContribution& getAssociationContribution();
0097
0098 [[deprecated("use getAssociationContribution instead")]]
0099 edm4eic::TruthinessContribution& associationContribution();
0100
0101
0102 void setUnassociatedMCParticlesContribution(const float unassociatedMCParticlesContribution);
0103
0104 float& getUnassociatedMCParticlesContribution();
0105
0106 [[deprecated("use getUnassociatedMCParticlesContribution instead")]]
0107 float& unassociatedMCParticlesContribution();
0108
0109
0110 void setUnassociatedRecoParticlesContribution(const float unassociatedRecoParticlesContribution);
0111
0112 float& getUnassociatedRecoParticlesContribution();
0113
0114 [[deprecated("use getUnassociatedRecoParticlesContribution instead")]]
0115 float& unassociatedRecoParticlesContribution();
0116
0117
0118
0119 void addToAssociations(const edm4eic::MCRecoParticleAssociation&);
0120 std::size_t associations_size() const;
0121 edm4eic::MCRecoParticleAssociation getAssociations(std::size_t) const;
0122 std::vector<edm4eic::MCRecoParticleAssociation>::const_iterator associations_begin() const;
0123 std::vector<edm4eic::MCRecoParticleAssociation>::const_iterator associations_end() const;
0124 podio::RelationRange<edm4eic::MCRecoParticleAssociation> getAssociations() const;
0125 void addToUnassociatedMCParticles(const edm4hep::MCParticle&);
0126 std::size_t unassociatedMCParticles_size() const;
0127 edm4hep::MCParticle getUnassociatedMCParticles(std::size_t) const;
0128 std::vector<edm4hep::MCParticle>::const_iterator unassociatedMCParticles_begin() const;
0129 std::vector<edm4hep::MCParticle>::const_iterator unassociatedMCParticles_end() const;
0130 podio::RelationRange<edm4hep::MCParticle> getUnassociatedMCParticles() const;
0131 void addToUnassociatedRecoParticles(const edm4eic::ReconstructedParticle&);
0132 std::size_t unassociatedRecoParticles_size() const;
0133 edm4eic::ReconstructedParticle getUnassociatedRecoParticles(std::size_t) const;
0134 std::vector<edm4eic::ReconstructedParticle>::const_iterator unassociatedRecoParticles_begin() const;
0135 std::vector<edm4eic::ReconstructedParticle>::const_iterator unassociatedRecoParticles_end() const;
0136 podio::RelationRange<edm4eic::ReconstructedParticle> getUnassociatedRecoParticles() const;
0137 void addToAssociationContributions(const edm4eic::TruthinessContribution&);
0138 std::size_t associationContributions_size() const;
0139 edm4eic::TruthinessContribution getAssociationContributions(std::size_t) const;
0140 std::vector<edm4eic::TruthinessContribution>::const_iterator associationContributions_begin() const;
0141 std::vector<edm4eic::TruthinessContribution>::const_iterator associationContributions_end() const;
0142 podio::RelationRange<edm4eic::TruthinessContribution> getAssociationContributions() const;
0143
0144
0145
0146
0147 bool isAvailable() const;
0148
0149 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TruthinessObj>{nullptr}; }
0150
0151 bool operator==(const MutableTruthiness& other) const { return m_obj == other.m_obj; }
0152 bool operator==(const Truthiness& other) const;
0153
0154 bool operator!=(const MutableTruthiness& other) const { return !(*this == other); }
0155 bool operator!=(const Truthiness& other) const { return !(*this == other); }
0156
0157
0158 bool operator<(const MutableTruthiness& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0159
0160 podio::ObjectID id() const { return getObjectID(); }
0161
0162 const podio::ObjectID getObjectID() const;
0163
0164 friend std::hash<MutableTruthiness>;
0165
0166 friend void swap(MutableTruthiness& a, MutableTruthiness& b) {
0167 using std::swap;
0168 swap(a.m_obj, b.m_obj);
0169 }
0170
0171 private:
0172
0173 explicit MutableTruthiness(podio::utils::MaybeSharedPtr<TruthinessObj> obj);
0174
0175 podio::utils::MaybeSharedPtr<TruthinessObj> m_obj{new TruthinessObj{}, podio::utils::MarkOwned};
0176 };
0177
0178 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0179 void to_json(nlohmann::json& j, const MutableTruthiness& value);
0180 #endif
0181
0182
0183 }
0184
0185
0186
0187 template<>
0188 struct std::hash<edm4eic::MutableTruthiness> {
0189 std::size_t operator()(const edm4eic::MutableTruthiness& obj) const {
0190 return std::hash<edm4eic::TruthinessObj*>{}(obj.m_obj.get());
0191 }
0192 };
0193
0194
0195 #endif