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