ATLAS Offline Software
IndexMultiAssociation.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #
4 # @file D3PDMakerCoreComps/python/IndexMultiAssociation.py
5 # @author scott snyder <snyder@bnl.gov>
6 # @author Ryan Reece <ryan.reece@cern.ch>
7 # @date Dec 2009
8 # @brief Helper for setting up an association via an index.
9 #
10 
11 
12 from .D3PDObject import D3PDObject
13 from AthenaConfiguration.ComponentFactory import CompFactory
14 
15 D3PD = CompFactory.D3PD
16 
17 
19  assoctool,
20  target,
21  prefix = '',
22  level = 0,
23  blockname = None,
24  allowMissing = False,
25  nrowName = 'n',
26  containerIndexName = '',
27  **kw):
28 
29  """Helper for setting up an association via an index.
30 
31  parent: The parent D3PDobject or block.
32  assoctool: The class for the (single) association tool.
33  target: The label for the getter within which we look up the index,
34  or a list of such labels if multiple targets are desired.
35  prefix: Prefix to add to the contained variables, if any.
36  level: Level of detail for the block.
37  blockname: Name for the block.
38  allowMissing: If true, then it is not considered an error for the
39  target getter to fail to find the input objects.
40  nrowName: Name of the variable for the count of objects.
41  Omitted if empty.
42 
43  Extra arguments are passed to the association tool.
44 """
45 
46  if blockname is None:
47  blockname = assoctool.__name__
48 
49  def maker (name, prefix, object_name, **kw2):
50  this_target = target
51  if 'target' in kw2:
52  this_target = kw2['target']
53  del kw2['target']
54 
55  if this_target == '':
56  this_target = []
57  elif not isinstance(this_target, list):
58  this_target = [ this_target ]
59 
60  assoc = assoctool (name + 'Assoc', **kw2)
62  (name,
63  Prefix = prefix,
64  Associator = assoc,
65  NrowName = nrowName)
66  indexer = D3PD.IndexFillerTool \
67  (name + 'Index',
68  Targets = this_target,
69  ContainerIndexName = containerIndexName,
70  AllowMissing = allowMissing)
71  filler.BlockFillers += [indexer]
72  return filler
73 
74  obj = D3PDObject (maker, prefix)
75  parent.defineBlock (level, blockname, obj, **kw)
76  return obj
python.IndexMultiAssociation.IndexMultiAssociation
def IndexMultiAssociation(parent, assoctool, target, prefix='', level=0, blockname=None, allowMissing=False, nrowName='n', containerIndexName='', **kw)
Definition: IndexMultiAssociation.py:18
D3PD::ContainedVectorMultiAssociationFillerTool
Represent a multiple association by containment inside vectors.
Definition: ContainedVectorMultiAssociationFillerTool.h:61
D3PD::IndexFillerTool
Fill an index of an object within a container.
Definition: IndexFillerTool.h:32