diff --git a/ostap/fitting/roostats.py b/ostap/fitting/roostats.py index 7e0f9255..80e3be16 100644 --- a/ostap/fitting/roostats.py +++ b/ostap/fitting/roostats.py @@ -70,6 +70,17 @@ ## allowed types for parameters par_types = ROOT.RooAbsReal, # ============================================================================== +if ( 6 , 28 ) <= root_info : # ================================================= + # ========================================================================== + def make_set ( source ) : return ROOT.RooArgSet ( source ) + # ========================================================================== +else : # ======================================================================= + # ========================================================================== + def make_set ( source ) : + result = ROOT.RooArgSet() + for item in source : result.add ( item ) + return result +# ============================================================================== ## @class ModelConfig # Helper class to create `RooStats::ModelConfig` # @see RooStats::ModelConfig @@ -192,8 +203,7 @@ def __init__ ( self , constraints = cnts ## Inform ModelConfig on the constraints - if ( 6 , 28 ) <= root_info : - self.__mc.SetExternalConstraints ( constraints ) + if ( 6 , 28 ) <= root_info : self.__mc.SetExternalConstraints ( constraints ) self.__external_constraints = constraints self.__raw_pdf = raw_pdf @@ -218,21 +228,22 @@ def __init__ ( self , assert all ( v in final_pdf for v in observables ), \ "Specified observables are not consistent with PDF" - observables = ROOT.RooArgSet ( self.pdf_observable ( o , dataset ) for o in observables ) - + + observables = make_set ( self.pdf_observable ( o , dataset ) for o in observables ) + ## (6) set observables self.__mc.SetObservables ( observables ) self.__observables = observables ## (7) get parameters of interess - poi = ROOT.RooArgSet ( self.pdf_param ( p , dataset ) for p in poi ) + poi = make_set ( self.pdf_param ( p , dataset ) for p in poi ) mc.SetParametersOfInterest ( poi ) self.__poi = poi ## (8) global observables assert all ( self.pdf_param ( p , dataset ) for p in global_observables ) - if global_observables : - global_observables = ROOT.RooArgSet ( v for v in global_observables ) + if global_observables : + global_observables = make_set ( v for v in global_observables ) assert all ( any ( o in c for c in constraints ) for o in global_observables ) , \ "Global observables are inconsisent with external constraints!" mc.SetGlobalObservables ( global_observables ) @@ -240,9 +251,9 @@ def __init__ ( self , ## nuisancee = all_parameters - poi - global_observables nuisance = final_pdf.getParameters ( dataset ) - poi - global_observables - if nuisance : ROOT.RooStats.RemoveConstantParameters ( nuisance ) - ## (9) Nuisance parameters + if nuisance : ROOT.RooStats.RemoveConstantParameters ( nuisance ) + ## (9) Nuisance parameters mc.SetNuisanceParameters ( nuisance ) self.__nuisance = nuisance @@ -256,7 +267,7 @@ def __init__ ( self , ## (11) constrained parameters (not used by RooStats! assert all ( self.pdf_param ( p , dataset ) for p in constrained ) if constrained : - constrained = ROOT.RooArgSet ( v for v in conditional ) + constrained = make_set ( v for v in conditional ) mc.SetConstraintParametrs ( constrained ) self.__constrained = constrained diff --git a/ostap/fitting/tests/test_fitting_roostats2.py b/ostap/fitting/tests/test_fitting_roostats2.py index 628dbb97..5309079c 100644 --- a/ostap/fitting/tests/test_fitting_roostats2.py +++ b/ostap/fitting/tests/test_fitting_roostats2.py @@ -375,7 +375,7 @@ def test_point_limit_hc () : # - Profile Likelihoood Calculator is used def test_point_limit_pl () : """ Get the upper limit at given point for small signal at fixed mass - - resoltuion is fixed + - resolution is fixed - Profile-Likelihood Calculator is used """ diff --git a/ostap/fitting/tests/test_fitting_roostats5.py b/ostap/fitting/tests/test_fitting_roostats5.py index 5c7a414b..d90d8015 100644 --- a/ostap/fitting/tests/test_fitting_roostats5.py +++ b/ostap/fitting/tests/test_fitting_roostats5.py @@ -94,7 +94,7 @@ model_sim.fitTo ( dataset , quiet = True ) -err = 0.1 +err = 0.3 reff = ROOT.RooRealVar ( 'reff' , 'ratio of efficiencies' , 1.0 , 0 , 10 ) ceff1 = model2.soft_constraint ( reff , VE ( 1.0, err**2 ) )