ATLAS Offline Software
Classes | Functions
SG::detail Namespace Reference

Classes

class  DataVectorAllocDummy
 
class  IteratorBase
 
class  WDHScan
 Helper to scan a tree of components to search for another handle key potentially conflicting with the container key part of a WriteDecorHandleKey. More...
 

Functions

bool handleInHolder (const DataObjID &contHandleKey, const IDataHandleHolder &holder)
 Test to see if HOLDER has registered a handle key matching CONTHANDLEKEY, as either input or output. More...
 
const IDataHandleHolder * findParent (const IDataHandleHolder *h)
 Find the top-level Gaudi component for H. More...
 
void registerWriteDecorHandleKey (IDataHandleHolder *owner, const DataObjID &contHandleKey)
 Optionally register read dependency of a WriteDecorHandleKey. More...
 

Function Documentation

◆ findParent()

const IDataHandleHolder* SG::detail::findParent ( const IDataHandleHolder *  h)

Find the top-level Gaudi component for H.

Parameters
HThe component at which to start the search.

We're given a Gaudi component H as an IDataHandleHolder. If this is an algorithm, return it. Otherwise, search up the list of parents to find either the owning algorithm or a top-level public tool or service.

Definition at line 58 of file WriteDecorHandleKey.cxx.

59 {
60  while (true) {
61  const IAlgTool* astool = dynamic_cast<const IAlgTool*> (h);
62  if (!astool) return h;
63  const IInterface* parent = astool->parent();
64  if (!parent) return h;
65  auto pdh = dynamic_cast<const IDataHandleHolder*> (parent);
66  if (!pdh) return h;
67  if (dynamic_cast<const Gaudi::Algorithm*> (parent)) return pdh;
68  h = pdh;
69  }
70 }

◆ handleInHolder()

bool SG::detail::handleInHolder ( const DataObjID &  contHandleKey,
const IDataHandleHolder &  holder 
)

Test to see if HOLDER has registered a handle key matching CONTHANDLEKEY, as either input or output.

Parameters
contHandleKeyThe handle key to test.
holderThe component to search.

Definition at line 30 of file WriteDecorHandleKey.cxx.

32 {
33  for (const Gaudi::DataHandle* h : holder.inputHandles()) {
34  if (h->fullKey() == contHandleKey) {
35  return true;
36  }
37  }
38 
39  for (const Gaudi::DataHandle* h : holder.outputHandles()) {
40  if (h->fullKey() == contHandleKey) {
41  return true;
42  }
43  }
44 
45  return false;
46 }

◆ registerWriteDecorHandleKey()

void SG::detail::registerWriteDecorHandleKey ( IDataHandleHolder *  owner,
const DataObjID &  contHandleKey 
)

Optionally register read dependency of a WriteDecorHandleKey.

A WriteDecorHandle logically has a read dependency on the container itself. However, just declaring this as a usual ReadHandleKey will cause problems if used in an algorithm that also creates the container: we'll get complaints from the Algorithm base class about circular dependencies.

To deal with this, we don't declare the container ReadHandleKey in declareProperty. Instead, we wait until initialize and declare the dependency with addDependency only if it is not already on a handle list.

This issue also comes up across multiple tools in a single algorithm. For example, if an algorithm that has one tool that creates an container and another tool with a WriteDecorHandleKey, we can get a warning about a circular dependency. To suppress this for the common case, we also search the component tree under the algorithm and avoid adding the ReadHandleKey if there's a matching component in the tree before the one owning the WriteDecorHandleKey. (We only do it for components earlier in the tree walk to make it less likely that we'll suppress the warning for a genuine use-before-write misconfiguration.)

Definition at line 154 of file WriteDecorHandleKey.cxx.

156 {
157  if (!owner) return;
158 
159  // Does this component already have a key matching @c contHandleKey?
160  bool found = handleInHolder (contHandleKey, *owner);
161 
162  if (!found) {
163  // No --- now search the complete component tree up to @c owner for a match.
164  const IDataHandleHolder* parent = findParent (owner);
165  if (parent && parent != owner) {
166  WDHScan scan (contHandleKey, owner);
167  parent->acceptDHVisitor (&scan);
168  found = scan.m_found;
169  }
170  }
171 
172  if (!found) {
173  owner->addDependency (contHandleKey, Gaudi::DataHandle::Reader);
174  }
175 }
SG::detail::findParent
const IDataHandleHolder * findParent(const IDataHandleHolder *h)
Find the top-level Gaudi component for H.
Definition: WriteDecorHandleKey.cxx:58
python.FakeAthena.Algorithm
def Algorithm(name)
Definition: FakeAthena.py:41
extractSporadic.h
list h
Definition: extractSporadic.py:97
LHEF::Reader
Pythia8::Reader Reader
Definition: Prophecy4fMerger.cxx:11
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SG::detail::handleInHolder
bool handleInHolder(const DataObjID &contHandleKey, const IDataHandleHolder &holder)
Test to see if HOLDER has registered a handle key matching CONTHANDLEKEY, as either input or output.
Definition: WriteDecorHandleKey.cxx:30
h
scan
void scan(TDirectory *td=0, int depth=0)
Definition: listroot.cxx:440
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101