The Gaudi Framework  v36r1 (3e2fb5a8)
ExtendedProperties2.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
13 """
14 *******************************************************************************
15 * *
16 * Simple example which illustrate the extended job-properties and their *
17 * *
18 *******************************************************************************
19 """
20 from __future__ import print_function
21 # =============================================================================
22 __author__ = 'Vanya BELYAEV ibelyaev@physics.syr.edu'
23 # =============================================================================
24 # @file
25 # Simple example (identical to C++ ExtendedProperties.opts) which illustrates
26 # the extended job-properties and their C++/Python intercommunication
27 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
28 # @date 2007-02-13
29 # =============================================================================
30 from Gaudi.Configuration import *
31 
32 from Configurables import ApplicationMgr
33 
34 from Configurables import Gaudi__Examples__ExtendedProperties2 as EP2
35 
36 # Flag to check if we are running on Windows, where LorentzVectors cannot be used as properties
37 import sys
38 isWin = sys.platform.startswith("win")
39 
40 ep2 = EP2("xProps2", Point3D=(10, 40, 55), Points3D=[(10, 40, 55), (1, 2, 3)])
41 
42 ApplicationMgr(EvtSel="NONE", TopAlg=[ep2], EvtMax=10)
43 
44 # =============================================================================
45 # The actual job excution
46 # =============================================================================
47 if '__main__' == __name__:
48 
49  print(__doc__, __author__)
50 
51  # make sure cling can generate all required methods in Gaudi::Property
52  # Workaround for ROOT-10769
53  import warnings
54  with warnings.catch_warnings():
55  warnings.simplefilter("ignore")
56  import cppyy
57  for h in ("GaudiKernel/SVectorAsProperty.h",
58  "GaudiKernel/VectorsAsProperty.h"):
59  cppyy.gbl.gInterpreter.Declare('#include "%s"' % h)
60 
61  from GaudiPython.Bindings import AppMgr
62 
63  gaudi = AppMgr()
64 
65  gaudi.run(5)
66 
67  xp2 = gaudi.algorithm('xProps2')
68 
69  xp2.Point3D = '(-10,3, Z : 24)'
70  xp2.Vector3D = [-120, -30, -40]
71  if not isWin:
72  xp2.Vector4D = [-100, -200, -300, 400]
73  xp2.Vector4D = (-100, -200, -300, 400)
74  xp2.Vector4D = [(-100, -200, -300), 400]
75  xp2.Vector4D = [[-100, -200, -300], 400]
76  xp2.Vector4D = ((-100, -200, -300), 400)
77  xp2.Vector4D = ([-100, -200, -300], 400)
78 
79  xp2.SVector5 = (1, 2, 3, 4, 5)
80 
81  xp2.SVector5 = [1, 2, 3, 4, 5]
82 
83  try:
84  xp2.SVector5 = [1, 2, 3, 4, 5, 6]
85  except Exception as e:
86  print(' Exception: ', e)
87 
88  try:
89  xp2.Point3D = (1, 2, 3, 4)
90  except Exception as e:
91  print(' Exception: ', e)
92 
93  if not isWin:
94  try:
95  xp2.Vector4D = (1, 2, 3)
96  except Exception as e:
97  print(' Exception: ', e)
98 
99  xp2.Vectors3D = [(1, 2, 3), (4, 5, 6), [7, 8, 9]]
100  if not isWin:
101  xp2.Vectors4D = ((1, 2, 3, 4), [4, 5, 6, 7])
102 
103  xp2.PropertiesPrint = True
104 
105 # =============================================================================
106 # The END
107 # =============================================================================
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:842
GaudiPython.Bindings
Definition: Bindings.py:1
Gaudi.Configuration
Definition: Configuration.py:1