Skip to content
Snippets Groups Projects

Resolve "Add systematic band stack"

Merged Frank Sauerburger requested to merge 59-add-systematic-band-stack into master
3 files
+ 194
1
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 133
0
%% Cell type:code id: tags:
``` python
import pandas as pd
import seaborn as sns
from nnfwtbn import Variable, Process, Cut, hist, SystStack, DataStack, \
McStack, TruthStack
from nnfwtbn import toydata
```
%% Cell type:code id: tags:
``` python
df = toydata.get()
df = df.compute()
```
%% Cell type:code id: tags:
``` python
df = df.assign(variation="NOMINAL")
df_up = df.assign(higgs_m=df.higgs_m + 1 * df.jet_1_eta.abs(),
variation="1up")
df_down = df.assign(higgs_m=df.higgs_m - 1 * df.jet_2_eta.abs(),
variation="1down")
df = pd.concat([df, df_up, df_down], sort=False)
```
%% Cell type:code id: tags:
``` python
p_ztt = Process(r"$Z\rightarrow\tau\tau$", range=(0, 0))
p_sig = Process(r"Signal", range=(1, 1))
p_bkg_up = Process(r"Up", lambda d: d.variation == "1up")
p_bkg_down = Process(r"Down", lambda d: d.variation == "1down")
p_ztt_nom = Process(r"$Z\rightarrow\tau\tau$", lambda d: (d.variation == "NOMINAL") & (d.fpid == 0))
p_sig_nom = Process(r"Signal", lambda d: (d.variation == "NOMINAL") & (d.fpid == 1))
p_asimov = Process(r"Asimov", selection=lambda d: (d.fpid >= 0) & (d.variation == "NOMINAL"))
```
%% Cell type:code id: tags:
``` python
c_nominal = Cut(lambda d: d.variation == "NOMINAL")
```
%% Cell type:code id: tags:
``` python
colors = ["windows blue", "amber", "greyish", "faded green", "dusty purple"]
s_bkg = McStack(p_ztt, p_sig, palette=sns.xkcd_palette(colors))
s_bkg_up = TruthStack(p_bkg_up,
histtype="step",
color='k',
palette=sns.xkcd_palette(colors))
s_bkg_down = TruthStack(p_bkg_down,
histtype="step",
color='k',
linestyle='--',
palette=sns.xkcd_palette(colors))
s_bkg_nom = McStack(p_ztt_nom, p_sig_nom, palette=sns.xkcd_palette(colors))
s_bkg_syst = SystStack(p_ztt, p_sig, palette=sns.xkcd_palette(colors))
s_data = DataStack(p_asimov)
```
%% Cell type:code id: tags:
``` python
v_higgs_m = Variable(r"$m^H$", "higgs_m", "GeV")
```
%% Cell type:code id: tags:
``` python
c_vbf = Cut(lambda d: d.dijet_p4__M > 400) & \
Cut(lambda d: d.jet_1_p4__Pt >= 30) & \
Cut(lambda d: d.is_dijet_centrality == 1) & \
Cut(lambda d: d.jet_0_p4__Eta * df.jet_1_p4__Eta < 0) & \
Cut(lambda d: (d.jet_0_p4__Eta - df.jet_1_p4__Eta).abs() > 3)
```
%% Cell type:markdown id: tags:
# Plot nominal
%% Cell type:code id: tags:
``` python
hist(c_nominal(df), v_higgs_m, 20, [s_bkg, s_data], range=(0, 200), selection=None,
weight="weight", ratio_label="Data / SM", ratio_range=(0.1, 1.9))
None
```
%% Cell type:markdown id: tags:
# Envelop
%% Cell type:code id: tags:
``` python
hist(df, v_higgs_m, 20, [s_bkg_nom, s_bkg_up, s_bkg_down], range=(0, 200), selection=None,
weight="weight", ratio_label="Up / Down", ratio_range=(0.1, 1.9))
None
```
%% Cell type:markdown id: tags:
# Full band
%% Cell type:code id: tags:
``` python
hist(df, v_higgs_m, 20, [s_bkg_syst, s_data], range=(0, 200), selection=None,
weight="weight", ratio_label="Data / SM", ratio_range=(0.1, 1.9))
None
```
%% Cell type:code id: tags:
``` python
```
Loading