From 1eef8d550b622cc73fd8b03e426c1909e8a8f52d Mon Sep 17 00:00:00 2001 From: Nick Wardle Date: Thu, 7 Mar 2024 12:47:11 +0100 Subject: [PATCH 1/2] Remove warning where not needed and add filter to printWorkspaceNormalisations.py --- src/Combine.cc | 2 +- test/printWorkspaceNormalisations.py | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Combine.cc b/src/Combine.cc index 1a2a2e4c227..38d33af7d1e 100644 --- a/src/Combine.cc +++ b/src/Combine.cc @@ -913,7 +913,7 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do } // Warn the user that they might be using funky values of POIs - if (!expectSignalSet_ && setPhysicsModelParameterExpression_ == "" && !(POI->getSize()==1 && POI->find("r"))) { + if (nToys!=0 && !expectSignalSet_ && setPhysicsModelParameterExpression_ == "" && !(POI->getSize()==1 && POI->find("r"))) { std::cerr << "Warning! -- You haven't picked default values for the Parameters of Interest (either with --expectSignal or --setParameters) for generating toys. Combine will use the 'B-only' ModelConfig to generate, which may lead to undesired behaviour if not using the default Physics Model" << std::endl; } // Ok now we're ready to go lets save a "clean snapshot" for the current parameters state diff --git a/test/printWorkspaceNormalisations.py b/test/printWorkspaceNormalisations.py index e6ec2f26e94..3a1512690fe 100644 --- a/test/printWorkspaceNormalisations.py +++ b/test/printWorkspaceNormalisations.py @@ -55,7 +55,22 @@ action="store_true", help="Set to true if workspace built with --use-cms-histsum option.", ) -parser.add_option("", "--output-json", dest="output_json", default="", help="Output norms in json.") +parser.add_option( + "", + "--procFilter", + dest="process_filter_list", + type='string', + help="Filter (keep) only processes containing these names. Enter option as comma separated string", +) +parser.add_option( + "-m", + "--mass", + dest="massVal", + default=125, + type=float, + help="Set mass value in workspace (default=125).", +) +parser.add_option("", "--output-json", dest="output_json", default="", help="Output norms in json. Note, filters/thresholds are ignored for this output") (options, args) = parser.parse_args() @@ -68,7 +83,8 @@ file_in = ROOT.TFile(args[0]) ws = file_in.Get("w") - +ws.var("MH").setVal(options.massVal) +print("Normalisation Values Evaluated at MH=",options.massVal) def find_chan_proc(name): chan = norm_name[norm_name.find("_bin") + len("_bin") : norm_name.find("_proc")] @@ -77,6 +93,7 @@ def find_chan_proc(name): proc = norm_name[norm_name.find("_proc_") + len("_proc_") :] return chan, proc +process_filter_list = options.process_filter_list.split(',') chan_procs = {} @@ -141,6 +158,11 @@ def find_chan_proc(name): if type(prop) == ROOT.CMSHistSum: chan_CMSHistSum_norms[chan] = dict(prop.getProcessNorms()) +def checkFilter(proc): + for pc in process_filter_list: + if pc in proc: return True + return False + # Now print out information default_norms = od() @@ -152,6 +174,7 @@ def find_chan_proc(name): chanInfo = chan_procs[chan] for proc in chanInfo: skipProc = False + if not checkFilter(proc): skipProc=True if options.min_threshold > 0: skipProc = proc[1].getVal() < options.min_threshold if options.max_threshold > 0: From 497f9d4df9bcaf53f99119f7da949d16992968a0 Mon Sep 17 00:00:00 2001 From: nucleosynthesis Date: Thu, 7 Mar 2024 12:04:04 +0000 Subject: [PATCH 2/2] formatting --- test/printWorkspaceNormalisations.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/printWorkspaceNormalisations.py b/test/printWorkspaceNormalisations.py index 3a1512690fe..39436ee9090 100644 --- a/test/printWorkspaceNormalisations.py +++ b/test/printWorkspaceNormalisations.py @@ -59,7 +59,7 @@ "", "--procFilter", dest="process_filter_list", - type='string', + type="string", help="Filter (keep) only processes containing these names. Enter option as comma separated string", ) parser.add_option( @@ -84,7 +84,8 @@ file_in = ROOT.TFile(args[0]) ws = file_in.Get("w") ws.var("MH").setVal(options.massVal) -print("Normalisation Values Evaluated at MH=",options.massVal) +print("Normalisation Values Evaluated at MH=", options.massVal) + def find_chan_proc(name): chan = norm_name[norm_name.find("_bin") + len("_bin") : norm_name.find("_proc")] @@ -93,7 +94,8 @@ def find_chan_proc(name): proc = norm_name[norm_name.find("_proc_") + len("_proc_") :] return chan, proc -process_filter_list = options.process_filter_list.split(',') + +process_filter_list = options.process_filter_list.split(",") chan_procs = {} @@ -158,11 +160,14 @@ def find_chan_proc(name): if type(prop) == ROOT.CMSHistSum: chan_CMSHistSum_norms[chan] = dict(prop.getProcessNorms()) + def checkFilter(proc): for pc in process_filter_list: - if pc in proc: return True + if pc in proc: + return True return False + # Now print out information default_norms = od() @@ -174,7 +179,8 @@ def checkFilter(proc): chanInfo = chan_procs[chan] for proc in chanInfo: skipProc = False - if not checkFilter(proc): skipProc=True + if not checkFilter(proc): + skipProc = True if options.min_threshold > 0: skipProc = proc[1].getVal() < options.min_threshold if options.max_threshold > 0: