ATLAS Offline Software
ToolTest.py
Go to the documentation of this file.
1 
6 
7 # load dict for MyCutClass
8 import cppyy
9 cppyy.load_library("libPyAnalysisExamplesDict")
10 
11 
12 from AthenaCommon.AlgSequence import AlgSequence
13 topSequence = AlgSequence()
14 
15 # add my Algorithm
16 from PyAnalysisExamples.PyAnalysisExamplesConf import AthPyEx__MySelectionAlg
17 topSequence += AthPyEx__MySelectionAlg("MySelectionAlg")
18 
19 # add my Tool
20 from PyAnalysisExamples.PyAnalysisExamplesConf import AthPyEx__MyTool
21 from AthenaCommon.AppMgr import ToolSvc
22 ToolSvc += AthPyEx__MyTool("MyTool")
23 
24 # init application mgr
25 theApp.initialize()
26 
27 # retrieve AlgTool
28 tool = theApp.toolsvc().retrieve(ToolSvc.MyTool.getFullJobOptName())._itool
29 tool.setPython(tool)
30 
31 # set proxy
32 def convFunc():
33  ptr = cppyy.libPyROOT.MakeNullPointer(g.AthPyEx.MyObj)
34  proxy = g.PyReverseProxy.getProxy("MyObj_Proxy")
35  proxy.getObj(ptr)
36  return ptr
37 proxy = g.PyReverseProxy.getProxy("MyObj_Proxy")
38 proxy.setFunc(convFunc)
39 
40 counter=567
41 # callback
42 def py_execute(obj):
43  print ("PyExecute begin")
44  print (" name : %s" % obj.name())
45  print (" A : %s" % obj.getA())
46  print ("setA float in Python")
47  obj.setA(1.22)
48  print ("setA int in Python" )
49  global counter
50  obj.setA(counter)
51  counter += 1
52  print ("PyExecute end" )
53  return True
54 tool.py_execute = py_execute
55 
56 
57 # run 1 event
58 theApp.nextEvent()
59 
60 # set different parameter to AlgTool
61 tool.setA(50)
62 
63 # run 1 event
64 theApp.nextEvent()
65 
66 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ToolTest.py_execute
def py_execute(obj)
Definition: ToolTest.py:42
ToolTest.convFunc
def convFunc()
Definition: ToolTest.py:32
python.AlgSequence.AlgSequence
AlgSequence
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py:7