Gaudi Framework, version v23r5

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

Generated at Wed Nov 28 2012 12:17:17 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004