1 #ifndef PhysicsTools_PatUtils_RefHelper_h
2 #define PhysicsTools_PatUtils_RefHelper_h
6 namespace pat {
namespace helper {
36 template<
typename V,
typename SomeRef>
41 template<
typename V,
typename SomeRef>
50 if (backRefMap_.contains(ref.
id())) {
52 return backRefMap_[ref];
67 Ref ret = parentOrNull(ref);
76 if (test.
isNull())
return ret;
84 return parentOrNull(ref).isNull();
91 if (test == old)
return true;
92 test = parentOrNull(test);
99 return ( ancestorOrSelf(ref1) == ancestorOrSelf(ref2) );
103 template<
typename V,
typename SomeRef>
116 test = parentOrNull(test);
119 "RefHelper: recursive Lookup failed: neither the specified ref nor any of its parents are in the map.\n";
123 template<
typename V,
typename SomeRef>
126 return map[ancestorOrSelf(tref)];
Code categoryCode() const
edm::Ref< Container > Ref
const edm::ValueMap< Ref > & backRefMap_
bool sharedAncestor(const Ref &ref1, const Ref &ref2) const
true if the two share the same root
Ref parentOrSelf(const Ref &ref) const
Returns a Ref to the direct parent of "ref", or "ref" itself if it's already root.
RefHelper(const edm::ValueMap< Ref > &backRefMap)
Constructor taking a ValueMap of back-references daughter => mother.
bool isNonnull() const
Checks for non-null.
bool contains(ProductID id) const
ProductID id() const
Accessor for product ID.
Ref parentOrNull(const Ref &ref) const
Returns a Ref to the direct parent of "ref", or a null Ref if "ref" is already root.
bool isAncestorOf(const Ref &old, const Ref &young) const
true if old is some ancestor of young (it does not have to be the root)
bool isRoot(const Ref &ref) const
V ancestorLookup(const SomeRef &ref, const edm::ValueMap< V > &map) const
bool isNull() const
Checks for null.
V recursiveLookup(const SomeRef &ref, const edm::ValueMap< V > &map) const
Ref ancestorOrSelf(const Ref &ref) const
Climbs back the Ref chain and returns the root of the branch starting from "ref". ...