From 070355b2a2fcdad886f085de5f78f4bd2a88b4b1 Mon Sep 17 00:00:00 2001 From: Matteo Bonanomi Date: Thu, 29 Jun 2023 09:27:48 +0200 Subject: [PATCH 01/20] [cache_objects.py] Add status == 2 check on visible had taus --- objectPerformance/src/cache_objects.py | 39 +++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/objectPerformance/src/cache_objects.py b/objectPerformance/src/cache_objects.py index 6af8a0e4..ef36d058 100755 --- a/objectPerformance/src/cache_objects.py +++ b/objectPerformance/src/cache_objects.py @@ -92,21 +92,34 @@ def _p4_sum(self, array, axis=-1): behavior=array.behavior ) - def _get_visible_taus(self, all_parts): + def _get_visible_taus(self, all_parts, status_check = True): """ Create a collection of gen-level taus. Leptonic taus are discarded. Only the visible component (i.e. no neutrinos) of hadronically-decaying taus is considered. """ + all_parts = ak.zip({k.lower(): all_parts[k] for k in all_parts.keys()}) + + if status_check: + + sel = ( (all_parts.id == 15) & + (all_parts.stat == 2) + ) + + is_tau = ak.any(sel, axis=-1) + all_parts = ak.where(is_tau, all_parts, ak.full_like(all_parts, -1000)) + + all_parts = {f: field for f, field in zip(['Id','Stat','Pt','Eta','Phi','Parent','E'],ak.unzip(all_parts))} + sel_no_nu_e = abs(all_parts["Id"]) != 12 sel_no_nu_mu = abs(all_parts["Id"]) != 14 sel_no_nu_tau = abs(all_parts["Id"]) != 16 - sel = sel_no_nu_e & sel_no_nu_mu & sel_no_nu_tau + sel_no_nan = abs(all_parts["Id"]) != 1000 + sel = sel_no_nu_e & sel_no_nu_mu & sel_no_nu_tau & sel_no_nan for branch in all_parts: all_parts[branch] = all_parts[branch][sel] - all_tau_p = all_parts.copy() all_tau_m = all_parts.copy() @@ -163,18 +176,32 @@ def _filter_genpart_branches(self, all_arrays): return all_arrays - def _filter_fspart_branches(self, all_parts): + def _filter_fspart_branches(self, all_parts, status_check = True): """ Select all the final state particles. This collection is used only for dR matching and Isolation computations, but it's not saved. Neutrino final state particles are not considered. """ + all_parts = ak.zip({k.lower(): all_parts[k] for k in all_parts.keys()}) + + if status_check: + + sel = ( (all_parts.id == 15) & + (all_parts.stat == 2) + ) + + is_tau = ak.any(sel, axis=-1) + all_parts = ak.where(is_tau, all_parts, ak.full_like(all_parts, -1000)) + + all_parts = {f: field for f, field in zip(['Id','Stat','Pt','Eta','Phi','Parent','E'],ak.unzip(all_parts))} + sel_no_nu_e = abs(all_parts["Id"]) != 12 sel_no_nu_mu = abs(all_parts["Id"]) != 14 sel_no_nu_tau = abs(all_parts["Id"]) != 16 + sel_no_nan = abs(all_parts["Id"]) != 1000 sel_fs = all_parts["Stat"] == 1 - sel = sel_fs & sel_no_nu_e & sel_no_nu_mu & sel_no_nu_tau + sel = sel_fs & sel_no_nu_e & sel_no_nu_mu & sel_no_nu_tau & sel_no_nan for branch in all_parts: all_parts[branch] = all_parts[branch][sel] @@ -348,5 +375,3 @@ def load(self): dryrun=args.dry_run ) loader.load() - - From 6c11b527a3ad63757c76147a5d64107cd9b7edf5 Mon Sep 17 00:00:00 2001 From: Matteo Bonanomi Date: Tue, 1 Aug 2023 12:41:31 +0200 Subject: [PATCH 02/20] [Rates] Start development on rates table --- rates/table/menu.py | 350 ++++++++++++++++++++++++++++++++++++++ rates/table/rate_table.py | 11 ++ rates/table/scaler.py | 107 ++++++++++++ rates/table/utils.py | 33 ++++ 4 files changed, 501 insertions(+) create mode 100644 rates/table/menu.py create mode 100644 rates/table/rate_table.py create mode 100644 rates/table/scaler.py create mode 100644 rates/table/utils.py diff --git a/rates/table/menu.py b/rates/table/menu.py new file mode 100644 index 00000000..72a5837d --- /dev/null +++ b/rates/table/menu.py @@ -0,0 +1,350 @@ +#!/afs/cern.ch/user/d/dhundhau/public/miniconda3/envs/py310/bin/python +import numpy as np + +from glob import glob + +import yaml, re +from utils import * + +import uproot +import awkward as ak +import vector + +vector.register_awkward() + +class MenuConfigurator: + def __init__(self, scalings, menu): + self.scalings = self.get_scalings(scalings) + self.menu = menu + self.menu_dict = self.parse_menu() + self.menu_branches = self.trignames_to_branch() + self.trig_seeds = self.get_trig_seeds() + self.fname = "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" + + def get_scalings(self, scalings): + with open(f'{scalings}', 'r') as infile: + scalings_eta = yaml.safe_load(infile.read()) + return scalings_eta + + def parse_menu(self): + with open(f'{self.menu}', 'r') as infile: + obj_dict = yaml.safe_load(infile.read()) + return obj_dict + + def trignames_to_branch(self): + trignames_to_branch = {} + for obj,items in self.menu_dict.items(): + br = items["basebranch"] + + trignames_to_branch[obj] = br + + return trignames_to_branch + + def get_trig_seeds(self): + cfg_fname = "./v29_menu_config_cleaned.yml" + + with open(cfg_fname, 'r') as infile: + test_trig_seeds = yaml.safe_load(infile.read()) + + return test_trig_seeds + + def add_offline_pt(self, arr, obj_scalings, pt_var = None): + # initialise array of zeros identical to the original pt + if pt_var is not None: pt_orig = arr[pt_var] + elif "pt" in arr.fields: pt_orig = arr.pt + elif "et" in arr.fields: pt_orig = arr.et + elif "" in arr.fields: pt_orig = arr[""][:,0] + else: + print("Error! Unknown pt branch") + return 0 + + if None in obj_scalings: + values = obj_scalings[None] + new_pt = pt_orig * values["slope"] + values["offset"] * (pt_orig > 0) + else: + new_pt = ak.zeros_like(pt_orig) + + # loop through eta regions with it's scaling parameters + for region,values in obj_scalings.items(): + # create eta mask for this eta region + eta_mask = (abs(arr.eta) >= values["eta_min"]) & (abs(arr.eta) < values["eta_max"]) + # scale pt for non-masked elements of this eta region + new_pt = new_pt + eta_mask * (pt_orig * values["slope"] + values["offset"]) + + return ak.with_field(arr, new_pt, "offline_pt") + + def scale_pt(self, obj, arr): + if obj in self.scalings: + arr = self.add_offline_pt(arr, self.scalings[obj]) + else: + print("No scalings found for " + obj) + if "" in arr.fields: + arr["et"] = arr[""] + arr["pt"] = arr[""] + arr["offline_pt"] = arr.pt + + if "eta" in arr.fields: arr = ak.with_name(arr, "Momentum3D") + + arr["idx"] = ak.local_index(arr) + return arr + + def format_values(self, arr): + if "et" not in arr.fields: + if "pt" in arr.fields: + arr["et"] = arr.pt + elif "" in arr.fields: + arr["pt"] = arr[""] + arr["et"] = arr[""] + elif "pt" not in arr.fields: + if "et" in arr.fields: + arr["pt"] = arr.et + + for x in ["passeseleid","passessaid","passesphoid"]: + if x in arr.fields: + arr[x] = ak.values_astype(arr[x], bool) + + return arr + + def load_minbias(self, obj): + with uproot.open(self.fname) as f: + arr = f["l1PhaseIITree/L1PhaseIITree"].arrays( + filter_name = f"{obj}*", + how = "zip" + ) + return arr + + def get_obj_arr(self, obj, + sample = "MinBias", + vers = "V29_part"): + + arr = self.load_minbias(obj) + if "jagged0" in arr.fields: + arr = arr["jagged0"] + + arr = ak.zip({f.replace(obj,"").lower():arr[f] for f in arr.fields}) + arr = self.format_values(arr) + arr = self.scale_pt(obj, arr) + + return arr + + def get_cut_str(self, leg, cut, trig_object, cut_str): + for var in trig_object["variables"]: + var = var.lower() + if var in cut: + # replace var only it not preceeded by legX where X is a digit + pattern = r"(?= {pt_cut})") + elif "leading" in cut: + leg_mask.append("("+cut.replace("leading",f"{leg}.et")+")") + else: + cut = cut.replace("etaRangeCutLess","RangeCutLess") + cut = cut.replace("deltaEta(Eta,","abs(Eta-").lower() + + cut_str = cut + cut_str = self.get_cut_str(leg, cut, trig_object, cut_str) + cut_str = cut_str.replace("deltar","deltaR") + + if "leg" in cut: + cross_mask.append(cut_str) + else: + leg_mask.append(cut_str) + + return leg_mask, cross_mask + + def decode_leg_cuts(self, leg, items): + obj = items["obj"] + + trig_object = self.menu_dict[obj] + + leg_mask, cross_mask = self.get_masks(leg, trig_object, items) + + return leg_mask, cross_mask + + def decode_seed(self, trig_seed): + ## make leg masks etc + seed_legs = {} + cross_masks_str = [] + cross_seeds = [] + + ### 0. decompose trig_seed + for leg, items in trig_seed.items(): + if "leg" in leg: + obj = items["obj"] + leg_mask, cross_mask = self.decode_leg_cuts(leg, items) + + if len(cross_mask) > 0: cross_masks_str.append(cross_mask) + + seed_legs[leg] = { "obj": self.menu_branches[obj], + "leg_mask": leg_mask + } + elif leg == "x-seeds": + if isinstance(items, list): cross_seeds+=items + else: cross_seeds.append(items) + + return seed_legs, cross_masks_str, cross_seeds + + def get_legs(self, seed_legs): + all_arrs = {} + leg_arrs = {} + + for leg, items in seed_legs.items(): + obj = items["obj"] + + if obj not in all_arrs: all_arrs[obj] = self.get_obj_arr(obj) + + leg_mask_str = items["leg_mask"] + + leg_mask_str = "&".join([f"({s})" for s in leg_mask_str]).replace(leg,"leg_arr") + leg_arr = all_arrs[obj] + + # get masked array + leg_mask = eval(leg_mask_str) + + ## apply mask if regular (non-jagged) array, e.g. MET/HT etc + if "var" in str(leg_arr.type): + leg_arrs[leg] = leg_arr[leg_mask] + else: + leg_arrs[leg] = ak.mask(leg_arr, leg_mask) + + return leg_arrs + + def get_combos(self, leg_arrs, seed_legs): + + if len(leg_arrs) > 1: + combos = ak.cartesian(leg_arrs) + else: + combos = leg_arrs + + ## duplicate handling (exclude combinations) + ### first check whether objects are repeating + objs = [o["obj"] for o in seed_legs.values()] + obj_cnts = {i: objs.count(i) for i in objs} + + if np.max(list(obj_cnts.values())) > 1: + nodup_masks = [] + + for i,l1 in enumerate(leg_arrs.keys()): + for j,l2 in enumerate(leg_arrs.keys()): + if i>=j: continue + ## check that the legs are the same type object, skip otherwise + if seed_legs[l1]["obj"] != seed_legs[l2]["obj"]: continue + nodup_masks.append(combos[l1].idx < combos[l2].idx) + + if len(nodup_masks) > 0: + eval_str = " & ".join([f"nodup_masks[{i}]" for i in range(len(nodup_masks))]) + nodup_mask = eval(eval_str) + combos = combos[nodup_mask] + + return combos + + def get_legs_and_masks(self, seed_legs): + ### load all legs + leg_arrs = self.get_legs(seed_legs) + + ### leg duplicate removal + combos = self.get_combos(leg_arrs, seed_legs) + + return leg_arrs, combos + + def get_eval_string(self, leg_arrs): + eval_str = [] + for leg, leg_arr in leg_arrs.items(): + if "var" in str(leg_arr.type): + eval_str.append(f"(ak.num({leg}) > 0)") + else: + eval_str.append(f"(ak.is_none({leg}) == False)") + eval_str = " & ".join(eval_str) + + return eval_str + + def get_npass(self, trig_seed): + seed_legs, cross_masks_str, cross_seeds = self.decode_seed(trig_seed) + leg_arrs, combos = self.get_legs_and_masks(seed_legs) + + ## define leg arrays + for leg in leg_arrs: exec(f"{leg} = combos['{leg}']") + + ## require presence of legs + eval_str = self.get_eval_string(leg_arrs) + nleg_mask = eval(eval_str) + + ## create event mask + total_mask = nleg_mask + + ## add cross_conditions + if len(cross_masks_str) > 0: + cross_mask = [] + + for cross_mask_str in [item for sublist in cross_masks_str for item in sublist]: + cross_mask.append(eval(cross_mask_str)) + + ## combine cross_masks + eval_str = " & ".join([f"cross_mask[{i}]" for i in range(len(cross_mask))]) + cross_mask_all = eval(f"ak.any({eval_str}, axis = 1)") + + total_mask = total_mask & cross_mask_all + + ## Add cross-seeds: + for xseed in cross_seeds: + xseed_mask = get_npass(self.trig_seeds[xseed]) + total_mask = total_mask & xseed_mask + + total_mask = ak.fill_none(total_mask, False) + return total_mask + + def prepare_masks(self): + trig_masks = {} + + seeds = self.trig_seeds + + for seed in sorted(seeds): + + if "PFTau" in seed: continue + + print(seed) + + mask = self.get_npass(self.trig_seeds[seed]) + npass = np.sum(mask) + print("##### Npasses:", npass,"\n") + + trig_masks[seed] = mask.to_numpy() + + return trig_masks + + @property + def make_table(self): + total_mask = 0 + trig_masks = self.prepare_masks() + + for seed, mask in trig_masks.items(): + + total_mask = total_mask | mask + npass = np.sum(mask) + eff = npass/len(mask) + rate = eff * 2760*11246 / 1e3 + print(seed.ljust(50), ":\t%8i\t%.5f\t%.1f" %(npass, eff, rate)) + + ## total + npass = np.sum(total_mask) + eff = npass/len(total_mask) + rate = eff * 2760*11246 / 1e3 + + tot_str = "Total:".ljust(50)+ "\t%8i\t%.5f\t%.1f" %(npass, eff, rate) + print((len(tot_str)+5)*"-") + print(tot_str) + + print("Total nev: %i" % len(total_mask)) diff --git a/rates/table/rate_table.py b/rates/table/rate_table.py new file mode 100644 index 00000000..18752fa5 --- /dev/null +++ b/rates/table/rate_table.py @@ -0,0 +1,11 @@ +#!/afs/cern.ch/user/d/dhundhau/public/miniconda3/envs/py310/bin/python +from scaler import Scaler +from menu import MenuConfigurator + +path_to_scalings = "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" +scaler = Scaler(path_to_scalings) +scaler.collect_scalings +scaler.scaling_dict + +menu_config = MenuConfigurator('scalings.yml', 'v29_WITHMUONS_Final_obj_dict.yml') +menu_config.make_table diff --git a/rates/table/scaler.py b/rates/table/scaler.py new file mode 100644 index 00000000..2df58d17 --- /dev/null +++ b/rates/table/scaler.py @@ -0,0 +1,107 @@ +#!/afs/cern.ch/user/d/dhundhau/public/miniconda3/envs/py310/bin/python + +import os, yaml +from glob import glob + +class Scaler: + def __init__(self, path_to_scalings): + self.dir = path_to_scalings + self.fnames = glob(f"{self.dir}/*.txt") + self.scaling_dict = {} +# self.scaling_file = None + + def get_lines(self, fname): + with open(fname) as f: + lines = f.readlines() + + return lines + + def get_basename(self, fname): + basename = os.path.basename(fname).replace(".txt","") + basename = basename.replace( + "Turnon","").replace( + "Trigger","").replace( + "Matching","").replace( + "_","") + + return basename + + def eta_ranges(self, obj, suffix): + eta_range = None + if obj == "Muons": + if suffix == "Barrel": + eta_range = (0,0.83) + elif suffix == "Overlap": + eta_range = (0.83,1.24) + elif suffix == "Endcap": + eta_range = (1.24,2.5) + else: + if suffix == "Barrel": + eta_range = (0,1.5) + elif suffix == "Endcap": + eta_range = (1.5,2.5) + elif suffix == "Forward": + eta_range = (2.5,5) + + return eta_range + + def get_eta_range(self, fname): + + basename = self.get_basename(fname) + + for suffix in ["Barrel","Endcap","Overlap"]: + if suffix in basename: + obj = basename.split(suffix)[0] + eta_range = self.eta_ranges(obj, suffix) + + if eta_range is None: + print("Not found! ", basename, obj) + else: + return obj, suffix, eta_range + + return None + + def decode_scaling(self, line): + line = line.replace(" ","") + items = line.split("::") + + obj = items[1][:-len("Scaling")] + slope = float(items[2][len("args:=(offline);lambda:="):items[2].find("*off")-10]) + offset = float(items[2][items[2].find("*off")+len("*offline"):-10]) + + return obj,slope,offset + + @property + def collect_scalings(self): + for fname in self.fnames: + r = self.get_eta_range(os.path.basename(fname)) + + if r is None: + print(30*"#", r) + objcat = None + region = None + eta_range = (None,None) + else: + objcat,region,eta_range = r + + lines = self.get_lines(fname) + + for line in lines: + obj,slope,offset = self.decode_scaling(line) + d = { region : { + "eta_min" : eta_range[0], + "eta_max" : eta_range[1], + "offset" : offset, + "slope" : slope + } + } + + if obj in self.scaling_dict: self.scaling_dict[obj].update(d) + else: self.scaling_dict[obj] = d + + @property + def dump_scalings(self): + with open('scalings.yml', 'w') as outfile: + yaml.dump(self.scaling_dict, + outfile, + default_flow_style=False) diff --git a/rates/table/utils.py b/rates/table/utils.py new file mode 100644 index 00000000..2617b468 --- /dev/null +++ b/rates/table/utils.py @@ -0,0 +1,33 @@ +import numpy as np + +def dr(leg1,leg2): + return leg1.deltaR(leg2) + +def deltar(eta1,eta2,phi1,phi2): + return np.sqrt(np.power(abs(eta1-eta2),2) + np.power(abs(phi1-phi2) if abs(phi1-phi2)<=np.pi else 2*np.pi-abs(phi1-phi2),2)) + #return np.sqrt(np.power(abs(eta1-eta2),2) + np.power(abs(phi1-phi2) * abs(phi1-phi2)<=np.pi else 2*np.pi-abs(phi1-phi2),2)) + +def notmatched(eta1,eta2,phi1,phi2): + return deltar(eta1,eta2,phi1,phi2) > 0.1 + +def pairinvmass(pt1,pt2,eta1,eta2,phi1,phi2): + return np.sqrt(2.0*pt1*pt2*(np.cosh(eta1-eta2)-np.cos(phi1-phi2))) + +def phoid(EleID, PhoID, Eta): + return EleID * (abs(Eta)<1.5) + PhoID * (abs(Eta)>=1.5) + +def egid(EleID, SaID, Eta): + return EleID * abs(Eta)<1.5 + SaID * (abs(Eta)>=1.5) + +def TkEleQualHIGH(Et,Eta,PassesEleID): return PassesEleID +def TkEleQualLOW(Et,Eta,PassesEleID): return PassesEleID * (abs(Eta)<1.479) + (abs(Eta)<1.479) +def TkEleIsoQualHIGH(Et,Eta,PassesEleID): return PassesEleID * (abs(Eta)>1.479) + (abs(Eta)<1.479) +def TkEleIsoQualLOW(Et,Eta,PassesEleID): return (PassesEleID>=0) # this should be always true: we can remove this condition from the menu + +def tkelequalhigh(et,eta,passeseleid): return passeseleid +def tkelequallow(et,eta,passeseleid): return passeseleid * (abs(eta)<1.479) + (abs(eta)<1.479) +def tkeleisoqualhigh(et,eta,passeseleid): return passeseleid * (abs(eta)>1.479) + (abs(eta)<1.479) +def tkeleisoquallow(et,eta,passeseleid): return (passeseleid>=0) # this should be always true: we can remove this condition from the menu + +def rangecutless(x,eta,etaRange,cutInRange,cutOutRange): + return (x=etaRange) From b58797f23014af2ff81200f31815880186b2c5c0 Mon Sep 17 00:00:00 2001 From: Matteo Bonanomi Date: Tue, 1 Aug 2023 17:00:33 +0200 Subject: [PATCH 03/20] [Rates] Improvements and cleanup. Move to a single config --- .../cfg/v29/v29_16Seeds_Final_clean_cfg.yml | 204 ++++++++++++++++++ rates/table/cfg/v29/v29_cfg.yml | 5 + rates/table/menu.py | 125 +++-------- rates/table/menu_config.py | 24 +++ rates/table/rate_table.py | 33 ++- 5 files changed, 284 insertions(+), 107 deletions(-) create mode 100644 rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml create mode 100644 rates/table/cfg/v29/v29_cfg.yml create mode 100644 rates/table/menu_config.py diff --git a/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml new file mode 100644 index 00000000..afc1762f --- /dev/null +++ b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml @@ -0,0 +1,204 @@ +L1_DoubleEGEle: + cross_masks: + - leg1.deltaR(leg2) > 0.1 + - leg1.offline_pt + leg2.offline_pt > 40 + leg1: + leg_mask: + - leg1.offline_pt >= 37.0 + - abs(leg1.eta)<2.4 + - egid(leg1.passeseleid,leg1.passessaid,leg1.eta) + obj: EG + leg2: + leg_mask: + - leg2.offline_pt >= 24.0 + - abs(leg2.eta)<2.4 + - egid(leg2.passeseleid,leg2.passessaid,leg2.eta) + obj: EG +L1_DoubleTkEle: + cross_masks: + - abs(leg2.zvtx-leg1.zvtx)<1 + leg1: + leg_mask: + - leg1.offline_pt >= 25.0 + - abs(leg1.eta)<2.4 + - tkelequallow(leg1.et,leg1.eta,leg1.passeseleid) + obj: tkElectron + leg2: + leg_mask: + - leg2.offline_pt >= 12.0 + - abs(leg2.eta)<2.4 + - tkelequallow(leg2.et,leg2.eta,leg2.passeseleid) + obj: tkElectron +L1_DoubleTkMu: + cross_masks: + - abs(leg1.z0-leg2.z0)<1 + leg1: + leg_mask: + - leg1.offline_pt >= 15.0 + - abs(leg1.eta)<2.4 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.offline_pt >= 7.0 + - abs(leg2.eta)<2.4 + obj: gmtTkMuon +L1_DoubleTkPhoIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 22.0 + - abs(leg1.eta)<2.4 + - phoid(leg1.passeseleid,leg1.passesphoid,leg1.eta) + - rangecutless(leg1.trkiso,leg1.eta,1.479,0.25,0.205) + obj: tkPhoton + leg2: + leg_mask: + - leg2.offline_pt >= 12.0 + - abs(leg2.eta)<2.4 + - phoid(leg2.passeseleid,leg2.passesphoid,leg2.eta) + - rangecutless(leg2.trkiso,leg2.eta,1.479,0.25,0.205) + obj: tkPhoton +L1_PFHTT: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 450.0 + obj: seededConePuppiHT +L1_PFHTT_QuadJet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 400.0 + obj: seededConePuppiHT + leg2: + leg_mask: + - leg2.offline_pt >= 70.0 + - leg2.et>25.0 + - abs(leg2.eta)<2.4 + obj: seededConePuppiJet + leg3: + leg_mask: + - leg3.offline_pt >= 55.0 + - leg3.et>25.0 + - abs(leg3.eta)<2.4 + obj: seededConePuppiJet + leg4: + leg_mask: + - leg4.offline_pt >= 40.0 + - leg4.et>25.0 + - abs(leg4.eta)<2.4 + obj: seededConePuppiJet + leg5: + leg_mask: + - leg5.offline_pt >= 40.0 + - leg5.et>25.0 + - abs(leg5.eta)<2.4 + obj: seededConePuppiJet +L1_PFIsoTau_PFIsoTau: + cross_masks: + - leg1.deltaR(leg2) > 0.5 + leg1: + leg_mask: + - leg1.offline_pt >= 52.0 + - abs(leg1.eta)<2.172 + - leg1.passloosenn>0 + obj: nnTau + leg2: + leg_mask: + - leg2.offline_pt >= 52.0 + - abs(leg2.eta)<2.172 + - leg2.passloosenn>0 + obj: nnTau +L1_PFMet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 200.0 + obj: puppiMET +L1_SingleEGEle: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 51.0 + - abs(leg1.eta)<2.4 + - egid(leg1.passeseleid,leg1.passessaid,leg1.eta) + obj: EG +L1_SinglePfJet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 230.0 + - leg1.et>25 + - abs(leg1.eta)<2.4 + obj: seededConePuppiJet +L1_SingleTkEle: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 36.0 + - abs(leg1.eta)<2.4 + - tkelequalhigh(leg1.et,leg1.eta,leg1.passeseleid) + obj: tkElectron +L1_SingleTkEleIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 28.0 + - tkeleisoquallow(leg1.et,leg1.eta,leg1.passeseleid) + - rangecutless(leg1.trkiso,leg1.eta,1.479,0.13,0.28) + obj: tkElectron +L1_SingleTkMu: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 22.0 + - abs(leg1.eta)<2.4 + obj: gmtTkMuon +L1_SingleTkPhoIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 36.0 + - abs(leg1.eta)<2.4 + - phoid(leg1.passeseleid,leg1.passesphoid,leg1.eta) + - rangecutless(leg1.trkiso,leg1.eta,1.479,0.25,0.205) + obj: tkPhoton +L1_TkEleIso_EG: + cross_masks: + - leg1.deltaR(leg2) > 0.1 + leg1: + leg_mask: + - leg1.offline_pt >= 22.0 + - abs(leg1.eta)<2.4 + - tkeleisoquallow(leg1.et,leg1.eta,leg1.passeseleid) + - rangecutless(leg1.trkiso,leg1.eta,1.479,0.13,0.28) + obj: tkElectron + leg2: + leg_mask: + - leg2.offline_pt >= 12.0 + - abs(leg2.eta)<2.4 + - egid(leg2.passeseleid,leg2.passessaid,leg2.eta) + obj: EG +L1_TripleTkMu: + cross_masks: + - abs(leg2.z0-leg1.z0)<1 + - abs(leg3.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>5 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>3 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.pt>3 + - abs(leg3.eta)<2.4 + - leg3.qual>0 + obj: gmtTkMuon + diff --git a/rates/table/cfg/v29/v29_cfg.yml b/rates/table/cfg/v29/v29_cfg.yml new file mode 100644 index 00000000..163d904f --- /dev/null +++ b/rates/table/cfg/v29/v29_cfg.yml @@ -0,0 +1,5 @@ +MenuV29: + version: "V29" + sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" + menu_config: "cfg/v29_16Seeds_Final_clean_cfg.yml" + scalings: "scalings.yml" diff --git a/rates/table/menu.py b/rates/table/menu.py index 72a5837d..e3ea42be 100644 --- a/rates/table/menu.py +++ b/rates/table/menu.py @@ -4,7 +4,9 @@ from glob import glob import yaml, re + from utils import * +from menu_config import MenuConfig import uproot import awkward as ak @@ -12,38 +14,21 @@ vector.register_awkward() -class MenuConfigurator: - def __init__(self, scalings, menu): - self.scalings = self.get_scalings(scalings) - self.menu = menu - self.menu_dict = self.parse_menu() - self.menu_branches = self.trignames_to_branch() +class MenuTable: + def __init__(self, cfg): + self.cfg = MenuConfig(cfg) + self.fname = self.cfg.sample + self.cfg_fname = self.cfg.menu_cfg + self.scalings = self.get_scalings(self.cfg.scalings) self.trig_seeds = self.get_trig_seeds() - self.fname = "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" def get_scalings(self, scalings): with open(f'{scalings}', 'r') as infile: scalings_eta = yaml.safe_load(infile.read()) return scalings_eta - def parse_menu(self): - with open(f'{self.menu}', 'r') as infile: - obj_dict = yaml.safe_load(infile.read()) - return obj_dict - - def trignames_to_branch(self): - trignames_to_branch = {} - for obj,items in self.menu_dict.items(): - br = items["basebranch"] - - trignames_to_branch[obj] = br - - return trignames_to_branch - def get_trig_seeds(self): - cfg_fname = "./v29_menu_config_cleaned.yml" - - with open(cfg_fname, 'r') as infile: + with open(self.cfg_fname, 'r') as infile: test_trig_seeds = yaml.safe_load(infile.read()) return test_trig_seeds @@ -126,77 +111,7 @@ def get_obj_arr(self, obj, arr = self.scale_pt(obj, arr) return arr - - def get_cut_str(self, leg, cut, trig_object, cut_str): - for var in trig_object["variables"]: - var = var.lower() - if var in cut: - # replace var only it not preceeded by legX where X is a digit - pattern = r"(?= {pt_cut})") - elif "leading" in cut: - leg_mask.append("("+cut.replace("leading",f"{leg}.et")+")") - else: - cut = cut.replace("etaRangeCutLess","RangeCutLess") - cut = cut.replace("deltaEta(Eta,","abs(Eta-").lower() - - cut_str = cut - cut_str = self.get_cut_str(leg, cut, trig_object, cut_str) - cut_str = cut_str.replace("deltar","deltaR") - - if "leg" in cut: - cross_mask.append(cut_str) - else: - leg_mask.append(cut_str) - - return leg_mask, cross_mask - - def decode_leg_cuts(self, leg, items): - obj = items["obj"] - - trig_object = self.menu_dict[obj] - - leg_mask, cross_mask = self.get_masks(leg, trig_object, items) - - return leg_mask, cross_mask - - def decode_seed(self, trig_seed): - ## make leg masks etc - seed_legs = {} - cross_masks_str = [] - cross_seeds = [] - - ### 0. decompose trig_seed - for leg, items in trig_seed.items(): - if "leg" in leg: - obj = items["obj"] - leg_mask, cross_mask = self.decode_leg_cuts(leg, items) - - if len(cross_mask) > 0: cross_masks_str.append(cross_mask) - - seed_legs[leg] = { "obj": self.menu_branches[obj], - "leg_mask": leg_mask - } - elif leg == "x-seeds": - if isinstance(items, list): cross_seeds+=items - else: cross_seeds.append(items) - - return seed_legs, cross_masks_str, cross_seeds - + def get_legs(self, seed_legs): all_arrs = {} leg_arrs = {} @@ -271,8 +186,19 @@ def get_eval_string(self, leg_arrs): return eval_str - def get_npass(self, trig_seed): - seed_legs, cross_masks_str, cross_seeds = self.decode_seed(trig_seed) + def seeds_from_cfg(self, seed): + seed_legs = {l: self.trig_seeds[seed][l] for l in self.trig_seeds[seed] if "leg" in l} + cross_masks_str = self.trig_seeds[seed]["cross_masks"] + if len(cross_masks_str)>0: cross_masks_str = [cross_masks_str] + cross_seeds = [] + for leg, items in self.trig_seeds[seed].items(): + if leg == "x-seeds": + if isinstance(items, list): cross_seeds+=items + else: cross_seeds.append(items) + return seed_legs, cross_masks_str, cross_seeds + + def get_npass(self, seed, trig_seed): + seed_legs, cross_masks_str, cross_seeds = self.seeds_from_cfg(seed) leg_arrs, combos = self.get_legs_and_masks(seed_legs) ## define leg arrays @@ -300,7 +226,7 @@ def get_npass(self, trig_seed): ## Add cross-seeds: for xseed in cross_seeds: - xseed_mask = get_npass(self.trig_seeds[xseed]) + xseed_mask = self.get_npass(self.trig_seeds[xseed]) total_mask = total_mask & xseed_mask total_mask = ak.fill_none(total_mask, False) @@ -312,12 +238,11 @@ def prepare_masks(self): seeds = self.trig_seeds for seed in sorted(seeds): - if "PFTau" in seed: continue print(seed) - mask = self.get_npass(self.trig_seeds[seed]) + mask = self.get_npass(seed, self.trig_seeds[seed]) npass = np.sum(mask) print("##### Npasses:", npass,"\n") diff --git a/rates/table/menu_config.py b/rates/table/menu_config.py new file mode 100644 index 00000000..ea915e45 --- /dev/null +++ b/rates/table/menu_config.py @@ -0,0 +1,24 @@ +class MenuConfig: + + def __init__(self, cfg: dict): + self._cfg = cfg + + @property + def sample(self): + return self._cfg["sample"] + + @property + def scalings(self): + return self._cfg["scalings"] + + @property + def menu_cfg(self): + return self._cfg["menu_config"] + + @property + def menu_objects(self): + return self._cfg["menu_objects"] + + @property + def version(self): + return self._cfg["version"] diff --git a/rates/table/rate_table.py b/rates/table/rate_table.py index 18752fa5..123c4155 100644 --- a/rates/table/rate_table.py +++ b/rates/table/rate_table.py @@ -1,11 +1,30 @@ #!/afs/cern.ch/user/d/dhundhau/public/miniconda3/envs/py310/bin/python +import argparse +import yaml + from scaler import Scaler -from menu import MenuConfigurator +from menu import MenuTable +from menu_config import MenuConfig + +if __name__ == "__main__": + + parser = argparse.ArgumentParser() + parser.add_argument( + "cfg", + default="cfg_caching/V22.yaml", + help="" + ) + args = parser.parse_args() + + with open(args.cfg, 'r') as f: + cfg = yaml.safe_load(f) + + path_to_scalings = "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" + scaler = Scaler(path_to_scalings) + scaler.collect_scalings + scaler.scaling_dict -path_to_scalings = "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" -scaler = Scaler(path_to_scalings) -scaler.collect_scalings -scaler.scaling_dict + for menu_title, menu_cfg in cfg.items(): + menu_config = MenuTable(menu_cfg) + menu_config.make_table -menu_config = MenuConfigurator('scalings.yml', 'v29_WITHMUONS_Final_obj_dict.yml') -menu_config.make_table From ded3cd24788c6f321768105623e07cc4ec7d545d Mon Sep 17 00:00:00 2001 From: Matteo Bonanomi Date: Wed, 2 Aug 2023 12:17:46 +0200 Subject: [PATCH 04/20] Clean up the code. Improve actions in config. Remove util functions from menu config definition --- .../cfg/v29/v29_16Seeds_Final_clean_cfg.yml | 38 +++-- rates/table/cfg/v29/v29_cfg.yml | 9 +- rates/table/menu_config.py | 24 ++- rates/table/{menu.py => menu_table.py} | 142 +++++++++++++++--- rates/table/rate_table.py | 15 +- rates/table/scaler.py | 73 +++++++-- rates/table/utils.py | 4 +- 7 files changed, 239 insertions(+), 66 deletions(-) rename rates/table/{menu.py => menu_table.py} (61%) mode change 100644 => 100755 rates/table/rate_table.py diff --git a/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml index afc1762f..0055f818 100644 --- a/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml +++ b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml @@ -1,18 +1,17 @@ L1_DoubleEGEle: cross_masks: - leg1.deltaR(leg2) > 0.1 - - leg1.offline_pt + leg2.offline_pt > 40 leg1: leg_mask: - leg1.offline_pt >= 37.0 - abs(leg1.eta)<2.4 - - egid(leg1.passeseleid,leg1.passessaid,leg1.eta) + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passessaid * (abs(leg1.eta) >= 1.5) obj: EG leg2: leg_mask: - leg2.offline_pt >= 24.0 - abs(leg2.eta)<2.4 - - egid(leg2.passeseleid,leg2.passessaid,leg2.eta) + - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passessaid * (abs(leg2.eta) >= 1.5) obj: EG L1_DoubleTkEle: cross_masks: @@ -21,13 +20,13 @@ L1_DoubleTkEle: leg_mask: - leg1.offline_pt >= 25.0 - abs(leg1.eta)<2.4 - - tkelequallow(leg1.et,leg1.eta,leg1.passeseleid) + - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) obj: tkElectron leg2: leg_mask: - leg2.offline_pt >= 12.0 - abs(leg2.eta)<2.4 - - tkelequallow(leg2.et,leg2.eta,leg2.passeseleid) + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) obj: tkElectron L1_DoubleTkMu: cross_masks: @@ -48,15 +47,15 @@ L1_DoubleTkPhoIso: leg_mask: - leg1.offline_pt >= 22.0 - abs(leg1.eta)<2.4 - - phoid(leg1.passeseleid,leg1.passesphoid,leg1.eta) - - rangecutless(leg1.trkiso,leg1.eta,1.479,0.25,0.205) + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passesphoid * (abs(leg1.eta) >= 1.5) + - (leg1.trkiso<0.25) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.205) * (abs(leg1.eta)>=1.479) obj: tkPhoton leg2: leg_mask: - leg2.offline_pt >= 12.0 - abs(leg2.eta)<2.4 - - phoid(leg2.passeseleid,leg2.passesphoid,leg2.eta) - - rangecutless(leg2.trkiso,leg2.eta,1.479,0.25,0.205) + - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passesphoid * (abs(leg2.eta) >= 1.5) + - (leg2.trkiso<0.25) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.205) * (abs(leg2.eta)>=1.479) obj: tkPhoton L1_PFHTT: cross_masks: [] @@ -121,7 +120,7 @@ L1_SingleEGEle: leg_mask: - leg1.offline_pt >= 51.0 - abs(leg1.eta)<2.4 - - egid(leg1.passeseleid,leg1.passessaid,leg1.eta) + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passessaid * (abs(leg1.eta) >= 1.5) obj: EG L1_SinglePfJet: cross_masks: [] @@ -137,15 +136,15 @@ L1_SingleTkEle: leg_mask: - leg1.offline_pt >= 36.0 - abs(leg1.eta)<2.4 - - tkelequalhigh(leg1.et,leg1.eta,leg1.passeseleid) + - leg1.passeseleid >= 0 obj: tkElectron L1_SingleTkEleIso: cross_masks: [] leg1: leg_mask: - leg1.offline_pt >= 28.0 - - tkeleisoquallow(leg1.et,leg1.eta,leg1.passeseleid) - - rangecutless(leg1.trkiso,leg1.eta,1.479,0.13,0.28) + - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) obj: tkElectron L1_SingleTkMu: cross_masks: [] @@ -160,8 +159,8 @@ L1_SingleTkPhoIso: leg_mask: - leg1.offline_pt >= 36.0 - abs(leg1.eta)<2.4 - - phoid(leg1.passeseleid,leg1.passesphoid,leg1.eta) - - rangecutless(leg1.trkiso,leg1.eta,1.479,0.25,0.205) + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passesphoid * (abs(leg1.eta) >= 1.5) + - (leg1.trkiso<0.25) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.205) * (abs(leg1.eta)>=1.479) obj: tkPhoton L1_TkEleIso_EG: cross_masks: @@ -170,14 +169,14 @@ L1_TkEleIso_EG: leg_mask: - leg1.offline_pt >= 22.0 - abs(leg1.eta)<2.4 - - tkeleisoquallow(leg1.et,leg1.eta,leg1.passeseleid) - - rangecutless(leg1.trkiso,leg1.eta,1.479,0.13,0.28) + - leg.passeseleid >= 0 + - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) obj: tkElectron leg2: leg_mask: - leg2.offline_pt >= 12.0 - abs(leg2.eta)<2.4 - - egid(leg2.passeseleid,leg2.passessaid,leg2.eta) + - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passessaid * (abs(leg2.eta) >= 1.5) obj: EG L1_TripleTkMu: cross_masks: @@ -200,5 +199,4 @@ L1_TripleTkMu: - leg3.pt>3 - abs(leg3.eta)<2.4 - leg3.qual>0 - obj: gmtTkMuon - + obj: gmtTkMuon \ No newline at end of file diff --git a/rates/table/cfg/v29/v29_cfg.yml b/rates/table/cfg/v29/v29_cfg.yml index 163d904f..04295717 100644 --- a/rates/table/cfg/v29/v29_cfg.yml +++ b/rates/table/cfg/v29/v29_cfg.yml @@ -2,4 +2,11 @@ MenuV29: version: "V29" sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" menu_config: "cfg/v29_16Seeds_Final_clean_cfg.yml" - scalings: "scalings.yml" + scalings: + scalings_path: "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" + collect_scalings: True + scalings_outdir: "scalings_input/V29/" + scalings_file: "scalings.yml" + table: + table_fname: "rates_16Seeds_Final" + table_outdir: "rates_tables/V29" \ No newline at end of file diff --git a/rates/table/menu_config.py b/rates/table/menu_config.py index ea915e45..2a60c3dd 100644 --- a/rates/table/menu_config.py +++ b/rates/table/menu_config.py @@ -8,8 +8,20 @@ def sample(self): return self._cfg["sample"] @property - def scalings(self): - return self._cfg["scalings"] + def scalings_path(self): + return self._cfg["scalings"]["scalings_path"] + + @property + def do_scalings(self): + return self._cfg["scalings"]["collect_scalings"] + + @property + def scalings_file(self): + return self._cfg["scalings"]["scalings_file"] + + @property + def scalings_outdir(self): + return self._cfg["scalings"]["scalings_outdir"] @property def menu_cfg(self): @@ -22,3 +34,11 @@ def menu_objects(self): @property def version(self): return self._cfg["version"] + + @property + def table_outdir(self): + return self._cfg["table"]["table_outdir"] + + @property + def table_fname(self): + return self._cfg["table"]["table_fname"] \ No newline at end of file diff --git a/rates/table/menu.py b/rates/table/menu_table.py similarity index 61% rename from rates/table/menu.py rename to rates/table/menu_table.py index e3ea42be..acf311ed 100644 --- a/rates/table/menu.py +++ b/rates/table/menu_table.py @@ -3,7 +3,7 @@ from glob import glob -import yaml, re +import yaml, re, os from utils import * from menu_config import MenuConfig @@ -15,25 +15,67 @@ vector.register_awkward() class MenuTable: + ''' + Base class that defines the rates table. + This class contains method to read the minbias sample, + convert online to offline pT, and compute the trigger rates. + All the relevant information is dumped to a csv table. + ''' def __init__(self, cfg): self.cfg = MenuConfig(cfg) + self.version = self.cfg.version self.fname = self.cfg.sample + self.table_outdir = self.cfg.table_outdir + self.table_fname = self.cfg.table_fname self.cfg_fname = self.cfg.menu_cfg - self.scalings = self.get_scalings(self.cfg.scalings) + self.scalings = self.get_scalings(os.path.join(self.cfg.scalings_outdir, + self.cfg.scalings_file)) self.trig_seeds = self.get_trig_seeds() + def load_minbias(self, obj): + ''' + Function to load the minbias sample to be used for the rates computation. + The name of the file is specified in the config used for the MenuTable init. + ''' + with uproot.open(self.fname) as f: + arr = f["l1PhaseIITree/L1PhaseIITree"].arrays( + filter_name = f"{obj}*", + how = "zip" + ) + return arr + def get_scalings(self, scalings): + ''' + Get the list of scalings for all the L1 objects. + Scalings are collected by the Scaler() class and + saved to a yaml file. + The inputs used are the files created in `objectPerformance` + and saved in `objectPerformance/output/VX/scalings/*.txt` + ''' with open(f'{scalings}', 'r') as infile: scalings_eta = yaml.safe_load(infile.read()) return scalings_eta def get_trig_seeds(self): + ''' + Get the menu definition. + Load a yaml file containing the definition of the objects + and the cuts of each leg for the different trigger paths. + ''' with open(self.cfg_fname, 'r') as infile: test_trig_seeds = yaml.safe_load(infile.read()) return test_trig_seeds def add_offline_pt(self, arr, obj_scalings, pt_var = None): + ''' + Use the scalings to convert online pT to offline pT. + The `pt_var` argument can be used to specify which observables + should be used as "pT" for a given object. + If `pt_var` is not specified, `pt` or `et` are used. + For each object, a dedicated scaling in the barrel/endcap regions + is applied to the online pT. + ''' # initialise array of zeros identical to the original pt if pt_var is not None: pt_orig = arr[pt_var] elif "pt" in arr.fields: pt_orig = arr.pt @@ -50,7 +92,7 @@ def add_offline_pt(self, arr, obj_scalings, pt_var = None): new_pt = ak.zeros_like(pt_orig) # loop through eta regions with it's scaling parameters - for region,values in obj_scalings.items(): + for region, values in obj_scalings.items(): # create eta mask for this eta region eta_mask = (abs(arr.eta) >= values["eta_min"]) & (abs(arr.eta) < values["eta_max"]) # scale pt for non-masked elements of this eta region @@ -59,6 +101,11 @@ def add_offline_pt(self, arr, obj_scalings, pt_var = None): return ak.with_field(arr, new_pt, "offline_pt") def scale_pt(self, obj, arr): + ''' + Wrapper function that calls `add_offline_pt` if the scaling is defined. + If the scaling for a given object is not found, `offline_pt` is set to + be equal to the online pt. + ''' if obj in self.scalings: arr = self.add_offline_pt(arr, self.scalings[obj]) else: @@ -74,6 +121,14 @@ def scale_pt(self, obj, arr): return arr def format_values(self, arr): + ''' + Function to format values in the array. + The `et` branch is converted to `pt`, if no `pt` is found in the array. + If neither `pt` nor `et` are found in the array, the corresponding + entries will be left empty or filled with the unique field of the array. + The ID branches (`["passeseleid","passessaid","passesphoid"]`) are + converted into boolean variables for easier usage in the triggers definition. + ''' if "et" not in arr.fields: if "pt" in arr.fields: arr["et"] = arr.pt @@ -90,18 +145,13 @@ def format_values(self, arr): return arr - def load_minbias(self, obj): - with uproot.open(self.fname) as f: - arr = f["l1PhaseIITree/L1PhaseIITree"].arrays( - filter_name = f"{obj}*", - how = "zip" - ) - return arr - - def get_obj_arr(self, obj, - sample = "MinBias", - vers = "V29_part"): - + def get_obj_arr(self, obj): + ''' + Function that loads the minbias sample and gets the relevant object from the TTree. + The TBranches are loaded in an awkward array, `format_values` is used to parse the + `pt`, `et`, and ID branches. + The `scale_pt` function is used to convert the online pT into offline using the scalings. + ''' arr = self.load_minbias(obj) if "jagged0" in arr.fields: arr = arr["jagged0"] @@ -113,6 +163,12 @@ def get_obj_arr(self, obj, return arr def get_legs(self, seed_legs): + ''' + Function that parses the config file (menu definition) + to get the cuts to be used for the definition of each trigger leg + and the L1 object used. + The function returns the awkard array after the application of the cuts. + ''' all_arrs = {} leg_arrs = {} @@ -138,14 +194,18 @@ def get_legs(self, seed_legs): return leg_arrs def get_combos(self, leg_arrs, seed_legs): - + ''' + For multi-leg triggers, this function creates the combination of the legs. + After the trigger legs are combined, the resulting array corresponding to the + AND of all the conditions on each leg is returned. + ''' if len(leg_arrs) > 1: combos = ak.cartesian(leg_arrs) else: combos = leg_arrs ## duplicate handling (exclude combinations) - ### first check whether objects are repeating + ## first check whether objects are repeating objs = [o["obj"] for o in seed_legs.values()] obj_cnts = {i: objs.count(i) for i in objs} @@ -167,6 +227,11 @@ def get_combos(self, leg_arrs, seed_legs): return combos def get_legs_and_masks(self, seed_legs): + ''' + Wrapper function that calls `get_legs` and `get_combos`. + This function returns the awkward arrays with the legs definition + and the definition of the combinations in case of multi-leg triggers. + ''' ### load all legs leg_arrs = self.get_legs(seed_legs) @@ -175,7 +240,11 @@ def get_legs_and_masks(self, seed_legs): return leg_arrs, combos - def get_eval_string(self, leg_arrs): + def get_eval_string(self, leg_arrs): + ''' + Function that selects only relevant entries in the arrays and returns the + awkward array corresponding to events which satisfy the cuts on the trigger legs. + ''' eval_str = [] for leg, leg_arr in leg_arrs.items(): if "var" in str(leg_arr.type): @@ -187,6 +256,10 @@ def get_eval_string(self, leg_arrs): return eval_str def seeds_from_cfg(self, seed): + ''' + Function that loads the information from the menu config. + Returns the legs, cross_masks, and cross-triggers (if present). + ''' seed_legs = {l: self.trig_seeds[seed][l] for l in self.trig_seeds[seed] if "leg" in l} cross_masks_str = self.trig_seeds[seed]["cross_masks"] if len(cross_masks_str)>0: cross_masks_str = [cross_masks_str] @@ -198,6 +271,12 @@ def seeds_from_cfg(self, seed): return seed_legs, cross_masks_str, cross_seeds def get_npass(self, seed, trig_seed): + ''' + Main function that computes the nr of events passing each trigger. + After loading the minbias sample and the menu definition, + each leg is selected and the masks are applied (together with cross-masks/seeds). + The function returns the total mask that defines the trigger. + ''' seed_legs, cross_masks_str, cross_seeds = self.seeds_from_cfg(seed) leg_arrs, combos = self.get_legs_and_masks(seed_legs) @@ -233,6 +312,11 @@ def get_npass(self, seed, trig_seed): return total_mask def prepare_masks(self): + ''' + Wrapper function that calls `get_npass` + for each object defined in the menu. + The function returns the masks for each object. + ''' trig_masks = {} seeds = self.trig_seeds @@ -250,8 +334,13 @@ def prepare_masks(self): return trig_masks - @property def make_table(self): + ''' + Function that prints to screen the rates table. + Returns a list containing the csv-compatible table. + ''' + table = [] + table.append("Seed,NPass,Eff,Rate\n") total_mask = 0 trig_masks = self.prepare_masks() @@ -261,6 +350,7 @@ def make_table(self): npass = np.sum(mask) eff = npass/len(mask) rate = eff * 2760*11246 / 1e3 + table.append(f"{seed},{npass},{eff},{rate}\n") print(seed.ljust(50), ":\t%8i\t%.5f\t%.1f" %(npass, eff, rate)) ## total @@ -269,7 +359,21 @@ def make_table(self): rate = eff * 2760*11246 / 1e3 tot_str = "Total:".ljust(50)+ "\t%8i\t%.5f\t%.1f" %(npass, eff, rate) + table.append(f"Total,{npass},{eff},{rate}\n") + table.append(f"Total nev,{len(total_mask)},,\n") print((len(tot_str)+5)*"-") print(tot_str) print("Total nev: %i" % len(total_mask)) + + return table + + def dump_table(self, table): + ''' + Function that dumps to file the table produced by `make_table`. + ''' + os.makedirs(f"{self.table_outdir}", exist_ok=True) + f = open(f"{self.table_outdir}/{self.table_fname}_{self.version}.csv", "w") + for line in table: + f.write(line) + f.close() diff --git a/rates/table/rate_table.py b/rates/table/rate_table.py old mode 100644 new mode 100755 index 123c4155..e5c84cc2 --- a/rates/table/rate_table.py +++ b/rates/table/rate_table.py @@ -3,7 +3,7 @@ import yaml from scaler import Scaler -from menu import MenuTable +from menu_table import MenuTable from menu_config import MenuConfig if __name__ == "__main__": @@ -19,12 +19,11 @@ with open(args.cfg, 'r') as f: cfg = yaml.safe_load(f) - path_to_scalings = "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" - scaler = Scaler(path_to_scalings) - scaler.collect_scalings - scaler.scaling_dict - for menu_title, menu_cfg in cfg.items(): - menu_config = MenuTable(menu_cfg) - menu_config.make_table + scaler = Scaler(menu_cfg) + scaler.collect_scalings + scaler.dump_scalings + menu_config = MenuTable(menu_cfg) + table = menu_config.make_table() + menu_config.dump_table(table) \ No newline at end of file diff --git a/rates/table/scaler.py b/rates/table/scaler.py index 2df58d17..ea67902a 100644 --- a/rates/table/scaler.py +++ b/rates/table/scaler.py @@ -2,13 +2,34 @@ import os, yaml from glob import glob +from menu_config import MenuConfig class Scaler: - def __init__(self, path_to_scalings): - self.dir = path_to_scalings - self.fnames = glob(f"{self.dir}/*.txt") + ''' + Base class that takes as input the scalings computed + in `objectPerformance` and aggregates all of them together + to be used for the rates computation. + ''' + def __init__(self, cfg): + self.cfg = MenuConfig(cfg) + self.scalings_path = self.cfg.scalings_path + self.scalings_file = self.cfg.scalings_file + self.scalings_outdir = self.cfg.scalings_outdir + self.do_scalings = self.cfg.do_scalings + self.fnames = glob(f"{self.scalings_path}/*.txt") self.scaling_dict = {} -# self.scaling_file = None + self.init_log + + @property + def init_log(self): + print(f"::: The scalings file used is: {self.scalings_outdir}/{self.scalings_file} :::") + if (not os.path.isfile(f"{self.scalings_outdir}/{self.scalings_file}")) and (not self.do_scalings): + print(f"::: WARNING!! You are trying to use {self.scalings_outdir}/{self.scalings_file}, but the file does not exist! :::") + print("::: WARNING!! Set do_scalings to True in config or specify a different location for the scalings file! :::") + if self.do_scalings: + print(f"::: Will collect scalings from scratch and recreate {self.scalings_file} :::") + print(f"::: Will load scalings from {self.scalings_path} :::") + print(f"::: Will dump scalings into {self.scalings_outdir} :::") def get_lines(self, fname): with open(fname) as f: @@ -17,16 +38,21 @@ def get_lines(self, fname): return lines def get_basename(self, fname): + # TODO: Harmonize the naming of the scaligns in `objectPerformance` + # so that we can drop this function. basename = os.path.basename(fname).replace(".txt","") basename = basename.replace( "Turnon","").replace( "Trigger","").replace( - "Matching","").replace( "_","") return basename def eta_ranges(self, obj, suffix): + ''' + Wrapper function that defines the Barrel/Overlap/Endcap + range definitions for different objects. + ''' eta_range = None if obj == "Muons": if suffix == "Barrel": @@ -46,22 +72,30 @@ def eta_ranges(self, obj, suffix): return eta_range def get_eta_range(self, fname): - + ''' + Wrapper function that calls `eta_ranges` + and returns the object and the relevant eta ranges + for the various detector regions. + ''' basename = self.get_basename(fname) - + for suffix in ["Barrel","Endcap","Overlap"]: if suffix in basename: obj = basename.split(suffix)[0] eta_range = self.eta_ranges(obj, suffix) - + if eta_range is None: print("Not found! ", basename, obj) else: return obj, suffix, eta_range - + return None def decode_scaling(self, line): + ''' + Function that parses the syntax used in the scaling.txt files + and returns the slope and offset of the scaling law for each object. + ''' line = line.replace(" ","") items = line.split("::") @@ -73,19 +107,24 @@ def decode_scaling(self, line): @property def collect_scalings(self): + ''' + Property that collects the scalings for all the objects available + and saves them to `self.scaling_dict`. + This function works only if `do_scalings` is set to True in the config. + ''' + if not self.do_scalings: return for fname in self.fnames: r = self.get_eta_range(os.path.basename(fname)) - if r is None: - print(30*"#", r) + if r is None: objcat = None region = None eta_range = (None,None) else: objcat,region,eta_range = r - + lines = self.get_lines(fname) - + for line in lines: obj,slope,offset = self.decode_scaling(line) d = { region : { @@ -101,7 +140,13 @@ def collect_scalings(self): @property def dump_scalings(self): - with open('scalings.yml', 'w') as outfile: + ''' + Property that dumps to file the content of `self.scaling_dict`. + This function works only if `do_scalings` is set to True in the config. + ''' + if not self.do_scalings: return + os.makedirs(f"{self.scalings_outdir}", exist_ok=True) + with open(f'{self.scalings_outdir}/{self.scalings_file}', 'w') as outfile: yaml.dump(self.scaling_dict, outfile, default_flow_style=False) diff --git a/rates/table/utils.py b/rates/table/utils.py index 2617b468..56238cf3 100644 --- a/rates/table/utils.py +++ b/rates/table/utils.py @@ -20,12 +20,12 @@ def egid(EleID, SaID, Eta): return EleID * abs(Eta)<1.5 + SaID * (abs(Eta)>=1.5) def TkEleQualHIGH(Et,Eta,PassesEleID): return PassesEleID -def TkEleQualLOW(Et,Eta,PassesEleID): return PassesEleID * (abs(Eta)<1.479) + (abs(Eta)<1.479) +def TkEleQualLOW(Et,Eta,PassesEleID): return PassesEleID * (abs(Eta)<1.479) + (abs(Eta)>1.479) def TkEleIsoQualHIGH(Et,Eta,PassesEleID): return PassesEleID * (abs(Eta)>1.479) + (abs(Eta)<1.479) def TkEleIsoQualLOW(Et,Eta,PassesEleID): return (PassesEleID>=0) # this should be always true: we can remove this condition from the menu def tkelequalhigh(et,eta,passeseleid): return passeseleid -def tkelequallow(et,eta,passeseleid): return passeseleid * (abs(eta)<1.479) + (abs(eta)<1.479) +def tkelequallow(et,eta,passeseleid): return passeseleid * (abs(eta)<1.479) + (abs(eta)>1.479) def tkeleisoqualhigh(et,eta,passeseleid): return passeseleid * (abs(eta)>1.479) + (abs(eta)<1.479) def tkeleisoquallow(et,eta,passeseleid): return (passeseleid>=0) # this should be always true: we can remove this condition from the menu From c9df08b010c71b19bc76ad55b64efc309814224f Mon Sep 17 00:00:00 2001 From: Matteo Bonanomi Date: Wed, 2 Aug 2023 13:06:34 +0200 Subject: [PATCH 05/20] Cleaned up config for v29_WITHMUONS menu --- .../cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml | 697 ++++++++++++++++++ 1 file changed, 697 insertions(+) create mode 100644 rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml diff --git a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml new file mode 100644 index 00000000..00478fa6 --- /dev/null +++ b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml @@ -0,0 +1,697 @@ +L1_DoubleEGEle: + cross_masks: + - leg1.deltaR(leg2) > 0.1 + leg1: + leg_mask: + - leg1.offline_pt >= 37.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passessaid * (abs(leg1.eta) >= 1.5) + obj: EG + leg2: + leg_mask: + - leg2.offline_pt >= 24.0 + - abs(leg2.eta)<2.4 + - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passessaid * (abs(leg2.eta) >= 1.5) + obj: EG +L1_DoublePFJet_MassMin: + cross_masks: + - pairinvmass(leg2.et,leg1.et,leg2.eta,leg1.eta,leg2.phi,leg1.phi)>620.0 + leg1: + leg_mask: + - leg1.offline_pt >= 160.0 + obj: seededConePuppiJet + leg2: + leg_mask: + - leg2.offline_pt >= 35.0 + - leg2.et>25 + obj: seededConePuppiJet +L1_DoublePFJet_dEtaMax: + cross_masks: + - abs(leg2.eta-leg1.eta)<1.6 + leg1: + leg_mask: + - leg1.offline_pt >= 112.0 + - leg1.et>25 + - abs(leg1.eta)<2.4 + obj: seededConePuppiJet + leg2: + leg_mask: + - leg2.offline_pt >= 112.0 + - leg2.et>25 + - abs(leg2.eta)<2.4 + obj: seededConePuppiJet +L1_DoubleTkEle: + cross_masks: + - abs(leg2.zvtx-leg1.zvtx)<1 + leg1: + leg_mask: + - leg1.offline_pt >= 25.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + obj: tkElectron + leg2: + leg_mask: + - leg2.offline_pt >= 12.0 + - abs(leg2.eta)<2.4 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + obj: tkElectron +L1_DoubleTkEle_PFHTT: + cross_masks: + - abs(leg2.zvtx-leg1.et)<1 + - abs(leg3.zvtx-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.offline_pt >= 8.0 + - abs(leg2.eta)<2.5 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + obj: tkElectron + leg3: + leg_mask: + - leg3.offline_pt >= 8.0 + - abs(leg3.eta)<2.5 + - leg3.passeseleid * (abs(leg3.eta)<1.479) + (abs(leg3.eta)>1.479) + obj: tkElectron + leg4: + leg_mask: + - leg4.offline_pt >= 390.0 + obj: seededConePuppiHT +L1_DoubleTkMu: + cross_masks: + - abs(leg1.z0-leg2.z0)<1 + leg1: + leg_mask: + - leg1.offline_pt >= 15.0 + - abs(leg1.eta)<2.4 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>7 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon +L1_DoubleTkMu0er1p5_SQ_OS_dR_Max1p4: + cross_masks: + - leg1.deltaR(leg2)<1.4 + - leg1.chg*leg2.chg<0.0 + - abs(leg2.z0-leg1.z0)<1 + leg1: + leg_mask: + - abs(leg1.eta)<1.5 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - abs(leg2.eta)<1.5 + - leg2.qual>0 + obj: gmtTkMuon +L1_DoubleTkMu4_SQ_OS_dR_Max1p2: + cross_masks: + - leg1.deltaR(leg2)<1.2 + - leg1.chg*leg2.chg<0.0 + - abs(leg2.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>4 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>4 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon +L1_DoubleTkMu4p5er2p0_SQ_OS_Mass7to18: + cross_masks: + - pairinvmass(leg2.pt,leg1.pt,leg2.eta,leg1.eta,leg2.phi,leg1.phi)>7.0 + - pairinvmass(leg2.pt,leg1.pt,leg2.eta,leg1.eta,leg2.phi,leg1.phi)<18.0 + - leg1.chg*leg2.chg<0.0 + - abs(leg2.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>4.5 + - abs(leg1.eta)<2.0 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>4.5 + - abs(leg2.eta)<2.0 + - leg2.qual>0 + obj: gmtTkMuon +L1_DoubleTkMu9_SQ: + cross_masks: + - abs(leg2.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.offline_pt >= 9.0 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.offline_pt >= 9.0 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon +L1_DoubleTkMu_PfHTT: + cross_masks: + - abs(leg2.z0-leg1.et)<1 + - abs(leg3.z0-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.pt>3 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.pt>3 + - abs(leg3.eta)<2.4 + - leg3.qual>0 + obj: gmtTkMuon + leg4: + leg_mask: + - leg4.offline_pt >= 300.0 + obj: seededConePuppiHT +L1_DoubleTkMu_PfJet_PfMet: + cross_masks: + - abs(leg2.z0-leg1.et)<1 + - abs(leg3.z0-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.pt>3 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.pt>3 + - abs(leg3.eta)<2.4 + - leg3.qual>0 + obj: gmtTkMuon + leg4: + leg_mask: + - leg4.offline_pt >= 60.0 + - leg4.et>25 + - abs(leg4.eta)<2.4 + obj: seededConePuppiJet + leg5: + leg_mask: + - leg5.offline_pt >= 130.0 + obj: puppiMET +L1_DoubleTkMu_TkEle: + cross_masks: + - abs(leg2.z0-leg1.z0)<1 + - abs(leg3.zvtx-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>5 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>5 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.offline_pt >= 9.0 + - abs(leg3.eta)<2.4 + - leg3.passeseleid * (abs(leg3.eta)<1.479) + (abs(leg3.eta)>1.479) + obj: tkElectron +L1_DoubleTkPhoIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 22.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passesphoid * (abs(leg1.eta) >= 1.5) + - (leg1.trkiso<0.25) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.205) * (abs(leg1.eta)>=1.479) + obj: tkPhoton + leg2: + leg_mask: + - leg2.offline_pt >= 12.0 + - abs(leg2.eta)<2.4 + - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passesphoid * (abs(leg2.eta) >= 1.5) + - (leg2.trkiso<0.25) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.205) * (abs(leg2.eta)>=1.479) + obj: tkPhoton +L1_PFHTT: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 450.0 + obj: seededConePuppiHT +L1_PFHTT_QuadJet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 400.0 + obj: seededConePuppiHT + leg2: + leg_mask: + - leg2.offline_pt >= 70.0 + - leg2.et>25.0 + - abs(leg2.eta)<2.4 + obj: seededConePuppiJet + leg3: + leg_mask: + - leg3.offline_pt >= 55.0 + - leg3.et>25.0 + - abs(leg3.eta)<2.4 + obj: seededConePuppiJet + leg4: + leg_mask: + - leg4.offline_pt >= 40.0 + - leg4.et>25.0 + - abs(leg4.eta)<2.4 + obj: seededConePuppiJet + leg5: + leg_mask: + - leg5.offline_pt >= 40.0 + - leg5.et>25.0 + - abs(leg5.eta)<2.4 + obj: seededConePuppiJet +L1_PFIsoTau_PFIsoTau: + cross_masks: + - leg1.deltaR(leg2)>0.5 + leg1: + leg_mask: + - leg1.offline_pt >= 52.0 + - abs(leg1.eta)<2.172 + - leg1.passloosenn>0 + obj: nnTau + leg2: + leg_mask: + - leg2.offline_pt >= 52.0 + - abs(leg2.eta)<2.172 + - leg2.passloosenn>0 + obj: nnTau +L1_PFIsoTau_PFMet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 55.0 + - abs(leg1.eta)<2.172 + - leg1.passloosenn>0 + obj: nnTau + leg2: + leg_mask: + - leg2.offline_pt >= 190.0 + obj: puppiMET +L1_PFIsoTau_TkMu: + cross_masks: + - abs(leg3.z0-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.offline_pt >= 42.0 + - abs(leg2.eta)<2.172 + - leg2.passloosenn>0 + obj: nnTau + leg3: + leg_mask: + - leg3.offline_pt >= 18.0 + - abs(leg3.eta)<2.1 + obj: gmtTkMuon +L1_PFMHTT: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 135.5 + obj: seededConePuppiMHT +L1_PFMet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 200.0 + obj: puppiMET +L1_PFTau_PFTau: + cross_masks: + - leg1.deltaR(leg2)>0.5 + leg1: + leg_mask: + - leg1.offline_pt >= 90.0 + - abs(leg1.eta)<2.172 + obj: caloTau + leg2: + leg_mask: + - leg2.offline_pt >= 90.0 + - abs(leg2.eta)<2.172 + obj: caloTau +L1_SingleEGEle: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 51.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passessaid * (abs(leg1.eta) >= 1.5) + obj: EG +L1_SinglePFTau: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 150.0 + - abs(leg1.eta)<2.172 + obj: caloTau +L1_SinglePfJet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 230.0 + - leg1.et>25 + - abs(leg1.eta)<2.4 + obj: seededConePuppiJet +L1_SingleTkEle: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 36.0 + - abs(leg1.eta)<2.4 + - tkelequalhigh(leg1.et,leg1.eta,leg1.passeseleid) + obj: tkElectron +L1_SingleTkEleIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 28.0 + - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) + obj: tkElectron +L1_SingleTkMu: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 22.0 + - abs(leg1.eta)<2.4 + obj: gmtTkMuon +L1_SingleTkPhoIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 36.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passesphoid * (abs(leg1.eta) >= 1.5) + - (leg1.trkiso<0.25) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.205) * (abs(leg1.eta)>=1.479) + obj: tkPhoton +L1_TkEleIso_EG: + cross_masks: + - leg1.deltaR(leg2) > 0.1 + leg1: + leg_mask: + - leg1.offline_pt >= 22.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) + obj: tkElectron + leg2: + leg_mask: + - leg2.offline_pt >= 12.0 + - abs(leg2.eta)<2.4 + - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passessaid * (abs(leg2.eta) >= 1.5) + obj: EG +L1_TkEleIso_PFHTT: + cross_masks: + - abs(leg2.zvtx-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.offline_pt >= 26.0 + - abs(leg2.eta)<2.1 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + - (leg2.trkiso<0.13) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.28) * (abs(leg2.eta)>=1.479) + obj: tkElectron + leg3: + leg_mask: + - leg3.offline_pt >= 190.0 + obj: seededConePuppiHT +L1_TkEleIso_PFIsoTau: + cross_masks: + - abs(leg2.zvtx-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.offline_pt >= 22.0 + - abs(leg2.eta)<2.1 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + - (leg2.trkiso<0.13) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.28) * (abs(leg2.eta)>=1.479) + obj: tkElectron + leg3: + leg_mask: + - leg3.offline_pt >= 45.0 + - abs(leg3.eta)<2.172 + - leg3.passloosenn>0 + obj: nnTau +L1_TkEle_PFJet_dRMin: + cross_masks: + - abs(leg2.zvtx-leg1.et)<1 + - leg2.deltaR(leg3)>0.3 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.offline_pt >= 28.0 + - abs(leg2.eta)<2.1 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + obj: tkElectron + leg3: + leg_mask: + - leg3.offline_pt >= 40.0 + - leg3.et>25 + - abs(leg3.eta)<2.4 + obj: seededConePuppiJet +L1_TkEle_TkMu: + cross_masks: + - abs(leg2.z0-leg1.zvtx)<1 + leg1: + leg_mask: + - leg1.offline_pt >= 10.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + obj: tkElectron + leg2: + leg_mask: + - leg2.offline_pt >= 20.0 + - abs(leg2.eta)<2.4 + obj: gmtTkMuon +L1_TkMu_DoubleTkEle: + cross_masks: + - abs(leg2.zvtx-leg1.z0)<1 + - abs(leg3.zvtx-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>6 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.offline_pt >= 17.0 + - abs(leg2.eta)<2.4 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + obj: tkElectron + leg3: + leg_mask: + - leg3.offline_pt >= 17.0 + - abs(leg3.eta)<2.4 + - leg3.passeseleid * (abs(leg3.eta)<1.479) + (abs(leg3.eta)>1.479) + obj: tkElectron +L1_TkMu_PfHTT: + cross_masks: + - abs(leg2.z0-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.pt>6 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.offline_pt >= 320.0 + obj: seededConePuppiHT +L1_TkMu_PfJet_PfMet: + cross_masks: + - abs(leg2.z0-leg1.et)<1 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.pt>3 + - abs(leg2.eta)<2.1 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.offline_pt >= 110.0 + - leg3.et>25 + - abs(leg3.eta)<2.5 + obj: seededConePuppiJet + leg4: + leg_mask: + - leg4.offline_pt >= 120.0 + obj: puppiMET +L1_TkMu_PfJet_dRMax_DoubleJet_dEtaMax: + cross_masks: + - abs(leg2.z0-leg1.et)<1 + - leg2.deltaR(leg3)<0.4 + - abs(leg5.eta-leg4.eta)<1.6 + leg1: + leg_mask: + - leg1.et>-99999.0 + obj: z0L1TkPV + leg2: + leg_mask: + - leg2.offline_pt >= 12.0 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.offline_pt >= 40.0 + - leg3.et>25 + - abs(leg3.eta)<2.4 + obj: seededConePuppiJet + leg4: + leg_mask: + - leg4.offline_pt >= 40.0 + - leg4.et>25 + - abs(leg4.eta)<2.4 + obj: seededConePuppiJet + leg5: + leg_mask: + - leg5.offline_pt >= 40.0 + - leg5.et>25 + - abs(leg5.eta)<2.4 + obj: seededConePuppiJet +L1_TkMu_TkEle: + cross_masks: + - abs(leg2.zvtx-leg1.z0)<1 + leg1: + leg_mask: + - leg1.offline_pt >= 7.0 + - abs(leg1.eta)<2.4 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.offline_pt >= 23.0 + - abs(leg2.eta)<2.4 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + obj: tkElectron +L1_TkMu_TkEleIso: + cross_masks: + - abs(leg2.zvtx-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>7 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.offline_pt >= 20.0 + - abs(leg2.eta)<2.4 + - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + - (leg2.trkiso<0.13) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.28) * (abs(leg2.eta)>=1.479) + obj: tkElectron +L1_TripleTkMu: + cross_masks: + - abs(leg2.z0-leg1.z0)<1 + - abs(leg3.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>5 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>3 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.pt>3 + - abs(leg3.eta)<2.4 + - leg3.qual>0 + obj: gmtTkMuon +L1_TripleTkMu_5SQ_3SQ_0OQ_DoubleMu_5_3_SQ_OS_Mass_Max9: + cross_masks: + - pairinvmass(leg2.pt,leg1.pt,leg2.eta,leg1.eta,leg2.phi,leg1.phi)<9.0 + - leg1.chg*leg2.chg<0.0 + - abs(leg2.z0-leg1.z0)<1 + - abs(leg3.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>5 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>3 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.pt>0 + - abs(leg3.eta)<2.4 + - leg3.qual>0 + obj: gmtTkMuon +L1_TripleTkMu_5_3p5_2p5_OS_Mass_5to17: + cross_masks: + - abs(leg2.z0-leg1.z0)<1 + - leg1.chg*leg3.chg<0.0 + - pairinvmass(leg3.pt,leg1.pt,leg3.eta,leg1.eta,leg3.phi,leg1.phi)>5.0 + - pairinvmass(leg3.pt,leg1.pt,leg3.eta,leg1.eta,leg3.phi,leg1.phi)<17.0 + - abs(leg3.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>5 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>3.5 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.pt>2.5 + - abs(leg3.eta)<2.4 + - leg3.qual>0 + obj: gmtTkMuon From 645265be37ee98822fe1ac7c7ade178a7e1ae00d Mon Sep 17 00:00:00 2001 From: Matteo Bonanomi Date: Mon, 7 Aug 2023 09:59:03 +0200 Subject: [PATCH 06/20] [v29_16Seeds] Scalings and minor modifications for full synch on v29_16Seeds menu (Double and TripleTkMuon slightly off) --- .../cfg/v29/v29_16Seeds_Final_clean_cfg.yml | 222 +++++++++--------- rates/table/menu_table.py | 7 +- rates/table/scalings_input/V29/scalings.yml | 200 ++++++++++++++++ rates/table/utils.py | 4 +- 4 files changed, 322 insertions(+), 111 deletions(-) create mode 100644 rates/table/scalings_input/V29/scalings.yml diff --git a/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml index 0055f818..f600ecaf 100644 --- a/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml +++ b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml @@ -1,18 +1,107 @@ L1_DoubleEGEle: cross_masks: - - leg1.deltaR(leg2) > 0.1 + - ak.where(abs(leg2.phi-leg1.phi) 0.1 leg1: leg_mask: - - leg1.offline_pt >= 37.0 + - leg1.offline_pt >= 37 - abs(leg1.eta)<2.4 - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passessaid * (abs(leg1.eta) >= 1.5) + # - ak.where(abs(leg1.eta)<1.5, leg1.passeseleid, leg1.passessaid) obj: EG leg2: leg_mask: - - leg2.offline_pt >= 24.0 + - leg2.offline_pt >= 24 - abs(leg2.eta)<2.4 - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passessaid * (abs(leg2.eta) >= 1.5) + # - ak.where(abs(leg2.eta)<1.5, leg2.passeseleid, leg2.passessaid) obj: EG +L1_SingleEGEle: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 51.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passessaid * (abs(leg1.eta) >= 1.5) + obj: EG +L1_SinglePfJet: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt > 230.0 + - leg1.et>25 + - abs(leg1.eta)<2.4 + obj: seededConePuppiJet +L1_SingleTkEle: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 36.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid + # - leg1.passeseleid > 0 + obj: tkElectron +L1_SingleTkEleIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 28.0 + - leg1.passeseleid>=0 + - ak.where(abs(leg1.eta)<1.479, leg1.trkiso<0.13, leg1.trkiso<0.28) + obj: tkElectron +L1_SingleTkMu: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt > 22.0 + - abs(leg1.eta)<2.4 + obj: gmtTkMuon +L1_SingleTkPhoIso: + cross_masks: [] + leg1: + leg_mask: + - leg1.offline_pt >= 36.0 + - abs(leg1.eta)<2.4 + - ak.where(abs(leg1.eta)<1.5, leg1.passeseleid, leg1.passesphoid) + - ak.where(abs(leg1.eta)<1.479, leg1.trkiso<0.25, leg1.trkiso<0.205) + obj: tkPhoton +L1_TkEleIso_EG: + cross_masks: + - leg2.deltaR(leg1) > 0.1 + leg1: + leg_mask: + - leg1.offline_pt > 22.0 + - abs(leg1.eta)<2.4 + - leg1.passeseleid >= 0 + - ak.where(abs(leg1.eta)<1.479, leg1.trkiso<0.13, leg1.trkiso<0.28) + obj: tkElectron + leg2: + leg_mask: + - leg2.offline_pt > 12.0 + - abs(leg2.eta)<2.4 + - ak.where(abs(leg2.eta)<1.5, leg2.passeseleid, leg2.passessaid) + obj: EG +L1_TripleTkMu: + cross_masks: + - abs(leg2.z0-leg1.z0)<1 + - abs(leg3.z0-leg1.z0)<1 + leg1: + leg_mask: + - leg1.pt>5 + - abs(leg1.eta)<2.4 + - leg1.qual>0 + obj: gmtTkMuon + leg2: + leg_mask: + - leg2.pt>3 + - abs(leg2.eta)<2.4 + - leg2.qual>0 + obj: gmtTkMuon + leg3: + leg_mask: + - leg3.pt>3 + - abs(leg3.eta)<2.4 + - leg3.qual>0 + obj: gmtTkMuon L1_DoubleTkEle: cross_masks: - abs(leg2.zvtx-leg1.zvtx)<1 @@ -20,91 +109,94 @@ L1_DoubleTkEle: leg_mask: - leg1.offline_pt >= 25.0 - abs(leg1.eta)<2.4 - - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + - (((leg1.passeseleid) * (abs(leg1.eta)<1.479)) + ((abs(leg1.eta)>1.479))) obj: tkElectron leg2: leg_mask: - leg2.offline_pt >= 12.0 - abs(leg2.eta)<2.4 - - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + - (((leg2.passeseleid) * (abs(leg2.eta)<1.479)) + ((abs(leg2.eta)>1.479))) obj: tkElectron L1_DoubleTkMu: cross_masks: - abs(leg1.z0-leg2.z0)<1 leg1: leg_mask: - - leg1.offline_pt >= 15.0 + - leg1.offline_pt > 15.0 - abs(leg1.eta)<2.4 obj: gmtTkMuon leg2: leg_mask: - - leg2.offline_pt >= 7.0 + - leg2.pt > 7.0 - abs(leg2.eta)<2.4 + - leg2.qual > 0 obj: gmtTkMuon L1_DoubleTkPhoIso: cross_masks: [] leg1: leg_mask: - - leg1.offline_pt >= 22.0 + - leg1.offline_pt > 22.0 - abs(leg1.eta)<2.4 - - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passesphoid * (abs(leg1.eta) >= 1.5) - - (leg1.trkiso<0.25) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.205) * (abs(leg1.eta)>=1.479) + - ak.where(abs(leg1.eta)<1.5, leg1.passeseleid, leg1.passesphoid) + - ak.where(abs(leg1.eta)<1.479, leg1.trkiso<0.25, leg1.trkiso<0.205) obj: tkPhoton leg2: leg_mask: - - leg2.offline_pt >= 12.0 + - leg2.offline_pt > 12.0 - abs(leg2.eta)<2.4 - - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passesphoid * (abs(leg2.eta) >= 1.5) - - (leg2.trkiso<0.25) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.205) * (abs(leg2.eta)>=1.479) + - ak.where(abs(leg2.eta)<1.5, leg2.passeseleid, leg2.passesphoid) + - ak.where(abs(leg2.eta)<1.479, leg2.trkiso<0.25, leg2.trkiso<0.205) obj: tkPhoton L1_PFHTT: cross_masks: [] leg1: leg_mask: - - leg1.offline_pt >= 450.0 + # - leg1.pt > 372.9 + - leg1.offline_pt > 450 obj: seededConePuppiHT L1_PFHTT_QuadJet: cross_masks: [] leg1: leg_mask: - - leg1.offline_pt >= 400.0 + - leg1.offline_pt > 400.0 obj: seededConePuppiHT leg2: leg_mask: - - leg2.offline_pt >= 70.0 + - leg2.offline_pt > 70.0 - leg2.et>25.0 - abs(leg2.eta)<2.4 obj: seededConePuppiJet leg3: leg_mask: - - leg3.offline_pt >= 55.0 + - leg3.offline_pt > 55.0 - leg3.et>25.0 - abs(leg3.eta)<2.4 obj: seededConePuppiJet leg4: leg_mask: - - leg4.offline_pt >= 40.0 + - leg4.offline_pt > 40.0 - leg4.et>25.0 - abs(leg4.eta)<2.4 obj: seededConePuppiJet leg5: leg_mask: - - leg5.offline_pt >= 40.0 + - leg5.offline_pt > 40.0 - leg5.et>25.0 - abs(leg5.eta)<2.4 obj: seededConePuppiJet L1_PFIsoTau_PFIsoTau: cross_masks: + # - ak.where(abs(leg2.phi-leg1.phi) 0.5 - leg1.deltaR(leg2) > 0.5 leg1: leg_mask: - - leg1.offline_pt >= 52.0 + - leg1.offline_pt > 52.0 - abs(leg1.eta)<2.172 - leg1.passloosenn>0 obj: nnTau leg2: leg_mask: - - leg2.offline_pt >= 52.0 + - leg2.offline_pt > 52.0 - abs(leg2.eta)<2.172 - leg2.passloosenn>0 obj: nnTau @@ -112,91 +204,5 @@ L1_PFMet: cross_masks: [] leg1: leg_mask: - - leg1.offline_pt >= 200.0 + - leg1.offline_pt > 200.0 obj: puppiMET -L1_SingleEGEle: - cross_masks: [] - leg1: - leg_mask: - - leg1.offline_pt >= 51.0 - - abs(leg1.eta)<2.4 - - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passessaid * (abs(leg1.eta) >= 1.5) - obj: EG -L1_SinglePfJet: - cross_masks: [] - leg1: - leg_mask: - - leg1.offline_pt >= 230.0 - - leg1.et>25 - - abs(leg1.eta)<2.4 - obj: seededConePuppiJet -L1_SingleTkEle: - cross_masks: [] - leg1: - leg_mask: - - leg1.offline_pt >= 36.0 - - abs(leg1.eta)<2.4 - - leg1.passeseleid >= 0 - obj: tkElectron -L1_SingleTkEleIso: - cross_masks: [] - leg1: - leg_mask: - - leg1.offline_pt >= 28.0 - - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) - - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) - obj: tkElectron -L1_SingleTkMu: - cross_masks: [] - leg1: - leg_mask: - - leg1.offline_pt >= 22.0 - - abs(leg1.eta)<2.4 - obj: gmtTkMuon -L1_SingleTkPhoIso: - cross_masks: [] - leg1: - leg_mask: - - leg1.offline_pt >= 36.0 - - abs(leg1.eta)<2.4 - - leg1.passeseleid * (abs(leg1.eta)<1.5) + leg1.passesphoid * (abs(leg1.eta) >= 1.5) - - (leg1.trkiso<0.25) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.205) * (abs(leg1.eta)>=1.479) - obj: tkPhoton -L1_TkEleIso_EG: - cross_masks: - - leg1.deltaR(leg2) > 0.1 - leg1: - leg_mask: - - leg1.offline_pt >= 22.0 - - abs(leg1.eta)<2.4 - - leg.passeseleid >= 0 - - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) - obj: tkElectron - leg2: - leg_mask: - - leg2.offline_pt >= 12.0 - - abs(leg2.eta)<2.4 - - leg2.passeseleid * (abs(leg2.eta)<1.5) + leg2.passessaid * (abs(leg2.eta) >= 1.5) - obj: EG -L1_TripleTkMu: - cross_masks: - - abs(leg2.z0-leg1.z0)<1 - - abs(leg3.z0-leg1.z0)<1 - leg1: - leg_mask: - - leg1.pt>5 - - abs(leg1.eta)<2.4 - - leg1.qual>0 - obj: gmtTkMuon - leg2: - leg_mask: - - leg2.pt>3 - - abs(leg2.eta)<2.4 - - leg2.qual>0 - obj: gmtTkMuon - leg3: - leg_mask: - - leg3.pt>3 - - abs(leg3.eta)<2.4 - - leg3.qual>0 - obj: gmtTkMuon \ No newline at end of file diff --git a/rates/table/menu_table.py b/rates/table/menu_table.py index acf311ed..e4b1a8f9 100644 --- a/rates/table/menu_table.py +++ b/rates/table/menu_table.py @@ -152,6 +152,11 @@ def get_obj_arr(self, obj): `pt`, `et`, and ID branches. The `scale_pt` function is used to convert the online pT into offline using the scalings. ''' + # TODO: Implement reading from parquet + # vers = self.version + # fname = f"/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/cache/{vers}/{vers}_MinBias_{obj}.parquet" + # arr = ak.from_parquet(fname) + arr = self.load_minbias(obj) if "jagged0" in arr.fields: arr = arr["jagged0"] @@ -217,7 +222,7 @@ def get_combos(self, leg_arrs, seed_legs): if i>=j: continue ## check that the legs are the same type object, skip otherwise if seed_legs[l1]["obj"] != seed_legs[l2]["obj"]: continue - nodup_masks.append(combos[l1].idx < combos[l2].idx) + nodup_masks.append(combos[l1].idx != combos[l2].idx) if len(nodup_masks) > 0: eval_str = " & ".join([f"nodup_masks[{i}]" for i in range(len(nodup_masks))]) diff --git a/rates/table/scalings_input/V29/scalings.yml b/rates/table/scalings_input/V29/scalings.yml new file mode 100644 index 00000000..f532a86d --- /dev/null +++ b/rates/table/scalings_input/V29/scalings.yml @@ -0,0 +1,200 @@ +EG: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 2.707 + slope: 1.188 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 1.572 + slope: 1.249 +caloTau: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: -2.553 + slope: 1.525 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 1.273 + slope: 1.968 +gmtMuon: + Barrel: + eta_max: 0.83 + eta_min: 0 + offset: -0.2379695 + slope: 1.13674 + Endcap: + eta_max: 2.5 + eta_min: 1.24 + offset: 11.219282 + slope: 1.5027 + Overlap: + eta_max: 1.24 + eta_min: 0.83 + offset: -2.5687838 + slope: 1.34598 +gmtTkMuon: + Barrel: + eta_max: 0.83 + eta_min: 0 + offset: 0.986 + slope: 1.049 + Endcap: + eta_max: 2.5 + eta_min: 1.24 + offset: 0.792 #1.075 + slope: 1.054 # 1.052 + Overlap: + eta_max: 1.24 + eta_min: 0.83 + offset: 1.075 # 0.792 + slope: 1.052 # 1.054 +nnTau: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: -2.065 + slope: 1.899 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 19.596 + slope: 1.584 +phase1PuppiHT: + null: + eta_max: null + eta_min: null + offset: 54.550 + slope: 1.087 +phase1PuppiJet: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 15.497 + slope: 1.383 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 9.362 + slope: 1.959 + null: + eta_max: null + eta_min: null + offset: 75.5 + slope: 1.41 +phase1PuppiMHT: + null: + eta_max: null + eta_min: null + offset: 49.175 + slope: 1.321 +puppiMET: + null: + eta_max: null + eta_min: null + offset: 63.781 + slope: 1.465 +seededConePuppiHT: + null: + eta_max: null + eta_min: null + offset: 47.986 + slope: 1.084 +seededConePuppiJet: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 20.10841 + slope: 1.30781 + Endcap: + eta_max: 2.4 + eta_min: 1.5 + offset: 7.971 + slope: 2.05 + # null: + # eta_max: null + # eta_min: null + # offset: 72.567 + # slope: 1.418 +seededConePuppiMHT: + null: + eta_max: null + eta_min: null + offset: 55.097 + slope: 1.202 +tkIsoElectron: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 1.441 + slope: 1.159 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 1.256 + slope: 1.217 +tkElectron: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 1.638 + slope: 1.144 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 1.219 + slope: 1.214 +tkIsoPhoton: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 2.697 + slope: 1.096 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 5.038 + slope: 1.067 +tkPhoton: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 2.697 + slope: 1.096 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 5.038 + slope: 1.067 +trackerHT: + null: + eta_max: null + eta_min: null + offset: -25.35696 + slope: 3.622799 +trackerJet: + Barrel: + eta_max: 1.5 + eta_min: 0 + offset: 446.22001 + slope: 0.341314 + Endcap: + eta_max: 2.5 + eta_min: 1.5 + offset: 477.198 + slope: 0.04346206 +trackerMET: + null: + eta_max: null + eta_min: null + offset: 417.67308 + slope: 0.2483366 +trackerMHT: + null: + eta_max: null + eta_min: null + offset: 410.9299 + slope: 0.295772 diff --git a/rates/table/utils.py b/rates/table/utils.py index 56238cf3..6bf8511d 100644 --- a/rates/table/utils.py +++ b/rates/table/utils.py @@ -14,10 +14,10 @@ def pairinvmass(pt1,pt2,eta1,eta2,phi1,phi2): return np.sqrt(2.0*pt1*pt2*(np.cosh(eta1-eta2)-np.cos(phi1-phi2))) def phoid(EleID, PhoID, Eta): - return EleID * (abs(Eta)<1.5) + PhoID * (abs(Eta)>=1.5) + return (EleID * (abs(Eta)<1.5)) + (PhoID * (abs(Eta)>=1.5)) def egid(EleID, SaID, Eta): - return EleID * abs(Eta)<1.5 + SaID * (abs(Eta)>=1.5) + return (EleID * (abs(Eta)<1.5)) + (SaID * (abs(Eta)>=1.5)) def TkEleQualHIGH(Et,Eta,PassesEleID): return PassesEleID def TkEleQualLOW(Et,Eta,PassesEleID): return PassesEleID * (abs(Eta)<1.479) + (abs(Eta)>1.479) From 41a1be170b319820f35ac21dbf6b6d16aa476064 Mon Sep 17 00:00:00 2001 From: Matteo Bonanomi Date: Mon, 7 Aug 2023 10:21:11 +0200 Subject: [PATCH 07/20] Add README --- rates/table/README.md | 38 ++++++++++++++++++++++++++++++++- rates/table/cfg/v29/v29_cfg.yml | 4 ++-- rates/table/rate_table.py | 2 +- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/rates/table/README.md b/rates/table/README.md index afdd252c..55b7bfaa 100644 --- a/rates/table/README.md +++ b/rates/table/README.md @@ -1,4 +1,40 @@ -# Rate table for the Phase-2 L1 Trigger Menu +# L1 Phase2 Menu Tools: Rate Table + +The rates table can be produced using the following command: + + ./rate_table.py cfg/v29/v29_cfg.yml + +where the `cfg` argument specifies the structure of the config file to be used. + +An example of config can be found in `./cfg/v29_cfg.yml` and it is a `yaml` file +with the following structure: + + MenuV29: + version: "V29" + sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" + menu_config: "cfg/v29/v29_16Seeds_Final_clean_cfg.yml" + scalings: + scalings_path: "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" + collect_scalings: False + scalings_outdir: "scalings_input/V29/" + scalings_file: "scalings.yml" + table: + table_fname: "rates_16Seeds_Final" + table_outdir: "rates_tables/V29" + +The block above defines entirely a menu table (`MenuV29` in the example above). +Several blocks (with a different title) can be specified in the config if one wants to produce +rate tables for different menu configurations. + +The other fields that can be specified are: +* `version`: specifies the version of the ntuples used; +* `sample`: specifies the sample to be used; +* `menu_config`: user-defined config of the menu seeds. See `cfg/v29/v29_16Seeds_Final_clean_cfg.yml` for an example. The current example replicates the menu config implemented in `cfg/v29/v29_16Seeds_Final`; +* `scalings`: this block defines the properties of the scalings file to be used. If `collect_scalings` is `False`, +the scalings file in `scalings_outdir` will be used (`scalings.yml` in the example above corresponds to the `v29` scalings used for AR). If `collect_scalings` is `True`, then the `Scaler` (cf `scaler.py`) class is used to create a new scalings file, with the name specified in `scalings_file` (which will be located in `scalings_outdir`), starting from the per-object `.txt` scalings saved under `scalings_path` (i.e. the output of the `objectPerformance` code); +* `table`: this block defines the properties of the rates table that will be dumped to a `.csv` file. The table will be saved under `table_outdir` with `table_fname` as name. + +## Outdated: Rate table for the Phase-2 L1 Trigger Menu To run the rate table, for example for the L1 TDR results, do ``` python run.py cfg/v10_TRIDAS_newThresholds_LHCCReview diff --git a/rates/table/cfg/v29/v29_cfg.yml b/rates/table/cfg/v29/v29_cfg.yml index 04295717..2d70e325 100644 --- a/rates/table/cfg/v29/v29_cfg.yml +++ b/rates/table/cfg/v29/v29_cfg.yml @@ -1,10 +1,10 @@ MenuV29: version: "V29" sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" - menu_config: "cfg/v29_16Seeds_Final_clean_cfg.yml" + menu_config: "cfg/v29/v29_16Seeds_Final_clean_cfg.yml" scalings: scalings_path: "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" - collect_scalings: True + collect_scalings: False scalings_outdir: "scalings_input/V29/" scalings_file: "scalings.yml" table: diff --git a/rates/table/rate_table.py b/rates/table/rate_table.py index e5c84cc2..bd878d10 100755 --- a/rates/table/rate_table.py +++ b/rates/table/rate_table.py @@ -11,7 +11,7 @@ parser = argparse.ArgumentParser() parser.add_argument( "cfg", - default="cfg_caching/V22.yaml", + default="cfg/v29/v29_cfg.yml", help="" ) args = parser.parse_args() From dfeec58c9415affdb9b1d240905cab383a2c02ff Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 14:08:00 +0200 Subject: [PATCH 08/20] Move old menu tool to separate folder --- rates/table/README.md | 47 +++++++++++++------ rates/table/cfg/v29/v29_cfg.yml | 4 +- rates/table/old_tool/README.md | 18 +++++++ .../v10/v10_TRIDAS_newThresholds_LHCCReview | 0 .../cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x | 0 ...E_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5 | 0 .../{ => old_tool}/cfg/v27/v27_1252_noSoftMu | 0 .../{ => old_tool}/cfg/v29/v29_16Seeds_Final | 0 .../{ => old_tool}/cfg/v29/v29_NOMUONS_Final | 0 .../cfg/v29/v29_WITHMUONS_Final | 0 rates/table/{ => old_tool}/lib/__init__.py | 0 rates/table/{ => old_tool}/lib/cfg.py | 0 rates/table/{ => old_tool}/lib/functions.py | 0 .../{ => old_tool}/lib/functionsTreeReader.py | 0 rates/table/{ => old_tool}/lib/master.py | 0 rates/table/{ => old_tool}/lib/menu.py | 0 rates/table/{ => old_tool}/lib/object.py | 0 rates/table/{ => old_tool}/lib/sample.py | 0 .../table/{ => old_tool}/lib/samplemanager.py | 0 rates/table/{ => old_tool}/lib/trigger.py | 0 rates/table/{ => old_tool}/lib/vb.py | 0 rates/table/{ => old_tool}/printRateTable.py | 0 rates/table/{ => old_tool}/run.py | 0 rates/table/rate_table.py | 2 +- 24 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 rates/table/old_tool/README.md rename rates/table/{ => old_tool}/cfg/v10/v10_TRIDAS_newThresholds_LHCCReview (100%) rename rates/table/{ => old_tool}/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x (100%) rename rates/table/{ => old_tool}/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5 (100%) rename rates/table/{ => old_tool}/cfg/v27/v27_1252_noSoftMu (100%) rename rates/table/{ => old_tool}/cfg/v29/v29_16Seeds_Final (100%) rename rates/table/{ => old_tool}/cfg/v29/v29_NOMUONS_Final (100%) rename rates/table/{ => old_tool}/cfg/v29/v29_WITHMUONS_Final (100%) rename rates/table/{ => old_tool}/lib/__init__.py (100%) rename rates/table/{ => old_tool}/lib/cfg.py (100%) rename rates/table/{ => old_tool}/lib/functions.py (100%) rename rates/table/{ => old_tool}/lib/functionsTreeReader.py (100%) rename rates/table/{ => old_tool}/lib/master.py (100%) rename rates/table/{ => old_tool}/lib/menu.py (100%) rename rates/table/{ => old_tool}/lib/object.py (100%) rename rates/table/{ => old_tool}/lib/sample.py (100%) rename rates/table/{ => old_tool}/lib/samplemanager.py (100%) rename rates/table/{ => old_tool}/lib/trigger.py (100%) rename rates/table/{ => old_tool}/lib/vb.py (100%) rename rates/table/{ => old_tool}/printRateTable.py (100%) rename rates/table/{ => old_tool}/run.py (100%) diff --git a/rates/table/README.md b/rates/table/README.md index afdd252c..f6e8bb2e 100644 --- a/rates/table/README.md +++ b/rates/table/README.md @@ -1,16 +1,35 @@ -# Rate table for the Phase-2 L1 Trigger Menu -To run the rate table, for example for the L1 TDR results, do -``` -python run.py cfg/v10_TRIDAS_newThresholds_LHCCReview -``` +# L1 Phase2 Menu Tools: Rate Table -For the firmware-based emulators under 123x, utilise `FBE_noMu_L1TDRMET_mhtSeed_123x` (`FBE_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5` only includes forward region for the singleJet seed). - -To display the rates in an easy-to-read format, run -``` -python3 printRateTable.py -c cfg/v10_TRIDAS_newThresholds_LHCCReview -r out/2020-05-26-MENU-LHCCReview-BugFix_v10_TRIDAS_newThresholds_LHCCReview/thresholds/menu.csv -``` -You can also edit the `CFG_RATE_COMBOS` dictionary at the top of -the file and run the script without any arguments `python3 printRateTable.py`. -This way multiple rate tables can be compared quickly. +The rates table can be produced using the following command: + ./rate_table.py cfg/v29/v29_cfg.yml + +where the `cfg` argument specifies the structure of the config file to be used. + +An example of config can be found in `./cfg/v29_cfg.yml` and it is a `yaml` file +with the following structure: + + MenuV29: + version: "V29" + sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" + menu_config: "cfg/v29/v29_16Seeds_Final_clean_cfg.yml" + scalings: + scalings_path: "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" + collect_scalings: False + scalings_outdir: "scalings_input/V29/" + scalings_file: "scalings.yml" + table: + table_fname: "rates_16Seeds_Final" + table_outdir: "rates_tables/V29" + +The block above defines entirely a menu table (`MenuV29` in the example above). +Several blocks (with a different title) can be specified in the config if one wants to produce +rate tables for different menu configurations. + +The other fields that can be specified are: +* `version`: specifies the version of the ntuples used; +* `sample`: specifies the sample to be used; +* `menu_config`: user-defined config of the menu seeds. See `cfg/v29/v29_16Seeds_Final_clean_cfg.yml` for an example. The current example replicates the menu config implemented in `cfg/v29/v29_16Seeds_Final`; +* `scalings`: this block defines the properties of the scalings file to be used. If `collect_scalings` is `False`, +the scalings file in `scalings_outdir` will be used (`scalings.yml` in the example above corresponds to the `v29` scalings used for AR). If `collect_scalings` is `True`, then the `Scaler` (cf `scaler.py`) class is used to create a new scalings file, with the name specified in `scalings_file` (which will be located in `scalings_outdir`), starting from the per-object `.txt` scalings saved under `scalings_path` (i.e. the output of the `objectPerformance` code); +* `table`: this block defines the properties of the rates table that will be dumped to a `.csv` file. The table will be saved under `table_outdir` with `table_fname` as name. diff --git a/rates/table/cfg/v29/v29_cfg.yml b/rates/table/cfg/v29/v29_cfg.yml index 04295717..2d70e325 100644 --- a/rates/table/cfg/v29/v29_cfg.yml +++ b/rates/table/cfg/v29/v29_cfg.yml @@ -1,10 +1,10 @@ MenuV29: version: "V29" sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" - menu_config: "cfg/v29_16Seeds_Final_clean_cfg.yml" + menu_config: "cfg/v29/v29_16Seeds_Final_clean_cfg.yml" scalings: scalings_path: "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" - collect_scalings: True + collect_scalings: False scalings_outdir: "scalings_input/V29/" scalings_file: "scalings.yml" table: diff --git a/rates/table/old_tool/README.md b/rates/table/old_tool/README.md new file mode 100644 index 00000000..bd5e82e4 --- /dev/null +++ b/rates/table/old_tool/README.md @@ -0,0 +1,18 @@ +# L1 Phase2 Menu Tools: Rate Table + +## Old fwk: Rate table for the Phase-2 L1 Trigger Menu +To run the rate table, for example for the L1 TDR results, do +``` +python run.py cfg/v10_TRIDAS_newThresholds_LHCCReview +``` + +For the firmware-based emulators under 123x, utilise `FBE_noMu_L1TDRMET_mhtSeed_123x` (`FBE_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5` only includes forward region for the singleJet seed). + +To display the rates in an easy-to-read format, run +``` +python3 printRateTable.py -c cfg/v10_TRIDAS_newThresholds_LHCCReview -r out/2020-05-26-MENU-LHCCReview-BugFix_v10_TRIDAS_newThresholds_LHCCReview/thresholds/menu.csv +``` +You can also edit the `CFG_RATE_COMBOS` dictionary at the top of +the file and run the script without any arguments `python3 printRateTable.py`. +This way multiple rate tables can be compared quickly. + diff --git a/rates/table/cfg/v10/v10_TRIDAS_newThresholds_LHCCReview b/rates/table/old_tool/cfg/v10/v10_TRIDAS_newThresholds_LHCCReview similarity index 100% rename from rates/table/cfg/v10/v10_TRIDAS_newThresholds_LHCCReview rename to rates/table/old_tool/cfg/v10/v10_TRIDAS_newThresholds_LHCCReview diff --git a/rates/table/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x b/rates/table/old_tool/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x similarity index 100% rename from rates/table/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x rename to rates/table/old_tool/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x diff --git a/rates/table/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5 b/rates/table/old_tool/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5 similarity index 100% rename from rates/table/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5 rename to rates/table/old_tool/cfg/v22/FBE_noMu_L1TDRMET_mhtSeed_123x_singleJetEta5 diff --git a/rates/table/cfg/v27/v27_1252_noSoftMu b/rates/table/old_tool/cfg/v27/v27_1252_noSoftMu similarity index 100% rename from rates/table/cfg/v27/v27_1252_noSoftMu rename to rates/table/old_tool/cfg/v27/v27_1252_noSoftMu diff --git a/rates/table/cfg/v29/v29_16Seeds_Final b/rates/table/old_tool/cfg/v29/v29_16Seeds_Final similarity index 100% rename from rates/table/cfg/v29/v29_16Seeds_Final rename to rates/table/old_tool/cfg/v29/v29_16Seeds_Final diff --git a/rates/table/cfg/v29/v29_NOMUONS_Final b/rates/table/old_tool/cfg/v29/v29_NOMUONS_Final similarity index 100% rename from rates/table/cfg/v29/v29_NOMUONS_Final rename to rates/table/old_tool/cfg/v29/v29_NOMUONS_Final diff --git a/rates/table/cfg/v29/v29_WITHMUONS_Final b/rates/table/old_tool/cfg/v29/v29_WITHMUONS_Final similarity index 100% rename from rates/table/cfg/v29/v29_WITHMUONS_Final rename to rates/table/old_tool/cfg/v29/v29_WITHMUONS_Final diff --git a/rates/table/lib/__init__.py b/rates/table/old_tool/lib/__init__.py similarity index 100% rename from rates/table/lib/__init__.py rename to rates/table/old_tool/lib/__init__.py diff --git a/rates/table/lib/cfg.py b/rates/table/old_tool/lib/cfg.py similarity index 100% rename from rates/table/lib/cfg.py rename to rates/table/old_tool/lib/cfg.py diff --git a/rates/table/lib/functions.py b/rates/table/old_tool/lib/functions.py similarity index 100% rename from rates/table/lib/functions.py rename to rates/table/old_tool/lib/functions.py diff --git a/rates/table/lib/functionsTreeReader.py b/rates/table/old_tool/lib/functionsTreeReader.py similarity index 100% rename from rates/table/lib/functionsTreeReader.py rename to rates/table/old_tool/lib/functionsTreeReader.py diff --git a/rates/table/lib/master.py b/rates/table/old_tool/lib/master.py similarity index 100% rename from rates/table/lib/master.py rename to rates/table/old_tool/lib/master.py diff --git a/rates/table/lib/menu.py b/rates/table/old_tool/lib/menu.py similarity index 100% rename from rates/table/lib/menu.py rename to rates/table/old_tool/lib/menu.py diff --git a/rates/table/lib/object.py b/rates/table/old_tool/lib/object.py similarity index 100% rename from rates/table/lib/object.py rename to rates/table/old_tool/lib/object.py diff --git a/rates/table/lib/sample.py b/rates/table/old_tool/lib/sample.py similarity index 100% rename from rates/table/lib/sample.py rename to rates/table/old_tool/lib/sample.py diff --git a/rates/table/lib/samplemanager.py b/rates/table/old_tool/lib/samplemanager.py similarity index 100% rename from rates/table/lib/samplemanager.py rename to rates/table/old_tool/lib/samplemanager.py diff --git a/rates/table/lib/trigger.py b/rates/table/old_tool/lib/trigger.py similarity index 100% rename from rates/table/lib/trigger.py rename to rates/table/old_tool/lib/trigger.py diff --git a/rates/table/lib/vb.py b/rates/table/old_tool/lib/vb.py similarity index 100% rename from rates/table/lib/vb.py rename to rates/table/old_tool/lib/vb.py diff --git a/rates/table/printRateTable.py b/rates/table/old_tool/printRateTable.py similarity index 100% rename from rates/table/printRateTable.py rename to rates/table/old_tool/printRateTable.py diff --git a/rates/table/run.py b/rates/table/old_tool/run.py similarity index 100% rename from rates/table/run.py rename to rates/table/old_tool/run.py diff --git a/rates/table/rate_table.py b/rates/table/rate_table.py index e5c84cc2..bd878d10 100755 --- a/rates/table/rate_table.py +++ b/rates/table/rate_table.py @@ -11,7 +11,7 @@ parser = argparse.ArgumentParser() parser.add_argument( "cfg", - default="cfg_caching/V22.yaml", + default="cfg/v29/v29_cfg.yml", help="" ) args = parser.parse_args() From e6c1871c21dec32f5e2397895d44d3a4b9ced8a9 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 14:08:25 +0200 Subject: [PATCH 09/20] Add loading math package --- rates/table/menu_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rates/table/menu_table.py b/rates/table/menu_table.py index e4b1a8f9..1eaa5365 100644 --- a/rates/table/menu_table.py +++ b/rates/table/menu_table.py @@ -3,7 +3,7 @@ from glob import glob -import yaml, re, os +import yaml, re, os, math from utils import * from menu_config import MenuConfig From 3db4eab852a07f37eeb3b95ec82bde149ef05aab Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 14:34:44 +0200 Subject: [PATCH 10/20] Fix scalings for caloTau and sc jets --- rates/table/scalings_input/V29/scalings.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rates/table/scalings_input/V29/scalings.yml b/rates/table/scalings_input/V29/scalings.yml index f532a86d..2f1744bc 100644 --- a/rates/table/scalings_input/V29/scalings.yml +++ b/rates/table/scalings_input/V29/scalings.yml @@ -18,7 +18,7 @@ caloTau: Endcap: eta_max: 2.5 eta_min: 1.5 - offset: 1.273 + offset: -1.273 slope: 1.968 gmtMuon: Barrel: @@ -114,11 +114,11 @@ seededConePuppiJet: eta_min: 1.5 offset: 7.971 slope: 2.05 - # null: - # eta_max: null - # eta_min: null - # offset: 72.567 - # slope: 1.418 + Forward: + eta_max: 6 + eta_min: 2.4 + offset: 72.567 + slope: 1.418 seededConePuppiMHT: null: eta_max: null From 14508a4603fac5c11881a47ebefd499e6549c6f2 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 14:35:46 +0200 Subject: [PATCH 11/20] Add pyc files to git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1d9df5e1..24ca9e3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/__pycache__/* +*.pyc **/*.png **/.DS_Store **/*.parquet From c8d38983d47175a10168cbbdd6171998b923a541 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 14:56:36 +0200 Subject: [PATCH 12/20] Change >= to > in Tau seeds in v29 config --- rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml index 00478fa6..8c83bd72 100644 --- a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml +++ b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml @@ -348,12 +348,12 @@ L1_PFTau_PFTau: - leg1.deltaR(leg2)>0.5 leg1: leg_mask: - - leg1.offline_pt >= 90.0 + - leg1.offline_pt > 90.0 - abs(leg1.eta)<2.172 obj: caloTau leg2: leg_mask: - - leg2.offline_pt >= 90.0 + - leg2.offline_pt > 90.0 - abs(leg2.eta)<2.172 obj: caloTau L1_SingleEGEle: @@ -368,7 +368,7 @@ L1_SinglePFTau: cross_masks: [] leg1: leg_mask: - - leg1.offline_pt >= 150.0 + - leg1.offline_pt > 150.0 - abs(leg1.eta)<2.172 obj: caloTau L1_SinglePfJet: From 031d667a1f767f6d926d9d250e2acd8f00f098f0 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 14:57:22 +0200 Subject: [PATCH 13/20] Removing skipping Tau seeds --- rates/table/menu_table.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rates/table/menu_table.py b/rates/table/menu_table.py index 1eaa5365..75424ea1 100644 --- a/rates/table/menu_table.py +++ b/rates/table/menu_table.py @@ -326,9 +326,7 @@ def prepare_masks(self): seeds = self.trig_seeds - for seed in sorted(seeds): - if "PFTau" in seed: continue - + for seed in sorted(seeds): print(seed) mask = self.get_npass(seed, self.trig_seeds[seed]) From 1e3abf5afb70ae9ae14f9dd1d74b15bfef5d88d8 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 15:07:35 +0200 Subject: [PATCH 14/20] Add full menu and 16seed menu v29 steering file --- rates/table/cfg/v29/v29_16seed_cfg.yml | 12 ++++++++++++ rates/table/cfg/v29/v29_cfg.yml | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 rates/table/cfg/v29/v29_16seed_cfg.yml diff --git a/rates/table/cfg/v29/v29_16seed_cfg.yml b/rates/table/cfg/v29/v29_16seed_cfg.yml new file mode 100644 index 00000000..2d70e325 --- /dev/null +++ b/rates/table/cfg/v29/v29_16seed_cfg.yml @@ -0,0 +1,12 @@ +MenuV29: + version: "V29" + sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" + menu_config: "cfg/v29/v29_16Seeds_Final_clean_cfg.yml" + scalings: + scalings_path: "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" + collect_scalings: False + scalings_outdir: "scalings_input/V29/" + scalings_file: "scalings.yml" + table: + table_fname: "rates_16Seeds_Final" + table_outdir: "rates_tables/V29" \ No newline at end of file diff --git a/rates/table/cfg/v29/v29_cfg.yml b/rates/table/cfg/v29/v29_cfg.yml index 2d70e325..e464ec13 100644 --- a/rates/table/cfg/v29/v29_cfg.yml +++ b/rates/table/cfg/v29/v29_cfg.yml @@ -1,12 +1,12 @@ MenuV29: version: "V29" sample: "/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/13X/v29_RelVal/RelValTTbar_14TeV/RelVal_13X_TT_200PU_crab_v29_13X_RelVal_FixGenTree/230710_081407/L1NtuplePhaseII_Step1_hadd.root" - menu_config: "cfg/v29/v29_16Seeds_Final_clean_cfg.yml" + menu_config: "cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml" scalings: scalings_path: "/eos/user/m/mbonanom/www/Postdoc/L1PhaseII/V29/scalings/" collect_scalings: False scalings_outdir: "scalings_input/V29/" scalings_file: "scalings.yml" table: - table_fname: "rates_16Seeds_Final" + table_fname: "rates_full_Final" table_outdir: "rates_tables/V29" \ No newline at end of file From 9e95004a9e3cf1adcdb18b1efc49757801d80990 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 15:42:58 +0200 Subject: [PATCH 15/20] Fix MHT scalings --- rates/table/scalings_input/V29/scalings.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rates/table/scalings_input/V29/scalings.yml b/rates/table/scalings_input/V29/scalings.yml index 2f1744bc..93271a05 100644 --- a/rates/table/scalings_input/V29/scalings.yml +++ b/rates/table/scalings_input/V29/scalings.yml @@ -121,10 +121,8 @@ seededConePuppiJet: slope: 1.418 seededConePuppiMHT: null: - eta_max: null - eta_min: null - offset: 55.097 - slope: 1.202 + offset: -20.499 + slope: 1.170 tkIsoElectron: Barrel: eta_max: 1.5 From 35a082930c72c419c7da9a1f627c20478eba20e7 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 15:43:21 +0200 Subject: [PATCH 16/20] Remove unused doublemu seed --- .../cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml index 8c83bd72..d83e512c 100644 --- a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml +++ b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml @@ -143,21 +143,6 @@ L1_DoubleTkMu4p5er2p0_SQ_OS_Mass7to18: - abs(leg2.eta)<2.0 - leg2.qual>0 obj: gmtTkMuon -L1_DoubleTkMu9_SQ: - cross_masks: - - abs(leg2.z0-leg1.z0)<1 - leg1: - leg_mask: - - leg1.offline_pt >= 9.0 - - abs(leg1.eta)<2.4 - - leg1.qual>0 - obj: gmtTkMuon - leg2: - leg_mask: - - leg2.offline_pt >= 9.0 - - abs(leg2.eta)<2.4 - - leg2.qual>0 - obj: gmtTkMuon L1_DoubleTkMu_PfHTT: cross_masks: - abs(leg2.z0-leg1.et)<1 From d407e80a7e508ea6277ba8f499464614caf837b7 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 15:43:42 +0200 Subject: [PATCH 17/20] Remove colon from old fwk printout --- rates/table/old_tool/lib/menu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rates/table/old_tool/lib/menu.py b/rates/table/old_tool/lib/menu.py index e68e70d9..5094e1ae 100644 --- a/rates/table/old_tool/lib/menu.py +++ b/rates/table/old_tool/lib/menu.py @@ -69,8 +69,8 @@ def dump(self, outdir): print refs names = refs.keys()[:] names.sort() - fs = "%-"+str(maxlength)+"s: %9.2f" - fss = fs + " %1.5f %3.3f" + fs = "%-"+str(maxlength)+"s\t%9.2f" + fss = fs + " \t%1.5f \t%3.3f" print print "MENU RESULT:" for tname in names: From 4a10178899bfa641f71bd668bb768c1b14d9c406 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 16:28:23 +0200 Subject: [PATCH 18/20] Introduce tkIsoEle fix and fix scalings and menu --- .../cfg/v29/v29_16Seeds_Final_clean_cfg.yml | 4 ++-- .../cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml | 22 +++++++++---------- rates/table/menu_table.py | 18 +++++++++++---- rates/table/scalings_input/V29/scalings.yml | 4 ++-- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml index f600ecaf..79bdd1b7 100644 --- a/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml +++ b/rates/table/cfg/v29/v29_16Seeds_Final_clean_cfg.yml @@ -47,7 +47,7 @@ L1_SingleTkEleIso: - leg1.offline_pt >= 28.0 - leg1.passeseleid>=0 - ak.where(abs(leg1.eta)<1.479, leg1.trkiso<0.13, leg1.trkiso<0.28) - obj: tkElectron + obj: tkIsoElectron L1_SingleTkMu: cross_masks: [] leg1: @@ -73,7 +73,7 @@ L1_TkEleIso_EG: - abs(leg1.eta)<2.4 - leg1.passeseleid >= 0 - ak.where(abs(leg1.eta)<1.479, leg1.trkiso<0.13, leg1.trkiso<0.28) - obj: tkElectron + obj: tkIsoElectron leg2: leg_mask: - leg2.offline_pt > 12.0 diff --git a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml index d83e512c..e8454224 100644 --- a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml +++ b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml @@ -376,10 +376,10 @@ L1_SingleTkEleIso: cross_masks: [] leg1: leg_mask: - - leg1.offline_pt >= 28.0 - - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + - leg1.offline_pt > 28.0 + - leg1.passeseleid >= 0 - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) - obj: tkElectron + obj: tkIsoElectron L1_SingleTkMu: cross_masks: [] leg1: @@ -403,9 +403,9 @@ L1_TkEleIso_EG: leg_mask: - leg1.offline_pt >= 22.0 - abs(leg1.eta)<2.4 - - leg1.passeseleid * (abs(leg1.eta)<1.479) + (abs(leg1.eta)>1.479) + - leg1.passeseleid >= 0 - (leg1.trkiso<0.13) * (abs(leg1.eta)<1.479) + (leg1.trkiso<0.28) * (abs(leg1.eta)>=1.479) - obj: tkElectron + obj: tkIsoElectron leg2: leg_mask: - leg2.offline_pt >= 12.0 @@ -423,9 +423,9 @@ L1_TkEleIso_PFHTT: leg_mask: - leg2.offline_pt >= 26.0 - abs(leg2.eta)<2.1 - - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + - leg2.passeseleid >= 0 - (leg2.trkiso<0.13) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.28) * (abs(leg2.eta)>=1.479) - obj: tkElectron + obj: tkIsoElectron leg3: leg_mask: - leg3.offline_pt >= 190.0 @@ -441,9 +441,9 @@ L1_TkEleIso_PFIsoTau: leg_mask: - leg2.offline_pt >= 22.0 - abs(leg2.eta)<2.1 - - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + - leg2.passeseleid >= 0 - (leg2.trkiso<0.13) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.28) * (abs(leg2.eta)>=1.479) - obj: tkElectron + obj: tkIsoElectron leg3: leg_mask: - leg3.offline_pt >= 45.0 @@ -606,9 +606,9 @@ L1_TkMu_TkEleIso: leg_mask: - leg2.offline_pt >= 20.0 - abs(leg2.eta)<2.4 - - leg2.passeseleid * (abs(leg2.eta)<1.479) + (abs(leg2.eta)>1.479) + - leg2.passeseleid >= 0 - (leg2.trkiso<0.13) * (abs(leg2.eta)<1.479) + (leg2.trkiso<0.28) * (abs(leg2.eta)>=1.479) - obj: tkElectron + obj: tkIsoElectron L1_TripleTkMu: cross_masks: - abs(leg2.z0-leg1.z0)<1 diff --git a/rates/table/menu_table.py b/rates/table/menu_table.py index 75424ea1..b5647128 100644 --- a/rates/table/menu_table.py +++ b/rates/table/menu_table.py @@ -78,8 +78,8 @@ def add_offline_pt(self, arr, obj_scalings, pt_var = None): ''' # initialise array of zeros identical to the original pt if pt_var is not None: pt_orig = arr[pt_var] - elif "pt" in arr.fields: pt_orig = arr.pt elif "et" in arr.fields: pt_orig = arr.et + elif "pt" in arr.fields: pt_orig = arr.pt elif "" in arr.fields: pt_orig = arr[""][:,0] else: print("Error! Unknown pt branch") @@ -106,7 +106,9 @@ def scale_pt(self, obj, arr): If the scaling for a given object is not found, `offline_pt` is set to be equal to the online pt. ''' + if obj in self.scalings: + # print(self.scalings[obj]) arr = self.add_offline_pt(arr, self.scalings[obj]) else: print("No scalings found for " + obj) @@ -157,12 +159,17 @@ def get_obj_arr(self, obj): # fname = f"/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/alobanov/phase2/menu/ntuples/cache/{vers}/{vers}_MinBias_{obj}.parquet" # arr = ak.from_parquet(fname) - arr = self.load_minbias(obj) + load_obj = obj + + if obj == "tkIsoElectron": load_obj = "tkElectron" + + arr = self.load_minbias(load_obj) if "jagged0" in arr.fields: arr = arr["jagged0"] - arr = ak.zip({f.replace(obj,"").lower():arr[f] for f in arr.fields}) + arr = ak.zip({f.replace(load_obj,"").lower():arr[f] for f in arr.fields}) arr = self.format_values(arr) + arr = self.scale_pt(obj, arr) return arr @@ -326,7 +333,10 @@ def prepare_masks(self): seeds = self.trig_seeds - for seed in sorted(seeds): + for seed in sorted(seeds): + + if "TkEle" not in seed: continue + print(seed) mask = self.get_npass(seed, self.trig_seeds[seed]) diff --git a/rates/table/scalings_input/V29/scalings.yml b/rates/table/scalings_input/V29/scalings.yml index 93271a05..ba55c642 100644 --- a/rates/table/scalings_input/V29/scalings.yml +++ b/rates/table/scalings_input/V29/scalings.yml @@ -123,7 +123,7 @@ seededConePuppiMHT: null: offset: -20.499 slope: 1.170 -tkIsoElectron: +tkElectron: Barrel: eta_max: 1.5 eta_min: 0 @@ -134,7 +134,7 @@ tkIsoElectron: eta_min: 1.5 offset: 1.256 slope: 1.217 -tkElectron: +tkIsoElectron: Barrel: eta_max: 1.5 eta_min: 0 From 43a655b0399206e61831ae4484c5f08497c8ed48 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 17:12:58 +0200 Subject: [PATCH 19/20] Add dump of masks --- rates/table/menu_table.py | 16 ++++++++++++++-- rates/table/rate_table.py | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/rates/table/menu_table.py b/rates/table/menu_table.py index b5647128..dd2de591 100644 --- a/rates/table/menu_table.py +++ b/rates/table/menu_table.py @@ -335,8 +335,6 @@ def prepare_masks(self): for seed in sorted(seeds): - if "TkEle" not in seed: continue - print(seed) mask = self.get_npass(seed, self.trig_seeds[seed]) @@ -356,6 +354,7 @@ def make_table(self): table.append("Seed,NPass,Eff,Rate\n") total_mask = 0 trig_masks = self.prepare_masks() + self.trig_masks = trig_masks for seed, mask in trig_masks.items(): @@ -380,6 +379,19 @@ def make_table(self): print("Total nev: %i" % len(total_mask)) return table + + def dump_masks(self): + ''' + Function that dumps to file the masks produced by `prepare_masks`. + ''' + if hasattr(self, "trig_masks"): + os.makedirs(f"{self.table_outdir}", exist_ok=True) + fname = f"{self.table_outdir}/{self.table_fname}_{self.version}_masks.parquet" + print(f"Dumping masks to parquet in: {fname}") + + ak.to_parquet(ak.zip(self.trig_masks), fname) + else: + print("No masks created! Run `prepare_masks` first.") def dump_table(self, table): ''' diff --git a/rates/table/rate_table.py b/rates/table/rate_table.py index bd878d10..96ae2fd6 100755 --- a/rates/table/rate_table.py +++ b/rates/table/rate_table.py @@ -26,4 +26,6 @@ menu_config = MenuTable(menu_cfg) table = menu_config.make_table() - menu_config.dump_table(table) \ No newline at end of file + menu_config.dump_table(table) + + menu_config.dump_masks() \ No newline at end of file From acc07d1793da0f7d50a30fc339b33f4948792678 Mon Sep 17 00:00:00 2001 From: Artur Lobanov Date: Tue, 8 Aug 2023 17:38:30 +0200 Subject: [PATCH 20/20] Fix seed threshold --- rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml index e8454224..ee00e269 100644 --- a/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml +++ b/rates/table/cfg/v29/v29_WITHMUONS_Final_clean_cfg.yml @@ -584,7 +584,8 @@ L1_TkMu_TkEle: - abs(leg2.zvtx-leg1.z0)<1 leg1: leg_mask: - - leg1.offline_pt >= 7.0 + #- leg1.offline_pt >= 7.0 + - leg1.pt>7 - abs(leg1.eta)<2.4 obj: gmtTkMuon leg2: