ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
D3PDMakerCoreComps
python
MakerAlgConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
#
3
# @file D3PDMakerCoreComps/python/MakerAlgConfig.py
4
# @author scott snyder <snyder@bnl.gov>
5
# @date Dec 2023, from old config
6
# @brief Configure algorithm for making a D3PD tree.
7
#
8
9
10
from
AthenaConfiguration.ComponentFactory
import
CompFactory
11
from
D3PDMakerCoreComps.D3PDObject
import
D3PDObject
12
from
D3PDMakerConfig.D3PDMakerFlags
import
D3PDMakerFlags
13
14
D3PD = CompFactory.D3PD
15
16
17
class
MakerAlg
:
18
def
__init__
(self, name, flags, acc, registry, *args, **kw):
19
self.
alg
=
D3PD.MakerAlg
(name, *args, **kw)
20
self.
registry
= registry
21
self.
flags
= flags
22
self.
acc
= acc
23
return
24
25
26
def
__iadd__
( self, configs ):
27
"""Add a new IObjFillerTool to a tree."""
28
29
# FIXME: should make sure name is unique within alg.
30
nchild = len (self.
alg
.Tools)
31
if
not
isinstance(configs, list):
32
configs = [configs]
33
self.
alg
.Tools += configs
34
35
for
c
in
self.
alg
.Tools[nchild:]:
36
# Scan children to set the proper collection getter registry.
37
self.
_setRegistry
(c)
38
39
D3PDObject.runHooks (c, self.
flags
, self.
acc
)
40
return
self
41
42
43
def
_setRegistry
(self, conf):
44
"""Scan CONF and all children to set the proper
45
collection getter registry for this tree.
46
"""
47
48
if
'CollectionGetterRegistry'
in
conf.getDefaultProperties():
49
conf.CollectionGetterRegistry = self.
registry
50
if
'BlockFillers'
in
conf.getDefaultProperties():
51
for
c
in
conf.BlockFillers:
52
self.
_setRegistry
(c)
53
D3PDObject.runHooks (c, self.
flags
, self.
acc
)
54
if
'Getter'
in
conf.getDefaultProperties():
55
self.
_setRegistry
(conf.Getter)
56
if
'SelectionGetter'
in
conf.getDefaultProperties():
57
self.
_setRegistry
(conf.SelectionGetter)
58
if
'Associator'
in
conf.getDefaultProperties():
59
self.
_setRegistry
(conf.Associator)
60
return
61
62
63
def
MakerAlgConfig (flags, acc, stream, file,
64
clevel = D3PDMakerFlags.CompressionLevel,
65
autoflush = D3PDMakerFlags.AutoFlush,
66
ExistDataHeader = True, **kw):
67
"""Configure algorithm for making a D3PD tree.
68
69
Each distinct D3PD tree is make by a separate algorithm.
70
This function is used to configure these algorithms.
71
72
Arguments:
73
74
flags: The configuration flags.
75
name: The name of the algorithm (required).
76
stream: Athena stream for the tuple.
77
file: Name of the file containing the tuple.
78
If it starts with `pool:', then the tree is being emitted
79
into a POOL file. In that case, stream is just the name
80
of the tree.
81
clevel: Compresson level for the output ROOT file. By default it is
82
controlled by the D3PDMakerFlags.CompressionLevel flag, but
83
can be controlled D3PD-by-D3PD as well.
84
autoflush: Allows overriding the global autoflush setting.
85
"""
86
87
88
89
90
name = stream +
'D3PDMaker'
91
tuplename = stream
92
93
if
file.startswith (
'pool:'
):
94
acc.addService (
D3PD.RootD3PDSvc
(AutoFlush = autoflush,
95
IndexMajor =
''
,
96
IndexMinor =
''
))
97
98
TuplePath = f
'{file}/{tuplename}'
99
100
else
:
101
102
acc.addService (CompFactory.THistSvc (Output = [
103
f
"{stream} DATAFILE='{file}' OPT='RECREATE' CL={clevel}"
]))
104
105
acc.addService (
D3PD.RootD3PDSvc
(AutoFlush = autoflush))
106
107
st = CompFactory.AANTupleStream (stream,
108
ExtraRefNames = [
'StreamESD'
,
109
'StreamRDO'
,
110
'StreamAOD'
],
111
OutputName = file,
112
ExistDataHeader = ExistDataHeader,
113
WriteInputDataHeader =
True
,
114
StreamName = stream)
115
acc.addEventAlgo (st)
116
117
TuplePath = f
'/{stream}/{tuplename}'
118
119
120
registry =
D3PD.CollectionGetterRegistryTool
(name +
'_CollectionGetterRegistry'
)
121
acc.addPublicTool (registry)
122
123
acc.addEventAlgo (
D3PD.DummyInitAlg
(name +
'DummyInit'
))
124
125
alg = MakerAlg (name, flags, acc,
126
registry = registry,
127
TuplePath = TuplePath,
128
**kw)
129
130
return
alg
D3PD::CollectionGetterRegistryTool
Tool to keep a registry of collection getter tools.
Definition
CollectionGetterRegistryTool.h:47
D3PD::DummyInitAlg
Work around initialization ordering problems.
Definition
DummyInitAlg.h:40
D3PD::MakerAlg
Algorithm to create a D3PD tree.
Definition
MakerAlg.h:46
D3PD::RootD3PDSvc
Service to create a root-based D3PD.
Definition
RootD3PDSvc.h:39
python.MakerAlgConfig.MakerAlg
Definition
MakerAlgConfig.py:17
python.MakerAlgConfig.MakerAlg.__init__
__init__(self, name, flags, acc, registry, *args, **kw)
Definition
MakerAlgConfig.py:18
python.MakerAlgConfig.MakerAlg._setRegistry
_setRegistry(self, conf)
Definition
MakerAlgConfig.py:43
python.MakerAlgConfig.MakerAlg.acc
acc
Definition
MakerAlgConfig.py:22
python.MakerAlgConfig.MakerAlg.__iadd__
__iadd__(self, configs)
Definition
MakerAlgConfig.py:26
python.MakerAlgConfig.MakerAlg.alg
alg
Definition
MakerAlgConfig.py:19
python.MakerAlgConfig.MakerAlg.flags
flags
Definition
MakerAlgConfig.py:21
python.MakerAlgConfig.MakerAlg.registry
registry
Definition
MakerAlgConfig.py:20
Generated on
for ATLAS Offline Software by
1.17.0