All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiAlgs.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # =============================================================================
3 # $Id: GaudiAlgs.py,v 1.2 2008/07/15 16:05:53 marcocle Exp $
4 # =============================================================================
5 ## @file
6 #
7 # Helper module, which effectively 'imports' few useful C++ algorithmic
8 # base classes into Python
9 #
10 #
11 # The major imported classes are :
12 #
13 # - GaudiAlgo - analogue for GaudiAlgorithm C++ class from GaudiAlg package
14 # - HistoAlgo - analogue for GaudiHistoAlg C++ class from GaudiAlg package
15 # - TupleAlgo - analogue for GaudiTupleAlg C++ class from GaudiAlg package
16 #
17 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
18 # @date 2006-11-26
19 # =============================================================================
20 """
21 *******************************************************************************
22 * * 'Physisics do not like it, *
23 * * physisics do not need it, *
24 * * physisics do not use it' *
25 * * ****************************
26 * *
27 * Helper module, which effectively 'imports' few useful C++ algorithmic *
28 * base classes into Python *
29 * *
30 *******************************************************************************
31 * The major imported classes are : *
32 * *
33 * (1) GaudiAlgo - analogue for GaudiAlgorithm C++ class from GaudiAlg package *
34 * (2) HistoAlgo - analogue for GaudiHistoAlg C++ class from GaudiAlg package *
35 * (3) TupleAlgo - analogue for GaudiTupleAlg C++ class from GaudiAlg package *
36 *******************************************************************************
37 """
38 # =============================================================================
39 __author__ = 'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
40 # =============================================================================
41 # list of "public" symbols
42 # =============================================================================
43 __all__ = (
44  'GaudiAlgo' , ## base class for algorithms
45  'HistoAlgo' , ## base class for histo-related algorithms
46  'TupleAlgo' , ## base class for tuple-related algorithms
47  'Tuple' , ## N-Tuple
48  'HistoID' , ## ID for N-tuples
49  'TupleID' , ## ID for Histograms
50  'aida2root' , ## AIDA -> ROOT converter
51  'SUCCESS' ## status code
52  )
53 # =============================================================================
54 # import core of Gaudi
55 import GaudiPython.Bindings ## The basic module
56 iAlgorithm = GaudiPython.Bindings.iAlgorithm ## Algorithm interface
57 iAlgTool = GaudiPython.Bindings.iAlgTool ## Tool interface
58 
59 from GaudiPython.Bindings import (
60  SUCCESS , ## status code
61  InterfaceCast , ## "queryInterface"
62  iDataSvc , ## Data Service
63  iHistogramSvc , ## Histogram Service
64  iNTupleSvc , ## N-Tuple service
65  AppMgr ## Application Manager
66  )
67 
68 from GaudiPython.Bindings import gbl as cpp ## global C++ namepspace
69 from GaudiPython.HistoUtils import aida2root ## AIDA -> ROTO converter
70 
71 # =============================================================================
72 # std C++ namespace
73 std = cpp.std ## std C++ namespace
74 
75 ## "typedef" for GaudiPython::Vector
76 Vector = std.vector('double')
77 ## "typedef" for GaudiPython::Matrix
78 Matrix = std.vector('std::vector<double>')
79 
80 ## histogram and N-Tuple universal identifier
81 HID = cpp.GaudiAlg.ID
82 HistoID = HID
83 TID = HID
84 TupleID = TID
85 
86 ## get the decorator:
87 AlgDecorator = cpp.GaudiPython.AlgDecorator
88 HistoDecorator = cpp.GaudiPython.HistoDecorator
89 TupleAlgDecorator = cpp.GaudiPython.TupleAlgDecorator
90 TupleDecorator = cpp.GaudiPython.TupleDecorator
91 
92 # =============================================================================
93 ## Useful method to locate the tool a certain
94 #
95 # Usage:
96 #
97 # @code
98 #
99 # # locate public tool
100 # t1 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator')
101 # # locate private tool
102 # t2 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator',parent=self)
103 # # locate public tool with defined name
104 # t3 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator/MyExt1')
105 # # locate private tool with defined name
106 # t4 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator/MyExt2',parent=self)
107 # # locate public tool with defined name
108 # t5 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator','MyExt3')
109 # # locate private tool with defined name
110 # t6 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator','MyExt4',parent=self)
111 #
112 # @endcode
113 #
114 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
115 # @date 2006-11-26
116 def _tool_ ( self ,
117  interface ,
118  typename ,
119  name = None ,
120  parent = None ,
121  create = True ) :
122  """
123  Useful method to locate the tool a certain
124 
125  Usage:
126 
127  # locate public tool
128  t1 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator')
129  # locate private tool
130  t2 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator',parent=self)
131  # locate public tool with defined name
132  t3 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator/MyExt1')
133  # locate private tool with defined name
134  t4 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator/MyExt2',parent=self)
135  # locate public tool with defined name
136  t5 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator','MyExt3')
137  # locate private tool with defined name
138  t6 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator','MyExt4',parent=self)
139 
140  """
141  if not interface : interface = cpp.IAlgTool
142  if not parent : parent = self
143  if name : typename += '/' + name
144  _tool = AlgDecorator.tool_( self , typename , parent , create )
145  if not _tool : return None
146  _tool = InterfaceCast(interface)(_tool)
147  if not _tool :
148  self.Warning('Invalid cast to interface %s' % interface )
149  return None
150  return _tool
151 
152 # =============================================================================
153 ## Useful method to locate a service:
154 #
155 # Usage:
156 #
157 # @code
158 #
159 # ntsvc = self.svc( INTupleSvc , 'NTUpleSvc' )
160 #
161 # @endcode
162 #
163 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
164 # @date 2006-11-26
165 def _service_ ( self ,
166  interface ,
167  name ,
168  create = True ) :
169  """
170  Useful method to locate a service:
171 
172  Usage:
173 
174  ntsvc = self.svc( INTupleSvc , 'NTUpleSvc' )
175 
176  """
177  if not interface : interface = cpp.IInterface
178  _svc = AlgDecorator.svc_ ( self , name , create )
179  if not _svc : return None
180  _svc = InterfaceCast(interface)(_svc)
181  if not _svc :
182  self.Warning('Invalid cast to interface %s' % interface )
183  return None
184  return _svc
185 
186 # =============================================================================
187 ## The constructor from unique algorithm instance name,
188 #
189 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
190 # @date 2006-11-26
191 def _init_ ( self , name , **args ) :
192  """
193  The constructor from unique algorithm instance name & parameters
194  """
195  self._Base.__init__( self , self , name )
196  appMgr = AppMgr()
197  algMgr = appMgr._algmgr
198  status = algMgr.addAlgorithm( self )
199  if status.isFailure() :
200  raise RuntimeError, 'Unable to add Algorithm "' + name + '"'
201  iAlgorithm.__init__ ( self , name , self )
202  for key in args : setattr ( self , key , args[key] )
203  # take some care about the ownership of the algorithms
204  if not appMgr.__dict__.has_key ( 'GaudiPythonAlgos') :
205  appMgr.__dict__[ 'GaudiPythonAlgos'] = []
206  appMgr.__dict__[ 'GaudiPythonAlgos'].append( self )
207 
208 # =============================================================================
209 ## The default initialization (initialization of base C++ class + data
210 #
211 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
212 # @date 2006-11-26
213 def _initialize_ ( self ) :
214  """
215  The default initialization (initialization of base C++ class + data)
216  """
217  status = self._Base.initialize_( self )
218  if status.isFailure() : return status
219 
220  # set the basic services
221  _e = self._Base.evtSvc( self )
222  _s = InterfaceCast(cpp.IService)(_e)
223  self._evtSvc_ = iDataSvc ( _s.name() , _e )
224 
225  _d = self._Base.detSvc( self )
226  _s = InterfaceCast(cpp.IService)(_d)
227  self._detSvc_ = iDataSvc ( _s.name() , _d )
228 
229  return status
230 
231 # =============================================================================
232 ## The default initialization (initialization of base C++ class + data members)
233 #
234 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
235 # @date 2006-11-26
236 def _initialize_histo_ ( self ) :
237  """
238  The default initialization (initialization of base C++ class + data members)
239  """
240  status = _initialize_( self )
241  if status.isFailure() : return status
242 
243  # set the basic services
244  _h = self._Base.histoSvc( self )
245  _s = InterfaceCast(cpp.IService)(_h)
246  self._histoSvc_ = iHistogramSvc ( _s.name() , _h )
247 
248  return status
249 
250 # =============================================================================
251 ## The default initialization (initialization of base C++ class + data members)
252 #
253 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
254 # @date 2006-11-26
255 def _initialize_tuple_ ( self ) :
256  """
257  The default initialization (initialization of base C++ class + data members)
258  """
259  status = _initialize_histo_( self )
260  if status.isFailure() : return status
261 
262  # set the basic services
263  if self.produceNTuples() :
264  _n = self._Base.ntupleSvc( self )
265  _s = InterfaceCast(cpp.IService)(_n)
266  self._ntupleSvc_ = iNTupleSvc ( _s.name() , _n )
267 
268  if self.produceEvtCols() :
269  _n = self._Base.evtColSvc( self )
270  _s = InterfaceCast(cpp.IService)(_n)
271  self._evtcolSvc_ = iNTupleSvc ( _s.name() , _n )
272 
273  return status
274 
275 # =============================================================================
276 ## Trivial helper function to access Event Data and Event Data Service
277 #
278 # Usage:
279 #
280 # @code
281 #
282 # # get event data service
283 # svc = self.evtSvc()
284 #
285 # # get the data
286 # hits = self.evtSvc('MC/Calo/Hits')
287 #
288 # @endcode
289 #
290 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
291 # @date 2006-11-26
292 def _evtSvc ( self , location = None ) :
293  """
294  Trivial helper function to access Event Data and Event Data Service
295 
296  Usage:
297 
298  # get event data service
299  svc = self.evtSvc()
300 
301  # get the data
302  hits = self.evtSvc('MC/Calo/Hits')
303  """
304  if not location :
305  return self._evtSvc_
306  return self._evtSvc_[location]
307 
308 # =============================================================================
309 ## Trivial helper function to access Detector Data and Detector Data Service
310 #
311 # Usage:
312 #
313 # @code
314 #
315 # # get detector data service
316 # svc = self.detSvc()
317 #
318 # # get the data
319 # lhcb = self.detSvc('/dd/Structure/LHCb')
320 #
321 # @endcode
322 #
323 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
324 # @date 2006-11-26
325 def _detSvc ( self ) :
326  """
327  Trivial helper function to access Detector Data and Event Data Service
328 
329  Usage:
330  # get detector data service
331  svc = self.detSvc()
332 
333  # get the data
334  lhcb = self.detSvc('/dd/Structure/LHCb')
335  """
336  if not location :
337  return self._detSvc_
338  return self._detSvc_[location]
339 
340 # =============================================================================
341 ## Trivial helper function to access Histogram Data and Histogram Data Service
342 #
343 # Usage:
344 #
345 # @code
346 #
347 # # get histogram data service
348 # svc = self.histoSvc()
349 #
350 # # get the data
351 # histo = self.histoSvc('/stat/Calo/1')
352 #
353 # @endcode
354 #
355 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
356 # @date 2006-11-26
357 def _histoSvc ( self , address = None ) :
358  """
359  Trivial helper function to access Histogram Data and Histogram Data Service
360 
361  Usage:
362 
363  # get histogram data service
364  svc = self.histoSvc()
365 
366  # get the data
367  histo = self.histoSvc('/stat/Calo/1')
368  """
369  if not address : return self._histoSvc_
370  return self._histoSvc_[ address ]
371 
372 # =============================================================================
373 ## Trivial function to access the data in TES
374 def _get ( self , location ) :
375  """
376  Trivial function to access the data in TES using the data service
377  """
378  return self._evtSvc_[location]
379 
380 # =============================================================================
381 ## Trivial function to access the data in TDS
382 def _getDet ( self , location ) :
383  """
384  Trivial function to access the data in TDS using data service
385  """
386  return self._detSvc_[location]
387 
388 # =============================================================================
389 ## get the data from TES using GaudiCommon methods, respecting RootInTES
390 def _get_ ( self , location , rootInTES = True ) :
391  """
392  Get the object from Transient Event Store using GaudiCommon machinery,
393  respecting RootInTES behaviour
394  """
395  return AlgDecorator.get_ ( self , location , rootInTES )
396 # =============================================================================
397 ## check the data from TES using GaudiCommon methods, respecting RootInTES
398 def _exist_ ( self , location , rootInTES = True ) :
399  """
400  Check the object in Transient Event Store using GaudiCommon machinery,
401  respecting RootInTES behaviour
402  """
403  return AlgDecorator.exist_ ( self , location , rootInTES )
404 
405 # =============================================================================
406 ## Trivial helper function to access NTuple Service
407 def _ntupleSvc ( self ) :
408  """
409  Trivial function to access N-Tuple Service
410  """
411  return self._ntupleSvc_
412 
413 # =============================================================================
414 ## Trivial helper function to access Event Collection Service
415 def _evtcolSvc ( self ) :
416  """
417  Trivial function to access Event Collection Service
418  """
419  return self._evtcolSvc_
420 
421 
422 # =============================================================================
423 ## The default finalization (finalization of base C++ class)
424 def _finalize_ ( self ) :
425  """
426  The default finalization : finalize the base C++ class
427  """
428  status = self._Base.finalize_ ( self )
429  return status
430 # =============================================================================
431 ## Dummy method returning success
432 def _success_ ( self ) : return SUCCESS
433 
434 
435 # =============================================================================
436 ## check the existence of the property with the given name
437 def _hasProperty_ ( self , pname ) :
438  """
439  The trivial function which checks the existence of the property with given name
440  """
441  return cpp.Gaudi.Utils.hasProperty ( self , pname )
442 
443 # =============================================================================
444 ## get the value of the given property
445 def _getProperty_ ( self , pname ) :
446  """
447  Get the property by name
448  """
449  if not self.hasProperty( pname ) :
450  raise AttributeError, 'property %s does not exist' % pname
451  return iAlgorithm.__getattr__( self , pname )
452 
453 # =============================================================================
454 ## set the value for the given property
455 def _setProperty_ ( self , pname , pvalue ) :
456  """
457  Set the property from the value
458  """
459  if not self.hasProperty( pname ) :
460  raise AttributeError, 'property %s does not exist' % pname
461  return iAlgorithm.__setattr__ ( self , pname , pvalue )
462 
463 # =============================================================================
464 ## get the attribute or property
465 def _get_attr_ ( self , pname ) :
466  """
467  Get the attribute (or property)
468  - if the attribute name corresponds to the property name, property value is returned
469  """
470  if self.hasProperty( pname ) :
471  return iAlgorithm.__getattr__ ( self , pname )
472  raise AttributeError, 'attribute/property %s does not exist' % pname
473 
474 # =============================================================================
475 ## set the attribute or property
476 def _set_attr_ ( self , pname , pvalue ) :
477  """
478  Set the attribute (or property) :
479  - if the attribute name corresponds to the property name, the property is updated
480  """
481  if not self.hasProperty( pname ) : self.__dict__[pname] = pvalue
482  else : iAlgorithm.__setattr__ ( self , pname , pvalue )
483 
484 
485 _GaudiAlgorithm = cpp.GaudiPython.PyAlg( 'GaudiAlgorithm' )
486 _GaudiHistoAlg = cpp.GaudiPython.PyAlg( 'GaudiHistoAlg' )
487 _GaudiTupleAlg = cpp.GaudiPython.PyAlg( 'GaudiTupleAlg' )
488 
489 # =============================================================================
490 ## @class GaudiAlgo
491 # the base class for all algorithm
492 # Python-image of C++ clkass GaudiAlgorithm
493 #
494 # Usage:
495 #
496 # @code
497 #
498 # from GauidPython.GaudiAlgs import GaudiAlgo, SUCCESS
499 #
500 # class MyClass(GaudiAlgo) :
501 # """
502 # My specific Algorithm, derived from GaudiAlgo base class
503 # """
504 # def __init__( self , name , **args ) :
505 # """
506 # Constructor from algorithm instance name & parameters'
507 # """
508 # #invoke the constructor of base class
509 # GaudiAlgo.__init__(self , name , **args )
510 #
511 # def initialize ( self ) :
512 # 'Algorithm initialization'
513 # # initialize the base class
514 # status = GaudiAlgo.initialize( self )
515 # if status.isFailure() : return status
516 #
517 # # locate the services and tools
518 #
519 # # locate some tool:
520 # extrapolator = self.tool(ITrExtrapolator,'TrExtrapolator')
521 #
522 # # locate the service
523 # rndmSvc = self.svc(IRndmGenSvc, 'RndmGenSvc')
524 #
525 # return SUCCESS
526 #
527 #
528 # def execute ( self ) :
529 # 'Major method (from IAlgorithm interface)'
530 #
531 # # get some data from Transient Event Store
532 # tracks = self.get('/Event/Rec/Tracks')
533 #
534 # # use counters
535 # c1 = self.counter('#Tracks')
536 # c2 = self.counter('No Tracks')
537 # if tracks.empty :
538 # c2+=1
539 # c1 += tracks->size()
540 #
541 # if 1000 < tracks.size() :
542 # return self.Error('The event is *VERY* busy')
543 #
544 # return SUCCESS
545 #
546 # @endcode
547 #
548 # @see GaudiAlgorithm
549 #
550 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
551 # @date 2006-11-26
553  """
554 *******************************************************************************
555 * * 'Physisics do not like it, *
556 * * physisics do not need it, *
557 * * physisics do not use it' *
558 * * ****************************
559 * Usage: *
560 * *
561 * from GaudiPython.GaudiAlgs import GaudiAlgo, SUCCESS *
562 * *
563 * class MyClass(GaudiAlgo) : *
564 * ' My specific Algorithm, derived from GaudiAlgo base class ' *
565 * def __init__( self , name , **args ) : *
566 * 'Constructor from algorithm instance name & parameters' *
567 * #invoke the constructor of base class *
568 * GaudiAlgo.__init__(self , name , **args ) *
569 * *
570 * def initialize ( self ) : *
571 * 'Algorithm initialization' *
572 * # initialize the base class *
573 * status = GaudiAlgo.initialize( self ) *
574 * if status.isFailure() : return status *
575 * *
576 * # locate the services and tools *
577 * *
578 * # locate some tool: *
579 * extrapolator = self.tool(ITrExtrapolator,'TrExtrapolator') *
580 * *
581 * # locate the service *
582 * rndmSvc = self.svc(IRndmGenSvc, 'RndmGenSvc') *
583 * *
584 * return SUCCESS *
585 * *
586 * *
587 * def execute ( self ) : *
588 * 'Major method (from IAlgorithm interface)' *
589 * *
590 * # get some data from Transient Event Store *
591 * tracks = self.get('/Event/Rec/Tracks') *
592 * *
593 * # use counters *
594 * c1 = self.counter('#Tracks') *
595 * c2 = self.counter('No Tracks') *
596 * if tracks.empty : *
597 * c2+=1 *
598 * c1 += tracks->size() *
599 * *
600 * if 1000 < tracks.size() : *
601 * return self.Error('The event is *VERY* busy') *
602 * *
603 * return SUCCESS *
604 * *
605 *******************************************************************************
606  """
607  pass
608 
609 # =============================================================================
610 ## @class HistoAlgo
611 # The base class for easy histogramming
612 #
613 # Usage:
614 #
615 #
616 # @code
617 #
618 # from GaudiPython.GaudiAlgs import HistoAlgo, SUCCESS
619 #
620 # class MyClass(HistoAlgo) :
621 # ' My specific Algorithm, derived from GaudiAlgo base class '
622 # def __init__( self , name , **args ) :
623 # 'Constructor from algorithm instance name & parameters'
624 # #invoke the constructor of base class
625 # HistoAlgo.__init__(self , name , **args )
626 #
627 # def execute ( self ) :
628 # 'Major method (from IAlgorithm interface)'
629 #
630 # # get some data from Transient Event Store
631 # tracks = self.get('/Event/Rec/Tracks')
632 #
633 # self.plot1D ( tracks->size() , '#tracks' , 0 , 100 )
634 #
635 # return SUCCESS
636 #
637 # @endcode
638 #
639 # Alternatively the histogram could be booked in advance:
640 #
641 # @code
642 #
643 # class MyClass(HistoAlgo) :
644 # ' My specific Algorithm, derived from GaudiAlgo base class '
645 # def __init__( self , name ) :
646 # 'Constructor from algorithm instance name'
647 # #invoke the constructor of base class
648 # HistoAlgo.__init__(self , name )
649 #
650 # def initialize ( self ) :
651 # 'Algorithm initialization'
652 # # initialize the base class
653 # status = HistoAlgo.initialize( self )
654 # if status.isFailure() : return status
655 #
656 # # book the histogram
657 # self.h1 = selff.book1D ( '#tracks' , 0 , 100 )
658 #
659 # return SUCCESS
660 #
661 #
662 # def execute ( self ) :
663 # 'Major method (from IAlgorithm interface)'
664 #
665 # # get some data from Transient Event Store
666 # tracks = self.get('/Event/Rec/Tracks')
667 #
668 # # fill the histogram
669 # self.h1.fill ( tracks->size() )
670 #
671 # return SUCCESS
672 # @endcode
673 #
674 # @see GaudiHistoAlg
675 #
676 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
677 # @date 2006-11-26
679  """
680 *******************************************************************************
681 * * 'Physisics do not like it, *
682 * * physisics do not need it, *
683 * * physisics do not use it' *
684 * * ****************************
685 * Usage: *
686 * *
687 * from GaudiPython.GaudiAlgs import HistoAlgo, SUCCESS *
688 * *
689 * class MyClass(HistoAlgo) : *
690 * ' My specific Algorithm, derived from GaudiAlgo base class ' *
691 * def __init__( self , name , **args ) : *
692 * 'Constructor from algorithm instance name' *
693 * #invoke the constructor of base class *
694 * HistoAlgo.__init__(self , name , **args ) *
695 * *
696 * def execute ( self ) : *
697 * 'Major method (from IAlgorithm interface)' *
698 * *
699 * # get some data from Transient Event Store *
700 * tracks = self.get('/Event/Rec/Tracks') *
701 * *
702 * self.plot1D ( tracks->size() , '#tracks' , 0 , 100 ) *
703 * *
704 * return SUCCESS *
705 * *
706 * Alternatively the histogram could be booked in advance: *
707 * *
708 * class MyClass(HistoAlgo) : *
709 * ' My specific Algorithm, derived from GaudiAlgo base class ' *
710 * def __init__( self , name ) : *
711 * 'Constructor from algorithm instance name' *
712 * #invoke the constructor of base class *
713 * HistoAlgo.__init__(self , name ) *
714 * *
715 * def initialize ( self ) : *
716 * 'Algorithm initialization' *
717 * # initialize the base class *
718 * status = HistoAlgo.initialize( self ) *
719 * if status.isFailure() : return status *
720 * *
721 * # book the histogram *
722 * self.h1 = selff.book1D ( '#tracks' , 0 , 100 ) *
723 * *
724 * return SUCCESS *
725 * *
726 * *
727 * def execute ( self ) : *
728 * 'Major method (from IAlgorithm interface)' *
729 * *
730 * # get some data from Transient Event Store *
731 * tracks = self.get('/Event/Rec/Tracks') *
732 * *
733 * # fill the histogram *
734 * self.h1.fill ( tracks->size() ) *
735 * *
736 * return SUCCESS *
737 * *
738 *******************************************************************************
739  """
740  pass
741 
742 # =============================================================================
743 ## @class TupleAlgo
744 # The base class for easy manupulations with N-Tuples
745 #
746 # Usage:
747 #
748 # @code
749 #
750 # from GaudiPython.GaudiAlgs import TupleAlgo, SUCCESS
751 #
752 # class MyClass(TupleAlgo) :
753 # ' My specific Algorithm, derived from TupleAlgo base class '
754 # def __init__( self , name , **args ) :
755 # 'Constructor from algorithm instance name& parameters'
756 # #invoke the constructor of base class
757 # TupleAlgo.__init__(self , name , **args )
758 #
759 # def execute ( self ) :
760 # 'Major method (from IAlgorithm interface)'
761 #
762 # # get some data from Transient Event Store
763 # tracks = self.get('/Event/Rec/Tracks')
764 #
765 # tup = self.nTuple('My N-Tuple')
766 #
767 # for track in tracks :
768 #
769 # pt = track.pt ()
770 # p = track.p ()
771 # chi2 = track.chi2 ()
772 #
773 # #fill N-tuple:
774 # tup.column ( 'pt' , pt )
775 # tup.column ( 'p' , p )
776 # tup.column ( 'chi2' , chi2 )
777 # #commit the row
778 # tup.write ()
779 #
780 # return SUCCESS
781 #
782 # @endcode
783 #
784 # @see GaudiTupleAlg
785 #
786 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
787 # @date 2006-11-26
789  """
790 *******************************************************************************
791 * * 'Physisics do not like it, *
792 * * physisics do not need it, *
793 * * physisics do not use it' *
794 * * ****************************
795 * Usage: *
796 * *
797 * from GaudiPython.GaudiAlgs import TupleAlgo, SUCCESS *
798 * *
799 * class MyClass(TupleAlgo) : *
800 * ' My specific Algorithm, derived from TupleAlgo base class ' *
801 * def __init__( self , name , **args ) : *
802 * 'Constructor from algorithm instance name & parameters' *
803 * #invoke the constructor of base class *
804 * TupleAlgo.__init__(self , name , **args ) *
805 * *
806 * def execute ( self ) : *
807 * 'Major method (from IAlgorithm interface)' *
808 * *
809 * # get some data from Transient Event Store *
810 * tracks = self.get('/Event/Rec/Tracks') *
811 * *
812 * tup = self.nTuple('My N-Tuple') *
813 * *
814 * for track in tracks : *
815 * *
816 * pt = track.pt () *
817 * p = track.p () *
818 * chi2 = track.chi2 () *
819 * *
820 * #fill N-tuple: *
821 * tup.column ( 'pt' , pt ) *
822 * tup.column ( 'p' , p ) *
823 * tup.column ( 'chi2' , chi2 ) *
824 * #commit the row *
825 * tup.write () *
826 * *
827 * return SUCCESS *
828 * *
829 *******************************************************************************
830  """
831  pass
832 class objectmethod(object) :
833  def __init__(self, m) :
834  self.method = m
835  def __call__(self, *args) :
836  print args
837  return self.method(*args )
838 
839 GaudiAlgo._Base = _GaudiAlgorithm
840 HistoAlgo._Base = _GaudiHistoAlg
841 TupleAlgo._Base = _GaudiTupleAlg
842 
843 # initialize is 'unique' method :
844 GaudiAlgo.initialize = _initialize_
845 HistoAlgo.initialize = _initialize_histo_
846 TupleAlgo.initialize = _initialize_tuple_
847 
848 def _start_ ( self ) :
849  """
850  The stub 'start' method needed by the internal implementation of PyAlg<>.
851  """
852  # return self._Base.start_(self)
853  return SUCCESS
854 
855 GaudiAlgo.start = _start_
856 HistoAlgo.start = _start_
857 TupleAlgo.start = _start_
858 
859 def _execute_ ( self ) :
860  """
861  The fictive 'execute' method, which MUST be overwitten by user
862  """
863  raise RuntimeError, 'Execute method is not implemented for %s' % self.name()
864 
865 GaudiAlgo.execute = _execute_
866 HistoAlgo.execute = _execute_
867 TupleAlgo.execute = _execute_
868 
869 def _stop_ ( self ) :
870  """
871  The stub 'stop' method needed by the internal implementation of PyAlg<>.
872  """
873  # return self._Base.stop_(self)
874  return SUCCESS
875 
876 GaudiAlgo.stop = _stop_
877 HistoAlgo.stop = _stop_
878 TupleAlgo.stop = _stop_
879 
880 # =============================================================================
881 def _plot1D_ ( s, *a ) :
882  """
883  The basic method to fill (book-on-demand) 1D-histogram
884 
885  The histogram will be created/booked dautomatically according to the
886  specifications:
887 
888  - literal or numerical ID (optional)
889  - title
890  - low edge
891  - high edge
892  - number of bins (default is 100)
893 
894  The reference to the histogram is returned and could be used for later manipulations
895 
896  """
897  return HistoDecorator.plot1D (s,*a)
898 # =============================================================================
899 def _plot2D_ ( s, *a ) :
900  """
901  The basic method to fill (book-on-demand) 2D-histogram
902 
903  The histogram will be created/booked dautomatically according to the
904  specifications:
905 
906  - literal or numerical ID (optional)
907  - title
908  - low X-edge
909  - high X-edge
910  - low Y-edge
911  - high Y-edge
912  - number of X-bins (default is 50)
913  - number of Y-bins (default is 50)
914 
915  The reference to the histogram is returned and could be used for later manipulations
916 
917  """
918  return HistoDecorator.plot2D (s,*a)
919 # =============================================================================
920 def _plot3D_ ( s, *a ) :
921  """
922  The basic method to fill (book-on-demand) 3D-histogram
923 
924  The histogram will be created/booked dautomatically according to the
925  specifications:
926 
927  - literal or numerical ID (optional)
928  - title
929  - low X-edge
930  - high X-edge
931  - low Y-edge
932  - high Y-edge
933  - low Z-edge
934  - high Z-edge
935  - number of X-bins (default is 10)
936  - number of Y-bins (default is 10)
937  - number of Y-bins (default is 10)
938 
939  The reference to the histogram is returned and could be used for later manipulations
940 
941  """
942  return HistoDecorator.plot3D (s,*a)
943 # =============================================================================
944 def _profile1D_ ( s, *a ) :
945  """
946  The basic method to fill (book-on-demand) 1D profile histogram
947 
948  The profile histogram will be created/booked dautomatically
949  according to the specifications:
950 
951  - literal or numerical ID (optional)
952  - title
953  - low X-edge
954  - high X-edge
955  - number of X-bins (default is 100)
956 
957  The reference to the histogram is returned and could be used for later manipulations
958 
959  """
960  return HistoDecorator.profile1D (s,*a)
961 # =============================================================================
962 def _profile2D_ ( s, *a ) :
963  """
964  The basic method to fill (book-on-demand) 2D profile histiogram
965 
966  The profile histogram will be created/booked automatically
967  according to the specifications:
968 
969  - literal or numerical ID (optional)
970  - title
971  - low X-edge
972  - high X-edge
973  - low Y-edge
974  - high Y-edge
975  - number of X-bins (default is 50)
976  - number of Y-bins (default is 50)
977 
978  The reference to the histogram is returned and could be used for later manipulations
979 
980  """
981  return HistoDecorator.profile2D (s,*a)
982 # =============================================================================
983 
984 _plot1D_ .__doc__ += '\n' + HistoDecorator.plot1D .__doc__
985 _plot2D_ .__doc__ += '\n' + HistoDecorator.plot2D .__doc__
986 _plot3D_ .__doc__ += '\n' + HistoDecorator.plot3D .__doc__
987 _profile1D_ .__doc__ += '\n' + HistoDecorator.profile1D .__doc__
988 _profile2D_ .__doc__ += '\n' + HistoDecorator.profile2D .__doc__
989 
990 def _decorate_plots_ ( klasses ) :
991  t = type( klasses )
992  if not issubclass ( t , list ) and \
993  not issubclass ( t , tuple ) : klasses = [ klasses ]
994  for klass in klasses :
995  klass .plot = _plot1D_
996  klass .plot1D = _plot1D_
997  klass .plot2D = _plot2D_
998  klass .plot3D = _plot3D_
999  klass .profile1D = _profile1D_
1000  klass .profile2D = _profile2D_
1001 
1002 _decorate_plots_ ( HistoAlgo )
1003 _decorate_plots_ ( TupleAlgo )
1004 
1005 
1006 # =============================================================================
1007 def _nTuple_ ( s , *a ) :
1008  """
1009  Retrieve (book-on-demand) N-Tuple object
1010  """
1011  return TupleAlgDecorator.nTuple ( s , *a )
1012 # =============================================================================
1013 def _evtCol_ ( s , *a ) :
1014  """
1015  Retrieve (book-on-demand) N-Tuple object for Event Tag Collections
1016  """
1017  return TupleAlgDecorator.evtCol ( s , *a )
1018 
1019 _nTuple_.__doc__ += '\n' + TupleAlgDecorator.nTuple.__doc__
1020 _evtCol_.__doc__ += '\n' + TupleAlgDecorator.evtCol.__doc__
1021 
1022 def _decorate_tuples_ ( klasses ) :
1023  t = type( klasses )
1024  if not issubclass ( t , list ) and \
1025  not issubclass ( t , tuple ) : klasses = [ klasses ]
1026  for klass in klasses :
1027  klass . nTuple = _nTuple_
1028  klass . evtCol = _evtCol_
1029  klass . ntupleSvc = _ntupleSvc
1030  klass . tupleSvc = _ntupleSvc
1031  klass . ntupSvc = _ntupleSvc
1032  klass . tupSvc = _ntupleSvc
1033  klass . evtColSvc = _evtcolSvc
1034  klass . evtcolSvc = _evtcolSvc
1035 
1036 # ==========================================================
1037 _decorate_tuples_ ( TupleAlgo )
1038 
1039 
1040 # "decorate N-Tuple object
1041 Tuple = cpp.Tuples.Tuple
1042 _Dec = TupleDecorator
1043 def _t_nTuple_ ( s , *a ) :
1044  """
1045  Access to underlying INTuple object
1046  """
1047  return _Dec.nTuple ( s , *a )
1048 def _t_ntuple_ ( s , *a ) :
1049  """
1050  Access to underlying NTuple::Tuple object
1051  """
1052  return _Dec.ntuple ( s , *a )
1053 def _t_valid_ ( s , *a ) :
1054  """
1055  Valid NTuple::Tuple object?
1056  """
1057  return _Dec.valid ( s , *a )
1058 def _t_write_ ( s , *a ) :
1059  """
1060  Commit the row/record to n-tuple
1061  """
1062  return _Dec.write ( s , *a )
1063 def _t_column_ ( s , *a ) :
1064  """
1065  Fill the certain column to n-tuple
1066  """
1067  return _Dec.column ( s , *a )
1068 def _t_column_ll_ ( s , *a ) :
1069  """
1070  Fill the 'long long' column
1071  """
1072  return _Dec.column_ll ( s , *a )
1073 def _t_column_ull_ ( s , *a ) :
1074  """
1075  Fill the 'unsigned long long' column
1076  """
1077  return _Dec.column_ull ( s , *a )
1078 def _t_array_ ( s , *a ) :
1079  """
1080  Fill the fixed-size array column
1081  """
1082  return _Dec.array ( s , *a )
1083 def _t_matrix_ ( s , *a ) :
1084  """
1085  Fill the fixed-size matrix column
1086  """
1087  return _Dec.matrix ( s , *a )
1088 def _t_farray_ ( s , *a ) :
1089  """
1090  Fill the floating-size array column
1091  """
1092  return _Dec.farray ( s , *a )
1093 def _t_fmatrix_ ( s , *a ) :
1094  """
1095  Fill the floating-size matrix column
1096  """
1097  return _Dec.fmatrix ( s , *a )
1098 
1099 _t_nTuple_ . __doc__ += '\n' + _Dec.nTuple . __doc__
1100 _t_ntuple_ . __doc__ += '\n' + _Dec.ntuple . __doc__
1101 _t_valid_ . __doc__ += '\n' + _Dec.valid . __doc__
1102 _t_write_ . __doc__ += '\n' + _Dec.write . __doc__
1103 _t_column_ . __doc__ += '\n' + _Dec.column . __doc__
1104 _t_column_ll_ . __doc__ += '\n' + _Dec.column_ll . __doc__
1105 _t_column_ull_ . __doc__ += '\n' + _Dec.column_ull . __doc__
1106 _t_array_ . __doc__ += '\n' + _Dec.array . __doc__
1107 _t_matrix_ . __doc__ += '\n' + _Dec.matrix . __doc__
1108 _t_farray_ . __doc__ += '\n' + _Dec.farray . __doc__
1109 _t_fmatrix_ . __doc__ += '\n' + _Dec.fmatrix . __doc__
1110 
1111 Tuple.nTuple = _t_nTuple_
1112 Tuple.ntuple = _t_ntuple_
1113 Tuple.valid = _t_valid_
1114 Tuple.write = _t_write_
1115 Tuple.column = _t_column_
1116 Tuple.column_ll = _t_column_ll_
1117 Tuple.column_ull = _t_column_ull_
1118 Tuple.array = _t_array_
1119 Tuple.matrix = _t_matrix_
1120 Tuple.farray = _t_farray_
1121 Tuple.fmatrix = _t_fmatrix_
1122 
1123 _alg_map_ = {
1124  '__init__' : _init_ , # constructor
1125  'tool' : _tool_ , # service locator
1126  'svc' : _service_ , # tool locator
1127  'evtSvc' : _evtSvc , # event data service
1128  'eventSvc' : _evtSvc , # event data service
1129  'detSvc' : _detSvc , # detector data service
1130  'histoSvc' : _histoSvc , # histogram data service
1131  'histSvc' : _histoSvc , # histogram data service
1132  'get' : _get , # access to event data
1133  'get_' : _get_ , # access to event data
1134  'exist_' : _exist_ , # check the event data
1135  'getDet' : _getDet , # access to detector data
1136  'finalize' : _finalize_ , # algorithm finalization
1137  'beginRun' : _success_ , # dummy function returning success
1138  'endRun' : _success_ , # dummy function returning success
1139  #
1140  'hasProperty' : _hasProperty_ , # check the existence of property with given name
1141  'getProperty' : _getProperty_ , # get the property value with given name
1142  'setProperty' : _setProperty_ , # set the property with given name
1143  '__setattr__' : _set_attr_ , # set the attribute/property with given name
1144  '__getattr__' : _get_attr_ # set the attribute/property with given name
1145  }
1146 
1147 
1148 # decorate the classes with the useful methods
1149 def _decorate_algs_ ( klasses ) :
1150  t = type( klasses )
1151  if not issubclass ( t , list ) and \
1152  not issubclass ( t , tuple ) : klasses = [ klasses ]
1153  for _alg in klasses :
1154  for key in _alg_map_ : setattr( _alg , key , _alg_map_[key] )
1155 
1156 # =
1157 _decorate_algs_ ( GaudiAlgo )
1158 _decorate_algs_ ( HistoAlgo )
1159 _decorate_algs_ ( TupleAlgo )
1160 
1161 # =============================================================================
1162 # Helper function to fill histogram/ntuple using 'map'-operation
1163 # =============================================================================
1164 def mapvct ( func , sequence , ovct = None ) :
1165  """ Helper function to fill histogram/ntuple using 'map'-operation """
1166  if not ovct :
1167  vct = GaudiPython.Vector
1168  else :
1169  vct = ovct
1170  if hasattr( sequence, 'size' ) :
1171  vct.reserve ( vct.size() + sequence.size() )
1172  elif hasattr( sequence, '__len__' ) :
1173  vct.reserve ( vct.size() + len( sequence ) )
1174  for object in sequence :
1175  vct.push_back( func( object ) )
1176  if not ovct : return vct
1177 # =============================================================================
1178 
1179 
1180 
1181 
1182 # =============================================================================
1183 # get the list of tools
1184 # =============================================================================
1185 def _get_all_tools_ ( self , method ) :
1186  """
1187  Get all tools
1188  """
1189  _tools = std.vector('IAlgTool*')()
1190  _func = getattr ( AlgDecorator , method )
1191  _num = _func ( self , _tools )
1192  if _tools.size() != _num :
1193  raise RuntimeError, 'Unable to extract Tools'
1194  _res = []
1195  for _tool in _tools : _res += [ iAlgTool ( _tool.name() , _tool ) ]
1196  return _res
1197 # =============================================================================
1198 def _Tools_a_ ( self ) :
1199  """
1200  Retrieve the list of tools,
1201  aquired by component through GaudiCommon<TYPE> base:
1202 
1203  >>> alg = ... ## get the algorithm
1204  >>> tools = alg.Tools() ## get the tools
1205  >>> for tool in tools :
1206  ... print tool
1207 
1208  """
1209  _cmp = getattr ( self , '_ialg' )
1210  if not _cmp : self.retrieveInterface()
1211  _cmp = getattr ( self , '_ialg' )
1212  return _get_all_tools_ ( _cmp , '_tools_a_' )
1213 # =============================================================================
1214 def _Tools_t_ ( self ) :
1215  """
1216  Retrieve the list of tools,
1217  aquired by component through GaudiCommon<TYPE> base:
1218 
1219  >>> tool = ... ## get the tool
1220  >>> tools = tool.Tools() ## get the tools
1221  >>> for t in tools :
1222  ... print t
1223 
1224  """
1225  _cmp = getattr ( self , '_itool' )
1226  if not _cmp : self.retrieveInterface()
1227  _cmp = getattr ( self , '_itool' )
1228  return _get_all_tools_ ( _cmp , '_tools_t_' )
1229 
1230 
1231 # =============================================================================
1232 # get the list of counters
1233 # =============================================================================
1234 ## get all counters
1235 def _get_all_counters_ ( self , method , name = None ) :
1236  """
1237  get all counters
1238  """
1239  _cnts = std.vector('const StatEntity*')()
1240  _nams = std.vector('std::string') ()
1241  _func = getattr ( AlgDecorator , method )
1242  _num = _func ( self , _nams , _cnts )
1243  if _nams.size() != _num or _cnts.size() != _num :
1244  raise RuntimeError, 'Unable to extract Counters'
1245  _res = {}
1246  for _i in range(0,_num) :
1247  _nam = _nams[_i]
1248  _cnt = _cnts[_i]
1249  _res [ _nam ] = _cnt
1250  if not name : return _res
1251  return _res.get( name , None )
1252 # =============================================================================
1253 ## get all counters
1254 def _Counters_a_ ( self , name = None ) :
1255  """
1256  Retrieve the counters, managed GaudiCommon<TYPE> base:
1257 
1258  >>> alg = ... ## get the algorithm
1259  >>> cnts = alg.Counters() ## get the counters
1260  >>> for key in cnts :
1261  ... print key, cnts[key]
1262 
1263 
1264  Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1265 
1266  >>> alg = ... ## get the algorithm
1267  >>> cnt = alg.Counters('MyCounter') ## get the counter
1268  >>> print cnt
1269 
1270  """
1271  _cmp = getattr ( self , '_ialg' )
1272  if not _cmp : self.retrieveInterface()
1273  _cmp = getattr ( self , '_ialg' )
1274  return _get_all_counters_ ( _cmp , '_counters_a_' , name )
1275 # =============================================================================
1276 def _Counters_t_ ( self , name = None ) :
1277  """
1278  Retrieve the counters, managed GaudiCommon<TYPE> base:
1279 
1280  >>> tool = ... ## get the tool
1281  >>> cnts = tool.Counters() ## get the counters
1282  >>> for key in cnts :
1283  ... print key, cnts[key]
1284 
1285 
1286  Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1287 
1288  >>> tool = ... ## get the tool
1289  >>> cnt = tool.Counters('MyCounter') ## get the counter
1290  >>> print cnt
1291 
1292  """
1293  _cmp = getattr ( self , '_itool' )
1294  if not _cmp : self.retrieveInterface()
1295  _cmp = getattr ( self , '_itool' )
1296  return _get_all_counters_ ( _cmp , '_counters_t_' , name )
1297 # =============================================================================
1298 # get the counter
1299 # =============================================================================
1300 def _get_counter_ ( self , method , name ) :
1301  """
1302  get the counter
1303  """
1304  _func = getattr ( AlgDecorator , method )
1305  return _func ( self , name )
1306 # ==============================================================================
1307 def _Counter_a_ ( self , name ) :
1308  """
1309  Retrieve the counter managed GaudiCommon<TYPE> base by name:
1310 
1311  >>> alg = ... ## get the algorithm
1312  >>> cnt = alg.Counter('#accept') ## get the counter
1313  >>> print cnt
1314 
1315  """
1316  _cmp = getattr ( self , '_ialg' )
1317  if not _cmp : self.retrieveInterface()
1318  _cmp = getattr ( self , '_ialg' )
1319  return _get_counter_ ( _cmp , '_counter_a_' , name )
1320 # ==============================================================================
1321 def _Counter_t_ ( self , name ) :
1322  """
1323  Retrieve the counter managed GaudiCommon<TYPE> base by name:
1324 
1325  >>> tool = ... ## get the tool
1326  >>> cnt = tool.Counter('#accept') ## get the counter
1327  >>> print cnt
1328 
1329  """
1330  _cmp = getattr ( self , '_itool' )
1331  if not _cmp : self.retrieveInterface()
1332  _cmp = getattr ( self , '_itool' )
1333  return _get_counter_ ( _cmp , '_counter_t_' , name )
1334 
1335 # =============================================================================
1336 # get all histos
1337 # =============================================================================
1338 cpp.GaudiAlg.ID .__repr__ = cpp.GaudiAlg.ID.idAsString
1339 cpp.GaudiAlg.ID . __str__ = cpp.GaudiAlg.ID.idAsString
1340 cpp.StatEntity .__repr__ = cpp.StatEntity.toString
1341 cpp.StatEntity . __str__ = cpp.StatEntity.toString
1342 # =============================================================================
1343 def _get_all_histos_ ( component , method , name ) :
1344  """
1345  Get All histogram form the component
1346  """
1347  _res = {}
1348  for _his in ( std.vector('AIDA::IProfile2D*' ) ,
1349  std.vector('AIDA::IProfile1D*' ) ,
1350  std.vector('AIDA::IHistogram3D*' ) ,
1351  std.vector('AIDA::IHistogram2D*' ) ,
1352  std.vector('AIDA::IHistogram1D*' ) ) :
1353  _his = _his()
1354  _ids = std.vector('GaudiAlg::ID') ()
1355  _fun = getattr ( HistoDecorator , method )
1356  _num = _fun ( component , _ids , _his )
1357  if _ids.size() != _num or _his.size() != _num :
1358  raise RuntimeError, 'Unable to extract Histos!'
1359  for _i in range(0,_num) :
1360  _id = _ids[ _i ]
1361  if _id.numeric() : _id = _id.numericID ()
1362  elif _id.literal() : _id = _id.literalID ()
1363  else : _id = _is.idAsString ()
1364  _res[ _id ] = _his[ _i ]
1365 
1366  if not name : return _res ## return the dictionary
1367 
1368  id = cpp.GaudiAlg.ID ( name )
1369  for i in ( name ,
1370  id.literalID () ,
1371  id.numericID () ,
1372  id.idAsString() , id ) :
1373  h = _res.get( i , None )
1374  if not not h : return h ## return the histogram
1375 
1376  return None
1377 # =============================================================================
1378 def _Histos_a_ ( self , name = None ) :
1379  """
1380  Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1381 
1382  >>> alg = ... ## get the algorithm
1383  >>> histos = alg.Histos() ## get all histograms & profiles
1384  >>> for key in histos :
1385  ... print key, histos[key]
1386 
1387  Retrive the histogram with the certain ID :
1388 
1389  >>> alg = ... ## get the algorithm
1390  >>> histo = alg.Histos('some histo ID') ## get the histo by ID
1391  >>> print histo
1392 
1393  """
1394  _cmp = getattr ( self , '_ialg' )
1395  if not _cmp : self.retrieveInterface()
1396  _cmp = getattr ( self , '_ialg' )
1397  return _get_all_histos_ ( _cmp , '_histos_a_' , name )
1398 # =============================================================================
1399 def _Histos_t_ ( self , name = None ) :
1400  """
1401  Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1402 
1403  >>> tool = ... ## get the tool
1404  >>> histos = tool.Histos() ## get all histograms & profiles
1405  >>> for key in histos :
1406  ... print key, histos[key]
1407 
1408  Retrive the historgam with certain ID :
1409 
1410  >>> tool = ... ## get the tool
1411  >>> histo = tool.Histos('some histo ID') ## get the histo by ID
1412  >>> print histo
1413 
1414  """
1415  _cmp = getattr ( self , '_itool' )
1416  if not _cmp : self.retrieveInterface()
1417  _cmp = getattr ( self , '_itool' )
1418  return _get_all_histos_ ( _cmp , '_histos_t_' , name )
1419 # =============================================================================
1420 
1421 
1422 _Tools_a_ . __doc__ += '\n' + AlgDecorator . _tools_a_ . __doc__
1423 _Tools_t_ . __doc__ += '\n' + AlgDecorator . _tools_t_ . __doc__
1424 _Counters_a_ . __doc__ += '\n' + AlgDecorator . _counters_a_ . __doc__
1425 _Counters_t_ . __doc__ += '\n' + AlgDecorator . _counters_t_ . __doc__
1426 _Counter_a_ . __doc__ += '\n' + AlgDecorator . _counter_a_ . __doc__
1427 _Counter_t_ . __doc__ += '\n' + AlgDecorator . _counter_t_ . __doc__
1428 _Histos_a_ . __doc__ += '\n' + HistoDecorator . _histos_a_ . __doc__
1429 _Histos_t_ . __doc__ += '\n' + HistoDecorator . _histos_t_ . __doc__
1430 
1431 iAlgorithm . Tools = _Tools_a_
1432 iAlgTool . Tools = _Tools_t_
1433 iAlgorithm . Counters = _Counters_a_
1434 iAlgTool . Counters = _Counters_t_
1435 iAlgorithm . Counter = _Counter_a_
1436 iAlgTool . Counter = _Counter_t_
1437 iAlgorithm . Histos = _Histos_a_
1438 iAlgTool . Histos = _Histos_t_
1439 
1440 ## finally add some decoration for histograms
1442 
1443 # =============================================================================
1444 # pseudo help
1445 # =============================================================================
1446 def _help_() :
1447  print __doc__ , __author__
1448  print '\t\t\tDoc-string for class GaudiAlgo \n' , GaudiAlgo.__doc__
1449  print '\t\t\tDoc-string for class HistoAlgo \n' , HistoAlgo.__doc__
1450  print '\t\t\tDoc-string for class TupleAlgo \n' , TupleAlgo.__doc__
1451 
1452 # =============================================================================
1453 # pseudo-test suite
1454 # =============================================================================
1455 if __name__ == '__main__' :
1456  _help_()
1457 
1458 # =============================================================================
1459 # The END
1460 # =============================================================================
def _getProperty_
get the value of the given property
Definition: GaudiAlgs.py:445
def _set_attr_
set the attribute or property
Definition: GaudiAlgs.py:476
def _get
Trivial function to access the data in TES.
Definition: GaudiAlgs.py:374
def _service_
Useful method to locate a service:
Definition: GaudiAlgs.py:168
def _tool_
Useful method to locate the tool a certain.
Definition: GaudiAlgs.py:121
def _evtcolSvc
Trivial helper function to access Event Collection Service.
Definition: GaudiAlgs.py:415
def _init_
The constructor from unique algorithm instance name,.
Definition: GaudiAlgs.py:191
def _initialize_tuple_
The default initialization (initialization of base C++ class + data members)
Definition: GaudiAlgs.py:255
def _get_all_counters_
get all counters
Definition: GaudiAlgs.py:1235
def _Counters_a_
get all counters
Definition: GaudiAlgs.py:1254
string type
Definition: gaudirun.py:126
def _getDet
Trivial function to access the data in TDS.
Definition: GaudiAlgs.py:382
def _success_
Dummy method returning success.
Definition: GaudiAlgs.py:432
The base class for easy histogramming.
Definition: GaudiAlgs.py:678
def _detSvc
Trivial helper function to access Detector Data and Detector Data Service.
Definition: GaudiAlgs.py:325
def _ntupleSvc
Trivial helper function to access NTuple Service.
Definition: GaudiAlgs.py:407
def _setProperty_
set the value for the given property
Definition: GaudiAlgs.py:455
def _histoSvc
Trivial helper function to access Histogram Data and Histogram Data Service.
Definition: GaudiAlgs.py:357
def _exist_
check the data from TES using GaudiCommon methods, respecting RootInTES
Definition: GaudiAlgs.py:398
def _get_attr_
get the attribute or property
Definition: GaudiAlgs.py:465
The base class for easy manupulations with N-Tuples.
Definition: GaudiAlgs.py:788
def _initialize_
The default initialization (initialization of base C++ class + data.
Definition: GaudiAlgs.py:213
the base class for all algorithm Python-image of C++ clkass GaudiAlgorithm
Definition: GaudiAlgs.py:552
def _finalize_
The default finalization (finalization of base C++ class)
Definition: GaudiAlgs.py:424
def _initialize_histo_
The default initialization (initialization of base C++ class + data members)
Definition: GaudiAlgs.py:236
def _get_
get the data from TES using GaudiCommon methods, respecting RootInTES
Definition: GaudiAlgs.py:390
def _evtSvc
Trivial helper function to access Event Data and Event Data Service.
Definition: GaudiAlgs.py:292
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:133