Skip to content

Commit

Permalink
Some parameter renaming and changes for the impact plots
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed Nov 18, 2024
1 parent 7dcb223 commit 55262f4
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 48 deletions.
33 changes: 28 additions & 5 deletions scripts/combine/pullsAndImpacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def plotImpacts(
asym_pulls=False,
include_ref=False,
ref_name="ref.",
nominal_name="",
show_numbers=False,
show_legend=True,
legend_pos="bottom",
Expand Down Expand Up @@ -316,7 +317,7 @@ def make_bar(
thickness=1.5,
width=5,
),
name="Pulls ± Constraints",
name=f" {nominal_name}" if nominal_name else "Pull ± Constraint",
showlegend=include_ref,
),
row=1,
Expand All @@ -329,13 +330,25 @@ def make_bar(
x=2 * df["constraint_ref"],
y=labels,
orientation="h",
**get_marker(filled=False, color="black"),
name=f"Pulls ± Constraints ({ref_name})",
**get_marker(filled=True, color="#5790FC", opacity=0.5),
name=f"{ref_name}" if ref_name else "Pulls ± Constraints",
showlegend=True,
),
row=1,
col=ncols,
)
fig.add_trace(
go.Bar(
base=df["pull_ref"] - df["constraint_ref"],
x=2 * df["constraint_ref"],
y=labels,
orientation="h",
**get_marker(filled=False, color="#5790FC"),
showlegend=False,
),
row=1,
col=ncols,
)

if asym_pulls:
fig.add_trace(
Expand Down Expand Up @@ -377,14 +390,17 @@ def make_bar(
col=ncols,
)
max_pull = np.max(df["abspull"])
if "abspull_ref" in df.columns:
max_pull = max(*[max_pull, *df["abspull_ref"]])

if pullrange is None:
# Round up to nearest 0.5, add 1.1 for display
pullrange = 0.5 * np.ceil(max_pull) + 1.1
# Keep it a factor of 0.5, but no bigger than 1
spacing = min(1, np.ceil(pullrange) / 2.0)
if spacing > 0.5 * pullrange: # make sure to have at least two ticks
spacing /= 2.0
xaxis_title = "Nuisance parameter"
xaxis_title = "Nuisance parameter" if impacts else "Pull ± Constraint"
# (
# "θ - θ<sub>0</sub> <span style='color:blue'>θ - θ<sub>0</sub> / √(σ<sup>2</sup>-σ<sub>0</sub><sup>2</sup>) </span>"
# if asym_pulls
Expand Down Expand Up @@ -519,6 +535,11 @@ def parseArgs():
type=str,
help="Name of reference input for legend",
)
parser.add_argument(
"--nominalName",
type=str,
help="Name of nominal input for legend",
)
parser.add_argument(
"-s",
"--sort",
Expand Down Expand Up @@ -875,8 +896,10 @@ def producePlots(
asym_pulls=args.diffPullAsym,
include_ref=include_ref,
ref_name=args.refName,
nominal_name=args.nominalName,
show_numbers=args.showNumbers,
show_legend=not group and not args.noImpacts,
show_legend=args.referenceFile is not None
or (not group and not args.noImpacts),
)

if args.num and args.num < df.size:
Expand Down
2 changes: 1 addition & 1 deletion scripts/plotting/controlPlotsHDF5.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def make_plot(
horizontalalignment="left",
verticalalignment="top",
transform=ax1.transAxes,
fontsize=20 * args.scaleleg * scale,
fontsize=20 * scale,
)

if add_ratio:
Expand Down
30 changes: 16 additions & 14 deletions scripts/plotting/make_postfit_vgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ def quadrature_sum_hist(hists, is_down):
"" for i, l in enumerate(labels) if i != idx_unfolded for _ in range(2)
]
linestyles = linestyles + [
l for l in ["dotted", "dashdot", "dashed", "dotted"] for _ in range(2)
# l for l in ["dotted", "dashdot", "dashed", "dotted"] for _ in range(2)
l
for l in [
"solid",
]
* 4
for _ in range(2)
]
linestyles = linestyles[: len(labels)]

Expand Down Expand Up @@ -229,19 +235,15 @@ def quadrature_sum_hist(hists, is_down):
if args.twoRatios:
# make two ratios
subplotsizes = [3, 2, 2]
ref = 2 if args.ratioToData else 3
rlabel = [
"Ratio to\n" + labels[3] + "fit",
"Ratio to\n " + ("data" if unfolded_data and args.ratioToData else "prefit"),
]
midratio_idxs = [
3,
1,
2,
6,
7,
8,
9,
"Ratio to\n" + ("data" if args.ratioToData else labels[ref] + "fit"),
# "Ratio to\n " + ("data" if unfolded_data and args.ratioToData else "prefit"),
"Ratio to\nprefit",
]
midratio_idxs = [ref]
midratio_idxs.extend([i for i in range(1, 10) if i not in [ref, 4, 5]])
print(midratio_idxs)
if len(args.rrange) == 2:
rrange = [args.rrange, args.rrange]
elif len(args.rrange) == 4:
Expand Down Expand Up @@ -288,7 +290,7 @@ def quadrature_sum_hist(hists, is_down):
cms_label=args.cmsDecor,
legtext_size=args.legSize,
dataIdx=idx_unfolded,
ratio_to_data=args.ratioToData,
# ratio_to_data=args.ratioToData,
width_scale=1.25,
subplotsizes=subplotsizes,
no_sci=args.noSciy,
Expand All @@ -307,7 +309,7 @@ def quadrature_sum_hist(hists, is_down):
name += "_ptll"
if args.ptll_yll_fit:
name += "_ptllyll"
name += "_PrefitRatio"
name += "_PrefitRatio" if not args.ratioToData else "_dataRatio"
if args.postfix:
name += f"_{args.postfix}"
if args.cmsDecor == "Preliminary":
Expand Down
56 changes: 28 additions & 28 deletions utilities/styles/nuisance_translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,32 @@
"pdfMSHT20mbrangeSymDiff": "PDF Δ<i>m</i><sub>b</sub> [diff.]",
"QCDscaleWinclusive_PtV0_13000helicity_0_SymAvg": "<i>A</i><sub>0</sub> angular coeff., W, inc.",
"QCDscaleWinclusive_PtV0_13000helicity_2_SymAvg": "<i>A</i><sub>2</sub> angular coeff., W, inc.",
"scetlibNPgamma": "SCETLib γ",
"chargeVgenNP0scetlibNPZLambda2": "SCETLib λ²(Z)",
"chargeVgenNP1scetlibNPWLambda2": "SCETLib λ²(W⁻)",
"chargeVgenNP0scetlibNPWLambda2": "SCETLib λ²(W⁺)",
"chargeVgenNP0scetlibNPWDelta_Lambda2": "SCETLib Δλ²(W⁻)",
"chargeVgenNP1scetlibNPWDelta_Lambda2": "SCETLib Δλ²(W⁺)",
"chargeVgenNP0scetlibNPZDelta_Lambda2": "SCETLib Δλ²(Z)",
"chargeVgenNP0scetlibNPWLambda4": "SCETLib λ⁴(W⁻)",
"chargeVgenNP1scetlibNPWLambda4": "SCETLib λ⁴(W⁺)",
"chargeVgenNP0scetlibNPZLambda4": "SCETLib λ⁴(Z)",
"resumTransitionWSymDiff": "resum. transition W [diff.]",
"resumTransitionZSymDiff": "resum. transition Z [diff.]",
"resumTransitionZSymAvg": "resum. transition W [avg.]",
"resumTransitionWSymAvg": "resum. transition Z [avg.]",
"resumFOScaleWSymAvg": "resum. FO scale W [avg.]",
"resumFOScaleWSymDiff": "resum. FO scale W [diff.]",
"resumFOScaleZSymAvg": "resum. FO scale Z [avg.]",
"resumFOScaleZSymDiff": "resum. FO scale Z [diff.]",
"resumTNP_b_qqV": "resum. TNP B<sub>qqV</sub>",
"resumTNP_b_qg": "resum. TNP B<sub>qg</sub>",
"resumTNP_b_qqS": "resum. TNP B<sub>qqS</sub>",
"resumTNP_b_qqbarV": "resum. TNP B<sub>qqV̄</sub>",
"resumTNP_b_qqDS": "resum. TNP B<sub>qq</sub> DS",
"resumTNP_gamma_nu": "resum. TNP Γ<sub>ν</sub> DS",
"resumTNP_gamma_mu_q": "resum. TNP Γ<sub>μ,q</sub> DS",
"resumTNP_gamma_cusp": "resum. TNP Γ<sub>c,u,s,p</sub> DS",
"resumTNP_h_qqV": "resum. TNP H<sub>qqV</sub> DS",
"resumTNP_s": "resum. TNP S<sub>qqV</sub> DS"
"scetlibNPgamma": "SCETLib Nonpert. CS c<sub>ν</sub>⋅ω<sub>ν</sub>",
"chargeVgenNP0scetlibNPZLambda2": "SCETLib Nonpert. λ²(Z)",
"chargeVgenNP1scetlibNPWLambda2": "SCETLib Nonpert. λ²(W⁻)",
"chargeVgenNP0scetlibNPWLambda2": "SCETLib Nonpert. λ²(W⁺)",
"chargeVgenNP0scetlibNPWDelta_Lambda2": "SCETLib Nonpert. Δλ²(W⁻)",
"chargeVgenNP1scetlibNPWDelta_Lambda2": "SCETLib Nonpert. Δλ²(W⁺)",
"chargeVgenNP0scetlibNPZDelta_Lambda2": "SCETLib Nonpert. Δλ²(Z)",
"chargeVgenNP0scetlibNPWLambda4": "SCETLib Nonpert. λ⁴(W⁻)",
"chargeVgenNP1scetlibNPWLambda4": "SCETLib Nonpert. λ⁴(W⁺)",
"chargeVgenNP0scetlibNPZLambda4": "SCETLib Nonpert. λ⁴(Z)",
"resumTransitionWSymDiff": "Resum.-FO transition W [diff.]",
"resumTransitionZSymDiff": "Resum.-FO transition Z [diff.]",
"resumTransitionZSymAvg": "Resum.-FO transition Z [avg.]",
"resumTransitionWSymAvg": "Resum.-FO transition W [avg.]",
"resumFOScaleWSymAvg": "FO μ<sub>R</sub>,μ<sub>F</sub> W [avg.]",
"resumFOScaleWSymDiff": "FO μ<sub>R</sub>,μ<sub>F</sub> W [diff.]",
"resumFOScaleZSymAvg": "FO μ<sub>R</sub>,μ<sub>F</sub> Z [avg.]",
"resumFOScaleZSymDiff": "FO μ<sub>R</sub>,μ<sub>F</sub> Z [diff.]",
"resumTNP_b_qqV": "Resum. TNP qqV BF",
"resumTNP_b_qg": "Resum. TNP qg BF",
"resumTNP_b_qqS": "Resum. TNP qqS BF",
"resumTNP_b_qqbarV": "Resum. TNP qqV̄ BF",
"resumTNP_b_qqDS": "Resum. TNP qqΔS BF",
"resumTNP_gamma_nu": "Resum. TNP γ<sub>ν</sub>",
"resumTNP_gamma_mu_q": "Resum. TNP γ<sub>μ<sub>q</sub></sub>",
"resumTNP_gamma_cusp": "Resum. TNP Γ<sub>cusp</sub>",
"resumTNP_h_qqV": "Resum. TNP Hard func.",
"resumTNP_s": "Resum. TNP Soft func."
}

0 comments on commit 55262f4

Please sign in to comment.