The Gaudi Framework  master (bdbe7744)
Loading...
Searching...
No Matches
GaudiPython.Pythonizations Namespace Reference

Functions

 _printHisto1D (h)
 _contentsHisto1D (h)
 _printHisto2D (h)
 _printStatusCode (s)
 _printBitReference (b)
 _printFillStream (o)
 _container__getitem__ (self, k)
 _container__len__ (self)
 _container__iter__ (self)
 _draw_aida_ (self, *args)
 __mapbase_iter__ (self)
 __mapbase_iteritems__ (self)
 __mapbase_keys__ (self)
 __mapbase_items__ (self)
 __mapbase_values__ (self)
 __mapbase_contains__ (self, key)
 __mapbase_get__ (self, key, value=None)
 __mapbase_str__ (self)
 __mapbase_setitem__ (self, key, value)
 __mapbase_delitem__ (self, key)

Variables

list __all__ = []
 (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE".
 __str__
 contents
 Draw
 plot
 __repr__
 __getitem__
 __len__
 __iter__
 SUCCESS
 FAILURE
 _eq = gbl.Gaudi.StringKey.__cpp_eq__
 _ne = gbl.Gaudi.StringKey.__cpp_ne__
 keys
 __iteritems__
 values
 __contains__
 get
 __setitem__
 __delitem__
 items
 executeEvent
 Helpers for re-entrant interfaces.
 isExecuted
 filterPassed
 _execute_orig
 execute
 self
 ctx

Function Documentation

◆ __mapbase_contains__()

__mapbase_contains__ ( self,
key )
Check if the certainkey is in the map

>>> m     = ...        ## the map
>>> if 'a' in m : ...  ##  chekc the presence of the key in the map

Definition at line 354 of file Pythonizations.py.

354def __mapbase_contains__(self, key):
355 """
356 Check if the certainkey is in the map
357
358 >>> m = ... ## the map
359 >>> if 'a' in m : ... ## chekc the presence of the key in the map
360
361 """
362 _num = self.count(key)
363 return False if 0 == _num else True
364
365
366# ============================================
367# Get the value for certain key,
368# return predefined value otherwise
369#
370# @code
371#
372# >>> m = ... ## the map
373# >>> v = m.get( key , 15 ) ## return the value[key] for existing key, else 15
374#
375# @endcode
376# @see Gaudi::Utils::MapBase
377# @see GaudiUtils::Map
378# @see GaudiUtils::HashMap
379# @see GaudiUtils::VectorMap
380# @see GaudiUtils::Map::count
381# @see GaudiUtils::HashMap::count
382# @ see GaudiUtils::VectorMap::count
383# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
384# @date 2010-02-20
385
386

◆ __mapbase_delitem__()

__mapbase_delitem__ ( self,
key )
'Del-item' for MapBase-based maps:

>>> m      = ...        ## the map
>>> del m[key]

Definition at line 491 of file Pythonizations.py.

491def __mapbase_delitem__(self, key):
492 """
493 'Del-item' for MapBase-based maps:
494
495 >>> m = ... ## the map
496 >>> del m[key]
497
498 """
499 _erased = True if key in self else False
500 self.erase(key)
501 return _erased
502
503

◆ __mapbase_get__()

__mapbase_get__ ( self,
key,
value = None )
Get the value for the certain key, or 'value' otherwise

>>> m     = ...        ## the map
>>> v = m.get ( key , 15 )

Definition at line 387 of file Pythonizations.py.

387def __mapbase_get__(self, key, value=None):
388 """
389 Get the value for the certain key, or 'value' otherwise
390
391 >>> m = ... ## the map
392 >>> v = m.get ( key , 15 )
393
394 """
395 if key in self:
396 return self.at(key)
397 return value
398
399
400# ============================================
401# Representation of MapBase-based maps
402#
403# @code
404#
405# >>> m = ... ## the map
406# >>> print(m)
407#
408# @endcode
409# @see Gaudi::Utils::MapBase
410# @see GaudiUtils::Map
411# @see GaudiUtils::HashMap
412# @see GaudiUtils::VectorMap
413# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
414# @date 2010-02-20
415
416

◆ __mapbase_items__()

__mapbase_items__ ( self)
Get the list of items

>>> m     = ...        ## the map
>>> items = m.keys()   ## get the list of items

Definition at line 281 of file Pythonizations.py.

281def __mapbase_items__(self):
282 """
283 Get the list of items
284
285 >>> m = ... ## the map
286 >>> items = m.keys() ## get the list of items
287
288 """
289 _size = len(self)
290 _items = []
291 for i in range(0, _size):
292 _key = self.key_at(i)
293 _value = self.at(_key)
294 _items.append((_key, _value))
295 return _items
296
297
298# ============================================
299# Get the list of values for the map
300#
301# @code
302#
303# >>> m = ... ## the map
304# >>> values = m.values () ## get the list of values
305#
306# @endcode
307# @see Gaudi::Utils::MapBase
308# @see GaudiUtils::Map
309# @see GaudiUtils::HashMap
310# @see GaudiUtils::VectorMap
311# @see GaudiUtils::Map::value_at
312# @see GaudiUtils::HashMap::value_at
313# @ see GaudiUtils::VectorMap::value_at
314# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
315# @date 2010-02-20
316
317

◆ __mapbase_iter__()

__mapbase_iter__ ( self)
The iterator for MapBase-based containers

>>> m = ...  ## the map
>>> for key in m : print(key , m[key])

Definition at line 172 of file Pythonizations.py.

172def __mapbase_iter__(self):
173 """
174 The iterator for MapBase-based containers
175
176 >>> m = ... ## the map
177 >>> for key in m : print(key , m[key])
178
179 """
180 _size = len(self)
181 _index = 0
182 while _index < _size:
183 yield self.key_at(_index)
184 _index += 1
185
186
187# =============================================================================
188# The iterator for MapBase class
189#
190# @code
191#
192# >>> m = ... ## the map
193# >>> for key,value in m.iteritems() : print(key , value)
194#
195# @endcode
196# @see Gaudi::Utils::MapBase
197# @see GaudiUtils::Map
198# @see GaudiUtils::HashMap
199# @see GaudiUtils::VectorMap
200# @see GaudiUtils::Map::key_at
201# @see GaudiUtils::HashMap::key_at
202# @see GaudiUtils::VectorMap::key_at
203# @see GaudiUtils::Map::value_at
204# @see GaudiUtils::HashMap::value_at
205# @see GaudiUtils::VectorMap::value_at
206# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
207# @date 2010-02-20
208
209

◆ __mapbase_iteritems__()

__mapbase_iteritems__ ( self)
The iterator for MapBase-based containers

>>> m = ...  ## the map
>>> for key,value in m.iteritems() : print(key, value)

Definition at line 210 of file Pythonizations.py.

210def __mapbase_iteritems__(self):
211 """
212 The iterator for MapBase-based containers
213
214 >>> m = ... ## the map
215 >>> for key,value in m.iteritems() : print(key, value)
216
217 """
218 _size = len(self)
219 _index = 0
220 while _index < _size:
221 _key = self.key_at(_index)
222 yield (_key, self.at(_key))
223 _index += 1
224
225
226# ============================================
227# Get the list of keys for the map
228#
229# @code
230#
231# >>> m = ... ## the map
232# >>> keys = m.keys() ## get the list of keys
233#
234# @endcode
235# @see Gaudi::Utils::MapBase
236# @see GaudiUtils::Map
237# @see GaudiUtils::HashMap
238# @see GaudiUtils::VectorMap
239# @see GaudiUtils::Map::key_at
240# @see GaudiUtils::HashMap::key_at
241# @ see GaudiUtils::VectorMap::key_at
242# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
243# @date 2010-02-20
244
245

◆ __mapbase_keys__()

__mapbase_keys__ ( self)
Get the list of keys

>>> m = ...           ## the map
>>> keys = m.keys()   ## get the list of keys

Definition at line 246 of file Pythonizations.py.

246def __mapbase_keys__(self):
247 """
248 Get the list of keys
249
250 >>> m = ... ## the map
251 >>> keys = m.keys() ## get the list of keys
252
253 """
254 _size = len(self)
255 _keys = []
256 for i in range(0, _size):
257 _keys.append(self.key_at(i))
258 return _keys
259
260
261# ============================================
262# Get the list of items for the map
263#
264# @code
265#
266# >>> m = ... ## the map
267# >>> items = m.items() ## get the list of items
268#
269# @endcode
270# @see Gaudi::Utils::MapBase
271# @see GaudiUtils::Map
272# @see GaudiUtils::HashMap
273# @see GaudiUtils::VectorMap
274# @see GaudiUtils::Map::key_at
275# @see GaudiUtils::HashMap::key_at
276# @ see GaudiUtils::VectorMap::key_at
277# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
278# @date 2010-02-20
279
280

◆ __mapbase_setitem__()

__mapbase_setitem__ ( self,
key,
value )
'Set-item' for MapBase-based maps:

>>> m      = ...        ## the map
>>> m[key] = value     ## set the item

Definition at line 457 of file Pythonizations.py.

457def __mapbase_setitem__(self, key, value):
458 """
459 'Set-item' for MapBase-based maps:
460
461 >>> m = ... ## the map
462 >>> m[key] = value ## set the item
463
464 """
465 _replaced = True if key in self else False
466 self.update(key, value)
467 return _replaced
468
469
470# ============================================
471# "Del-item" for MapBase-based maps:
472#
473# @code
474#
475# >>> m = ... ## the map
476# >>> del m [ key] ## del th eitem
477#
478# @endcode
479#
480# @see Gaudi::Utils::MapBase
481# @see GaudiUtils::Map
482# @see GaudiUtils::HashMap
483# @see GaudiUtils::VectorMap
484# @see GaudiUtils::Map::erase
485# @see GaudiUtils::HashMap::erase
486# @see GaudiUtils::VectorMap::erase
487# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
488# @date 2010-02-20
489
490

◆ __mapbase_str__()

__mapbase_str__ ( self)
Representation of MapBase-based maps:

>>> m     = ...        ## the map
>>> print(map)

Definition at line 417 of file Pythonizations.py.

417def __mapbase_str__(self):
418 """
419 Representation of MapBase-based maps:
420
421 >>> m = ... ## the map
422 >>> print(map)
423
424 """
425 _result = " { "
426 _size = len(self)
427 for i in range(0, _size):
428 _key = self.key_at(i)
429 _val = self.at(_key)
430 if 0 != i:
431 _result += " , "
432 _result += f" {_key} : {_val} "
433 _result += " } "
434 return _result
435
436
437# ============================================
438# "Setitem" for MapBase-based maps:
439#
440# @code
441#
442# >>> m = ... ## the map
443# >>> m [ key] = value ## set the item
444#
445# @endcode
446# @see Gaudi::Utils::MapBase
447# @see GaudiUtils::Map
448# @see GaudiUtils::HashMap
449# @see GaudiUtils::VectorMap
450# @see GaudiUtils::Map::update
451# @see GaudiUtils::HashMap::update
452# @see GaudiUtils::VectorMap::update
453# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
454# @date 2010-02-20
455
456

◆ __mapbase_values__()

__mapbase_values__ ( self)
Get the list of values

>>> m      = ...          ## the map
>>> values = m.values()   ## get the list of values

Definition at line 318 of file Pythonizations.py.

318def __mapbase_values__(self):
319 """
320 Get the list of values
321
322 >>> m = ... ## the map
323 >>> values = m.values() ## get the list of values
324
325 """
326 _size = len(self)
327 _values = []
328 for i in range(0, _size):
329 _value = self.value_at(i)
330 _values.append(_value)
331 return _values
332
333
334# ============================================
335# Check if the certain key is in the map
336#
337# @code
338#
339# >>> m = ... ## the map
340# >>> if 'a' in m : print('key is in the map!')
341#
342# @endcode
343# @see Gaudi::Utils::MapBase
344# @see GaudiUtils::Map
345# @see GaudiUtils::HashMap
346# @see GaudiUtils::VectorMap
347# @see GaudiUtils::Map::count
348# @see GaudiUtils::HashMap::count
349# @ see GaudiUtils::VectorMap::count
350# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
351# @date 2010-02-20
352
353

◆ _container__getitem__()

_container__getitem__ ( self,
k )
protected

Definition at line 76 of file Pythonizations.py.

76def _container__getitem__(self, k):
77 return self.containedObject(k)
78
79

◆ _container__iter__()

_container__iter__ ( self)
protected

Definition at line 84 of file Pythonizations.py.

84def _container__iter__(self):
85 if hasattr(self, "containedObjects"):
86 sequential = self.containedObjects()
87 else:
88 sequential = self
89 count = 0
90 limit = self.__len__()
91 while count < limit:
92 yield sequential.__getitem__(count)
93 count += 1
94
95

◆ _container__len__()

_container__len__ ( self)
protected

Definition at line 80 of file Pythonizations.py.

80def _container__len__(self):
81 return self.numberOfObjects()
82
83

◆ _contentsHisto1D()

_contentsHisto1D ( h)
protected

Definition at line 41 of file Pythonizations.py.

41def _contentsHisto1D(h):
42 x = h.axis()
43 return map(h.binEntries, range(x.bins()))
44
45

◆ _draw_aida_()

_draw_aida_ ( self,
* args )
protected
Draw AIDA histogram (through access to internal ROOT histogram

>>> aida = ...    # get the historgam
>>> aida.Draw()

Definition at line 96 of file Pythonizations.py.

96def _draw_aida_(self, *args):
97 """
98 Draw AIDA histogram (through access to internal ROOT histogram
99
100 >>> aida = ... # get the historgam
101 >>> aida.Draw()
102
103 """
104 _fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
105 _root = _fun(self)
106 return _root.Draw(*args)
107
108

◆ _printBitReference()

_printBitReference ( b)
protected

Definition at line 58 of file Pythonizations.py.

58def _printBitReference(b):
59 return str(1 == b.bool())
60
61

◆ _printFillStream()

_printFillStream ( o)
protected

Definition at line 62 of file Pythonizations.py.

62def _printFillStream(o):
63 if o:
64 s = gbl.stringstream()
65 o.fillStream(s)
66 out = str(s.str())
67 if out == "":
68 out = o.__class__.__name__ + " object"
69 if hasattr(o, "hasKey") and o.hasKey():
70 out += " key = " + str(o.key())
71 else:
72 out = o.__class__.__name__ + " NULL object"
73 return out
74
75

◆ _printHisto1D()

_printHisto1D ( h)
protected

Definition at line 34 of file Pythonizations.py.

34def _printHisto1D(h):
35 x = h.axis()
36 return (
37 f'Histogram 1D "{h.title()}" {x.bins()} bins [{x.lowerEdge()},{x.upperEdge()}]'
38 )
39
40

◆ _printHisto2D()

_printHisto2D ( h)
protected

Definition at line 46 of file Pythonizations.py.

46def _printHisto2D(h):
47 x, y = h.xAxis(), h.yAxis()
48 return f'Histogram 2D "{h.title()}" {x.bins()} xbins [{x.lowerEdge()},{x.upperEdge()}], {y.bins()} ybins [{y.lowerEdge()},{y.upperEdge()}]'
49
50

◆ _printStatusCode()

_printStatusCode ( s)
protected

Definition at line 51 of file Pythonizations.py.

51def _printStatusCode(s):
52 if s.isSuccess():
53 return "SUCCESS"
54 else:
55 return "FAILURE"
56
57

Variable Documentation

◆ __all__

list GaudiPython.Pythonizations.__all__ = []
private

(c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE".

# # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. #

File: GaudiPython/Pythonizations.py Author: Pere Mato (pere..nosp@m.mato.nosp@m.@cern.nosp@m..ch)

Definition at line 17 of file Pythonizations.py.

◆ __contains__

GaudiPython.Pythonizations.__contains__
private

Definition at line 509 of file Pythonizations.py.

◆ __delitem__

GaudiPython.Pythonizations.__delitem__
private

Definition at line 514 of file Pythonizations.py.

◆ __getitem__

GaudiPython.Pythonizations.__getitem__
private

Definition at line 130 of file Pythonizations.py.

◆ __iter__

GaudiPython.Pythonizations.__iter__
private

Definition at line 132 of file Pythonizations.py.

◆ __iteritems__

GaudiPython.Pythonizations.__iteritems__
private

Definition at line 507 of file Pythonizations.py.

◆ __len__

GaudiPython.Pythonizations.__len__
private

Definition at line 131 of file Pythonizations.py.

◆ __repr__

GaudiPython.Pythonizations.__repr__
private

Definition at line 123 of file Pythonizations.py.

◆ __setitem__

GaudiPython.Pythonizations.__setitem__
private

Definition at line 513 of file Pythonizations.py.

◆ __str__

GaudiPython.Pythonizations.__str__
private

Definition at line 109 of file Pythonizations.py.

◆ _eq

GaudiPython.Pythonizations._eq = gbl.Gaudi.StringKey.__cpp_eq__
protected

Definition at line 142 of file Pythonizations.py.

◆ _execute_orig

GaudiPython.Pythonizations._execute_orig
protected

Definition at line 553 of file Pythonizations.py.

◆ _ne

GaudiPython.Pythonizations._ne = gbl.Gaudi.StringKey.__cpp_ne__
protected

Definition at line 147 of file Pythonizations.py.

◆ contents

GaudiPython.Pythonizations.contents

Definition at line 110 of file Pythonizations.py.

◆ ctx

GaudiPython.Pythonizations.ctx

Definition at line 554 of file Pythonizations.py.

◆ Draw

GaudiPython.Pythonizations.Draw

Definition at line 120 of file Pythonizations.py.

◆ execute

GaudiPython.Pythonizations.execute

Definition at line 554 of file Pythonizations.py.

◆ executeEvent

GaudiPython.Pythonizations.executeEvent

Helpers for re-entrant interfaces.

GaudiPython is inherently single threaded and it's unpractical to use the new re-entrant interfaces. Moreover a lot of existing code (like GaudiMP) expects the old signatures.

Definition at line 550 of file Pythonizations.py.

◆ FAILURE

GaudiPython.Pythonizations.FAILURE

Definition at line 138 of file Pythonizations.py.

◆ filterPassed

GaudiPython.Pythonizations.filterPassed

Definition at line 552 of file Pythonizations.py.

◆ get

GaudiPython.Pythonizations.get

Definition at line 510 of file Pythonizations.py.

◆ isExecuted

GaudiPython.Pythonizations.isExecuted

Definition at line 551 of file Pythonizations.py.

◆ items

GaudiPython.Pythonizations.items

Definition at line 516 of file Pythonizations.py.

◆ keys

GaudiPython.Pythonizations.keys

Definition at line 506 of file Pythonizations.py.

◆ plot

GaudiPython.Pythonizations.plot

Definition at line 121 of file Pythonizations.py.

◆ self

GaudiPython.Pythonizations.self

Definition at line 554 of file Pythonizations.py.

◆ SUCCESS

GaudiPython.Pythonizations.SUCCESS

Definition at line 137 of file Pythonizations.py.

◆ values

GaudiPython.Pythonizations.values

Definition at line 508 of file Pythonizations.py.