Skip to content

Commit

Permalink
?
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Aug 10, 2024
1 parent 6cba5ba commit 381af8f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
27 changes: 20 additions & 7 deletions ostap/fitting/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,34 +1677,47 @@ def _rds_makeWeighted_ ( dataset ,
>>> dataset = ...
>>> wdata = dataset.makeWeighted ( 'S_sw' )
"""

print ( 'MAKE EI"GHOTED/0' )
assert not dataset.isWeighted () , "Dataset '%s/%s' is already weighted!" % ( dataset.GetName () ,
dataset.GetTitle () )

print ( 'MAKE EI"GHOTED/1' )

assert isinstance ( weightvar , expression_types ) , \
"Invalid type of `weigthvar':%s" % type ( weightvar )
assert isinstance ( cuts , expression_types ) or not cuts , \
"Invalid type of `cuts':%s" % type ( cuts )

print ( 'MAKE EI"GHOTED/2' )

##
cuts = str ( cuts ).strip()
weightvar = str ( weightvar ).strip()

print ( 'MAKE EI"GHOTED/3' )

if not weightvar in dataset :
## is it a formula ?
wname = wname or 'Weight'
while wname in dataset : wname += 'W'
dataset.addVar ( wname , weightwar )
weightvar = wname

print ( 'MAKE EI"GHOTED/4' )

varset = dataset.get()
## make weighted dataset
return ROOT.RooDataSet ( dsID() ,
dataset.GetTitle() ,
dataset ,
varset ,
cuts ,
weightvar )

result = ROOT.RooDataSet ( dsID() ,
dataset.GetTitle() ,
dataset ,
varset ,
cuts ,
weightvar )

print ( 'MAKE EI"GHOTED/5' )
return result

ROOT.RooDataSet.makeWeighted = _rds_makeWeighted_

# =============================================================================
Expand Down
1 change: 1 addition & 0 deletions ostap/fitting/tests/test_fitting_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@


# =============================================================================
logger.info ( 'Print unweighted dataset:\n%s' % dataset .table ( prefix = '# ' ) )
weighted = dataset.makeWeighted ( 'Weight' )

"""
Expand Down

0 comments on commit 381af8f

Please sign in to comment.