11 from .D3PDObject
import D3PDObject
12 from AthenaConfiguration.ComponentFactory
import CompFactory
14 D3PD = CompFactory.D3PD
25 """Helper for setting up an association to a contained object.
27 parent: The parent D3PDobject or block.
28 assoctool: The class for the (single) association tool.
29 prefix: Prefix to add to the contained variables, if any.
30 matched: If not null, a flag variable with this name will
31 be created, set to true when the association succeeds.
32 level: Level of detail for the block.
33 blockname: Name for the block.
34 suffix: Suffix to add to the contained variables, if any.
36 Extra arguments are passed to the association tool.
38 Here's an example. Suppose we have a generic tool that tuples
39 Perigee objects, producing variables z0, d0, etc. Suppose that
40 we also have an `electron' object that has a method to return
41 a Perigee. We want to use the Perigee filling tool to tuple
42 these variables as a new block.
44 We can do this by creating an associator tool that will go from
45 an electron object to its contained Perigee object. We then configure
46 things by creating a ContainedAssociationFillerTool using this
47 associator. We then add this as a block to the electron object,
48 and then add a Perigee block to the associator block. The helper
49 here reduces the amount of boilerplate configuration code
52 Usage is something like this:
55 ElectronPerigee = SimpleAssocation (ElectronObject,
56 electronPerigeeAssociator)
57 ElectronPerigee.defineBlock (1, 'Perigee', PerigeeFillerTool)
59 If the electron prefix is `el_', this would create variables
60 `el_z0', etc. With `prefix="track"', the names would be
63 If we add `matched="hastrack"', then this will add a boolean
64 variable `el_hastrack', which is true if the association succeeded.
67 blockname = assoctool.__name__
69 def maker (name, prefix, object_name, **kw2):
70 assoc = assoctool (name +
'Assoc', **kw2)
72 (name, Prefix = prefix, Suffix = suffix,
73 Associator = assoc, Matched = matched)
75 obj = D3PDObject (maker, prefix)
76 parent.defineBlock (level, blockname, obj, **kw)
81 """A SimpleAssociation configured with an identity association.
83 This can be useful to group blocks together in subblocks.
85 return SimpleAssociation (parent,