ATLAS Offline Software
Loading...
Searching...
No Matches
OverlapLinkHelper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ASSOCIATIONUTILS_OVERLAPLINKHELPER_H
6#define ASSOCIATIONUTILS_OVERLAPLINKHELPER_H
7
8// Framework includes
10
11// EDM includes
13
14// Columnar includes
19
20// Local includes
22
23namespace ORUtils
24{
25
40 template<columnar::ContainerIdConcept CI>
42 {
43
44 public:
45
47 OverlapLinkHelper(const std::string& linkLabel);
48
50 template<columnar::ContainerIdConcept LT>
52 columnar::ObjectId<LT> p2) const;
53
56 template<columnar::ContainerIdConcept LT>
58
59 private:
60
61 // we need to use a columnar variant link here, because other
62 // tools may send a link to a container we are not listing here.
63 // however, at the same time having a variant link here also means
64 // I can point to either of my two containers without extra
65 // effort.
67
72
73 }; // class OverlapLinkHelper
74
75 //---------------------------------------------------------------------------
76 // Constructor
77 //---------------------------------------------------------------------------
78 template<columnar::ContainerIdConcept CI>
79 OverlapLinkHelper<CI>::OverlapLinkHelper(const std::string& linkLabel)
80 : m_linkDecorator(*this,linkLabel),
81 m_linkAccessor(*this,linkLabel)
82 {}
83
84 //---------------------------------------------------------------------------
85 // Link p1 to p2
86 //---------------------------------------------------------------------------
87 template<columnar::ContainerIdConcept CI> template<columnar::ContainerIdConcept LT>
90 {
91 m_linkDecorator.set (p1, p2);
92 return StatusCode::SUCCESS;
93 }
94
95 //---------------------------------------------------------------------------
96 // Retrieve an overlap-linked particle or null.
97 //---------------------------------------------------------------------------
98 template<columnar::ContainerIdConcept CI> template<columnar::ContainerIdConcept LT>
101 {
102 // Check if the decoration is present and valid
103 if(!m_linkAccessor.isAvailable(p))
104 return {};
105 auto link = m_linkAccessor(p);
106 if (!link)
107 return {};
109 {
110 if (link.getXAODObject()->container() != &container.getXAODObject())
111 return {};
112 }
113 return link.template tryGetVariant<LT>();
114 }
115
116} // namespace ORUtils
117
118#endif
columnar::ColumnAccessor< CI, columnar::ObjectLink< LTDef > > m_linkAccessor
Corresponding object link accessor (for reading only)
OverlapLinkHelper(const std::string &linkLabel)
Constructor.
columnar::ColumnDecorator< CI, columnar::ObjectLink< LTDef > > m_linkDecorator
Object link decorator.
columnar::OptObjectId< LT > getObjectLink(columnar::ObjectId< CI > p, columnar::ObjectRange< LT > container) const
Retrieve an overlap-linked particle.
StatusCode addObjectLink(columnar::ObjectId< CI > p1, columnar::ObjectId< LT > p2) const
Decorate p1 with an overlap object link to p2.
columnar::VariantContainerId< columnar::ContainerId::particle1, columnar::ContainerId::particle1, columnar::ContainerId::particle2 > LTDef
the base class for all columnar components
a class representing a single object (electron, muons, etc.)
a class representing a continuous sequence of objects (a.k.a. a container)
a class representing a single optional object (electron, muons, etc.)
AccessorTemplate< CI, CT, ColumnAccessMode::input, CM > ColumnAccessor
AccessorTemplate< CI, CT, ColumnAccessMode::output, CM > ColumnDecorator
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition ColumnarDef.h:20
a "variant" ContainerId
Definition VariantDef.h:98