ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaPython
python
tests
PyTestsLib.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
# @file: AthenaPython/python/tests/PyTestsLib.py
4
# @purpose: a set of py-components to test various aspects of PyAthena
5
# @author: Sebastien Binet <binet@cern.ch>
6
7
__doc__ =
"""Module containing a set of py-components to test various aspects
8
of PyAthena.
9
"""
10
__author__ =
"Sebastien Binet <binet@cern.ch>"
11
12
import
AthenaCommon.SystemOfUnits
as
Units
13
import
AthenaPython.PyAthena
as
PyAthena
14
from
AthenaPython.PyAthena
import
StatusCode
15
16
class
MyAlg
(
PyAthena.Alg
):
17
"""Simple test of a py-algorithm
18
"""
19
def
__init__
(self, name = "MyAlg", **kw):
20
21
kw[
'name'
] = name
22
super(MyAlg,self).
__init__
(**kw)
23
24
self.
px
= kw.get(
'px'
, 10.*Units.GeV)
25
self.
eta
= kw.get(
'eta'
, 2.5)
26
self.
pt
= kw.get(
'pt'
, 40.*Units.GeV)
27
self.
mytool
= kw.get(
'mytool'
,
MyTool
(
"%s_mytool"
%self.
name
))
28
self.
filterPassed
= kw.get(
'filterPassed'
,
True
)
29
30
def
initialize
(self):
31
self.
sg
= PyAthena.py_svc(
"StoreGateSvc"
)
32
self.
msg
.info(
"==> initializing [%s]..."
, self.
name
)
33
self.
msg
.info(
"eta: %r"
,self.
eta
)
34
self.
msg
.info(
"pt: %r"
,self.
pt
)
35
self.
msg
.info(
"px: %r"
,self.
px
)
36
self.
mytool
.counter += 1
37
self.
msg
.info(
"tool:%r %r"
,self.
mytool
.counter, self.
mytool
.name )
38
return
StatusCode.Success
39
40
def
execute
(self):
41
_info = self.
msg
.info
42
_info(
"==> execute..."
)
43
45
_info(
"hasattr('_cppHandle'): %s"
, hasattr(self,
'_cppHandle'
))
46
self._cppHandle.
setFilterPassed
(self.
filterPassed
, self.getContext())
47
_info(
"has passed filter: %s"
, bool(self._cppHandle.
filterPassed
(self.getContext())))
48
return
StatusCode.Success
49
50
def
finalize
(self):
51
self.msg.info(
"==> finalize..."
)
52
return
StatusCode.Success
53
54
class
MySvc
(
PyAthena.Svc
):
55
"""Simple test of a py-service
56
"""
57
def
__init__
(self, name = "MySvc", **kw):
58
59
kw[
'name'
] = name
60
super(MySvc,self).
__init__
(**kw)
61
62
self.
counter
= kw.get(
'counter'
, 0)
63
64
def
initialize
(self):
65
self.
sg
= PyAthena.py_svc(
"StoreGateSvc"
)
66
self.msg.info(
"==> initializing [%s]..."
, self.
name
)
67
self.msg.info(
"cnt: %r"
,self.
counter
)
68
return
StatusCode.Success
69
70
def
finalize
(self):
71
self.msg.info(
"==> finalize..."
)
72
self.msg.info(
"cnt: %r"
,self.
counter
)
73
return
StatusCode.Success
74
75
class
MyTool
( PyAthena.AlgTool ):
76
"""Simple test of a py-tool
77
"""
78
def
__init__
(self, name = "MyTool", **kw):
79
80
kw[
'name'
] = name
81
super(MyTool,self).
__init__
(**kw)
82
83
self.
counter
= kw.get(
'counter'
, 0)
84
85
def
initialize
(self):
86
self.
sg
= PyAthena.py_svc(
"StoreGateSvc"
)
87
self.msg.info(
"==> initializing [%s]..."
, self.
name
)
88
self.msg.info(
"cnt: %r"
,self.
counter
)
89
return
StatusCode.Success
90
91
def
finalize
(self):
92
self.msg.info(
"==> finalize..."
)
93
self.msg.info(
"cnt: %r"
,self.
counter
)
94
return
StatusCode.Success
95
96
class
MyNameAud
(
PyAthena.Aud
):
97
"""Simple test of a py-auditor
98
"""
99
def
__init__
(self, name="MyNameAud", **kw):
100
101
kw[
'name'
] = name
102
super(MyNameAud,self).
__init__
(**kw)
103
104
def
initialize
(self):
105
self.msg.info(
"==> initializing [%s]..."
, self.
name
)
106
return
StatusCode.Success
107
108
def
finalize
(self):
109
self.msg.info(
"==> finalizing [%s]..."
, self.
name
)
110
return
StatusCode.Success
111
112
def
before
(self, evt_name, comp_name):
113
self.msg.info(
"Entering %s [%s]..."
, evt_name.lower(), comp_name)
114
return
115
116
def
after
(self, evt_name, comp_name, sc):
117
self.msg.info(
"Exiting %s [%s]..."
, evt_name.lower(), comp_name)
118
return
119
AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Definition
AthCommonAlgorithm.h:99
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
PyAthena::Alg
Definition
PyAthenaAlg.h:33
PyAthena::Alg::initialize
virtual StatusCode initialize() override
Definition
PyAthenaAlg.cxx:60
PyAthena::Aud
Definition
PyAthenaAud.h:32
PyAthena::Aud::initialize
virtual StatusCode initialize() override
Gaudi Aud Implementation.
Definition
PyAthenaAud.cxx:61
PyAthena::Aud::finalize
virtual StatusCode finalize() override
Definition
PyAthenaAud.cxx:87
PyAthena::Svc
Definition
PyAthenaSvc.h:33
PyAthena::Svc::finalize
virtual StatusCode finalize() override
Definition
PyAthenaSvc.cxx:71
PyAthena::Svc::initialize
virtual StatusCode initialize() override
Gaudi Service Implementation.
Definition
PyAthenaSvc.cxx:57
python.tests.PyTestsLib.MyAlg
Definition
PyTestsLib.py:16
python.tests.PyTestsLib.MyAlg.mytool
mytool
Definition
PyTestsLib.py:27
python.tests.PyTestsLib.MyAlg.execute
execute(self)
Definition
PyTestsLib.py:40
python.tests.PyTestsLib.MyAlg.px
px
Definition
PyTestsLib.py:24
python.tests.PyTestsLib.MyAlg.__init__
__init__(self, name="MyAlg", **kw)
Definition
PyTestsLib.py:19
python.tests.PyTestsLib.MyAlg.eta
eta
Definition
PyTestsLib.py:25
python.tests.PyTestsLib.MyAlg.pt
pt
Definition
PyTestsLib.py:26
python.tests.PyTestsLib.MyAlg.sg
sg
Definition
PyTestsLib.py:31
python.tests.PyTestsLib.MyAlg.name
name
Definition
PyTestsLib.py:32
python.tests.PyTestsLib.MyNameAud
Definition
PyTestsLib.py:96
python.tests.PyTestsLib.MyNameAud.name
name
Definition
PyTestsLib.py:105
python.tests.PyTestsLib.MyNameAud.before
before(self, evt_name, comp_name)
Definition
PyTestsLib.py:112
python.tests.PyTestsLib.MyNameAud.__init__
__init__(self, name="MyNameAud", **kw)
Definition
PyTestsLib.py:99
python.tests.PyTestsLib.MyNameAud.after
after(self, evt_name, comp_name, sc)
Definition
PyTestsLib.py:116
python.tests.PyTestsLib.MySvc
Definition
PyTestsLib.py:54
python.tests.PyTestsLib.MySvc.name
name
Definition
PyTestsLib.py:66
python.tests.PyTestsLib.MySvc.__init__
__init__(self, name="MySvc", **kw)
Definition
PyTestsLib.py:57
python.tests.PyTestsLib.MySvc.sg
sg
Definition
PyTestsLib.py:65
python.tests.PyTestsLib.MySvc.counter
counter
Definition
PyTestsLib.py:62
python.tests.PyTestsLib.MyTool
Definition
PyTestsLib.py:75
python.tests.PyTestsLib.MyTool.finalize
finalize(self)
Definition
PyTestsLib.py:91
python.tests.PyTestsLib.MyTool.counter
counter
Definition
PyTestsLib.py:83
python.tests.PyTestsLib.MyTool.__init__
__init__(self, name="MyTool", **kw)
Definition
PyTestsLib.py:78
python.tests.PyTestsLib.MyTool.name
name
Definition
PyTestsLib.py:87
python.tests.PyTestsLib.MyTool.sg
sg
Definition
PyTestsLib.py:86
python.tests.PyTestsLib.finalize
finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition
PyTestsLib.py:50
initialize
void initialize()
Definition
run_EoverP.cxx:894
Generated on
for ATLAS Offline Software by
1.17.0