The Gaudi Framework
master (37c0b60a)
ConfigurableUser.py
Go to the documentation of this file.
1
11
"""
12
Example of usage of ConfigurableUser classes (for high level configuration).
13
"""
14
15
from
Gaudi.Configuration
import
*
16
17
18
class
ExampleIO
(
ConfigurableUser
):
19
__slots__ = {
"EvtMax"
: 1,
"Read"
:
"NONE"
,
"Write"
:
"NONE"
}
20
__used_configurables__ = [ApplicationMgr]
21
22
def
__apply_configuration__
(self):
23
# Propagate the properties to all used configurables
24
# In this case the only effect is to set the ApplicationMgr EvtMax.
25
self.
propagateProperties
()
26
27
read = self.
getProp
(
"Read"
)
28
if
read ==
"NONE"
:
29
ApplicationMgr
(EvtSel=
"NONE"
)
30
else
:
31
log.warning(
32
"%s: Cannot handle value %r of property Read"
, self.
name
(), read
33
)
34
35
write = self.
getProp
(
"Write"
)
36
if
read ==
"NONE"
:
37
ApplicationMgr
(HistogramPersistency=
"NONE"
)
38
else
:
39
log.warning(
40
"%s: Cannot handle value %r of property Write"
, self.
name
(), write
41
)
42
43
44
class
ExampleCommon
(
ConfigurableUser
):
45
__slots__ = {
"OutputLevel"
: INFO}
46
__used_configurables__ = []
47
48
def
__apply_configuration__
(self):
49
MessageSvc
().OutputLevel = self.
getProp
(
"OutputLevel"
)
50
51
52
class
ExampleApplication
(
ConfigurableUser
):
53
__slots__ = {
54
"FullDebug"
:
False
,
55
"TopAlg"
: [],
56
}
57
__used_configurables__ = [ExampleCommon, ApplicationMgr]
58
59
def
__apply_configuration__
(self):
60
if
self.
getProp
(
"FullDebug"
):
61
ExampleCommon
(OutputLevel=VERBOSE)
62
else
:
63
ExampleCommon
(OutputLevel=INFO)
64
# Propagate the properties to all used configurables
65
# In this case the only effect is to set the ApplicationMgr TopAlg.
66
self.
propagateProperties
()
67
68
69
def
PostConfAction
():
70
"""
71
Action printing the result of the configuration of the ApplicationMgr.
72
"""
73
print(
"==== Configuration completed ===="
)
74
print(
ApplicationMgr
())
75
76
77
appendPostConfigAction
(PostConfAction)
78
79
ExampleApplication
(TopAlg=[
"GaudiTestSuite::TimingAlg/Timing"
], FullDebug=
True
)
80
ExampleIO
(EvtMax=10)
GaudiKernel.Configurable.ConfigurableUser
Definition:
Configurable.py:1361
ConfigurableUser.ExampleCommon
Definition:
ConfigurableUser.py:44
GaudiKernel.Configurable.ConfigurableUser.propagateProperties
def propagateProperties(self, names=None, others=None, force=True)
Definition:
Configurable.py:1517
GaudiKernel.Configurable.Configurable.getProp
def getProp(self, name)
Definition:
Configurable.py:773
ConfigurableUser.ExampleIO
Definition:
ConfigurableUser.py:18
ConfigurableUser.ExampleApplication.__apply_configuration__
def __apply_configuration__(self)
Definition:
ConfigurableUser.py:59
GaudiKernel.Configurable.Configurable.name
def name(self)
Definition:
Configurable.py:805
ConfigurableUser.ExampleCommon.__apply_configuration__
def __apply_configuration__(self)
Definition:
ConfigurableUser.py:48
GaudiKernel.Configurable.appendPostConfigAction
def appendPostConfigAction(function)
Definition:
Configurable.py:1581
Gaudi.Configuration
Definition:
Configuration.py:1
MessageSvc
Definition:
MessageSvc.h:40
ConfigurableUser.ExampleApplication
Definition:
ConfigurableUser.py:52
ConfigurableUser.PostConfAction
def PostConfAction()
Definition:
ConfigurableUser.py:69
ApplicationMgr
Definition:
ApplicationMgr.h:57
ConfigurableUser.ExampleIO.__apply_configuration__
def __apply_configuration__(self)
Definition:
ConfigurableUser.py:22
GaudiTestSuite
options
ConfigurableUser.py
Generated on Thu Dec 19 2024 15:35:06 for The Gaudi Framework by
1.8.18