The Gaudi Framework  master (b9786168)
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 372 of file Pythonizations.py.

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

◆ __mapbase_delitem__()

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

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

Definition at line 509 of file Pythonizations.py.

509def __mapbase_delitem__(self, key):
510 """
511 'Del-item' for MapBase-based maps:
512
513 >>> m = ... ## the map
514 >>> del m[key]
515
516 """
517 _erased = True if key in self else False
518 self.erase(key)
519 return _erased
520
521

◆ __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 405 of file Pythonizations.py.

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

◆ __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 299 of file Pythonizations.py.

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

◆ __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 190 of file Pythonizations.py.

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

◆ __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 228 of file Pythonizations.py.

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

◆ __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 264 of file Pythonizations.py.

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

◆ __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 475 of file Pythonizations.py.

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

◆ __mapbase_str__()

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

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

Definition at line 435 of file Pythonizations.py.

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

◆ __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 336 of file Pythonizations.py.

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

◆ _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 527 of file Pythonizations.py.

◆ __delitem__

GaudiPython.Pythonizations.__delitem__
private

Definition at line 532 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 525 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 531 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 571 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 572 of file Pythonizations.py.

◆ Draw

GaudiPython.Pythonizations.Draw

Definition at line 131 of file Pythonizations.py.

◆ execute

GaudiPython.Pythonizations.execute

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

◆ FAILURE

GaudiPython.Pythonizations.FAILURE

Definition at line 156 of file Pythonizations.py.

◆ filterPassed

GaudiPython.Pythonizations.filterPassed

Definition at line 570 of file Pythonizations.py.

◆ get

GaudiPython.Pythonizations.get

Definition at line 528 of file Pythonizations.py.

◆ invalidate

GaudiPython.Pythonizations.invalidate

Definition at line 148 of file Pythonizations.py.

◆ isExecuted

GaudiPython.Pythonizations.isExecuted

Definition at line 569 of file Pythonizations.py.

◆ items

GaudiPython.Pythonizations.items

Definition at line 534 of file Pythonizations.py.

◆ keys

GaudiPython.Pythonizations.keys

Definition at line 524 of file Pythonizations.py.

◆ plot

GaudiPython.Pythonizations.plot

Definition at line 132 of file Pythonizations.py.

◆ self

GaudiPython.Pythonizations.self

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