The Gaudi Framework
master (6507eef1)
Toggle main menu visibility
Loading...
Searching...
No Matches
SuperAlgDynamicGraph.py
Go to the documentation of this file.
1
11
12
from
Configurables
import
AlgTimingAuditor, EventLoopMgr, GaudiTestSuiteCommonConf
13
from
Gaudi.Configuration
import
*
14
from
GaudiKernel.Configurable
import
SuperAlgorithm
15
16
19
20
21
GaudiTestSuiteCommonConf()
22
23
24
class
MySuperAlg
(
SuperAlgorithm
):
25
"""
26
Example implementation of a SuperAlgorithm specialization with behaviour
27
depending on a property.
28
29
In this case the boolean option UseHelloWorld defines if the HelloWorld
30
instance has to be used or not.
31
"""
32
33
def
__init__
(self, *args, **kwargs):
34
# preset the internal flag bypassing __setattr__
35
self.__dict__[
"_hello_flag"
] = kwargs.pop(
"UseHelloWorld"
,
True
)
36
super(MySuperAlg, self).
__init__
(*args, **kwargs)
37
38
# define setter and getter callbacks for UseHelloWorld
39
@property
40
def
UseHelloWorld
(self):
41
return
self.
_hello_flag
42
43
@UseHelloWorld.setter
44
def
UseHelloWorld
(self, value):
45
self.
_hello_flag
= value
46
# re-generate the graph (which takes into account the flag)
47
self.
graph
= self.
_initGraph
()
48
49
def
_initGraph
(self):
50
"""
51
Prepare the graph represented by the SuperAlgorithm.
52
"""
53
from
Configurables
import
Gaudi__TestSuite__EventCounter
as
EventCounter
54
from
Configurables
import
Gaudi__TestSuite__Prescaler
as
Prescaler
55
from
Configurables
import
HelloWorld
56
57
p = self.
_makeAlg
(Prescaler, name=
"Prescaler"
, PercentPass=50.0)
58
h = self.
_makeAlg
(HelloWorld, name=
"HW"
)
59
c = self.
_makeAlg
(EventCounter, name=
"Counter"
)
60
# the actual graph depends on the UseHelloWorld flag
61
return
(p & h & c)
if
self.
UseHelloWorld
else
(p & c)
62
63
64
s1 =
MySuperAlg
(
"s1"
, OutputLevel=INFO)
65
s2 =
MySuperAlg
(
"s2"
, OutputLevel=WARNING)
66
top = s1 >> s2
67
68
MySuperAlg
(
"s2"
, PercentPass=75, OutputLevel=DEBUG, UseHelloWorld=
False
)
69
70
print(
"# --- Configured Control Flow Expression:"
)
71
print(
"#"
, top)
72
print(
"# ---"
)
73
EventLoopMgr
(PrintControlFlowExpression=
True
)
74
75
# -----------------------------------------------------------------
76
ApplicationMgr
(
77
TopAlg=[top],
78
EvtMax=10,
# events to be processed (default is 10)
79
EvtSel=
"NONE"
,
# do not use any event input
80
ExtSvc=[
"ToolSvc"
,
"AuditorSvc"
,
"Gaudi::Monitoring::MessageSvcSink"
],
81
AuditAlgorithms=
True
,
82
)
83
84
AuditorSvc
().Auditors.append(
AlgTimingAuditor
(
"TIMER"
))
ApplicationMgr
The Application Manager class.
Definition
ApplicationMgr.h:54
AuditorSvc
This service manages Auditors.
Definition
AuditorSvc.h:22
EventLoopMgr
Class definition of EventLoopMgr.
Definition
EventLoopMgr.h:43
GaudiKernel.Configurable.SuperAlgorithm
Definition
Configurable.py:1842
GaudiKernel.Configurable.SuperAlgorithm._initGraph
_initGraph(self)
Definition
Configurable.py:1899
GaudiKernel.Configurable.SuperAlgorithm._makeAlg
_makeAlg(self, typ, **kwargs)
Definition
Configurable.py:1891
GaudiKernel.Configurable.SuperAlgorithm.graph
graph
Definition
Configurable.py:1866
SuperAlgDynamicGraph.MySuperAlg
Job options file.
Definition
SuperAlgDynamicGraph.py:24
SuperAlgDynamicGraph.MySuperAlg.UseHelloWorld
UseHelloWorld(self)
Definition
SuperAlgDynamicGraph.py:40
SuperAlgDynamicGraph.MySuperAlg._hello_flag
_hello_flag
Definition
SuperAlgDynamicGraph.py:45
SuperAlgDynamicGraph.MySuperAlg._initGraph
_initGraph(self)
Definition
SuperAlgDynamicGraph.py:49
SuperAlgDynamicGraph.MySuperAlg.__init__
__init__(self, *args, **kwargs)
Definition
SuperAlgDynamicGraph.py:33
Gaudi.Configuration
Definition
Configuration.py:1
GaudiKernel.Configurable
Definition
Configurable.py:1
SuperAlgDynamicGraph.UseHelloWorld
UseHelloWorld
Definition
SuperAlgDynamicGraph.py:68
AlgTimingAuditor
Definition
AlgTimingAuditor.cpp:22
GaudiTestSuite
options
ControlFlow
SuperAlgDynamicGraph.py
Generated on
for The Gaudi Framework by
1.17.0