11 from D3PDMakerCoreComps.D3PDObject
import D3PDObject
12 from AthenaConfiguration.ComponentFactory
import CompFactory
14 D3PD = CompFactory.D3PD
26 """Helper for setting up a nearest-DR association to a contained object.
28 We get an source object and a collection of target objects.
29 We pick the target object that's closest in DR to the source object.
30 By default, the target collection is a DataVector from StoreGate.
32 parent: The parent D3PDobject or block.
33 type_name: The C++ type of the target object collection.
34 default_sgkey: Default StoreGate key for the target collection.
35 default_drcut: Default DR cut. If no target objects are within
36 this DR, the association will fail.
37 prefix: Prefix to add to the contained variables, if any.
38 matched: If not null, a flag variable with this name will
39 be created, set to true when the association succeeds.
40 level: Level of detail for the block.
41 blockname: Name for the block.
43 Extra arguments are passed to the association tool.
45 Here's an example. Suppose we have an electron object, and we
46 want to record the 4-vector of a matching jet.
48 Usage is something like this:
52 EleJetAssoc = DRAssociation (ElectronObject,
58 blockname = 'JetMatch')
59 EleJetAssoc.defineBlock (2, 'JetKinematics',
60 D3PD.FourMomFillerTool)
62 The DRAssociation call makes the association. We'll look in SG
63 for a JetCollection called `Cone4H1TowerJets' and find the jet from
64 there that's closest in DR to the electron (but not farther away
65 than 0.2). If the electron prefix is `el_', then we'll automatically
66 create the variables `el_jet_matched' and `el_jet_dr'. The second
67 call then adds the jet kinematic variables: `el_jet_pt', etc.
68 Additional blocks can be added if desired.
71 blockname = prefix +
'DRAssoc'
73 def maker (name, prefix, object_name,
74 sgkey = default_sgkey,
77 drcut = default_drcut):
94 obj = D3PDObject (maker, prefix)
95 parent.defineBlock (level, blockname, obj)