19 *******************************************************************************
20 * * 'Physisics do not like it, *
21 * * physisics do not need it, *
22 * * physisics do not use it' *
23 * * ****************************
25 * Helper module, which effectively 'imports' few useful C++ algorithmic *
26 * base classes into Python *
28 *******************************************************************************
29 * The major imported classes are : *
31 * (1) GaudiAlgo - analogue for GaudiAlgorithm C++ class from GaudiAlg package *
32 * (2) HistoAlgo - analogue for GaudiHistoAlg C++ class from GaudiAlg package *
33 * (3) TupleAlgo - analogue for GaudiTupleAlg C++ class from GaudiAlg package *
34 *******************************************************************************
37 __author__ =
'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
69 from GaudiKernel
import ROOT6WorkAroundEnabled
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 '''Helper decorator class to workaround ROOT-6697'''
1050 mapping = {int:
'int', bool:
'bool', float:
'double'}
1052 signature =
'const Tuples::Tuple& tuple, const string& name, const %s value'%(mapping[k])
1053 mapping[k] = func.disp(signature)
1058 Explicitly call the explicit signature for the case with 3 arguments and
1059 the last one is 'int', 'bool' or 'float', for the other cases fall back
1060 on the default dispatcher.
1068 return self.
func(*a)
1075 Access to underlying INTuple object
1077 return _Dec.nTuple ( s , *a )
1080 Access to underlying NTuple::Tuple object
1082 return _Dec.ntuple ( s , *a )
1085 Valid NTuple::Tuple object?
1087 return _Dec.valid ( s , *a )
1090 Commit the row/record to n-tuple
1092 return _Dec.write ( s , *a )
1095 Fill the certain column to n-tuple
1097 return _Dec.column ( s , *a )
1100 Fill the 'long long' column
1102 return _Dec.column_ll ( s , *a )
1105 Fill the 'unsigned long long' column
1107 return _Dec.column_ull ( s , *a )
1110 Fill the fixed-size array column
1112 return _Dec.array ( s , *a )
1115 Fill the fixed-size matrix column
1117 return _Dec.matrix ( s , *a )
1120 Fill the floating-size array column
1122 return _Dec.farray ( s , *a )
1125 Fill the floating-size matrix column
1127 return _Dec.fmatrix ( s , *a )
1129 _t_nTuple_ . __doc__ +=
'\n' + _Dec.nTuple . __doc__
1130 _t_ntuple_ . __doc__ +=
'\n' + _Dec.ntuple . __doc__
1131 _t_valid_ . __doc__ +=
'\n' + _Dec.valid . __doc__
1132 _t_write_ . __doc__ +=
'\n' + _Dec.write . __doc__
1133 _t_column_ . __doc__ +=
'\n' + _Dec.column . __doc__
1134 _t_column_ll_ . __doc__ +=
'\n' + _Dec.column_ll . __doc__
1135 _t_column_ull_ . __doc__ +=
'\n' + _Dec.column_ull . __doc__
1136 _t_array_ . __doc__ +=
'\n' + _Dec.array . __doc__
1137 _t_matrix_ . __doc__ +=
'\n' + _Dec.matrix . __doc__
1138 _t_farray_ . __doc__ +=
'\n' + _Dec.farray . __doc__
1139 _t_fmatrix_ . __doc__ +=
'\n' + _Dec.fmatrix . __doc__
1141 Tuple.nTuple = _t_nTuple_
1142 Tuple.ntuple = _t_ntuple_
1143 Tuple.valid = _t_valid_
1144 Tuple.write = _t_write_
1145 Tuple.column = _t_column_
1146 Tuple.column_ll = _t_column_ll_
1147 Tuple.column_ull = _t_column_ull_
1148 Tuple.array = _t_array_
1149 Tuple.matrix = _t_matrix_
1150 Tuple.farray = _t_farray_
1151 Tuple.fmatrix = _t_fmatrix_
1154 '__init__' : _init_ ,
1157 'evtSvc' : _evtSvc ,
1158 'eventSvc' : _evtSvc ,
1159 'detSvc' : _detSvc ,
1160 'histoSvc' : _histoSvc ,
1161 'histSvc' : _histoSvc ,
1164 'exist_' : _exist_ ,
1165 'getDet' : _getDet ,
1166 'finalize' : _finalize_ ,
1167 'beginRun' : _success_ ,
1168 'endRun' : _success_ ,
1170 'hasProperty' : _hasProperty_ ,
1171 'getProperty' : _getProperty_ ,
1172 'setProperty' : _setProperty_ ,
1173 '__setattr__' : _set_attr_ ,
1174 '__getattr__' : _get_attr_
1181 if not issubclass ( t , list )
and \
1182 not issubclass ( t , tuple ) : klasses = [ klasses ]
1183 for _alg
in klasses :
1184 for key
in _alg_map_ : setattr( _alg , key , _alg_map_[key] )
1187 _decorate_algs_ ( GaudiAlgo )
1188 _decorate_algs_ ( HistoAlgo )
1189 _decorate_algs_ ( TupleAlgo )
1194 def mapvct ( func , sequence , ovct = None ) :
1195 """ Helper function to fill histogram/ntuple using 'map'-operation """
1200 if hasattr( sequence,
'size' ) :
1201 vct.reserve ( vct.size() + sequence.size() )
1202 elif hasattr( sequence,
'__len__' ) :
1203 vct.reserve ( vct.size() + len( sequence ) )
1204 for object
in sequence :
1205 vct.push_back(
func( object ) )
1206 if not ovct :
return vct
1220 _func = getattr ( AlgDecorator , method )
1221 _num = _func ( self , _tools )
1222 if _tools.size() != _num :
1223 raise RuntimeError,
'Unable to extract Tools'
1225 for _tool
in _tools : _res += [ iAlgTool ( _tool.name() , _tool ) ]
1230 Retrieve the list of tools,
1231 aquired by component through GaudiCommon<TYPE> base:
1233 >>> alg = ... ## get the algorithm
1234 >>> tools = alg.Tools() ## get the tools
1235 >>> for tool in tools :
1239 _cmp = getattr ( self ,
'_ialg' )
1240 if not _cmp : self.retrieveInterface()
1241 _cmp = getattr ( self ,
'_ialg' )
1242 return _get_all_tools_ ( _cmp ,
'_tools_a_' )
1246 Retrieve the list of tools,
1247 aquired by component through GaudiCommon<TYPE> base:
1249 >>> tool = ... ## get the tool
1250 >>> tools = tool.Tools() ## get the tools
1251 >>> for t in tools :
1255 _cmp = getattr ( self ,
'_itool' )
1256 if not _cmp : self.retrieveInterface()
1257 _cmp = getattr ( self ,
'_itool' )
1258 return _get_all_tools_ ( _cmp ,
'_tools_t_' )
1271 _func = getattr ( AlgDecorator , method )
1272 _num = _func ( self , _nams , _cnts )
1273 if _nams.size() != _num
or _cnts.size() != _num :
1274 raise RuntimeError,
'Unable to extract Counters'
1276 for _i
in range(0,_num) :
1279 _res [ _nam ] = _cnt
1280 if not name :
return _res
1281 return _res.get( name ,
None )
1286 Retrieve the counters, managed GaudiCommon<TYPE> base:
1288 >>> alg = ... ## get the algorithm
1289 >>> cnts = alg.Counters() ## get the counters
1290 >>> for key in cnts :
1291 ... print key, cnts[key]
1294 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1296 >>> alg = ... ## get the algorithm
1297 >>> cnt = alg.Counters('MyCounter') ## get the counter
1301 _cmp = getattr ( self ,
'_ialg' )
1302 if not _cmp : self.retrieveInterface()
1303 _cmp = getattr ( self ,
'_ialg' )
1304 return _get_all_counters_ ( _cmp ,
'_counters_a_' , name )
1308 Retrieve the counters, managed GaudiCommon<TYPE> base:
1310 >>> tool = ... ## get the tool
1311 >>> cnts = tool.Counters() ## get the counters
1312 >>> for key in cnts :
1313 ... print key, cnts[key]
1316 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1318 >>> tool = ... ## get the tool
1319 >>> cnt = tool.Counters('MyCounter') ## get the counter
1323 _cmp = getattr ( self ,
'_itool' )
1324 if not _cmp : self.retrieveInterface()
1325 _cmp = getattr ( self ,
'_itool' )
1326 return _get_all_counters_ ( _cmp ,
'_counters_t_' , name )
1334 _func = getattr ( AlgDecorator , method )
1335 return _func ( self , name )
1339 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1341 >>> alg = ... ## get the algorithm
1342 >>> cnt = alg.Counter('#accept') ## get the counter
1346 _cmp = getattr ( self ,
'_ialg' )
1347 if not _cmp : self.retrieveInterface()
1348 _cmp = getattr ( self ,
'_ialg' )
1349 return _get_counter_ ( _cmp ,
'_counter_a_' , name )
1353 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1355 >>> tool = ... ## get the tool
1356 >>> cnt = tool.Counter('#accept') ## get the counter
1360 _cmp = getattr ( self ,
'_itool' )
1361 if not _cmp : self.retrieveInterface()
1362 _cmp = getattr ( self ,
'_itool' )
1363 return _get_counter_ ( _cmp ,
'_counter_t_' , name )
1368 cpp.GaudiAlg.ID .__repr__ = cpp.GaudiAlg.ID.idAsString
1369 cpp.GaudiAlg.ID . __str__ = cpp.GaudiAlg.ID.idAsString
1370 cpp.StatEntity .__repr__ = cpp.StatEntity.toString
1371 cpp.StatEntity . __str__ = cpp.StatEntity.toString
1375 Get All histogram form the component
1378 for _his
in (
std.vector(
'AIDA::IProfile2D*' ) ,
1385 _fun = getattr ( HistoDecorator , method )
1386 _num = _fun ( component , _ids , _his )
1387 if _ids.size() != _num
or _his.size() != _num :
1388 raise RuntimeError,
'Unable to extract Histos!'
1389 for _i
in range(0,_num) :
1391 if _id.numeric() : _id = _id.numericID ()
1392 elif _id.literal() : _id = _id.literalID ()
1393 else : _id = _is.idAsString ()
1394 _res[ _id ] = _his[ _i ]
1396 if not name :
return _res
1398 id = cpp.GaudiAlg.ID ( name )
1402 id.idAsString() , id ) :
1403 h = _res.get( i ,
None )
1404 if not not h :
return h
1410 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1412 >>> alg = ... ## get the algorithm
1413 >>> histos = alg.Histos() ## get all histograms & profiles
1414 >>> for key in histos :
1415 ... print key, histos[key]
1417 Retrive the histogram with the certain ID :
1419 >>> alg = ... ## get the algorithm
1420 >>> histo = alg.Histos('some histo ID') ## get the histo by ID
1424 _cmp = getattr ( self ,
'_ialg' )
1425 if not _cmp : self.retrieveInterface()
1426 _cmp = getattr ( self ,
'_ialg' )
1427 return _get_all_histos_ ( _cmp ,
'_histos_a_' , name )
1431 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1433 >>> tool = ... ## get the tool
1434 >>> histos = tool.Histos() ## get all histograms & profiles
1435 >>> for key in histos :
1436 ... print key, histos[key]
1438 Retrive the historgam with certain ID :
1440 >>> tool = ... ## get the tool
1441 >>> histo = tool.Histos('some histo ID') ## get the histo by ID
1445 _cmp = getattr ( self ,
'_itool' )
1446 if not _cmp : self.retrieveInterface()
1447 _cmp = getattr ( self ,
'_itool' )
1448 return _get_all_histos_ ( _cmp ,
'_histos_t_' , name )
1452 _Tools_a_ . __doc__ +=
'\n' + AlgDecorator . _tools_a_ . __doc__
1453 _Tools_t_ . __doc__ +=
'\n' + AlgDecorator . _tools_t_ . __doc__
1454 _Counters_a_ . __doc__ +=
'\n' + AlgDecorator . _counters_a_ . __doc__
1455 _Counters_t_ . __doc__ +=
'\n' + AlgDecorator . _counters_t_ . __doc__
1456 _Counter_a_ . __doc__ +=
'\n' + AlgDecorator . _counter_a_ . __doc__
1457 _Counter_t_ . __doc__ +=
'\n' + AlgDecorator . _counter_t_ . __doc__
1458 _Histos_a_ . __doc__ +=
'\n' + HistoDecorator . _histos_a_ . __doc__
1459 _Histos_t_ . __doc__ +=
'\n' + HistoDecorator . _histos_t_ . __doc__
1461 iAlgorithm . Tools = _Tools_a_
1462 iAlgTool . Tools = _Tools_t_
1463 iAlgorithm . Counters = _Counters_a_
1464 iAlgTool . Counters = _Counters_t_
1465 iAlgorithm . Counter = _Counter_a_
1466 iAlgTool . Counter = _Counter_t_
1467 iAlgorithm . Histos = _Histos_a_
1468 iAlgTool . Histos = _Histos_t_
1477 print __doc__ , __author__
1478 print '\t\t\tDoc-string for class GaudiAlgo \n' , GaudiAlgo.__doc__
1479 print '\t\t\tDoc-string for class HistoAlgo \n' , HistoAlgo.__doc__
1480 print '\t\t\tDoc-string for class TupleAlgo \n' , TupleAlgo.__doc__
1485 if __name__ ==
'__main__' :
def _getDet(self, location)
Trivial function to access the data in TDS.
def _Counter_a_(self, name)
def _Counter_t_(self, name)
def _decorate_tuples_(klasses)
def _initialize_(self)
The default initialization (initialization of base C++ class + data.
def _detSvc(self)
Trivial helper function to access Detector Data and Detector Data Service.
def _service_
Useful method to locate a service:
def _init_(self, name, args)
The constructor from unique algorithm instance name,.
def _tool_
Useful method to locate the tool a certain.
def _initialize_tuple_(self)
The default initialization (initialization of base C++ class + data members)
def _get_all_counters_
get all counters
def _Counters_a_
get all counters
def _get_all_histos_(component, method, name)
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
def _decorate_algs_(klasses)
def _decorate_plots_(klasses)
def _get_counter_(self, method, name)
def _get_attr_(self, pname)
get the attribute or property
def _set_attr_(self, pname, pvalue)
set the attribute or property
def _get(self, location)
Trivial function to access the data in TES.
The base class for easy histogramming.
def ROOT6WorkAroundEnabled
def _initialize_histo_(self)
The default initialization (initialization of base C++ class + data members)
def _evtcolSvc(self)
Trivial helper function to access Event Collection Service.
def _get_all_tools_(self, method)
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
The base class for easy manupulations with N-Tuples.
the base class for all algorithm Python-image of C++ clkass GaudiAlgorithm
def _success_(self)
Dummy method returning success.
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.
def _finalize_(self)
The default finalization (finalization of base C++ class)
def _ntupleSvc(self)
Trivial helper function to access NTuple Service.
def _setProperty_(self, pname, pvalue)
set the value for the given property
def _getProperty_(self, pname)
get the value of the given property