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