21 *******************************************************************************
22 * * 'Physisics do not like it, *
23 * * physisics do not need it, *
24 * * physisics do not use it' *
25 * * ****************************
27 * Helper module, which effectively 'imports' few useful C++ algorithmic *
28 * base classes into Python *
30 *******************************************************************************
31 * The major imported classes are : *
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 *******************************************************************************
39 __author__ =
'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
86 AlgDecorator = cpp.GaudiPython.AlgDecorator
87 HistoDecorator = cpp.GaudiPython.HistoDecorator
88 TupleAlgDecorator = cpp.GaudiPython.TupleAlgDecorator
89 TupleDecorator = cpp.GaudiPython.TupleDecorator
122 Useful method to locate the tool a certain
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)
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
147 self.Warning(
'Invalid cast to interface %s' % interface )
169 Useful method to locate a service:
173 ntsvc = self.svc( INTupleSvc , 'NTUpleSvc' )
176 if not interface : interface = cpp.IInterface
177 _svc = AlgDecorator.svc_ ( self , name , create )
178 if not _svc :
return None
181 self.Warning(
'Invalid cast to interface %s' % interface )
192 The constructor from unique algorithm instance name & parameters
194 self._Base.__init__( self , self , name )
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] )
203 if not appMgr.__dict__.has_key (
'GaudiPythonAlgos') :
204 appMgr.__dict__[
'GaudiPythonAlgos'] = []
205 appMgr.__dict__[
'GaudiPythonAlgos'].append( self )
214 The default initialization (initialization of base C++ class + data)
216 status = self._Base.initialize_( self )
217 if status.isFailure() :
return status
220 _e = self._Base.evtSvc( self )
222 self._evtSvc_ = iDataSvc ( _s.name() , _e )
224 _d = self._Base.detSvc( self )
226 self._detSvc_ = iDataSvc ( _s.name() , _d )
237 The default initialization (initialization of base C++ class + data members)
240 if status.isFailure() :
return status
243 _h = self._Base.histoSvc( self )
245 self._histoSvc_ = iHistogramSvc ( _s.name() , _h )
256 The default initialization (initialization of base C++ class + data members)
259 if status.isFailure() :
return status
262 if self.produceNTuples() :
263 _n = self._Base.ntupleSvc( self )
265 self._ntupleSvc_ = iNTupleSvc ( _s.name() , _n )
267 if self.produceEvtCols() :
268 _n = self._Base.evtColSvc( self )
270 self._evtcolSvc_ = iNTupleSvc ( _s.name() , _n )
293 Trivial helper function to access Event Data and Event Data Service
297 # get event data service
301 hits = self.evtSvc('MC/Calo/Hits')
305 return self._evtSvc_[location]
326 Trivial helper function to access Detector Data and Event Data Service
329 # get detector data service
333 lhcb = self.detSvc('/dd/Structure/LHCb')
337 return self._detSvc_[location]
358 Trivial helper function to access Histogram Data and Histogram Data Service
362 # get histogram data service
363 svc = self.histoSvc()
366 histo = self.histoSvc('/stat/Calo/1')
368 if not address :
return self._histoSvc_
369 return self._histoSvc_[ address ]
375 Trivial function to access the data in TES using the data service
377 return self._evtSvc_[location]
383 Trivial function to access the data in TDS using data service
385 return self._detSvc_[location]
389 def _get_ ( self , location , rootInTES = True ) :
391 Get the object from Transient Event Store using GaudiCommon machinery,
392 respecting RootInTES behaviour
394 return AlgDecorator.get_ ( self , location , rootInTES )
397 def _exist_ ( self , location , rootInTES = True ) :
399 Check the object in Transient Event Store using GaudiCommon machinery,
400 respecting RootInTES behaviour
402 return AlgDecorator.exist_ ( self , location , rootInTES )
408 Trivial function to access N-Tuple Service
410 return self._ntupleSvc_
416 Trivial function to access Event Collection Service
418 return self._evtcolSvc_
425 The default finalization : finalize the base C++ class
427 status = self._Base.finalize_ ( self )
436 def _hasProperty_ ( self , pname ) :
438 The trivial function which checks the existence of the property with given name
440 return cpp.Gaudi.Utils.hasProperty ( self , pname )
446 Get the property by name
448 if not self.hasProperty( pname ) :
449 raise AttributeError,
'property %s does not exist' % pname
450 return iAlgorithm.__getattr__( self , pname )
456 Set the property from the value
458 if not self.hasProperty( pname ) :
459 raise AttributeError,
'property %s does not exist' % pname
460 return iAlgorithm.__setattr__ ( self , pname , pvalue )
466 Get the attribute (or property)
467 - if the attribute name corresponds to the property name, property value is returned
469 if self.hasProperty( pname ) :
470 return iAlgorithm.__getattr__ ( self , pname )
471 raise AttributeError,
'attribute/property %s does not exist' % pname
477 Set the attribute (or property) :
478 - if the attribute name corresponds to the property name, the property is updated
480 if not self.hasProperty( pname ) : self.__dict__[pname] = pvalue
481 else : iAlgorithm.__setattr__ ( self , pname , pvalue )
484 _GaudiAlgorithm = cpp.GaudiPython.PyAlg(
'GaudiAlgorithm' )
485 _GaudiHistoAlg = cpp.GaudiPython.PyAlg(
'GaudiHistoAlg' )
486 _GaudiTupleAlg = cpp.GaudiPython.PyAlg(
'GaudiTupleAlg' )
553 *******************************************************************************
554 * * 'Physisics do not like it, *
555 * * physisics do not need it, *
556 * * physisics do not use it' *
557 * * ****************************
560 * from GaudiPython.GaudiAlgs import GaudiAlgo, SUCCESS *
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 ) *
569 * def initialize ( self ) : *
570 * 'Algorithm initialization' *
571 * # initialize the base class *
572 * status = GaudiAlgo.initialize( self ) *
573 * if status.isFailure() : return status *
575 * # locate the services and tools *
577 * # locate some tool: *
578 * extrapolator = self.tool(ITrExtrapolator,'TrExtrapolator') *
580 * # locate the service *
581 * rndmSvc = self.svc(IRndmGenSvc, 'RndmGenSvc') *
586 * def execute ( self ) : *
587 * 'Major method (from IAlgorithm interface)' *
589 * # get some data from Transient Event Store *
590 * tracks = self.get('/Event/Rec/Tracks') *
593 * c1 = self.counter('#Tracks') *
594 * c2 = self.counter('No Tracks') *
595 * if tracks.empty : *
597 * c1 += tracks->size() *
599 * if 1000 < tracks.size() : *
600 * return self.Error('The event is *VERY* busy') *
604 *******************************************************************************
679 *******************************************************************************
680 * * 'Physisics do not like it, *
681 * * physisics do not need it, *
682 * * physisics do not use it' *
683 * * ****************************
686 * from GaudiPython.GaudiAlgs import HistoAlgo, SUCCESS *
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 ) *
695 * def execute ( self ) : *
696 * 'Major method (from IAlgorithm interface)' *
698 * # get some data from Transient Event Store *
699 * tracks = self.get('/Event/Rec/Tracks') *
701 * self.plot1D ( tracks->size() , '#tracks' , 0 , 100 ) *
705 * Alternatively the histogram could be booked in advance: *
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 ) *
714 * def initialize ( self ) : *
715 * 'Algorithm initialization' *
716 * # initialize the base class *
717 * status = HistoAlgo.initialize( self ) *
718 * if status.isFailure() : return status *
720 * # book the histogram *
721 * self.h1 = selff.book1D ( '#tracks' , 0 , 100 ) *
726 * def execute ( self ) : *
727 * 'Major method (from IAlgorithm interface)' *
729 * # get some data from Transient Event Store *
730 * tracks = self.get('/Event/Rec/Tracks') *
732 * # fill the histogram *
733 * self.h1.fill ( tracks->size() ) *
737 *******************************************************************************
789 *******************************************************************************
790 * * 'Physisics do not like it, *
791 * * physisics do not need it, *
792 * * physisics do not use it' *
793 * * ****************************
796 * from GaudiPython.GaudiAlgs import TupleAlgo, SUCCESS *
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 ) *
805 * def execute ( self ) : *
806 * 'Major method (from IAlgorithm interface)' *
808 * # get some data from Transient Event Store *
809 * tracks = self.get('/Event/Rec/Tracks') *
811 * tup = self.nTuple('My N-Tuple') *
813 * for track in tracks : *
817 * chi2 = track.chi2 () *
820 * tup.column ( 'pt' , pt ) *
821 * tup.column ( 'p' , p ) *
822 * tup.column ( 'chi2' , chi2 ) *
828 *******************************************************************************
836 return self.
method(*args )
838 GaudiAlgo._Base = _GaudiAlgorithm
839 HistoAlgo._Base = _GaudiHistoAlg
840 TupleAlgo._Base = _GaudiTupleAlg
843 GaudiAlgo.initialize = _initialize_
844 HistoAlgo.initialize = _initialize_histo_
845 TupleAlgo.initialize = _initialize_tuple_
849 The stub 'start' method needed by the internal implementation of PyAlg<>.
854 GaudiAlgo.start = _start_
855 HistoAlgo.start = _start_
856 TupleAlgo.start = _start_
860 The fictive 'execute' method, which MUST be overwitten by user
862 raise RuntimeError,
'Execute method is not implemented for %s' % self.name()
864 GaudiAlgo.execute = _execute_
865 HistoAlgo.execute = _execute_
866 TupleAlgo.execute = _execute_
870 The stub 'stop' method needed by the internal implementation of PyAlg<>.
875 GaudiAlgo.stop = _stop_
876 HistoAlgo.stop = _stop_
877 TupleAlgo.stop = _stop_
882 The basic method to fill (book-on-demand) 1D-histogram
884 The histogram will be created/booked dautomatically according to the
887 - literal or numerical ID (optional)
891 - number of bins (default is 100)
893 The reference to the histogram is returned and could be used for later manipulations
896 return HistoDecorator.plot1D (s,*a)
900 The basic method to fill (book-on-demand) 2D-histogram
902 The histogram will be created/booked dautomatically according to the
905 - literal or numerical ID (optional)
911 - number of X-bins (default is 50)
912 - number of Y-bins (default is 50)
914 The reference to the histogram is returned and could be used for later manipulations
917 return HistoDecorator.plot2D (s,*a)
921 The basic method to fill (book-on-demand) 3D-histogram
923 The histogram will be created/booked dautomatically according to the
926 - literal or numerical ID (optional)
934 - number of X-bins (default is 10)
935 - number of Y-bins (default is 10)
936 - number of Y-bins (default is 10)
938 The reference to the histogram is returned and could be used for later manipulations
941 return HistoDecorator.plot3D (s,*a)
945 The basic method to fill (book-on-demand) 1D profile histogram
947 The profile histogram will be created/booked dautomatically
948 according to the specifications:
950 - literal or numerical ID (optional)
954 - number of X-bins (default is 100)
956 The reference to the histogram is returned and could be used for later manipulations
959 return HistoDecorator.profile1D (s,*a)
963 The basic method to fill (book-on-demand) 2D profile histiogram
965 The profile histogram will be created/booked automatically
966 according to the specifications:
968 - literal or numerical ID (optional)
974 - number of X-bins (default is 50)
975 - number of Y-bins (default is 50)
977 The reference to the histogram is returned and could be used for later manipulations
980 return HistoDecorator.profile2D (s,*a)
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__
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_
1001 _decorate_plots_ ( HistoAlgo )
1002 _decorate_plots_ ( TupleAlgo )
1008 Retrieve (book-on-demand) N-Tuple object
1010 return TupleAlgDecorator.nTuple ( s , *a )
1014 Retrieve (book-on-demand) N-Tuple object for Event Tag Collections
1016 return TupleAlgDecorator.evtCol ( s , *a )
1018 _nTuple_.__doc__ +=
'\n' + TupleAlgDecorator.nTuple.__doc__
1019 _evtCol_.__doc__ +=
'\n' + TupleAlgDecorator.evtCol.__doc__
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
1036 _decorate_tuples_ ( TupleAlgo )
1040 Tuple = cpp.Tuples.Tuple
1041 _Dec = TupleDecorator
1044 Access to underlying INTuple object
1046 return _Dec.nTuple ( s , *a )
1049 Access to underlying NTuple::Tuple object
1051 return _Dec.ntuple ( s , *a )
1054 Valid NTuple::Tuple object?
1056 return _Dec.valid ( s , *a )
1059 Commit the row/record to n-tuple
1061 return _Dec.write ( s , *a )
1064 Fill the certain column to n-tuple
1066 return _Dec.column ( s , *a )
1069 Fill the 'long long' column
1071 return _Dec.column_ll ( s , *a )
1074 Fill the 'unsigned long long' column
1076 return _Dec.column_ull ( s , *a )
1079 Fill the fixed-size array column
1081 return _Dec.array ( s , *a )
1084 Fill the fixed-size matrix column
1086 return _Dec.matrix ( s , *a )
1089 Fill the floating-size array column
1091 return _Dec.farray ( s , *a )
1094 Fill the floating-size matrix column
1096 return _Dec.fmatrix ( s , *a )
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__
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_
1123 '__init__' : _init_ ,
1126 'evtSvc' : _evtSvc ,
1127 'eventSvc' : _evtSvc ,
1128 'detSvc' : _detSvc ,
1129 'histoSvc' : _histoSvc ,
1130 'histSvc' : _histoSvc ,
1133 'exist_' : _exist_ ,
1134 'getDet' : _getDet ,
1135 'finalize' : _finalize_ ,
1136 'beginRun' : _success_ ,
1137 'endRun' : _success_ ,
1139 'hasProperty' : _hasProperty_ ,
1140 'getProperty' : _getProperty_ ,
1141 'setProperty' : _setProperty_ ,
1142 '__setattr__' : _set_attr_ ,
1143 '__getattr__' : _get_attr_
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] )
1156 _decorate_algs_ ( GaudiAlgo )
1157 _decorate_algs_ ( HistoAlgo )
1158 _decorate_algs_ ( TupleAlgo )
1163 def mapvct ( func , sequence , ovct = None ) :
1164 """ Helper function to fill histogram/ntuple using 'map'-operation """
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
1189 _func = getattr ( AlgDecorator , method )
1190 _num = _func ( self , _tools )
1191 if _tools.size() != _num :
1192 raise RuntimeError,
'Unable to extract Tools'
1194 for _tool
in _tools : _res += [ iAlgTool ( _tool.name() , _tool ) ]
1199 Retrieve the list of tools,
1200 aquired by component through GaudiCommon<TYPE> base:
1202 >>> alg = ... ## get the algorithm
1203 >>> tools = alg.Tools() ## get the tools
1204 >>> for tool in tools :
1208 _cmp = getattr ( self ,
'_ialg' )
1209 if not _cmp : self.retrieveInterface()
1210 _cmp = getattr ( self ,
'_ialg' )
1211 return _get_all_tools_ ( _cmp ,
'_tools_a_' )
1215 Retrieve the list of tools,
1216 aquired by component through GaudiCommon<TYPE> base:
1218 >>> tool = ... ## get the tool
1219 >>> tools = tool.Tools() ## get the tools
1220 >>> for t in tools :
1224 _cmp = getattr ( self ,
'_itool' )
1225 if not _cmp : self.retrieveInterface()
1226 _cmp = getattr ( self ,
'_itool' )
1227 return _get_all_tools_ ( _cmp ,
'_tools_t_' )
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'
1245 for _i
in range(0,_num) :
1248 _res [ _nam ] = _cnt
1249 if not name :
return _res
1250 return _res.get( name ,
None )
1255 Retrieve the counters, managed GaudiCommon<TYPE> base:
1257 >>> alg = ... ## get the algorithm
1258 >>> cnts = alg.Counters() ## get the counters
1259 >>> for key in cnts :
1260 ... print key, cnts[key]
1263 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1265 >>> alg = ... ## get the algorithm
1266 >>> cnt = alg.Counters('MyCounter') ## get the counter
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 )
1277 Retrieve the counters, managed GaudiCommon<TYPE> base:
1279 >>> tool = ... ## get the tool
1280 >>> cnts = tool.Counters() ## get the counters
1281 >>> for key in cnts :
1282 ... print key, cnts[key]
1285 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1287 >>> tool = ... ## get the tool
1288 >>> cnt = tool.Counters('MyCounter') ## get the counter
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 )
1303 _func = getattr ( AlgDecorator , method )
1304 return _func ( self , name )
1308 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1310 >>> alg = ... ## get the algorithm
1311 >>> cnt = alg.Counter('#accept') ## get the counter
1315 _cmp = getattr ( self ,
'_ialg' )
1316 if not _cmp : self.retrieveInterface()
1317 _cmp = getattr ( self ,
'_ialg' )
1318 return _get_counter_ ( _cmp ,
'_counter_a_' , name )
1322 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1324 >>> tool = ... ## get the tool
1325 >>> cnt = tool.Counter('#accept') ## get the counter
1329 _cmp = getattr ( self ,
'_itool' )
1330 if not _cmp : self.retrieveInterface()
1331 _cmp = getattr ( self ,
'_itool' )
1332 return _get_counter_ ( _cmp ,
'_counter_t_' , name )
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
1344 Get All histogram form the component
1347 for _his
in (
std.vector(
'AIDA::IProfile2D*' ) ,
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) :
1360 if _id.numeric() : _id = _id.numericID ()
1361 elif _id.literal() : _id = _id.literalID ()
1362 else : _id = _is.idAsString ()
1363 _res [ _id ] = _his[ _i ]
1365 if not name :
return _res
1367 id = cpp.GaudiAlg.ID ( name )
1371 id.idAsString() , id ) :
1372 h = _res.get( i ,
None )
1373 if not not h :
return h
1379 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1381 >>> alg = ... ## get the algorithm
1382 >>> histos = alg.Histos() ## get all histograms & profiles
1383 >>> for key in histos :
1384 ... print key, histos[key]
1386 Retrive the histogram with the certain ID :
1388 >>> alg = ... ## get the algorithm
1389 >>> histo = alg.Histos('some histo ID') ## get the histo by ID
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 )
1400 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1402 >>> tool = ... ## get the tool
1403 >>> histos = tool.Histos() ## get all histograms & profiles
1404 >>> for key in histos :
1405 ... print key, histos[key]
1407 Retrive the historgam with certain ID :
1409 >>> tool = ... ## get the tool
1410 >>> histo = tool.Histos('some histo ID') ## get the histo by ID
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 )
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__
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_
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__
1454 if __name__ ==
'__main__' :