ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
EventCommonD3PDMaker
python
DRAssociation.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 EventCommonD3PDMaker/python/DRAssociation.py
5
# @author scott snyder <snyder@bnl.gov>
6
# @date Aug, 2009
7
# @brief Helper for setting up a nearest-DR association to a contained object.
8
#
9
10
11
from
D3PDMakerCoreComps.D3PDObject
import
D3PDObject
12
from
AthenaConfiguration.ComponentFactory
import
CompFactory
13
14
D3PD = CompFactory.D3PD
15
16
17
def
DRAssociation (parent,
18
type_name,
19
default_sgkey,
20
default_drcut,
21
prefix = '',
22
matched = 'matched',
23
level = 0,
24
blockname = None,
25
*args, **kw):
26
"""Helper for setting up a nearest-DR association to a contained object.
27
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.
31
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.
42
43
Extra arguments are passed to the association tool.
44
45
Here's an example. Suppose we have an electron object, and we
46
want to record the 4-vector of a matching jet.
47
48
Usage is something like this:
49
50
ElectronObject = ...
51
52
EleJetAssoc = DRAssociation (ElectronObject,
53
'JetCollection',
54
'Cone4H1TowerJets',
55
0.2,
56
'jet_',
57
level = 2,
58
blockname = 'JetMatch')
59
EleJetAssoc.defineBlock (2, 'JetKinematics',
60
D3PD.FourMomFillerTool)
61
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.
69
"""
70
if
blockname
is
None
:
71
blockname = prefix +
'DRAssoc'
72
73
def
maker (name, prefix, object_name,
74
sgkey = default_sgkey,
75
getter = None,
76
assoc = None,
77
drcut = default_drcut):
78
79
if
not
getter:
80
getter =
D3PD.SGDataVectorGetterTool
\
81
(name +
'_Getter'
,
82
TypeName = type_name,
83
SGKey = sgkey)
84
if
not
assoc:
85
assoc = D3PD.DRAssociationTool (name +
'Assoc'
,
86
Getter = getter,
87
DRCut = drcut)
88
89
return
D3PD.ContainedAssociationFillerTool
(name,
90
Prefix = prefix,
91
Associator = assoc,
92
Matched = matched)
93
94
obj = D3PDObject (maker, prefix)
95
parent.defineBlock (level, blockname, obj)
96
return
obj
D3PD::ContainedAssociationFillerTool
Represent a single association by containment.
Definition
ContainedAssociationFillerTool.h:54
D3PD::SGDataVectorGetterTool
Getter tool to retrieve DataVector/List collections from StoreGate.
Definition
SGDataVectorGetterTool.h:55
Generated on
for ATLAS Offline Software by
1.17.0