The Gaudi Framework  master (82fdf313)
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-2025 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__
 
 update
 
 invalidate
 
 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__()

GaudiPython.Pythonizations.__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 378 of file Pythonizations.py.

378def __mapbase_contains__(self, key):
379 """
380 Check if the certainkey is in the map
381
382 >>> m = ... ## the map
383 >>> if 'a' in m : ... ## chekc the presence of the key in the map
384
385 """
386 _num = self.count(key)
387 return False if 0 == _num else True
388
389
390# ============================================
391# Get the value for certain key,
392# return predefined value otherwise
393#
394# @code
395#
396# >>> m = ... ## the map
397# >>> v = m.get( key , 15 ) ## return the value[key] for existing key, else 15
398#
399# @endcode
400# @see Gaudi::Utils::MapBase
401# @see GaudiUtils::Map
402# @see GaudiUtils::HashMap
403# @see GaudiUtils::VectorMap
404# @see GaudiUtils::Map::count
405# @see GaudiUtils::HashMap::count
406# @ see GaudiUtils::VectorMap::count
407# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
408# @date 2010-02-20
409
410

◆ __mapbase_delitem__()

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

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

Definition at line 515 of file Pythonizations.py.

515def __mapbase_delitem__(self, key):
516 """
517 'Del-item' for MapBase-based maps:
518
519 >>> m = ... ## the map
520 >>> del m[key]
521
522 """
523 _erased = True if key in self else False
524 self.erase(key)
525 return _erased
526
527

◆ __mapbase_get__()

GaudiPython.Pythonizations.__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 411 of file Pythonizations.py.

411def __mapbase_get__(self, key, value=None):
412 """
413 Get the value for the certain key, or 'value' otherwise
414
415 >>> m = ... ## the map
416 >>> v = m.get ( key , 15 )
417
418 """
419 if key in self:
420 return self.at(key)
421 return value
422
423
424# ============================================
425# Representation of MapBase-based maps
426#
427# @code
428#
429# >>> m = ... ## the map
430# >>> print(m)
431#
432# @endcode
433# @see Gaudi::Utils::MapBase
434# @see GaudiUtils::Map
435# @see GaudiUtils::HashMap
436# @see GaudiUtils::VectorMap
437# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
438# @date 2010-02-20
439
440

◆ __mapbase_items__()

GaudiPython.Pythonizations.__mapbase_items__ ( self)
Get the list of items

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

Definition at line 305 of file Pythonizations.py.

305def __mapbase_items__(self):
306 """
307 Get the list of items
308
309 >>> m = ... ## the map
310 >>> items = m.keys() ## get the list of items
311
312 """
313 _size = len(self)
314 _items = []
315 for i in range(0, _size):
316 _key = self.key_at(i)
317 _value = self.at(_key)
318 _items.append((_key, _value))
319 return _items
320
321
322# ============================================
323# Get the list of values for the map
324#
325# @code
326#
327# >>> m = ... ## the map
328# >>> values = m.values () ## get the list of values
329#
330# @endcode
331# @see Gaudi::Utils::MapBase
332# @see GaudiUtils::Map
333# @see GaudiUtils::HashMap
334# @see GaudiUtils::VectorMap
335# @see GaudiUtils::Map::value_at
336# @see GaudiUtils::HashMap::value_at
337# @ see GaudiUtils::VectorMap::value_at
338# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
339# @date 2010-02-20
340
341

◆ __mapbase_iter__()

GaudiPython.Pythonizations.__mapbase_iter__ ( self)
The iterator for MapBase-based containers

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

Definition at line 196 of file Pythonizations.py.

196def __mapbase_iter__(self):
197 """
198 The iterator for MapBase-based containers
199
200 >>> m = ... ## the map
201 >>> for key in m : print(key , m[key])
202
203 """
204 _size = len(self)
205 _index = 0
206 while _index < _size:
207 yield self.key_at(_index)
208 _index += 1
209
210
211# =============================================================================
212# The iterator for MapBase class
213#
214# @code
215#
216# >>> m = ... ## the map
217# >>> for key,value in m.iteritems() : print(key , value)
218#
219# @endcode
220# @see Gaudi::Utils::MapBase
221# @see GaudiUtils::Map
222# @see GaudiUtils::HashMap
223# @see GaudiUtils::VectorMap
224# @see GaudiUtils::Map::key_at
225# @see GaudiUtils::HashMap::key_at
226# @see GaudiUtils::VectorMap::key_at
227# @see GaudiUtils::Map::value_at
228# @see GaudiUtils::HashMap::value_at
229# @see GaudiUtils::VectorMap::value_at
230# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
231# @date 2010-02-20
232
233

◆ __mapbase_iteritems__()

GaudiPython.Pythonizations.__mapbase_iteritems__ ( self)
The iterator for MapBase-based containers

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

Definition at line 234 of file Pythonizations.py.

234def __mapbase_iteritems__(self):
235 """
236 The iterator for MapBase-based containers
237
238 >>> m = ... ## the map
239 >>> for key,value in m.iteritems() : print(key, value)
240
241 """
242 _size = len(self)
243 _index = 0
244 while _index < _size:
245 _key = self.key_at(_index)
246 yield (_key, self.at(_key))
247 _index += 1
248
249
250# ============================================
251# Get the list of keys for the map
252#
253# @code
254#
255# >>> m = ... ## the map
256# >>> keys = m.keys() ## get the list of keys
257#
258# @endcode
259# @see Gaudi::Utils::MapBase
260# @see GaudiUtils::Map
261# @see GaudiUtils::HashMap
262# @see GaudiUtils::VectorMap
263# @see GaudiUtils::Map::key_at
264# @see GaudiUtils::HashMap::key_at
265# @ see GaudiUtils::VectorMap::key_at
266# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
267# @date 2010-02-20
268
269

◆ __mapbase_keys__()

GaudiPython.Pythonizations.__mapbase_keys__ ( self)
Get the list of keys

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

Definition at line 270 of file Pythonizations.py.

270def __mapbase_keys__(self):
271 """
272 Get the list of keys
273
274 >>> m = ... ## the map
275 >>> keys = m.keys() ## get the list of keys
276
277 """
278 _size = len(self)
279 _keys = []
280 for i in range(0, _size):
281 _keys.append(self.key_at(i))
282 return _keys
283
284
285# ============================================
286# Get the list of items for the map
287#
288# @code
289#
290# >>> m = ... ## the map
291# >>> items = m.items() ## get the list of items
292#
293# @endcode
294# @see Gaudi::Utils::MapBase
295# @see GaudiUtils::Map
296# @see GaudiUtils::HashMap
297# @see GaudiUtils::VectorMap
298# @see GaudiUtils::Map::key_at
299# @see GaudiUtils::HashMap::key_at
300# @ see GaudiUtils::VectorMap::key_at
301# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
302# @date 2010-02-20
303
304

◆ __mapbase_setitem__()

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

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

Definition at line 481 of file Pythonizations.py.

481def __mapbase_setitem__(self, key, value):
482 """
483 'Set-item' for MapBase-based maps:
484
485 >>> m = ... ## the map
486 >>> m[key] = value ## set the item
487
488 """
489 _replaced = True if key in self else False
490 self.update(key, value)
491 return _replaced
492
493
494# ============================================
495# "Del-item" for MapBase-based maps:
496#
497# @code
498#
499# >>> m = ... ## the map
500# >>> del m [ key] ## del th eitem
501#
502# @endcode
503#
504# @see Gaudi::Utils::MapBase
505# @see GaudiUtils::Map
506# @see GaudiUtils::HashMap
507# @see GaudiUtils::VectorMap
508# @see GaudiUtils::Map::erase
509# @see GaudiUtils::HashMap::erase
510# @see GaudiUtils::VectorMap::erase
511# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
512# @date 2010-02-20
513
514

◆ __mapbase_str__()

GaudiPython.Pythonizations.__mapbase_str__ ( self)
Representation of MapBase-based maps:

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

Definition at line 441 of file Pythonizations.py.

441def __mapbase_str__(self):
442 """
443 Representation of MapBase-based maps:
444
445 >>> m = ... ## the map
446 >>> print(map)
447
448 """
449 _result = " { "
450 _size = len(self)
451 for i in range(0, _size):
452 _key = self.key_at(i)
453 _val = self.at(_key)
454 if 0 != i:
455 _result += " , "
456 _result += " %s : %s " % (str(_key), str(_val))
457 _result += " } "
458 return _result
459
460
461# ============================================
462# "Setitem" for MapBase-based maps:
463#
464# @code
465#
466# >>> m = ... ## the map
467# >>> m [ key] = value ## set the item
468#
469# @endcode
470# @see Gaudi::Utils::MapBase
471# @see GaudiUtils::Map
472# @see GaudiUtils::HashMap
473# @see GaudiUtils::VectorMap
474# @see GaudiUtils::Map::update
475# @see GaudiUtils::HashMap::update
476# @see GaudiUtils::VectorMap::update
477# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
478# @date 2010-02-20
479
480

◆ __mapbase_values__()

GaudiPython.Pythonizations.__mapbase_values__ ( self)
Get the list of values

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

Definition at line 342 of file Pythonizations.py.

342def __mapbase_values__(self):
343 """
344 Get the list of values
345
346 >>> m = ... ## the map
347 >>> values = m.values() ## get the list of values
348
349 """
350 _size = len(self)
351 _values = []
352 for i in range(0, _size):
353 _value = self.value_at(i)
354 _values.append(_value)
355 return _values
356
357
358# ============================================
359# Check if the certain key is in the map
360#
361# @code
362#
363# >>> m = ... ## the map
364# >>> if 'a' in m : print('key is in the map!')
365#
366# @endcode
367# @see Gaudi::Utils::MapBase
368# @see GaudiUtils::Map
369# @see GaudiUtils::HashMap
370# @see GaudiUtils::VectorMap
371# @see GaudiUtils::Map::count
372# @see GaudiUtils::HashMap::count
373# @ see GaudiUtils::VectorMap::count
374# @author Vanya BELYAEV Ivan.BElyaev@itep.ru
375# @date 2010-02-20
376
377

◆ _container__getitem__()

GaudiPython.Pythonizations._container__getitem__ ( self,
k )
protected

Definition at line 87 of file Pythonizations.py.

87def _container__getitem__(self, k):
88 return self.containedObject(k)
89
90

◆ _container__iter__()

GaudiPython.Pythonizations._container__iter__ ( self)
protected

Definition at line 95 of file Pythonizations.py.

95def _container__iter__(self):
96 if hasattr(self, "containedObjects"):
97 sequential = self.containedObjects()
98 else:
99 sequential = self
100 count = 0
101 limit = self.__len__()
102 while count < limit:
103 yield sequential.__getitem__(count)
104 count += 1
105
106

◆ _container__len__()

GaudiPython.Pythonizations._container__len__ ( self)
protected

Definition at line 91 of file Pythonizations.py.

91def _container__len__(self):
92 return self.numberOfObjects()
93
94

◆ _contentsHisto1D()

GaudiPython.Pythonizations._contentsHisto1D ( h)
protected

Definition at line 44 of file Pythonizations.py.

44def _contentsHisto1D(h):
45 x = h.axis()
46 return map(h.binEntries, range(x.bins()))
47
48

◆ _draw_aida_()

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

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

Definition at line 107 of file Pythonizations.py.

107def _draw_aida_(self, *args):
108 """
109 Draw AIDA histogram (through access to internal ROOT histogram
110
111 >>> aida = ... # get the historgam
112 >>> aida.Draw()
113
114 """
115 _fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
116 _root = _fun(self)
117 return _root.Draw(*args)
118
119

◆ _printBitReference()

GaudiPython.Pythonizations._printBitReference ( b)
protected

Definition at line 69 of file Pythonizations.py.

69def _printBitReference(b):
70 return str(1 == b.bool())
71
72

◆ _printFillStream()

GaudiPython.Pythonizations._printFillStream ( o)
protected

Definition at line 73 of file Pythonizations.py.

73def _printFillStream(o):
74 if o:
75 s = gbl.stringstream()
76 o.fillStream(s)
77 out = str(s.str())
78 if out == "":
79 out = o.__class__.__name__ + " object"
80 if hasattr(o, "hasKey") and o.hasKey():
81 out += " key = " + str(o.key())
82 else:
83 out = o.__class__.__name__ + " NULL object"
84 return out
85
86

◆ _printHisto1D()

GaudiPython.Pythonizations._printHisto1D ( h)
protected

Definition at line 34 of file Pythonizations.py.

34def _printHisto1D(h):
35 x = h.axis()
36 return 'Histogram 1D "%s" %d bins [%f,%f]' % (
37 h.title(),
38 x.bins(),
39 x.lowerEdge(),
40 x.upperEdge(),
41 )
42
43

◆ _printHisto2D()

GaudiPython.Pythonizations._printHisto2D ( h)
protected

Definition at line 49 of file Pythonizations.py.

49def _printHisto2D(h):
50 x, y = h.xAxis(), h.yAxis()
51 return 'Histogram 2D "%s" %d xbins [%f,%f], %d ybins [%f,%f]' % (
52 h.title(),
53 x.bins(),
54 x.lowerEdge(),
55 x.upperEdge(),
56 y.bins(),
57 y.lowerEdge(),
58 y.upperEdge(),
59 )
60
61

◆ _printStatusCode()

GaudiPython.Pythonizations._printStatusCode ( s)
protected

Definition at line 62 of file Pythonizations.py.

62def _printStatusCode(s):
63 if s.isSuccess():
64 return "SUCCESS"
65 else:
66 return "FAILURE"
67
68

Variable Documentation

◆ __all__

list GaudiPython.Pythonizations.__all__ = []
private

(c) Copyright 1998-2025 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 533 of file Pythonizations.py.

◆ __delitem__

GaudiPython.Pythonizations.__delitem__
private

Definition at line 538 of file Pythonizations.py.

◆ __getitem__

GaudiPython.Pythonizations.__getitem__
private

Definition at line 141 of file Pythonizations.py.

◆ __iter__

GaudiPython.Pythonizations.__iter__
private

Definition at line 143 of file Pythonizations.py.

◆ __iteritems__

GaudiPython.Pythonizations.__iteritems__
private

Definition at line 531 of file Pythonizations.py.

◆ __len__

GaudiPython.Pythonizations.__len__
private

Definition at line 142 of file Pythonizations.py.

◆ __repr__

GaudiPython.Pythonizations.__repr__
private

Definition at line 134 of file Pythonizations.py.

◆ __setitem__

GaudiPython.Pythonizations.__setitem__
private

Definition at line 537 of file Pythonizations.py.

◆ __str__

GaudiPython.Pythonizations.__str__
private

Definition at line 120 of file Pythonizations.py.

◆ _eq

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

Definition at line 160 of file Pythonizations.py.

◆ _execute_orig

GaudiPython.Pythonizations._execute_orig
protected

Definition at line 577 of file Pythonizations.py.

◆ _ne

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

Definition at line 165 of file Pythonizations.py.

◆ contents

GaudiPython.Pythonizations.contents

Definition at line 121 of file Pythonizations.py.

◆ ctx

GaudiPython.Pythonizations.ctx

Definition at line 578 of file Pythonizations.py.

◆ Draw

GaudiPython.Pythonizations.Draw

Definition at line 131 of file Pythonizations.py.

◆ execute

GaudiPython.Pythonizations.execute

Definition at line 578 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 574 of file Pythonizations.py.

◆ FAILURE

GaudiPython.Pythonizations.FAILURE

Definition at line 156 of file Pythonizations.py.

◆ filterPassed

GaudiPython.Pythonizations.filterPassed

Definition at line 576 of file Pythonizations.py.

◆ get

GaudiPython.Pythonizations.get

Definition at line 534 of file Pythonizations.py.

◆ invalidate

GaudiPython.Pythonizations.invalidate

Definition at line 148 of file Pythonizations.py.

◆ isExecuted

GaudiPython.Pythonizations.isExecuted

Definition at line 575 of file Pythonizations.py.

◆ items

GaudiPython.Pythonizations.items

Definition at line 540 of file Pythonizations.py.

◆ keys

GaudiPython.Pythonizations.keys

Definition at line 530 of file Pythonizations.py.

◆ plot

GaudiPython.Pythonizations.plot

Definition at line 132 of file Pythonizations.py.

◆ self

GaudiPython.Pythonizations.self

Definition at line 578 of file Pythonizations.py.

◆ SUCCESS

GaudiPython.Pythonizations.SUCCESS

Definition at line 155 of file Pythonizations.py.

◆ update

GaudiPython.Pythonizations.update

Definition at line 145 of file Pythonizations.py.

◆ values

GaudiPython.Pythonizations.values

Definition at line 532 of file Pythonizations.py.