The Gaudi Framework  v36r4 (0a924e98)
Mix.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
18 """
19 Simple example to illustrate the problem for task #13911
20 https://savannah.cern.ch/task/?13911
21 """
22 from __future__ import print_function
23 
24 # =============================================================================
25 __author__ = "Vanya BELYAEV Ivan.Belyaev@itep.ru"
26 __date__ = "2010-04-24"
27 # =============================================================================
28 import sys
29 
30 from Configurables import GaudiSequencer, HelloWorld, Sequencer
31 from Gaudi.Configuration import *
32 from GaudiPython.Bindings import AppMgr
33 from GaudiPython.Bindings import gbl as cpp
34 from GaudiPython.Bindings import setOwnership
35 from GaudiPython.GaudiAlgs import SUCCESS, GaudiAlgo
36 
37 # =============================================================================
38 # @class SimpleAlgo
39 # very simple (empty) python algorith
40 # @author Vanya BELYAEV Ivan.Belyaev@itep.ru
41 # @date 2010-04-24
42 
43 
45  def execute(self):
46 
47  print("I am SimpleAlgo.execute! ", self.name())
48  sys.stdout.flush()
49 
50  return SUCCESS
51 
52 
53 # =============================================================================
54 # configure the application :
55 
56 
57 def configure():
58 
59  importOptions("Common.opts")
60 
62  TopAlg=[
63  HelloWorld(),
64  GaudiSequencer(
65  "MySequencer",
66  MeasureTime=True,
67  Members=[HelloWorld("Hello1"), HelloWorld("Hello2")],
68  ),
69  ],
70  # do not use any event input
71  EvtSel="NONE",
72  )
73 
74  gaudi = AppMgr()
75 
76  # create two "identical" algorithms:
77 
78  myAlg1 = SimpleAlgo("Simple1")
79  myAlg2 = SimpleAlgo("Simple2")
80 
81  # Adding something into TopAlg-sequence is OK:
82  gaudi.setAlgorithms([myAlg1] + gaudi.TopAlg)
83 
84  # Extending of "other"-sequences causes failures:
85  seq = gaudi.algorithm("MySequencer")
86 
87  seq.Members += ["HelloWorld/Hello3"] # it is ok
88  seq.Members += [myAlg2.name()] # it fails
89 
90  cpp.StatusCode.enableChecking()
91 
92 
93 if "__main__" == __name__:
94 
95  # make printout of the own documentations
96  print("*" * 120)
97  print(__doc__)
98  print(" Author : %s " % __author__)
99  print(" Date : %s " % __date__)
100  print("*" * 120)
101  sys.stdout.flush()
102 
103  configure()
104 
105  gaudi = AppMgr()
106 
107  gaudi.run(4)
108 
109  # add 'late' algorithms
110 
111  myAlg3 = SimpleAlgo("Simple3")
112 
113  seq = gaudi.algorithm("MySequencer")
114  seq.Members += ["HelloWorld/Hello4"]
115 
116  gaudi.run(8)
117 
118  seq.Members += [myAlg3.name()]
119 
120  gaudi.run(3)
121 
122 # =============================================================================
123 # The END
124 # =============================================================================
Mix.configure
def configure()
Definition: Mix.py:57
Mix.SimpleAlgo
Definition: Mix.py:44
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:873
Mix.SimpleAlgo.execute
def execute(self)
Definition: Mix.py:45
GaudiPython.GaudiAlgs.GaudiAlgo
Definition: GaudiAlgs.py:638
GaudiPython.Bindings
Definition: Bindings.py:1
Gaudi.Configuration
Definition: Configuration.py:1
GaudiKernel.ProcessJobOptions.importOptions
def importOptions(optsfile)
Definition: ProcessJobOptions.py:541
ApplicationMgr
Definition: ApplicationMgr.h:57
GaudiPython.GaudiAlgs
Definition: GaudiAlgs.py:1