ATLAS Offline Software
Loading...
Searching...
No Matches
python.POOL2EI_Lib.POOL2EISvc Class Reference
Inheritance diagram for python.POOL2EI_Lib.POOL2EISvc:
Collaboration diagram for python.POOL2EI_Lib.POOL2EISvc:

Public Member Functions

 __init__ (self, name='POOL2EISvc', **kw)
 initialize (self)
 finalize (self)
 handle (self, incident)
virtual StatusCode reinitialize () override
virtual StatusCode start () override
virtual StatusCode stop () override
virtual StatusCode sysInitialize () override
const char * typeName () const override
 return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part
virtual PyObjectself () override
 return associated python object.

Public Attributes

bool insideInputFile = False
 algo = kw['algo']

Protected Member Functions

virtual bool setPyAttr (PyObject *pyobj) override
 attach the C++ component to its python cousin

Protected Attributes

PyObjectm_self
 Pointer to self (from the python world)

Detailed Description

POOL2EI Service
Registers with the Incident Service so we can deal with:
  - Begin of new input file processing
  - End of input file processing
  - End of the event processing loop
and notify the POOL2EI algorithm accordingly

Definition at line 1005 of file POOL2EI_Lib.py.

Constructor & Destructor Documentation

◆ __init__()

python.POOL2EI_Lib.POOL2EISvc.__init__ ( self,
name = 'POOL2EISvc',
** kw )

Definition at line 1015 of file POOL2EI_Lib.py.

1015 def __init__(self, name='POOL2EISvc', **kw):
1016 super(POOL2EISvc, self).__init__(name, **kw)
1017 _info = self.msg.info
1018 _info("POOL2EISvc::__init__")
1019
1020 # whether we are inside beginFile ... endFile
1021 self.insideInputFile = False
1022
1023 # save algorithm to call on incident
1024 if 'algo' in kw:
1025 _info("POOL2EISvc::__init__ algo: {}".format(kw['algo']))
1026 self.algo = kw['algo']
1027

Member Function Documentation

◆ finalize()

python.POOL2EI_Lib.POOL2EISvc.finalize ( self)

Definition at line 1044 of file POOL2EI_Lib.py.

1044 def finalize(self):
1045 _info = self.msg.info
1046 _info("POOL2EISvc::finalize")
1047 return StatusCode.Success
1048

◆ handle()

python.POOL2EI_Lib.POOL2EISvc.handle ( self,
incident )

Definition at line 1049 of file POOL2EI_Lib.py.

1049 def handle(self, incident):
1050 # process registered incidents
1051
1052 _info = self.msg.info
1053 tp = incident.type()
1054 if tp == 'EndEvent':
1055 pass
1056 elif tp == 'BeginInputFile':
1057 _info('POOL2EISvc::handle BeginInputFile')
1058 self.insideInputFile = True
1059 self.algo.beginFile()
1060 elif tp == 'EndInputFile':
1061 _info('POOL2EISvc::handle EndInputFile')
1062 self.insideInputFile = False
1063 self.algo.endFile()
1064 elif tp == 'EndEvtLoop':
1065 _info('POOL2EISvc::handle EndEvtLoop')
1066 # when maxEvents is reached, we are still insideInputFile
1067 if self.insideInputFile:
1068 self.algo.endFile()
1069 else:
1070 _info('POOL2EISvc::handle {}. Unknown for POOL2EI'.format(tp))
1071 return
1072

◆ initialize()

python.POOL2EI_Lib.POOL2EISvc.initialize ( self)

Definition at line 1028 of file POOL2EI_Lib.py.

1028 def initialize(self):
1029 # register with the incident svc
1030 _info = self.msg.info
1031 _info("POOL2EISvc::initialize")
1032 incsvc = PyAthena.py_svc('IncidentSvc', iface='IIncidentSvc')
1033 if not incsvc:
1034 self.msg.error('unable to get the incident svc')
1035 return StatusCode.Failure
1036
1037 incsvc.addListener(self, 'BeginInputFile')
1038 incsvc.addListener(self, 'EndInputFile')
1039 incsvc.addListener(self, 'EndEvtLoop')
1040 incsvc.release()
1041
1042 return StatusCode.Success
1043
void initialize()

◆ reinitialize()

StatusCode PyAthena::Svc::reinitialize ( )
overridevirtualinherited

Definition at line 64 of file PyAthenaSvc.cxx.

65{
66 ATH_MSG_INFO("Re-Initializing " << name() << "...");
67 return PyAthena::callPyMethod( m_self, "sysReinitialize" );
68}
#define ATH_MSG_INFO(x)
PyObject * m_self
Pointer to self (from the python world)
Definition PyAthenaSvc.h:89

◆ self()

virtual PyObject * PyAthena::Svc::self ( )
inlineoverridevirtualinherited

return associated python object.

BORROWED reference.

Definition at line 68 of file PyAthenaSvc.h.

68{ return m_self; }

◆ setPyAttr()

bool PyAthena::Svc::setPyAttr ( PyObject * pyobj)
overrideprotectedvirtualinherited

attach the C++ component to its python cousin

Definition at line 154 of file PyAthenaSvc.cxx.

155{
156 // now we tell the PyObject which C++ object it is the cousin of.
157 RootUtils::PyGILStateEnsure ensure;
158 PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
159 ( (void*)this, this->typeName() );
160 if ( !pyobj ) {
161 PyErr_Clear();
162 // try PyAthena::Svc
163 pyobj = TPython::CPPInstance_FromVoidPtr ((void*)this, "PyAthena::Svc");
165 ("could not dyncast component [" << name() << "] to a python "
166 << "object of type [" << this->typeName() << "] (probably a missing "
167 << "dictionary)" << endmsg
168 << "fallback to [PyAthena::Svc]...");
169 }
170 if ( !pyobj ) {
171 PyErr_Clear();
173 ("Could not dyncast component [" << name() << "] to a pyobject of type ["
174 << this->typeName() << "]");
175 } else {
176 if ( -1 == PyObject_SetAttrString(o, "_cppHandle", pyobj) ) {
177 PyErr_Clear();
179 ("Could not attach C++ handle [" << name() << "] to its python "
180 << "cousin !");
181 if ( -1 == PyObject_SetAttrString(o, "_cppHandle", Py_None) ) {
182 PyErr_Clear();
184 ("could not attach a dummy C++ handle [" << name() << "] to its "
185 << "python cousin !");
186 }
187 } else {
188 return true;
189 }
190 }
191 return false;
192}
#define endmsg
#define ATH_MSG_WARNING(x)
_object PyObject
const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...

◆ start()

StatusCode PyAthena::Svc::start ( )
overridevirtualinherited

Definition at line 78 of file PyAthenaSvc.cxx.

79{
80 return PyAthena::callPyMethod( m_self, "sysStart" );
81}

◆ stop()

StatusCode PyAthena::Svc::stop ( )
overridevirtualinherited

Definition at line 84 of file PyAthenaSvc.cxx.

85{
86 return PyAthena::callPyMethod( m_self, "sysStop" );
87}

◆ sysInitialize()

StatusCode PyAthena::Svc::sysInitialize ( )
overridevirtualinherited

Definition at line 90 of file PyAthenaSvc.cxx.

91{
92 ServiceHandle<IPyComponentMgr> pyMgr
93 ( "PyAthena::PyComponentMgr/PyComponentMgr", name() );
94 if ( !pyMgr.retrieve().isSuccess() ) {
96 ("Could not retrieve service [" << pyMgr.typeAndName() << "] !!");
97 return StatusCode::FAILURE;
98 }
99
100 // first retrieve our python object cousin...
101 m_self = pyMgr->pyObject( this );
102
103 if ( m_self == Py_None ) {
104 ATH_MSG_ERROR("Wrapped PyObject is NONE !");
105 return StatusCode::FAILURE;
106 }
107
108 // re-route to usual sysInit...
109 return SvcBase_t::sysInitialize();
110}
#define ATH_MSG_ERROR(x)

◆ typeName()

const char * PyAthena::Svc::typeName ( ) const
overrideinherited

return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part

Definition at line 114 of file PyAthenaSvc.cxx.

115{
116 static const std::string tname = System::typeinfoName(typeid(*this));
117 return tname.c_str();
118}

Member Data Documentation

◆ algo

python.POOL2EI_Lib.POOL2EISvc.algo = kw['algo']

Definition at line 1026 of file POOL2EI_Lib.py.

◆ insideInputFile

bool python.POOL2EI_Lib.POOL2EISvc.insideInputFile = False

Definition at line 1021 of file POOL2EI_Lib.py.

◆ m_self

PyObject* PyAthena::Svc::m_self
protectedinherited

Pointer to self (from the python world)

Definition at line 89 of file PyAthenaSvc.h.


The documentation for this class was generated from the following file: