Skip to content

Commit

Permalink
remove ULEGACYV8 variable
Browse files Browse the repository at this point in the history
  • Loading branch information
anmalara committed Mar 17, 2023
1 parent 92425e4 commit 6dc169e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
1 change: 0 additions & 1 deletion bucoffea/config/vbfhinv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ default:

run:
sync: False
ulegacyv8: True
one_fifth_unblind: False
tight_mjj_cut: False
qcd_estimation: True
Expand Down
33 changes: 12 additions & 21 deletions bucoffea/helpers/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,22 @@ def varied_weight(sfname, *args):


### Electrons (For UL: Both 2017 and 2018 have their SFs split by electron pt)
if extract_year(df['dataset']) == 2017 or cfg.RUN.ULEGACYV8:
high_et = electrons.pt>20
high_et = electrons.pt>20

# Low pt SFs
low_pt_args = (electrons.etasc[~high_et], electrons.pt[~high_et])
ele_reco_sf_low = varied_weight('ele_reco_pt_lt_20', *low_pt_args)
ele_id_sf_low = varied_weight("ele_id_loose", *low_pt_args)
# Low pt SFs
low_pt_args = (electrons.etasc[~high_et], electrons.pt[~high_et])
ele_reco_sf_low = varied_weight('ele_reco_pt_lt_20', *low_pt_args)
ele_id_sf_low = varied_weight("ele_id_loose", *low_pt_args)

# High pt SFs
high_pt_args = (electrons.etasc[high_et], electrons.pt[high_et])
# High pt SFs
high_pt_args = (electrons.etasc[high_et], electrons.pt[high_et])

ele_reco_sf_high = varied_weight("ele_reco", *high_pt_args)
ele_id_sf_high = varied_weight("ele_id_loose", *high_pt_args)

# Combine
veto_weight_ele = (1 - ele_reco_sf_low*ele_id_sf_low).prod() * (1-ele_reco_sf_high*ele_id_sf_high).prod()
else:
# No split for 2018
args = (electrons.etasc, electrons.pt)
ele_reco_sf = varied_weight("ele_reco", *args)
ele_id_sf = varied_weight("ele_id_loose", *args)

# Combine
veto_weight_ele = (1 - ele_id_sf*ele_reco_sf).prod()
ele_reco_sf_high = varied_weight("ele_reco", *high_pt_args)
ele_id_sf_high = varied_weight("ele_id_loose", *high_pt_args)

# Combine
veto_weight_ele = (1 - ele_reco_sf_low*ele_id_sf_low).prod() * (1-ele_reco_sf_high*ele_id_sf_high).prod()

# Gen-checking for electrons
if cfg.ELECTRON.GENCHECK:
veto_weight_ele = gen_check_for_leptons(electrons, veto_weight_ele)
Expand Down
16 changes: 7 additions & 9 deletions bucoffea/vbfhinv/vbfhinvProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,9 @@ def ewk_correction(a, b):
output['tree_float16'][region]["leadak4_chf"] += processor.column_accumulator(np.float16(diak4.i0.chf[mask]))
output['tree_float16'][region]["leadak4_cef"] += processor.column_accumulator(np.float16(diak4.i0.cef[mask]))

if cfg.RUN.ULEGACYV8:
output['tree_float16'][region]["leadak4_setaeta"] += processor.column_accumulator(np.float16(diak4.i0.setaeta[mask]))
output['tree_float16'][region]["leadak4_sphiphi"] += processor.column_accumulator(np.float16(diak4.i0.sphiphi[mask]))
output['tree_float16'][region]["leadak4_cssize"] += processor.column_accumulator(np.float16(diak4.i0.hfcentralstripsize[mask]))
output['tree_float16'][region]["leadak4_setaeta"] += processor.column_accumulator(np.float16(diak4.i0.setaeta[mask]))
output['tree_float16'][region]["leadak4_sphiphi"] += processor.column_accumulator(np.float16(diak4.i0.sphiphi[mask]))
output['tree_float16'][region]["leadak4_cssize"] += processor.column_accumulator(np.float16(diak4.i0.hfcentralstripsize[mask]))

output['tree_float16'][region]["trailak4_pt"] += processor.column_accumulator(np.float16(diak4.i1.pt[mask]))
output['tree_float16'][region]["trailak4_eta"] += processor.column_accumulator(np.float16(diak4.i1.eta[mask]))
Expand All @@ -648,10 +647,9 @@ def ewk_correction(a, b):
output['tree_float16'][region]["trailak4_chf"] += processor.column_accumulator(np.float16(diak4.i1.chf[mask]))
output['tree_float16'][region]["trailak4_cef"] += processor.column_accumulator(np.float16(diak4.i1.cef[mask]))

if cfg.RUN.ULEGACYV8:
output['tree_float16'][region]["trailak4_setaeta"] += processor.column_accumulator(np.float16(diak4.i1.setaeta[mask]))
output['tree_float16'][region]["trailak4_sphiphi"] += processor.column_accumulator(np.float16(diak4.i1.sphiphi[mask]))
output['tree_float16'][region]["trailak4_cssize"] += processor.column_accumulator(np.float16(diak4.i1.hfcentralstripsize[mask]))
output['tree_float16'][region]["trailak4_setaeta"] += processor.column_accumulator(np.float16(diak4.i1.setaeta[mask]))
output['tree_float16'][region]["trailak4_sphiphi"] += processor.column_accumulator(np.float16(diak4.i1.sphiphi[mask]))
output['tree_float16'][region]["trailak4_cssize"] += processor.column_accumulator(np.float16(diak4.i1.hfcentralstripsize[mask]))

output['tree_float16'][region]["mjj"] += processor.column_accumulator(np.float16(df["mjj"][mask]))
output['tree_float16'][region]["detajj"] += processor.column_accumulator(np.float16(df["detajj"][mask]))
Expand Down Expand Up @@ -815,7 +813,7 @@ def ezfill(name, **kwargs):
ezfill('ak4_central_eta', jeteta=get_more_central_jeteta(diak4)[mask].flatten(), weight=w_diak4)
ezfill('ak4_forward_eta', jeteta=get_more_forward_jeteta(diak4)[mask].flatten(), weight=w_diak4)

if cfg.RUN.ULEGACYV8 and cfg.RUN.SAVE_HF_VARIABLES:
if cfg.RUN.SAVE_HF_VARIABLES:
def is_hf_jet(_ak4, ptmin=80, etamin=2.9, etamax=5.0):
return (_ak4.pt > ptmin) & (_ak4.abseta > etamin) & (_ak4.abseta < etamax)

Expand Down

0 comments on commit 6dc169e

Please sign in to comment.