diff --git a/ostap/fitting/printable.py b/ostap/fitting/printable.py index 6e44bae0..42299570 100644 --- a/ostap/fitting/printable.py +++ b/ostap/fitting/printable.py @@ -38,7 +38,7 @@ def print_multiline ( o , content = 1 , verbose = False , indent = '' ) : - see RooPrintable - see Ostap::Utils::print_printable1 """ - if not valid_pointer ( o ) : return 'Invalid object' + if not valid_pointer ( o ) : return 'Invalid object/nullptr' return Ostap.Utils.print_printable1 ( o , content , verbose , indent ) # ============================================================================= ## Use RooPrintable::printStream function @@ -49,7 +49,7 @@ def print_stream ( o , content = 1 , style = 3 , indent = '' ) : - see RooPrintable - see Ostap::Utils::print_printable2 """ - if not valid_pointer ( o ) : return 'Invalid object' + if not valid_pointer ( o ) : return 'Invalid object/nullptr' return Ostap.Utils.print_printable2 ( o , content , style , indent ) # ============================================================================= ## Use RooPrintable::printTree function @@ -60,7 +60,7 @@ def print_tree ( o , indent = '' ) : - see RooPrintable - see Ostap::Utils::print_printable_tree """ - if not valid_pointer ( o ) : return 'Invalid object' + if not valid_pointer ( o ) : return 'Invalid object/nullptr' return Ostap.Utils.print_printable_tree ( o , indent ) # ============================================================================= @@ -70,6 +70,7 @@ def _rp_print_ ( obj , opts = 'vv' , *style ) : >>> o = ... >>> print o """ + if not valid_pointer ( obj ) : return 'Invalid object/nullptr' return Ostap.Utils.print_printable ( obj , opts , *style ) ROOT.RooPrintable.print_multiline = print_multiline diff --git a/ostap/fitting/roocollections.py b/ostap/fitting/roocollections.py index 62376cad..1cba1fb6 100644 --- a/ostap/fitting/roocollections.py +++ b/ostap/fitting/roocollections.py @@ -369,15 +369,17 @@ def _stl_contains_ ( lst , item ) : return any ( i.name == item for i in lst ) return False - -if ( 6 , 24 ) < root_info : _STLList = ROOT.RooSTLRefCountList[ROOT.RooAbsArg] -else : _STLList = ROOT.RooSTLRefCountList(ROOT.RooAbsArg) - -_STLList .__str__ = lambda s : str ( tuple ( _rs_list_ ( s ) ) ) if s else '[]' -_STLList .__repr__ = lambda s : str ( tuple ( _rs_list_ ( s ) ) ) if s else '[]' -_STLList .__contains__ = _stl_contains_ - - +if ( 8 , 18 ) <= root_info < ( 6 , 24 ) : + _STLList = ROOT.RooSTLRefCountList[ROOT.RooAbsArg] + _STLList .__str__ = lambda s : str ( tuple ( _rs_list_ ( s ) ) ) if s else '[]' + _STLList .__repr__ = lambda s : str ( tuple ( _rs_list_ ( s ) ) ) if s else '[]' + _STLList .__contains__ = _stl_contains_ +else ( 6 , 24 ) <= root_info : + _STLList = ROOT.RooSTLRefCountList(ROOT.RooAbsArg) + _STLList .__str__ = lambda s : str ( tuple ( _rs_list_ ( s ) ) ) if s else '[]' + _STLList .__repr__ = lambda s : str ( tuple ( _rs_list_ ( s ) ) ) if s else '[]' + _STLList .__contains__ = _stl_contains_ + if not hasattr ( ROOT.RooArgList , '__iter__' ) or root_info < ( 6 , 31 ) : ROOT.RooArgList . __iter__ = _ral_iter_ _new_methods_ += [ ROOT.RooArgList. __iter__ ] diff --git a/ostap/fitting/variables.py b/ostap/fitting/variables.py index 0ac59d2e..044dd944 100644 --- a/ostap/fitting/variables.py +++ b/ostap/fitting/variables.py @@ -157,23 +157,44 @@ def _rrv_ve_ ( var ) : # return VE ( v , e2 ) -# =============================================================================== -## does var depends on item ? -# - if type(item) is RooAbsArg : check var.dependsOn ( item ) -# - if type(item) is string_type : check item in var.servers() -# - else , return False -def _var_contains_ ( var , item ) : - """ Does var depends on item ? - - if type(item) is RooAbsArg : check var.dependsOn ( item ) - - if type(item) is string_type : check item in var.servers() - - else , return False - """ - if isinstance ( var , ROOT.RooAbsArg ) : return var.dependsOn ( item ) - elif isinstance ( var , string_types ) : return item in var.servers() - # - return False - -# ============================================================================== + +# ================================================================================== +if ( 6 , 18 ) <= root_info : # ===================================================== + # ============================================================================== + ## does var depends on item ? + # - if type(item) is RooAbsArg : check var.dependsOn ( item ) + # - if type(item) is string_type : check item in var.servers() + # - else , return False + def _var_contains_ ( var , item ) : + """ Does var depends on item ? + - if type(item) is RooAbsArg : check var.dependsOn ( item ) + - if type(item) is string_type : check item in var.servers() + - else , return False + """ + if isinstance ( item , ROOT.RooAbsArg ) : return var.dependsOn ( item ) + elif isinstance ( item , string_types ) : return item in var.servers() + # + return False + # =============================================================================== +else : # ============================================================================ + # =============================================================================== + ## does var depends on item ? + # - if type(item) is RooAbsArg : check var.dependsOn ( item ) + # - if type(item) is string_type : check var.findServer ( item ) + # - else , return False + def _var_contains_ ( var , item ) : + """ Does var depends on item ? + - if type(item) is RooAbsArg : check var.dependsOn ( item ) + - if type(item) is string_type : check var.findServer ( item )) + - else , return False + """ + if isinstance ( item , ROOT.RooAbsArg ) : return var.dependsOn ( item ) + elif isinstance ( item , string_types ) : + return valid_pointer ( var.findServer ( item ) ) + # + return False + # ============================================================================== +# ================================================================================== ## check if the given value is in the range of RooRealVar # @code # mass_range = ...