The Gaudi Framework  v36r9p1 (5c15b2bb)
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 
91 if "__main__" == __name__:
92 
93  # make printout of the own documentations
94  print("*" * 120)
95  print(__doc__)
96  print(" Author : %s " % __author__)
97  print(" Date : %s " % __date__)
98  print("*" * 120)
99  sys.stdout.flush()
100 
101  configure()
102 
103  gaudi = AppMgr()
104 
105  gaudi.run(4)
106 
107  # add 'late' algorithms
108 
109  myAlg3 = SimpleAlgo("Simple3")
110 
111  seq = gaudi.algorithm("MySequencer")
112  seq.Members += ["HelloWorld/Hello4"]
113 
114  gaudi.run(8)
115 
116  seq.Members += [myAlg3.name()]
117 
118  gaudi.run(3)
119 
120 # =============================================================================
121 # The END
122 # =============================================================================
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