Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
farakiko committed Oct 11, 2024
1 parent c7fa685 commit 5dc0c3d
Show file tree
Hide file tree
Showing 7 changed files with 1,650 additions and 2,017 deletions.
3,129 changes: 1,554 additions & 1,575 deletions binder/hists_plots.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions combine/config_make_templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ regions_sel:
"TopCR": (n_bjets_T>0) & (rec_higgs_pt>250)

samples_dir:
"2018": ../eos/July18_hww_2018
"2017": ../eos/July18_hww_2017
"2016": ../eos/July18_hww_2016
"2016APV": ../eos/July18_hww_2016APV
"2018": ../eos/Oct10_hww_2018
"2017": ../eos/Oct10_hww_2017
"2016": ../eos/Oct10_hww_2016
"2016APV": ../eos/Oct10_hww_2016APV

model_path: ../../weaver-core-dev/experiments_finetuning/v35_30/model.onnx
26 changes: 0 additions & 26 deletions combine/config_make_templates_QCDscale.yaml

This file was deleted.

75 changes: 41 additions & 34 deletions combine/make_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,13 @@ def get_templates(years, channels, samples, samples_dir, regions_sel, model_path
"mu": {
"fj_mass": "fj_mass>40",
"tagger>0.75": "THWW>0.75",
"jetvetomap": "jetvetomap==1",
"lepmiso": "(lep_pt<55) | ( (lep_pt>=55) & (lep_misolation<0.8))", # needed for the fakes
},
"ele": {
"fj_mass": "fj_mass>40",
"tagger>0.75": "THWW>0.75",
"jetvetomap": "jetvetomap==1",
},
}

Expand Down Expand Up @@ -477,43 +480,47 @@ def get_templates(years, channels, samples, samples_dir, regions_sel, model_path
)

if add_fake:

fake_SF = {
"ele": 0.75,
"mu": 1.0,
}
for variation in ["FR_Nominal", "FR_stat_Up", "FR_stat_Down", "EWK_SF_Up", "EWK_SF_Down"]:

for year in years:

data = pd.read_parquet(f"{samples_dir[year]}/fake_{year}_ele_{variation}.parquet")

# apply selection
for selection in presel["ele"]:
logging.info(f"Applying {selection} selection on {len(data)} events")
data = data.query(presel["ele"][selection])

data["event_weight"] *= 0.6 # the closure test SF

for region in hists.axes["Region"]:
df = data.copy()

logging.info(f"Applying {region} selection on {len(df)} events")
df = df.query(regions_sel[region])
logging.info(f"Will fill the histograms with the remaining {len(df)} events")

if variation == "FR_Nominal":
hists.fill(
Sample="Fake",
Systematic="nominal",
Region=region,
mass_observable=df["rec_higgs_m"],
weight=df["event_weight"],
)
else:
hists.fill(
Sample="Fake",
Systematic=variation,
Region=region,
mass_observable=df["rec_higgs_m"],
weight=df["event_weight"],
)
for ch in channels:

data = pd.read_parquet(f"{samples_dir[year]}/fake_{year}_{ch}_{variation}.parquet")

# apply selection
for selection in presel[ch]:
logging.info(f"Applying {selection} selection on {len(data)} events")
data = data.query(presel[ch][selection])

data["nominal"] *= fake_SF[ch] # the closure test SF

for region in hists.axes["Region"]:
df = data.copy()

logging.info(f"Applying {region} selection on {len(df)} events")
df = df.query(regions_sel[region])
logging.info(f"Will fill the histograms with the remaining {len(df)} events")

if variation == "FR_Nominal":
hists.fill(
Sample="Fake",
Systematic="nominal",
Region=region,
mass_observable=df["rec_higgs_m"],
weight=df["event_weight"],
)
else:
hists.fill(
Sample="Fake",
Systematic=variation,
Region=region,
mass_observable=df["rec_higgs_m"],
weight=df["event_weight"],
)

logging.info(hists)

Expand Down
Loading

0 comments on commit 5dc0c3d

Please sign in to comment.