diff --git a/data/tutorials/tutorial_unfolding_2023/scripts/get_migration_matrix.py b/data/tutorials/tutorial_unfolding_2023/scripts/get_migration_matrix.py index b76d620accd..c34442f8310 100644 --- a/data/tutorials/tutorial_unfolding_2023/scripts/get_migration_matrix.py +++ b/data/tutorials/tutorial_unfolding_2023/scripts/get_migration_matrix.py @@ -30,29 +30,20 @@ "vhbb_Zee_250_400_13TeV", "vhbb_Zee_gt400_13TeV", ] -hist = ROOT.TH2F( - "migration", "", len(signals), 0, len(signals), len(bins), 0, len(bins) -) +hist = ROOT.TH2F("migration", "", len(signals), 0, len(signals), len(bins), 0, len(bins)) for i, b in enumerate(bins): total_signal = 0 for j, p in enumerate(signals): procs = cb.cp().bin([b]).process([p]).GetRate() procs += cb.cp().bin([b]).process([p.replace("ZH", "ggZH")]).GetRate() procs += cb.cp().bin([b.replace("Zee", "Zmm")]).process([p]).GetRate() - procs += ( - cb.cp() - .bin([b.replace("Zee", "Zmm")]) - .process([p.replace("ZH", "ggZH")]) - .GetRate() - ) + procs += cb.cp().bin([b.replace("Zee", "Zmm")]).process([p.replace("ZH", "ggZH")]).GetRate() total_signal += procs hist.SetBinContent(j + 1, i + 1, procs) hist.GetXaxis().SetBinLabel(j + 1, p) hist.GetYaxis().SetBinLabel(i + 1, b.replace("Zee", "Zll")) for j, p in enumerate(signals): - hist.SetBinContent( - j + 1, i + 1, hist.GetBinContent(j + 1, i + 1) / total_signal - ) + hist.SetBinContent(j + 1, i + 1, hist.GetBinContent(j + 1, i + 1) / total_signal) c1 = ROOT.TCanvas() c1.cd() diff --git a/data/tutorials/tutorial_unfolding_2023/scripts/make_XSplot.py b/data/tutorials/tutorial_unfolding_2023/scripts/make_XSplot.py index ecf417c1b1c..4f9343357af 100644 --- a/data/tutorials/tutorial_unfolding_2023/scripts/make_XSplot.py +++ b/data/tutorials/tutorial_unfolding_2023/scripts/make_XSplot.py @@ -42,9 +42,7 @@ meas_dict = json.load(json_file)["STXS"] for i, p in enumerate(pois): - symm_err = ( - float(meas_dict[p]["ErrorHi"]) + float(-1 * meas_dict[p]["ErrorLo"]) - ) / 2.0 + symm_err = (float(meas_dict[p]["ErrorHi"]) + float(-1 * meas_dict[p]["ErrorLo"])) / 2.0 unfolded.SetBinContent(i + 2, meas_dict[p]["Val"] * sm_xs.GetBinContent(i + 2)) unfolded.SetBinError(i + 2, symm_err * sm_xs.GetBinContent(i + 2)) sm_xs.GetXaxis().SetBinLabel(i + 2, bin_labels_ZH[i]) diff --git a/data/tutorials/tutorial_unfolding_2023/scripts/plot1DScan.py b/data/tutorials/tutorial_unfolding_2023/scripts/plot1DScan.py index efa6198aa8a..3bca841da94 100755 --- a/data/tutorials/tutorial_unfolding_2023/scripts/plot1DScan.py +++ b/data/tutorials/tutorial_unfolding_2023/scripts/plot1DScan.py @@ -41,10 +41,7 @@ def BuildScan(scan, param, files, color, yvals, ycut): if graph.GetN() <= 1: graph.Print() - raise RuntimeError( - "Attempting to build %s scan from TGraph with zero or one point (see above)" - % files - ) + raise RuntimeError("Attempting to build %s scan from TGraph with zero or one point (see above)" % files) bestfit = None for i in range(graph.GetN()): @@ -111,23 +108,13 @@ def BuildScan(scan, param, files, color, yvals, ycut): parser = argparse.ArgumentParser() parser.add_argument("main", help="Main input file for the scan") -parser.add_argument( - "--y-cut", type=float, default=7.0, help="Remove points with y > y-cut" -) +parser.add_argument("--y-cut", type=float, default=7.0, help="Remove points with y > y-cut") parser.add_argument("--y-max", type=float, default=8.0, help="y-axis maximum") -parser.add_argument( - "--output", "-o", help="output name without file extension", default="scan" -) +parser.add_argument("--output", "-o", help="output name without file extension", default="scan") parser.add_argument("--POI", help="use this parameter of interest", default="r") -parser.add_argument( - "--translate", default=None, help="json file with POI name translation" -) -parser.add_argument( - "--main-label", default="Observed", type=str, help="legend label for the main scan" -) -parser.add_argument( - "--main-color", default=1, type=int, help="line and marker color for main scan" -) +parser.add_argument("--translate", default=None, help="json file with POI name translation") +parser.add_argument("--main-label", default="Observed", type=str, help="legend label for the main scan") +parser.add_argument("--main-color", default=1, type=int, help="line and marker color for main scan") parser.add_argument( "--others", nargs="*", @@ -155,9 +142,7 @@ def BuildScan(scan, param, files, color, yvals, ycut): yvals = [1.0, 4.0] -main_scan = BuildScan( - args.output, args.POI, [args.main], args.main_color, yvals, args.y_cut -) +main_scan = BuildScan(args.output, args.POI, [args.main], args.main_color, yvals, args.y_cut) other_scans = [] other_scans_opts = [] @@ -201,9 +186,7 @@ def BuildScan(scan, param, files, color, yvals, ycut): if min(mins) < main_scan["graph"].GetX()[0]: new_min = min(mins) - (main_scan["graph"].GetX()[0] - new_min) if max(maxs) > main_scan["graph"].GetX()[main_scan["graph"].GetN() - 1]: - new_max = max(maxs) + ( - new_max - main_scan["graph"].GetX()[main_scan["graph"].GetN() - 1] - ) + new_max = max(maxs) + (new_max - main_scan["graph"].GetX()[main_scan["graph"].GetN() - 1]) axishist.GetXaxis().SetLimits(new_min, new_max) for other in other_scans: @@ -306,9 +289,7 @@ def BuildScan(scan, param, files, color, yvals, ycut): pt.SetTextFont(42) pt.Draw() -plot.DrawCMSLogo( - pads[0], args.logo, args.logo_sub, 11, 0.045, 0.035, 1.2, cmsTextSize=1.0 -) +plot.DrawCMSLogo(pads[0], args.logo, args.logo_sub, 11, 0.045, 0.035, 1.2, cmsTextSize=1.0) legend_l = 0.69 if len(other_scans) > 0: @@ -352,22 +333,14 @@ def BuildScan(scan, param, files, color, yvals, ycut): interval = other["other_1sig"][0] js_extra["OtherLimit%sLo" % breakdown[oi + 1]] = interval["lo"] js_extra["OtherLimit%sHi" % breakdown[oi + 1]] = interval["hi"] - js_extra["ValidOtherLimit%sLo" % breakdown[oi + 1]] = interval[ - "valid_lo" - ] - js_extra["ValidOtherLimit%sHi" % breakdown[oi + 1]] = interval[ - "valid_hi" - ] + js_extra["ValidOtherLimit%sLo" % breakdown[oi + 1]] = interval["valid_lo"] + js_extra["ValidOtherLimit%sHi" % breakdown[oi + 1]] = interval["valid_hi"] if len(main_scan["other_2sig"]) >= 1: interval = other["other_2sig"][0] js_extra["2sig_OtherLimit%sLo" % breakdown[oi + 1]] = interval["lo"] js_extra["2sig_OtherLimit%sHi" % breakdown[oi + 1]] = interval["hi"] - js_extra["2sig_ValidOtherLimit%sLo" % breakdown[oi + 1]] = interval[ - "valid_lo" - ] - js_extra["2sig_ValidOtherLimit%sHi" % breakdown[oi + 1]] = interval[ - "valid_hi" - ] + js_extra["2sig_ValidOtherLimit%sLo" % breakdown[oi + 1]] = interval["valid_lo"] + js_extra["2sig_ValidOtherLimit%sHi" % breakdown[oi + 1]] = interval["valid_hi"] js[args.model][args.POI].update(js_extra) with open(args.json, "w") as outfile: @@ -375,8 +348,6 @@ def BuildScan(scan, param, files, color, yvals, ycut): save_graph = main_scan["graph"].Clone() -save_graph.GetXaxis().SetTitle( - "%s = %.3f %+.3f/%+.3f" % (fixed_name, val_nom[0], val_nom[2], val_nom[1]) -) +save_graph.GetXaxis().SetTitle("%s = %.3f %+.3f/%+.3f" % (fixed_name, val_nom[0], val_nom[2], val_nom[1])) canv.Print(".pdf") canv.Print(".png") diff --git a/data/tutorials/tutorial_unfolding_2023/scripts/plotCorrelations_pois.py b/data/tutorials/tutorial_unfolding_2023/scripts/plotCorrelations_pois.py index 15169a593c2..a12d5c099f3 100644 --- a/data/tutorials/tutorial_unfolding_2023/scripts/plotCorrelations_pois.py +++ b/data/tutorials/tutorial_unfolding_2023/scripts/plotCorrelations_pois.py @@ -52,9 +52,7 @@ for p2 in range(0, len(parameters_stxs)): param1 = parameters_stxs[p1] param2 = parameters_stxs[p2] - correlation_matrix_pruned.SetBinContent( - p1 + 1, p2 + 1, rfr.correlation(param1, param2) - ) + correlation_matrix_pruned.SetBinContent(p1 + 1, p2 + 1, rfr.correlation(param1, param2)) correlation_matrix_pruned.GetXaxis().SetBinLabel(p1 + 1, parameters_stxs[p1]) correlation_matrix_pruned.GetYaxis().SetBinLabel(p1 + 1, parameters_stxs[p1]) @@ -80,9 +78,7 @@ c2.SetFixedAspectRatio() pads[0].cd() correlation_matrix_pruned.Draw("COLZTEXT") -plot.DrawCMSLogo( - pads[0], "CMS", "Material for Combine tutorial", 0.0, 0.15, 0.04, 1.0, "", 0.6 -) +plot.DrawCMSLogo(pads[0], "CMS", "Material for Combine tutorial", 0.0, 0.15, 0.04, 1.0, "", 0.6) plot.DrawTitle(pads[0], "", 3, textSize=0.4) c2.SaveAs("%(outname)s_pois.pdf" % vars())