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'
76 Vector = std.vector(
'double')
78 Matrix = std.vector(
'std::vector<double>')
87 AlgDecorator = cpp.GaudiPython.AlgDecorator
88 HistoDecorator = cpp.GaudiPython.HistoDecorator
89 TupleAlgDecorator = cpp.GaudiPython.TupleAlgDecorator
90 TupleDecorator = cpp.GaudiPython.TupleDecorator
123 Useful method to locate the tool a certain
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)
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
148 self.Warning(
'Invalid cast to interface %s' % interface )
170 Useful method to locate a service:
174 ntsvc = self.svc( INTupleSvc , 'NTUpleSvc' )
177 if not interface : interface = cpp.IInterface
178 _svc = AlgDecorator.svc_ ( self , name , create )
179 if not _svc :
return None
182 self.Warning(
'Invalid cast to interface %s' % interface )
193 The constructor from unique algorithm instance name & parameters
195 self._Base.__init__( self , self , name )
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] )
204 if not appMgr.__dict__.has_key (
'GaudiPythonAlgos') :
205 appMgr.__dict__[
'GaudiPythonAlgos'] = []
206 appMgr.__dict__[
'GaudiPythonAlgos'].append( self )
215 The default initialization (initialization of base C++ class + data)
217 status = self._Base.initialize_( self )
218 if status.isFailure() :
return status
221 _e = self._Base.evtSvc( self )
223 self._evtSvc_ = iDataSvc ( _s.name() , _e )
225 _d = self._Base.detSvc( self )
227 self._detSvc_ = iDataSvc ( _s.name() , _d )
238 The default initialization (initialization of base C++ class + data members)
241 if status.isFailure() :
return status
244 _h = self._Base.histoSvc( self )
246 self._histoSvc_ = iHistogramSvc ( _s.name() , _h )
257 The default initialization (initialization of base C++ class + data members)
260 if status.isFailure() :
return status
263 if self.produceNTuples() :
264 _n = self._Base.ntupleSvc( self )
266 self._ntupleSvc_ = iNTupleSvc ( _s.name() , _n )
268 if self.produceEvtCols() :
269 _n = self._Base.evtColSvc( self )
271 self._evtcolSvc_ = iNTupleSvc ( _s.name() , _n )
294 Trivial helper function to access Event Data and Event Data Service
298 # get event data service
302 hits = self.evtSvc('MC/Calo/Hits')
306 return self._evtSvc_[location]
327 Trivial helper function to access Detector Data and Event Data Service
330 # get detector data service
334 lhcb = self.detSvc('/dd/Structure/LHCb')
338 return self._detSvc_[location]
359 Trivial helper function to access Histogram Data and Histogram Data Service
363 # get histogram data service
364 svc = self.histoSvc()
367 histo = self.histoSvc('/stat/Calo/1')
369 if not address :
return self._histoSvc_
370 return self._histoSvc_[ address ]
376 Trivial function to access the data in TES using the data service
378 return self._evtSvc_[location]
384 Trivial function to access the data in TDS using data service
386 return self._detSvc_[location]
390 def _get_ ( self , location , rootInTES = True ) :
392 Get the object from Transient Event Store using GaudiCommon machinery,
393 respecting RootInTES behaviour
395 return AlgDecorator.get_ ( self , location , rootInTES )
398 def _exist_ ( self , location , rootInTES = True ) :
400 Check the object in Transient Event Store using GaudiCommon machinery,
401 respecting RootInTES behaviour
403 return AlgDecorator.exist_ ( self , location , rootInTES )
409 Trivial function to access N-Tuple Service
411 return self._ntupleSvc_
417 Trivial function to access Event Collection Service
419 return self._evtcolSvc_
426 The default finalization : finalize the base C++ class
428 status = self._Base.finalize_ ( self )
437 def _hasProperty_ ( self , pname ) :
439 The trivial function which checks the existence of the property with given name
441 return cpp.Gaudi.Utils.hasProperty ( self , pname )
447 Get the property by name
449 if not self.hasProperty( pname ) :
450 raise AttributeError,
'property %s does not exist' % pname
451 return iAlgorithm.__getattr__( self , pname )
457 Set the property from the value
459 if not self.hasProperty( pname ) :
460 raise AttributeError,
'property %s does not exist' % pname
461 return iAlgorithm.__setattr__ ( self , pname , pvalue )
467 Get the attribute (or property)
468 - if the attribute name corresponds to the property name, property value is returned
470 if self.hasProperty( pname ) :
471 return iAlgorithm.__getattr__ ( self , pname )
472 raise AttributeError,
'attribute/property %s does not exist' % pname
478 Set the attribute (or property) :
479 - if the attribute name corresponds to the property name, the property is updated
481 if not self.hasProperty( pname ) : self.__dict__[pname] = pvalue
482 else : iAlgorithm.__setattr__ ( self , pname , pvalue )
485 _GaudiAlgorithm = cpp.GaudiPython.PyAlg(
'GaudiAlgorithm' )
486 _GaudiHistoAlg = cpp.GaudiPython.PyAlg(
'GaudiHistoAlg' )
487 _GaudiTupleAlg = cpp.GaudiPython.PyAlg(
'GaudiTupleAlg' )
554 *******************************************************************************
555 * * 'Physisics do not like it, *
556 * * physisics do not need it, *
557 * * physisics do not use it' *
558 * * ****************************
561 * from GaudiPython.GaudiAlgs import GaudiAlgo, SUCCESS *
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 ) *
570 * def initialize ( self ) : *
571 * 'Algorithm initialization' *
572 * # initialize the base class *
573 * status = GaudiAlgo.initialize( self ) *
574 * if status.isFailure() : return status *
576 * # locate the services and tools *
578 * # locate some tool: *
579 * extrapolator = self.tool(ITrExtrapolator,'TrExtrapolator') *
581 * # locate the service *
582 * rndmSvc = self.svc(IRndmGenSvc, 'RndmGenSvc') *
587 * def execute ( self ) : *
588 * 'Major method (from IAlgorithm interface)' *
590 * # get some data from Transient Event Store *
591 * tracks = self.get('/Event/Rec/Tracks') *
594 * c1 = self.counter('#Tracks') *
595 * c2 = self.counter('No Tracks') *
596 * if tracks.empty : *
598 * c1 += tracks->size() *
600 * if 1000 < tracks.size() : *
601 * return self.Error('The event is *VERY* busy') *
605 *******************************************************************************
680 *******************************************************************************
681 * * 'Physisics do not like it, *
682 * * physisics do not need it, *
683 * * physisics do not use it' *
684 * * ****************************
687 * from GaudiPython.GaudiAlgs import HistoAlgo, SUCCESS *
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 ) *
696 * def execute ( self ) : *
697 * 'Major method (from IAlgorithm interface)' *
699 * # get some data from Transient Event Store *
700 * tracks = self.get('/Event/Rec/Tracks') *
702 * self.plot1D ( tracks->size() , '#tracks' , 0 , 100 ) *
706 * Alternatively the histogram could be booked in advance: *
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 ) *
715 * def initialize ( self ) : *
716 * 'Algorithm initialization' *
717 * # initialize the base class *
718 * status = HistoAlgo.initialize( self ) *
719 * if status.isFailure() : return status *
721 * # book the histogram *
722 * self.h1 = selff.book1D ( '#tracks' , 0 , 100 ) *
727 * def execute ( self ) : *
728 * 'Major method (from IAlgorithm interface)' *
730 * # get some data from Transient Event Store *
731 * tracks = self.get('/Event/Rec/Tracks') *
733 * # fill the histogram *
734 * self.h1.fill ( tracks->size() ) *
738 *******************************************************************************
790 *******************************************************************************
791 * * 'Physisics do not like it, *
792 * * physisics do not need it, *
793 * * physisics do not use it' *
794 * * ****************************
797 * from GaudiPython.GaudiAlgs import TupleAlgo, SUCCESS *
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 ) *
806 * def execute ( self ) : *
807 * 'Major method (from IAlgorithm interface)' *
809 * # get some data from Transient Event Store *
810 * tracks = self.get('/Event/Rec/Tracks') *
812 * tup = self.nTuple('My N-Tuple') *
814 * for track in tracks : *
818 * chi2 = track.chi2 () *
821 * tup.column ( 'pt' , pt ) *
822 * tup.column ( 'p' , p ) *
823 * tup.column ( 'chi2' , chi2 ) *
829 *******************************************************************************
837 return self.
method(*args )
839 GaudiAlgo._Base = _GaudiAlgorithm
840 HistoAlgo._Base = _GaudiHistoAlg
841 TupleAlgo._Base = _GaudiTupleAlg
844 GaudiAlgo.initialize = _initialize_
845 HistoAlgo.initialize = _initialize_histo_
846 TupleAlgo.initialize = _initialize_tuple_
850 The stub 'start' method needed by the internal implementation of PyAlg<>.
855 GaudiAlgo.start = _start_
856 HistoAlgo.start = _start_
857 TupleAlgo.start = _start_
861 The fictive 'execute' method, which MUST be overwitten by user
863 raise RuntimeError,
'Execute method is not implemented for %s' % self.name()
865 GaudiAlgo.execute = _execute_
866 HistoAlgo.execute = _execute_
867 TupleAlgo.execute = _execute_
871 The stub 'stop' method needed by the internal implementation of PyAlg<>.
876 GaudiAlgo.stop = _stop_
877 HistoAlgo.stop = _stop_
878 TupleAlgo.stop = _stop_
883 The basic method to fill (book-on-demand) 1D-histogram
885 The histogram will be created/booked dautomatically according to the
888 - literal or numerical ID (optional)
892 - number of bins (default is 100)
894 The reference to the histogram is returned and could be used for later manipulations
897 return HistoDecorator.plot1D (s,*a)
901 The basic method to fill (book-on-demand) 2D-histogram
903 The histogram will be created/booked dautomatically according to the
906 - literal or numerical ID (optional)
912 - number of X-bins (default is 50)
913 - number of Y-bins (default is 50)
915 The reference to the histogram is returned and could be used for later manipulations
918 return HistoDecorator.plot2D (s,*a)
922 The basic method to fill (book-on-demand) 3D-histogram
924 The histogram will be created/booked dautomatically according to the
927 - literal or numerical ID (optional)
935 - number of X-bins (default is 10)
936 - number of Y-bins (default is 10)
937 - number of Y-bins (default is 10)
939 The reference to the histogram is returned and could be used for later manipulations
942 return HistoDecorator.plot3D (s,*a)
946 The basic method to fill (book-on-demand) 1D profile histogram
948 The profile histogram will be created/booked dautomatically
949 according to the specifications:
951 - literal or numerical ID (optional)
955 - number of X-bins (default is 100)
957 The reference to the histogram is returned and could be used for later manipulations
960 return HistoDecorator.profile1D (s,*a)
964 The basic method to fill (book-on-demand) 2D profile histiogram
966 The profile histogram will be created/booked automatically
967 according to the specifications:
969 - literal or numerical ID (optional)
975 - number of X-bins (default is 50)
976 - number of Y-bins (default is 50)
978 The reference to the histogram is returned and could be used for later manipulations
981 return HistoDecorator.profile2D (s,*a)
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__
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_
1002 _decorate_plots_ ( HistoAlgo )
1003 _decorate_plots_ ( TupleAlgo )
1009 Retrieve (book-on-demand) N-Tuple object
1011 return TupleAlgDecorator.nTuple ( s , *a )
1015 Retrieve (book-on-demand) N-Tuple object for Event Tag Collections
1017 return TupleAlgDecorator.evtCol ( s , *a )
1019 _nTuple_.__doc__ +=
'\n' + TupleAlgDecorator.nTuple.__doc__
1020 _evtCol_.__doc__ +=
'\n' + TupleAlgDecorator.evtCol.__doc__
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
1037 _decorate_tuples_ ( TupleAlgo )
1041 Tuple = cpp.Tuples.Tuple
1042 _Dec = TupleDecorator
1045 Access to underlying INTuple object
1047 return _Dec.nTuple ( s , *a )
1050 Access to underlying NTuple::Tuple object
1052 return _Dec.ntuple ( s , *a )
1055 Valid NTuple::Tuple object?
1057 return _Dec.valid ( s , *a )
1060 Commit the row/record to n-tuple
1062 return _Dec.write ( s , *a )
1065 Fill the certain column to n-tuple
1067 return _Dec.column ( s , *a )
1070 Fill the 'long long' column
1072 return _Dec.column_ll ( s , *a )
1075 Fill the 'unsigned long long' column
1077 return _Dec.column_ull ( s , *a )
1080 Fill the fixed-size array column
1082 return _Dec.array ( s , *a )
1085 Fill the fixed-size matrix column
1087 return _Dec.matrix ( s , *a )
1090 Fill the floating-size array column
1092 return _Dec.farray ( s , *a )
1095 Fill the floating-size matrix column
1097 return _Dec.fmatrix ( s , *a )
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__
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_
1124 '__init__' : _init_ ,
1127 'evtSvc' : _evtSvc ,
1128 'eventSvc' : _evtSvc ,
1129 'detSvc' : _detSvc ,
1130 'histoSvc' : _histoSvc ,
1131 'histSvc' : _histoSvc ,
1134 'exist_' : _exist_ ,
1135 'getDet' : _getDet ,
1136 'finalize' : _finalize_ ,
1137 'beginRun' : _success_ ,
1138 'endRun' : _success_ ,
1140 'hasProperty' : _hasProperty_ ,
1141 'getProperty' : _getProperty_ ,
1142 'setProperty' : _setProperty_ ,
1143 '__setattr__' : _set_attr_ ,
1144 '__getattr__' : _get_attr_
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] )
1157 _decorate_algs_ ( GaudiAlgo )
1158 _decorate_algs_ ( HistoAlgo )
1159 _decorate_algs_ ( TupleAlgo )
1164 def mapvct ( func , sequence , ovct = None ) :
1165 """ Helper function to fill histogram/ntuple using 'map'-operation """
1167 vct = GaudiPython.Vector
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
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'
1195 for _tool
in _tools : _res += [ iAlgTool ( _tool.name() , _tool ) ]
1200 Retrieve the list of tools,
1201 aquired by component through GaudiCommon<TYPE> base:
1203 >>> alg = ... ## get the algorithm
1204 >>> tools = alg.Tools() ## get the tools
1205 >>> for tool in tools :
1209 _cmp = getattr ( self ,
'_ialg' )
1210 if not _cmp : self.retrieveInterface()
1211 _cmp = getattr ( self ,
'_ialg' )
1212 return _get_all_tools_ ( _cmp ,
'_tools_a_' )
1216 Retrieve the list of tools,
1217 aquired by component through GaudiCommon<TYPE> base:
1219 >>> tool = ... ## get the tool
1220 >>> tools = tool.Tools() ## get the tools
1221 >>> for t in tools :
1225 _cmp = getattr ( self ,
'_itool' )
1226 if not _cmp : self.retrieveInterface()
1227 _cmp = getattr ( self ,
'_itool' )
1228 return _get_all_tools_ ( _cmp ,
'_tools_t_' )
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'
1246 for _i
in range(0,_num) :
1249 _res [ _nam ] = _cnt
1250 if not name :
return _res
1251 return _res.get( name ,
None )
1256 Retrieve the counters, managed GaudiCommon<TYPE> base:
1258 >>> alg = ... ## get the algorithm
1259 >>> cnts = alg.Counters() ## get the counters
1260 >>> for key in cnts :
1261 ... print key, cnts[key]
1264 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1266 >>> alg = ... ## get the algorithm
1267 >>> cnt = alg.Counters('MyCounter') ## get the counter
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 )
1278 Retrieve the counters, managed GaudiCommon<TYPE> base:
1280 >>> tool = ... ## get the tool
1281 >>> cnts = tool.Counters() ## get the counters
1282 >>> for key in cnts :
1283 ... print key, cnts[key]
1286 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1288 >>> tool = ... ## get the tool
1289 >>> cnt = tool.Counters('MyCounter') ## get the counter
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 )
1304 _func = getattr ( AlgDecorator , method )
1305 return _func ( self , name )
1309 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1311 >>> alg = ... ## get the algorithm
1312 >>> cnt = alg.Counter('#accept') ## get the counter
1316 _cmp = getattr ( self ,
'_ialg' )
1317 if not _cmp : self.retrieveInterface()
1318 _cmp = getattr ( self ,
'_ialg' )
1319 return _get_counter_ ( _cmp ,
'_counter_a_' , name )
1323 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1325 >>> tool = ... ## get the tool
1326 >>> cnt = tool.Counter('#accept') ## get the counter
1330 _cmp = getattr ( self ,
'_itool' )
1331 if not _cmp : self.retrieveInterface()
1332 _cmp = getattr ( self ,
'_itool' )
1333 return _get_counter_ ( _cmp ,
'_counter_t_' , name )
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
1345 Get All histogram form the component
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*' ) ) :
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) :
1361 if _id.numeric() : _id = _id.numericID ()
1362 elif _id.literal() : _id = _id.literalID ()
1363 else : _id = _is.idAsString ()
1364 _res[ _id ] = _his[ _i ]
1366 if not name :
return _res
1368 id = cpp.GaudiAlg.ID ( name )
1372 id.idAsString() , id ) :
1373 h = _res.get( i ,
None )
1374 if not not h :
return h
1380 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1382 >>> alg = ... ## get the algorithm
1383 >>> histos = alg.Histos() ## get all histograms & profiles
1384 >>> for key in histos :
1385 ... print key, histos[key]
1387 Retrive the histogram with the certain ID :
1389 >>> alg = ... ## get the algorithm
1390 >>> histo = alg.Histos('some histo ID') ## get the histo by ID
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 )
1401 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1403 >>> tool = ... ## get the tool
1404 >>> histos = tool.Histos() ## get all histograms & profiles
1405 >>> for key in histos :
1406 ... print key, histos[key]
1408 Retrive the historgam with certain ID :
1410 >>> tool = ... ## get the tool
1411 >>> histo = tool.Histos('some histo ID') ## get the histo by ID
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 )
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__
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_
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__
1455 if __name__ ==
'__main__' :
def _getProperty_
get the value of the given property
def _set_attr_
set the attribute or property
def _get
Trivial function to access the data in TES.
def _service_
Useful method to locate a service:
def _tool_
Useful method to locate the tool a certain.
def _evtcolSvc
Trivial helper function to access Event Collection Service.
def _init_
The constructor from unique algorithm instance name,.
def _initialize_tuple_
The default initialization (initialization of base C++ class + data members)
def _get_all_counters_
get all counters
def _Counters_a_
get all counters
def _getDet
Trivial function to access the data in TDS.
def _success_
Dummy method returning success.
The base class for easy histogramming.
def _detSvc
Trivial helper function to access Detector Data and Detector Data Service.
def _ntupleSvc
Trivial helper function to access NTuple Service.
def _setProperty_
set the value for the given property
def _histoSvc
Trivial helper function to access Histogram Data and Histogram Data Service.
def _exist_
check the data from TES using GaudiCommon methods, respecting RootInTES
def _get_attr_
get the attribute or property
The base class for easy manupulations with N-Tuples.
def _initialize_
The default initialization (initialization of base C++ class + data.
the base class for all algorithm Python-image of C++ clkass GaudiAlgorithm
def _finalize_
The default finalization (finalization of base C++ class)
def _initialize_histo_
The default initialization (initialization of base C++ class + data members)
def _get_
get the data from TES using GaudiCommon methods, respecting RootInTES
def _evtSvc
Trivial helper function to access Event Data and Event Data Service.
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container