The Gaudi Framework  v36r1 (3e2fb5a8)
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 __author__ = "Vanya BELYAEV Ivan.Belyaev@itep.ru"
25 __date__ = "2010-04-24"
26 # =============================================================================
27 import sys
28 
29 from Gaudi.Configuration import *
30 from Configurables import HelloWorld, GaudiSequencer, Sequencer
31 
32 from GaudiPython.Bindings import AppMgr, setOwnership
33 from GaudiPython.Bindings import gbl as cpp
34 from GaudiPython.GaudiAlgs import GaudiAlgo, SUCCESS
35 
36 # =============================================================================
37 # @class SimpleAlgo
38 # very simple (empty) python algorith
39 # @author Vanya BELYAEV Ivan.Belyaev@itep.ru
40 # @date 2010-04-24
41 
42 
44  def execute(self):
45 
46  print('I am SimpleAlgo.execute! ', self.name())
47  sys.stdout.flush()
48 
49  return SUCCESS
50 
51 
52 # =============================================================================
53 # configure the application :
54 
55 
56 def configure():
57 
58  importOptions('Common.opts')
59 
61  TopAlg=[
62  HelloWorld(),
63  GaudiSequencer(
64  'MySequencer',
65  MeasureTime=True,
66  Members=[HelloWorld('Hello1'),
67  HelloWorld('Hello2')])
68  ],
69  # do not use any event input
70  EvtSel='NONE')
71 
72  gaudi = AppMgr()
73 
74  # create two "identical" algorithms:
75 
76  myAlg1 = SimpleAlgo('Simple1')
77  myAlg2 = SimpleAlgo('Simple2')
78 
79  # Adding something into TopAlg-sequence is OK:
80  gaudi.setAlgorithms([myAlg1] + gaudi.TopAlg)
81 
82  # Extending of "other"-sequences causes failures:
83  seq = gaudi.algorithm('MySequencer')
84 
85  seq.Members += ['HelloWorld/Hello3'] # it is ok
86  seq.Members += [myAlg2.name()] # it fails
87 
88  cpp.StatusCode.enableChecking()
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:56
Mix.SimpleAlgo
Definition: Mix.py:43
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:842
Mix.SimpleAlgo.execute
def execute(self)
Definition: Mix.py:44
GaudiPython.GaudiAlgs.GaudiAlgo
Definition: GaudiAlgs.py:639
GaudiPython.Bindings
Definition: Bindings.py:1
Gaudi.Configuration
Definition: Configuration.py:1
GaudiKernel.ProcessJobOptions.importOptions
def importOptions(optsfile)
Definition: ProcessJobOptions.py:491
ApplicationMgr
Definition: ApplicationMgr.h:57
GaudiPython.GaudiAlgs
Definition: GaudiAlgs.py:1