Skip to content
Snippets Groups Projects
Commit 71ffd7b8 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Merge branch 'issue-Moore#538' into 'master'

More deterministic comparison for ProtoParticle Relations

Closes Moore#538

See merge request !3998
parents 93048dd9 85c06e95
No related branches found
No related tags found
1 merge request!3998More deterministic comparison for ProtoParticle Relations
Pipeline #5248646 passed
......@@ -13,6 +13,7 @@
// Include files
#include "Event/CaloHypo.h"
#include "Event/Track.h"
#include "GaudiKernel/IRegistry.h"
#include "GaudiKernel/KeyedContainer.h"
#include "GaudiKernel/KeyedObject.h"
#include "GaudiKernel/SmartRef.h"
......@@ -749,3 +750,32 @@ inline int LHCb::ProtoParticle::charge() const { return ( track() != nullptr ? t
namespace Gaudi::Parsers {
StatusCode parse( std::vector<LHCb::ProtoParticle::additionalInfo>& v, const std::string& in );
} // namespace Gaudi::Parsers
namespace Relations {
template <typename>
struct ObjectTypeTraits;
// TODO: generalize Relations/Pointer.h to do this for all classes derived from KeyedObject<K>...
template <>
struct ObjectTypeTraits<LHCb::ProtoParticle> {
// ========================================================================
using Type = LHCb::ProtoParticle;
using Input = const LHCb::ProtoParticle*;
using Output = const LHCb::ProtoParticle*;
using Inner = SmartRef<LHCb::ProtoParticle>;
struct Less {
bool operator()( const LHCb::ProtoParticle& lhs, const LHCb::ProtoParticle& rhs ) const {
// relations should only be between objects in the event store, hence there _should_ be a
// valid `parent()`, and that `parent()` should have a non-nullptr `registry()`.
return lhs.parent() == rhs.parent()
? ( lhs.key() < rhs.key() )
: ( lhs.parent()->registry()->identifier() < rhs.parent()->registry()->identifier() );
}
bool operator()( const LHCb::ProtoParticle* lhs, const LHCb::ProtoParticle* rhs ) const {
// there should not be any nullptrs in the 'from' side of a relation table...
return ( *this )( *lhs, *rhs );
}
};
// ========================================================================
};
} // namespace Relations
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment