From 30e9598b181d1d1d85312a5c51ce4b02d8defa89 Mon Sep 17 00:00:00 2001 From: Vanya Belyaev Date: Fri, 9 Feb 2024 13:49:12 +0100 Subject: [PATCH] fiex? --- ostap/fitting/simfit.py | 9 ++++++++- ostap/fitting/tests/test_fitting_simfit7.py | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ostap/fitting/simfit.py b/ostap/fitting/simfit.py index 8daec861..5f5d65c5 100644 --- a/ostap/fitting/simfit.py +++ b/ostap/fitting/simfit.py @@ -1194,7 +1194,14 @@ def generate ( self , weight = None wvar = None - + + if not varset : + varset = ROOT.RooArgSet () + for lab in self.categories : + pdf = self.categories [ lab ] + for v in pdf.vars : + if not v in varset : varset.add ( v ) + ## generate all categories separately: for label in nEvents : diff --git a/ostap/fitting/tests/test_fitting_simfit7.py b/ostap/fitting/tests/test_fitting_simfit7.py index 67a1ed45..2e0d2dc5 100644 --- a/ostap/fitting/tests/test_fitting_simfit7.py +++ b/ostap/fitting/tests/test_fitting_simfit7.py @@ -99,7 +99,8 @@ fDATA = model_sim.draw ( 'DATA' , cds ) with use_canvas ( 'test_simfit7: simultaneous fit/MC' ) : fMC = model_sim.draw ( 'MC' , cds ) - + + # ============================================================================= ## (2) Perform DATA fit with MC constraints to get scale-factor # ============================================================================= @@ -113,6 +114,23 @@ logger.info ( "Scale factor from 'simultaneous' fit: %s" % ( rSIM .sfactor * 1 ) ) logger.info ( "Scale factor from 'constrained' fit: %s" % ( rDATA.sfactor * 1 ) ) + + +# ========================================================================= +## test creation of dataset +# ========================================================================= +ds_gen = model_sim.generate ( nEvents = { 'MC' : len ( ds_MC ) , + 'DATA' : len ( ds_DATA ) } , + varset = vars ) + +rg , f = model_sim.fitTo ( ds_gen , silent = True ) +rg , f = model_sim.fitTo ( ds_gen , silent = True ) + +title = 'Results of simultaneous fit to generated dataset' +logger.info ( '%s\n%s' % ( title , rg.table ( title = title , prefix = '# ' ) ) ) + + + # ============================================================================= ## The END