Helper for setting up a nearest-DR association to a contained object.
We get an source object and a collection of target objects.
We pick the target object that's closest in DR to the source object.
By default, the target collection is a DataVector from StoreGate.
parent: The parent D3PDobject or block.
type_name: The C++ type of the target object collection.
default_sgkey: Default StoreGate key for the target collection.
default_drcut: Default DR cut. If no target objects are within
this DR, the association will fail.
prefix: Prefix to add to the contained variables, if any.
matched: If not null, a flag variable with this name will
be created, set to true when the association succeeds.
level: Level of detail for the block.
blockname: Name for the block.
Extra arguments are passed to the association tool.
Here's an example. Suppose we have an electron object, and we
want to record the 4-vector of a matching jet.
Usage is something like this:
ElectronObject = ...
EleJetAssoc = DRAssociation (ElectronObject,
'JetCollection',
'Cone4H1TowerJets',
0.2,
'jet_',
level = 2,
blockname = 'JetMatch')
EleJetAssoc.defineBlock (2, 'JetKinematics',
D3PD.FourMomFillerTool)
The DRAssociation call makes the association. We'll look in SG
for a JetCollection called `Cone4H1TowerJets' and find the jet from
there that's closest in DR to the electron (but not farther away
than 0.2). If the electron prefix is `el_', then we'll automatically
create the variables `el_jet_matched' and `el_jet_dr'. The second
call then adds the jet kinematic variables: `el_jet_pt', etc.
Additional blocks can be added if desired.
Definition at line 17 of file DRAssociation.py.
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)