Skip to content

Commit

Permalink
fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Jan 14, 2025
1 parent a10f0be commit 52c3761
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 29 deletions.
7 changes: 4 additions & 3 deletions ostap/fitting/printable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 )

# =============================================================================
Expand All @@ -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
Expand Down
20 changes: 11 additions & 9 deletions ostap/fitting/roocollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ ]
Expand Down
55 changes: 38 additions & 17 deletions ostap/fitting/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...
Expand Down

0 comments on commit 52c3761

Please sign in to comment.