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'
71 from GaudiKernel
import ROOT6WorkAroundEnabled
78 Vector = std.vector(
'double')
80 Matrix = std.vector(
'std::vector<double>')
89 AlgDecorator = cpp.GaudiPython.AlgDecorator
90 HistoDecorator = cpp.GaudiPython.HistoDecorator
91 TupleAlgDecorator = cpp.GaudiPython.TupleAlgDecorator
92 TupleDecorator = cpp.GaudiPython.TupleDecorator
125 Useful method to locate the tool a certain
130 t1 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator')
131 # locate private tool
132 t2 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator',parent=self)
133 # locate public tool with defined name
134 t3 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator/MyExt1')
135 # locate private tool with defined name
136 t4 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator/MyExt2',parent=self)
137 # locate public tool with defined name
138 t5 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator','MyExt3')
139 # locate private tool with defined name
140 t6 = self.tool(ITrExtrapolator,'TrParabolicExtrapolator','MyExt4',parent=self)
143 if not interface : interface = cpp.IAlgTool
144 if not parent : parent = self
145 if name : typename +=
'/' + name
146 _tool = AlgDecorator.tool_( self , typename , parent , create )
147 if not _tool :
return None
150 self.Warning(
'Invalid cast to interface %s' % interface )
172 Useful method to locate a service:
176 ntsvc = self.svc( INTupleSvc , 'NTUpleSvc' )
179 if not interface : interface = cpp.IInterface
180 _svc = AlgDecorator.svc_ ( self , name , create )
181 if not _svc :
return None
184 self.Warning(
'Invalid cast to interface %s' % interface )
195 The constructor from unique algorithm instance name & parameters
197 self._Base.__init__( self , self , name )
199 algMgr = appMgr._algmgr
200 status = algMgr.addAlgorithm( self )
201 if status.isFailure() :
202 raise RuntimeError,
'Unable to add Algorithm "' + name +
'"'
203 iAlgorithm.__init__ ( self , name , self )
204 for key
in args : setattr ( self , key , args[key] )
206 if not appMgr.__dict__.has_key (
'GaudiPythonAlgos') :
207 appMgr.__dict__[
'GaudiPythonAlgos'] = []
208 appMgr.__dict__[
'GaudiPythonAlgos'].append( self )
217 The default initialization (initialization of base C++ class + data)
219 status = self._Base.initialize_( self )
220 if status.isFailure() :
return status
223 _e = self._Base.evtSvc( self )
225 self._evtSvc_ = iDataSvc ( _s.name() , _e )
227 _d = self._Base.detSvc( self )
229 self._detSvc_ = iDataSvc ( _s.name() , _d )
240 The default initialization (initialization of base C++ class + data members)
243 if status.isFailure() :
return status
246 _h = self._Base.histoSvc( self )
248 self._histoSvc_ = iHistogramSvc ( _s.name() , _h )
259 The default initialization (initialization of base C++ class + data members)
262 if status.isFailure() :
return status
265 if self.produceNTuples() :
266 _n = self._Base.ntupleSvc( self )
268 self._ntupleSvc_ = iNTupleSvc ( _s.name() , _n )
270 if self.produceEvtCols() :
271 _n = self._Base.evtColSvc( self )
273 self._evtcolSvc_ = iNTupleSvc ( _s.name() , _n )
296 Trivial helper function to access Event Data and Event Data Service
300 # get event data service
304 hits = self.evtSvc('MC/Calo/Hits')
308 return self._evtSvc_[location]
329 Trivial helper function to access Detector Data and Event Data Service
332 # get detector data service
336 lhcb = self.detSvc('/dd/Structure/LHCb')
340 return self._detSvc_[location]
361 Trivial helper function to access Histogram Data and Histogram Data Service
365 # get histogram data service
366 svc = self.histoSvc()
369 histo = self.histoSvc('/stat/Calo/1')
371 if not address :
return self._histoSvc_
372 return self._histoSvc_[ address ]
378 Trivial function to access the data in TES using the data service
380 return self._evtSvc_[location]
386 Trivial function to access the data in TDS using data service
388 return self._detSvc_[location]
392 def _get_ ( self , location , rootInTES = True ) :
394 Get the object from Transient Event Store using GaudiCommon machinery,
395 respecting RootInTES behaviour
397 return AlgDecorator.get_ ( self , location , rootInTES )
400 def _exist_ ( self , location , rootInTES = True ) :
402 Check the object in Transient Event Store using GaudiCommon machinery,
403 respecting RootInTES behaviour
405 return AlgDecorator.exist_ ( self , location , rootInTES )
411 Trivial function to access N-Tuple Service
413 return self._ntupleSvc_
419 Trivial function to access Event Collection Service
421 return self._evtcolSvc_
428 The default finalization : finalize the base C++ class
430 status = self._Base.finalize_ ( self )
439 def _hasProperty_ ( self , pname ) :
441 The trivial function which checks the existence of the property with given name
443 return cpp.Gaudi.Utils.hasProperty ( self , pname )
449 Get the property by name
451 if not self.hasProperty( pname ) :
452 raise AttributeError,
'property %s does not exist' % pname
453 return iAlgorithm.__getattr__( self , pname )
459 Set the property from the value
461 if not self.hasProperty( pname ) :
462 raise AttributeError,
'property %s does not exist' % pname
463 return iAlgorithm.__setattr__ ( self , pname , pvalue )
469 Get the attribute (or property)
470 - if the attribute name corresponds to the property name, property value is returned
472 if self.hasProperty( pname ) :
473 return iAlgorithm.__getattr__ ( self , pname )
474 raise AttributeError,
'attribute/property %s does not exist' % pname
480 Set the attribute (or property) :
481 - if the attribute name corresponds to the property name, the property is updated
483 if not self.hasProperty( pname ) : self.__dict__[pname] = pvalue
484 else : iAlgorithm.__setattr__ ( self , pname , pvalue )
487 _GaudiAlgorithm = cpp.GaudiPython.PyAlg(
'GaudiAlgorithm' )
488 _GaudiHistoAlg = cpp.GaudiPython.PyAlg(
'GaudiHistoAlg' )
489 _GaudiTupleAlg = cpp.GaudiPython.PyAlg(
'GaudiTupleAlg' )
556 *******************************************************************************
557 * * 'Physisics do not like it, *
558 * * physisics do not need it, *
559 * * physisics do not use it' *
560 * * ****************************
563 * from GaudiPython.GaudiAlgs import GaudiAlgo, SUCCESS *
565 * class MyClass(GaudiAlgo) : *
566 * ' My specific Algorithm, derived from GaudiAlgo base class ' *
567 * def __init__( self , name , **args ) : *
568 * 'Constructor from algorithm instance name & parameters' *
569 * #invoke the constructor of base class *
570 * GaudiAlgo.__init__(self , name , **args ) *
572 * def initialize ( self ) : *
573 * 'Algorithm initialization' *
574 * # initialize the base class *
575 * status = GaudiAlgo.initialize( self ) *
576 * if status.isFailure() : return status *
578 * # locate the services and tools *
580 * # locate some tool: *
581 * extrapolator = self.tool(ITrExtrapolator,'TrExtrapolator') *
583 * # locate the service *
584 * rndmSvc = self.svc(IRndmGenSvc, 'RndmGenSvc') *
589 * def execute ( self ) : *
590 * 'Major method (from IAlgorithm interface)' *
592 * # get some data from Transient Event Store *
593 * tracks = self.get('/Event/Rec/Tracks') *
596 * c1 = self.counter('#Tracks') *
597 * c2 = self.counter('No Tracks') *
598 * if tracks.empty : *
600 * c1 += tracks->size() *
602 * if 1000 < tracks.size() : *
603 * return self.Error('The event is *VERY* busy') *
607 *******************************************************************************
682 *******************************************************************************
683 * * 'Physisics do not like it, *
684 * * physisics do not need it, *
685 * * physisics do not use it' *
686 * * ****************************
689 * from GaudiPython.GaudiAlgs import HistoAlgo, SUCCESS *
691 * class MyClass(HistoAlgo) : *
692 * ' My specific Algorithm, derived from GaudiAlgo base class ' *
693 * def __init__( self , name , **args ) : *
694 * 'Constructor from algorithm instance name' *
695 * #invoke the constructor of base class *
696 * HistoAlgo.__init__(self , name , **args ) *
698 * def execute ( self ) : *
699 * 'Major method (from IAlgorithm interface)' *
701 * # get some data from Transient Event Store *
702 * tracks = self.get('/Event/Rec/Tracks') *
704 * self.plot1D ( tracks->size() , '#tracks' , 0 , 100 ) *
708 * Alternatively the histogram could be booked in advance: *
710 * class MyClass(HistoAlgo) : *
711 * ' My specific Algorithm, derived from GaudiAlgo base class ' *
712 * def __init__( self , name ) : *
713 * 'Constructor from algorithm instance name' *
714 * #invoke the constructor of base class *
715 * HistoAlgo.__init__(self , name ) *
717 * def initialize ( self ) : *
718 * 'Algorithm initialization' *
719 * # initialize the base class *
720 * status = HistoAlgo.initialize( self ) *
721 * if status.isFailure() : return status *
723 * # book the histogram *
724 * self.h1 = selff.book1D ( '#tracks' , 0 , 100 ) *
729 * def execute ( self ) : *
730 * 'Major method (from IAlgorithm interface)' *
732 * # get some data from Transient Event Store *
733 * tracks = self.get('/Event/Rec/Tracks') *
735 * # fill the histogram *
736 * self.h1.fill ( tracks->size() ) *
740 *******************************************************************************
792 *******************************************************************************
793 * * 'Physisics do not like it, *
794 * * physisics do not need it, *
795 * * physisics do not use it' *
796 * * ****************************
799 * from GaudiPython.GaudiAlgs import TupleAlgo, SUCCESS *
801 * class MyClass(TupleAlgo) : *
802 * ' My specific Algorithm, derived from TupleAlgo base class ' *
803 * def __init__( self , name , **args ) : *
804 * 'Constructor from algorithm instance name & parameters' *
805 * #invoke the constructor of base class *
806 * TupleAlgo.__init__(self , name , **args ) *
808 * def execute ( self ) : *
809 * 'Major method (from IAlgorithm interface)' *
811 * # get some data from Transient Event Store *
812 * tracks = self.get('/Event/Rec/Tracks') *
814 * tup = self.nTuple('My N-Tuple') *
816 * for track in tracks : *
820 * chi2 = track.chi2 () *
823 * tup.column ( 'pt' , pt ) *
824 * tup.column ( 'p' , p ) *
825 * tup.column ( 'chi2' , chi2 ) *
831 *******************************************************************************
839 return self.
method(*args )
841 GaudiAlgo._Base = _GaudiAlgorithm
842 HistoAlgo._Base = _GaudiHistoAlg
843 TupleAlgo._Base = _GaudiTupleAlg
846 GaudiAlgo.initialize = _initialize_
847 HistoAlgo.initialize = _initialize_histo_
848 TupleAlgo.initialize = _initialize_tuple_
852 The stub 'start' method needed by the internal implementation of PyAlg<>.
857 GaudiAlgo.start = _start_
858 HistoAlgo.start = _start_
859 TupleAlgo.start = _start_
863 The fictive 'execute' method, which MUST be overwitten by user
865 raise RuntimeError,
'Execute method is not implemented for %s' % self.name()
867 GaudiAlgo.execute = _execute_
868 HistoAlgo.execute = _execute_
869 TupleAlgo.execute = _execute_
873 The stub 'stop' method needed by the internal implementation of PyAlg<>.
878 GaudiAlgo.stop = _stop_
879 HistoAlgo.stop = _stop_
880 TupleAlgo.stop = _stop_
885 The basic method to fill (book-on-demand) 1D-histogram
887 The histogram will be created/booked dautomatically according to the
890 - literal or numerical ID (optional)
894 - number of bins (default is 100)
896 The reference to the histogram is returned and could be used for later manipulations
899 return HistoDecorator.plot1D (s,*a)
903 The basic method to fill (book-on-demand) 2D-histogram
905 The histogram will be created/booked dautomatically according to the
908 - literal or numerical ID (optional)
914 - number of X-bins (default is 50)
915 - number of Y-bins (default is 50)
917 The reference to the histogram is returned and could be used for later manipulations
920 return HistoDecorator.plot2D (s,*a)
924 The basic method to fill (book-on-demand) 3D-histogram
926 The histogram will be created/booked dautomatically according to the
929 - literal or numerical ID (optional)
937 - number of X-bins (default is 10)
938 - number of Y-bins (default is 10)
939 - number of Y-bins (default is 10)
941 The reference to the histogram is returned and could be used for later manipulations
944 return HistoDecorator.plot3D (s,*a)
948 The basic method to fill (book-on-demand) 1D profile histogram
950 The profile histogram will be created/booked dautomatically
951 according to the specifications:
953 - literal or numerical ID (optional)
957 - number of X-bins (default is 100)
959 The reference to the histogram is returned and could be used for later manipulations
962 return HistoDecorator.profile1D (s,*a)
966 The basic method to fill (book-on-demand) 2D profile histiogram
968 The profile histogram will be created/booked automatically
969 according to the specifications:
971 - literal or numerical ID (optional)
977 - number of X-bins (default is 50)
978 - number of Y-bins (default is 50)
980 The reference to the histogram is returned and could be used for later manipulations
983 return HistoDecorator.profile2D (s,*a)
986 _plot1D_ .__doc__ +=
'\n' + HistoDecorator.plot1D .__doc__
987 _plot2D_ .__doc__ +=
'\n' + HistoDecorator.plot2D .__doc__
988 _plot3D_ .__doc__ +=
'\n' + HistoDecorator.plot3D .__doc__
989 _profile1D_ .__doc__ +=
'\n' + HistoDecorator.profile1D .__doc__
990 _profile2D_ .__doc__ +=
'\n' + HistoDecorator.profile2D .__doc__
994 if not issubclass ( t , list )
and \
995 not issubclass ( t , tuple ) : klasses = [ klasses ]
996 for klass
in klasses :
997 klass .plot = _plot1D_
998 klass .plot1D = _plot1D_
999 klass .plot2D = _plot2D_
1000 klass .plot3D = _plot3D_
1001 klass .profile1D = _profile1D_
1002 klass .profile2D = _profile2D_
1004 _decorate_plots_ ( HistoAlgo )
1005 _decorate_plots_ ( TupleAlgo )
1011 Retrieve (book-on-demand) N-Tuple object
1013 return TupleAlgDecorator.nTuple ( s , *a )
1017 Retrieve (book-on-demand) N-Tuple object for Event Tag Collections
1019 return TupleAlgDecorator.evtCol ( s , *a )
1021 _nTuple_.__doc__ +=
'\n' + TupleAlgDecorator.nTuple.__doc__
1022 _evtCol_.__doc__ +=
'\n' + TupleAlgDecorator.evtCol.__doc__
1026 if not issubclass ( t , list )
and \
1027 not issubclass ( t , tuple ) : klasses = [ klasses ]
1028 for klass
in klasses :
1029 klass . nTuple = _nTuple_
1030 klass . evtCol = _evtCol_
1031 klass . ntupleSvc = _ntupleSvc
1032 klass . tupleSvc = _ntupleSvc
1033 klass . ntupSvc = _ntupleSvc
1034 klass . tupSvc = _ntupleSvc
1035 klass . evtColSvc = _evtcolSvc
1036 klass . evtcolSvc = _evtcolSvc
1039 _decorate_tuples_ ( TupleAlgo )
1043 Tuple = cpp.Tuples.Tuple
1044 _Dec = TupleDecorator
1047 '''Helper decorator class to workaround ROOT-6697'''
1053 Explicitly call the explicit signature for the case with 3 arguments and
1054 the last one is 'int', 'bool' or 'float', for the other cases fall back
1055 on the default dispatcher.
1059 mapping = {int:
'int', bool:
'bool', float:
'double'}
1061 signature =
'const Tuples::Tuple& tuple, const string& name, const %s value' % mapping[t]
1062 return self.func.disp(signature)(*a)
1063 return self.
func(*a)
1070 Access to underlying INTuple object
1072 return _Dec.nTuple ( s , *a )
1075 Access to underlying NTuple::Tuple object
1077 return _Dec.ntuple ( s , *a )
1080 Valid NTuple::Tuple object?
1082 return _Dec.valid ( s , *a )
1085 Commit the row/record to n-tuple
1087 return _Dec.write ( s , *a )
1090 Fill the certain column to n-tuple
1092 return _Dec.column ( s , *a )
1095 Fill the 'long long' column
1097 return _Dec.column_ll ( s , *a )
1100 Fill the 'unsigned long long' column
1102 return _Dec.column_ull ( s , *a )
1105 Fill the fixed-size array column
1107 return _Dec.array ( s , *a )
1110 Fill the fixed-size matrix column
1112 return _Dec.matrix ( s , *a )
1115 Fill the floating-size array column
1117 return _Dec.farray ( s , *a )
1120 Fill the floating-size matrix column
1122 return _Dec.fmatrix ( s , *a )
1124 _t_nTuple_ . __doc__ +=
'\n' + _Dec.nTuple . __doc__
1125 _t_ntuple_ . __doc__ +=
'\n' + _Dec.ntuple . __doc__
1126 _t_valid_ . __doc__ +=
'\n' + _Dec.valid . __doc__
1127 _t_write_ . __doc__ +=
'\n' + _Dec.write . __doc__
1128 _t_column_ . __doc__ +=
'\n' + _Dec.column . __doc__
1129 _t_column_ll_ . __doc__ +=
'\n' + _Dec.column_ll . __doc__
1130 _t_column_ull_ . __doc__ +=
'\n' + _Dec.column_ull . __doc__
1131 _t_array_ . __doc__ +=
'\n' + _Dec.array . __doc__
1132 _t_matrix_ . __doc__ +=
'\n' + _Dec.matrix . __doc__
1133 _t_farray_ . __doc__ +=
'\n' + _Dec.farray . __doc__
1134 _t_fmatrix_ . __doc__ +=
'\n' + _Dec.fmatrix . __doc__
1136 Tuple.nTuple = _t_nTuple_
1137 Tuple.ntuple = _t_ntuple_
1138 Tuple.valid = _t_valid_
1139 Tuple.write = _t_write_
1140 Tuple.column = _t_column_
1141 Tuple.column_ll = _t_column_ll_
1142 Tuple.column_ull = _t_column_ull_
1143 Tuple.array = _t_array_
1144 Tuple.matrix = _t_matrix_
1145 Tuple.farray = _t_farray_
1146 Tuple.fmatrix = _t_fmatrix_
1149 '__init__' : _init_ ,
1152 'evtSvc' : _evtSvc ,
1153 'eventSvc' : _evtSvc ,
1154 'detSvc' : _detSvc ,
1155 'histoSvc' : _histoSvc ,
1156 'histSvc' : _histoSvc ,
1159 'exist_' : _exist_ ,
1160 'getDet' : _getDet ,
1161 'finalize' : _finalize_ ,
1162 'beginRun' : _success_ ,
1163 'endRun' : _success_ ,
1165 'hasProperty' : _hasProperty_ ,
1166 'getProperty' : _getProperty_ ,
1167 'setProperty' : _setProperty_ ,
1168 '__setattr__' : _set_attr_ ,
1169 '__getattr__' : _get_attr_
1176 if not issubclass ( t , list )
and \
1177 not issubclass ( t , tuple ) : klasses = [ klasses ]
1178 for _alg
in klasses :
1179 for key
in _alg_map_ : setattr( _alg , key , _alg_map_[key] )
1182 _decorate_algs_ ( GaudiAlgo )
1183 _decorate_algs_ ( HistoAlgo )
1184 _decorate_algs_ ( TupleAlgo )
1189 def mapvct ( func , sequence , ovct = None ) :
1190 """ Helper function to fill histogram/ntuple using 'map'-operation """
1192 vct = GaudiPython.Vector
1195 if hasattr( sequence,
'size' ) :
1196 vct.reserve ( vct.size() + sequence.size() )
1197 elif hasattr( sequence,
'__len__' ) :
1198 vct.reserve ( vct.size() + len( sequence ) )
1199 for object
in sequence :
1200 vct.push_back(
func( object ) )
1201 if not ovct :
return vct
1214 _tools = std.vector(
'IAlgTool*')()
1215 _func = getattr ( AlgDecorator , method )
1216 _num = _func ( self , _tools )
1217 if _tools.size() != _num :
1218 raise RuntimeError,
'Unable to extract Tools'
1220 for _tool
in _tools : _res += [ iAlgTool ( _tool.name() , _tool ) ]
1225 Retrieve the list of tools,
1226 aquired by component through GaudiCommon<TYPE> base:
1228 >>> alg = ... ## get the algorithm
1229 >>> tools = alg.Tools() ## get the tools
1230 >>> for tool in tools :
1234 _cmp = getattr ( self ,
'_ialg' )
1235 if not _cmp : self.retrieveInterface()
1236 _cmp = getattr ( self ,
'_ialg' )
1237 return _get_all_tools_ ( _cmp ,
'_tools_a_' )
1241 Retrieve the list of tools,
1242 aquired by component through GaudiCommon<TYPE> base:
1244 >>> tool = ... ## get the tool
1245 >>> tools = tool.Tools() ## get the tools
1246 >>> for t in tools :
1250 _cmp = getattr ( self ,
'_itool' )
1251 if not _cmp : self.retrieveInterface()
1252 _cmp = getattr ( self ,
'_itool' )
1253 return _get_all_tools_ ( _cmp ,
'_tools_t_' )
1264 _cnts = std.vector(
'const StatEntity*')()
1265 _nams = std.vector(
'std::string') ()
1266 _func = getattr ( AlgDecorator , method )
1267 _num = _func ( self , _nams , _cnts )
1268 if _nams.size() != _num
or _cnts.size() != _num :
1269 raise RuntimeError,
'Unable to extract Counters'
1271 for _i
in range(0,_num) :
1274 _res [ _nam ] = _cnt
1275 if not name :
return _res
1276 return _res.get( name ,
None )
1281 Retrieve the counters, managed GaudiCommon<TYPE> base:
1283 >>> alg = ... ## get the algorithm
1284 >>> cnts = alg.Counters() ## get the counters
1285 >>> for key in cnts :
1286 ... print key, cnts[key]
1289 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1291 >>> alg = ... ## get the algorithm
1292 >>> cnt = alg.Counters('MyCounter') ## get the counter
1296 _cmp = getattr ( self ,
'_ialg' )
1297 if not _cmp : self.retrieveInterface()
1298 _cmp = getattr ( self ,
'_ialg' )
1299 return _get_all_counters_ ( _cmp ,
'_counters_a_' , name )
1303 Retrieve the counters, managed GaudiCommon<TYPE> base:
1305 >>> tool = ... ## get the tool
1306 >>> cnts = tool.Counters() ## get the counters
1307 >>> for key in cnts :
1308 ... print key, cnts[key]
1311 Retrieve the counter, managed GaudiCommon<TYPE> base by name:
1313 >>> tool = ... ## get the tool
1314 >>> cnt = tool.Counters('MyCounter') ## get the counter
1318 _cmp = getattr ( self ,
'_itool' )
1319 if not _cmp : self.retrieveInterface()
1320 _cmp = getattr ( self ,
'_itool' )
1321 return _get_all_counters_ ( _cmp ,
'_counters_t_' , name )
1329 _func = getattr ( AlgDecorator , method )
1330 return _func ( self , name )
1334 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1336 >>> alg = ... ## get the algorithm
1337 >>> cnt = alg.Counter('#accept') ## get the counter
1341 _cmp = getattr ( self ,
'_ialg' )
1342 if not _cmp : self.retrieveInterface()
1343 _cmp = getattr ( self ,
'_ialg' )
1344 return _get_counter_ ( _cmp ,
'_counter_a_' , name )
1348 Retrieve the counter managed GaudiCommon<TYPE> base by name:
1350 >>> tool = ... ## get the tool
1351 >>> cnt = tool.Counter('#accept') ## get the counter
1355 _cmp = getattr ( self ,
'_itool' )
1356 if not _cmp : self.retrieveInterface()
1357 _cmp = getattr ( self ,
'_itool' )
1358 return _get_counter_ ( _cmp ,
'_counter_t_' , name )
1363 cpp.GaudiAlg.ID .__repr__ = cpp.GaudiAlg.ID.idAsString
1364 cpp.GaudiAlg.ID . __str__ = cpp.GaudiAlg.ID.idAsString
1365 cpp.StatEntity .__repr__ = cpp.StatEntity.toString
1366 cpp.StatEntity . __str__ = cpp.StatEntity.toString
1370 Get All histogram form the component
1373 for _his
in ( std.vector(
'AIDA::IProfile2D*' ) ,
1374 std.vector(
'AIDA::IProfile1D*' ) ,
1375 std.vector(
'AIDA::IHistogram3D*' ) ,
1376 std.vector(
'AIDA::IHistogram2D*' ) ,
1377 std.vector(
'AIDA::IHistogram1D*' ) ) :
1379 _ids = std.vector(
'GaudiAlg::ID') ()
1380 _fun = getattr ( HistoDecorator , method )
1381 _num = _fun ( component , _ids , _his )
1382 if _ids.size() != _num
or _his.size() != _num :
1383 raise RuntimeError,
'Unable to extract Histos!'
1384 for _i
in range(0,_num) :
1386 if _id.numeric() : _id = _id.numericID ()
1387 elif _id.literal() : _id = _id.literalID ()
1388 else : _id = _is.idAsString ()
1389 _res[ _id ] = _his[ _i ]
1391 if not name :
return _res
1393 id = cpp.GaudiAlg.ID ( name )
1397 id.idAsString() , id ) :
1398 h = _res.get( i ,
None )
1399 if not not h :
return h
1405 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1407 >>> alg = ... ## get the algorithm
1408 >>> histos = alg.Histos() ## get all histograms & profiles
1409 >>> for key in histos :
1410 ... print key, histos[key]
1412 Retrive the histogram with the certain ID :
1414 >>> alg = ... ## get the algorithm
1415 >>> histo = alg.Histos('some histo ID') ## get the histo by ID
1419 _cmp = getattr ( self ,
'_ialg' )
1420 if not _cmp : self.retrieveInterface()
1421 _cmp = getattr ( self ,
'_ialg' )
1422 return _get_all_histos_ ( _cmp ,
'_histos_a_' , name )
1426 Retrieve all histograms & profiles, booked through GauydiHistos<TYPE> base:
1428 >>> tool = ... ## get the tool
1429 >>> histos = tool.Histos() ## get all histograms & profiles
1430 >>> for key in histos :
1431 ... print key, histos[key]
1433 Retrive the historgam with certain ID :
1435 >>> tool = ... ## get the tool
1436 >>> histo = tool.Histos('some histo ID') ## get the histo by ID
1440 _cmp = getattr ( self ,
'_itool' )
1441 if not _cmp : self.retrieveInterface()
1442 _cmp = getattr ( self ,
'_itool' )
1443 return _get_all_histos_ ( _cmp ,
'_histos_t_' , name )
1447 _Tools_a_ . __doc__ +=
'\n' + AlgDecorator . _tools_a_ . __doc__
1448 _Tools_t_ . __doc__ +=
'\n' + AlgDecorator . _tools_t_ . __doc__
1449 _Counters_a_ . __doc__ +=
'\n' + AlgDecorator . _counters_a_ . __doc__
1450 _Counters_t_ . __doc__ +=
'\n' + AlgDecorator . _counters_t_ . __doc__
1451 _Counter_a_ . __doc__ +=
'\n' + AlgDecorator . _counter_a_ . __doc__
1452 _Counter_t_ . __doc__ +=
'\n' + AlgDecorator . _counter_t_ . __doc__
1453 _Histos_a_ . __doc__ +=
'\n' + HistoDecorator . _histos_a_ . __doc__
1454 _Histos_t_ . __doc__ +=
'\n' + HistoDecorator . _histos_t_ . __doc__
1456 iAlgorithm . Tools = _Tools_a_
1457 iAlgTool . Tools = _Tools_t_
1458 iAlgorithm . Counters = _Counters_a_
1459 iAlgTool . Counters = _Counters_t_
1460 iAlgorithm . Counter = _Counter_a_
1461 iAlgTool . Counter = _Counter_t_
1462 iAlgorithm . Histos = _Histos_a_
1463 iAlgTool . Histos = _Histos_t_
1472 print __doc__ , __author__
1473 print '\t\t\tDoc-string for class GaudiAlgo \n' , GaudiAlgo.__doc__
1474 print '\t\t\tDoc-string for class HistoAlgo \n' , HistoAlgo.__doc__
1475 print '\t\t\tDoc-string for class TupleAlgo \n' , TupleAlgo.__doc__
1480 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 ROOT6WorkAroundEnabled
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