7 __doc__ =
"""Module containing a set of Python base classes for PyAthena"""
8 __author__ =
"Sebastien Binet <binet@cern.ch>"
11 __all__ = [
'StatusCode',
23 from AthenaPython.Configurables
import (CfgPyAlgorithm,
31 """A convenient class to access py-components by name
35 self.__setattr__(k, weakref.ref(v))
38 services.__doc__ =
"""The list of PyAthena::Svc which have been instantiated"""
39 services.__setattr__ = __wk_setattr__
42 algs.__doc__ =
"""The list of PyAthena::Alg which have been instantiated"""
43 algs.__setattr__ = __wk_setattr__
49 if propname
in pycomp.properties()
and pycomp.properties()[propname] != pycomp.propertyNoValue:
50 return pycomp.properties()[propname]
52 return pycomp.getDefaultProperty(propname)
62 class Alg( CfgPyAlgorithm ):
64 Base class from which all concrete algorithm classes should
67 In order for a concrete algorithm class to do anything
68 useful the methods initialize(), execute() and finalize()
72 if name
is None: name = kw.get(
'name', self.__class__.__name__)
73 kw.setdefault(
'OutputLevel', 3)
75 super(Alg, self).
__init__(name, **kw)
87 import AthenaPython.PyAthena
as PyAthena
94 import AthenaPython.PyAthena
as PyAthena
101 import AthenaPython.PyAthena
as PyAthena
106 if hasattr(self,
'OutputLevel'):
113 return StatusCode.Success
116 if hasattr(self,
'OutputLevel'):
123 return StatusCode.Success
127 self.
_ctx = cppyy.bind_object(cppcontext,
"EventContext")
135 return StatusCode.Success
141 return StatusCode.Success
147 return StatusCode.Success
153 return StatusCode.Success
156 """Did this algorithm pass or fail its filter criterion for the last event?"""
160 """Set the filter passed flag to the specified state"""
165 return StatusCode.Success
179 class Svc( CfgPyService ):
180 """Base class for all services
183 kw.setdefault(
'OutputLevel', 3)
184 if name
is None: name = kw.get(
'name', self.__class__.__name__)
186 super(Svc, self).
__init__(name, **kw)
191 if hasattr(self,
'OutputLevel'):
198 return StatusCode.Success
201 if hasattr(self,
'OutputLevel'):
208 return StatusCode.Success
214 return StatusCode.Success
220 return StatusCode.Success
226 return StatusCode.Success
233 Base class from which all concrete algtool classes should be derived.
237 kw.setdefault(
'OutputLevel', 3)
238 if name
is None: name = kw.get(
'name', self.__class__.__name__)
239 if not (parent
is None):
240 if isinstance(parent, str): name =
"%s.%s" % (parent,name)
241 else: name =
"%s.%s" % (parent.name(),name)
243 super(AlgTool, self).
__init__(name, **kw)
253 import AthenaPython.PyAthena
as PyAthena
260 import AthenaPython.PyAthena
as PyAthena
267 import AthenaPython.PyAthena
as PyAthena
272 if hasattr(self,
'OutputLevel'):
279 raise NotImplementedError(
280 "You have to implement PyAthena.AlgTool.initialize() !"
284 if hasattr(self,
'OutputLevel'):
291 self.msg.
info(
"==> re-initialize..." )
292 return StatusCode.Success
298 raise NotImplementedError(
299 "You have to implement PyAthena.AlgTool.finalize() !"
307 Base class from which all concrete auditor classes should be derived.
310 kw.setdefault(
'OutputLevel', 3)
311 if name
is None: name = kw.get(
'name', self.__class__.__name__)
313 super(Aud, self).
__init__(name, **kw)
317 if hasattr(self,
'OutputLevel'):
324 raise NotImplementedError(
325 "You have to implement PyAthena.Aud.initialize() !"
332 raise NotImplementedError(
333 "You have to implement PyAthena.Aud.finalize() !"
341 def after (self, evt_name, comp_name):
348 """base class for a filter algorithm, making use of the cutflow-svc.
350 instances of this class (and its derived class) shall have:
351 - a `cutID` attribute of type `CutIdentifier*` from `initialize`
352 (included) and onwards,
353 - a `cutFlowSvc()` method from `initialize` (included) and onwards.
355 The `cutID` attribute is the CutIdentifier returned by the `ICutFlowSvc`
356 when `self` registered itself with the `ICutFlowSvc`.
358 _dflt_FilterDescription=
'N/A'
362 name = kw.get(
'name', self.__class__.__name__)
364 kw.setdefault(
'OutputLevel', 3)
367 super(AthFilterAlgorithm, self).
__init__(**kw)
371 AthFilterAlgorithm._dflt_FilterDescription)
372 '''describes to the cutflowsvc what this filter does.'''
380 FilterDescription = property(_get_filter_descr,
382 doc=
'describes to the cutflowsvc what this filter does.')
385 if not hasattr(self,
'_cutflowsvc'):
386 import AthenaPython.PyAthena
as PyAthena
392 """This function updates self's CutFlow description if (and only if)
393 it has not been explicitely set during the python-level configuration
395 if hasattr(self,
'cutID'):
399 self.msg.
error(
"AthFilterAlg has no self.cutID: could not set filter description.")
403 if hasattr(self,
'OutputLevel'):
407 myName=self.
name()
if callable(self.
name)
else self.
name
410 self.msg.
error(
"could not register filter-cut with cutflowsvc")
411 return StatusCode.Failure
416 """Set the filter passed flag to the specified state"""