File indexing completed on 2025-01-28 03:05:32
0001 """
0002 Module for handling L1 trigger menu constants and conversions.
0003 """
0004
0005 import FWCore.ParameterSet.Config as cms
0006 from L1Trigger.Configuration.Phase2GTMenus.SeedDefinitions.step1_2024.l1tGTObject_scalings import scalings
0007 from L1Trigger.Configuration.Phase2GTMenus.SeedDefinitions.step1_2024.l1tGTObject_ids import objectIDs
0008
0009 obj_regions_abseta_lowbounds = {
0010 "CL2Photons": { "barrel": 0, "endcap": 1.479 },
0011 "CL2Electrons": { "barrel": 0, "endcap": 1.479 },
0012
0013 "CL2Taus": { "barrel": 0, "endcap": 1.5 },
0014 "CL2JetsSC4": { "barrel": 0, "endcap": 1.5, "forward": 2.4 },
0015
0016 "GMTTkMuons": { "barrel": 0, "overlap": 0.83, "endcap": 1.24 },
0017 "GMTMuons": { "barrel": 0, "overlap": 0.83, "endcap": 1.24 },
0018
0019 "CL2HtSum": {"inclusive": 0},
0020 "CL2EtSum": {"inclusive": 0},
0021 }
0022
0023 def get_object_etalowbounds(obj):
0024 return cms.vdouble(tuple(obj_regions_abseta_lowbounds[obj].values()))
0025
0026 def off2onl_thresholds(thr, obj, id, region, scalings=scalings):
0027 """
0028 Convert offline thresholds to online thresholds.
0029
0030 Args:
0031 thr (float): The offline threshold.
0032 obj (str): The object type.
0033 id (str): The object ID.
0034 region (str): The region.
0035 scalings (dict): The scalings dictionary.
0036
0037 Returns:
0038 float: The online threshold.
0039 """
0040 offset = scalings[obj][id][region]["offset"]
0041 slope = scalings[obj][id][region]["slope"]
0042 new_thr = round((thr - offset) / slope, 1)
0043
0044 if "Jet" in obj:
0045
0046 return max(25, new_thr)
0047 else:
0048 return max(0, new_thr)
0049
0050 def get_object_thrs(thr, obj, id = "default", scalings=scalings):
0051 regions = obj_regions_abseta_lowbounds[obj].keys()
0052 thresholds = [off2onl_thresholds(thr, obj, id, region) for region in regions]
0053 if len(thresholds) > 1:
0054 return cms.vdouble(tuple(thresholds))
0055 else:
0056 return cms.double(thresholds[0])
0057
0058 def get_object_ids(obj, id = "default", obj_dict=objectIDs):
0059 values = obj_dict[obj][id]["qual"]
0060 if isinstance(values, dict):
0061 regions = obj_regions_abseta_lowbounds[obj].keys()
0062 return cms.vuint32(tuple(values[region] for region in regions))
0063 else:
0064 return cms.uint32(values)
0065
0066 def get_object_isos(obj, id = "default", obj_dict=objectIDs):
0067 values = obj_dict[obj][id]["iso"]
0068 if isinstance(values, dict):
0069 regions = obj_regions_abseta_lowbounds[obj].keys()
0070 return cms.vdouble(tuple(values[region] for region in regions))
0071 else:
0072 return cms.double(values)