5 '''Function to configure LVL1 JetEfficiency algorithm in the monitoring system.'''
8 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory
import CompFactory
10 from TrigConfigSvc.TriggerConfigAccess
import getL1MenuAccess
15 from AthenaConfiguration.Enums
import Format
18 if flags.Input.Format
is Format.POOL
and not flags.Input.isMC
and not any([
"AOD" in a
for a
in flags.Input.ProcessingTags]):
19 from JetRecConfig.JetRecConfig
import JetRecCfg
20 from JetRecConfig.StandardSmallRJets
import AntiKt4EMPFlow
21 result.merge(
JetRecCfg(flags,AntiKt4EMPFlow) )
23 from eflowRec.PFCfg
import PFGlobalFlowElementLinkingCfg
24 if flags.DQ.Environment ==
"AOD":
28 from eflowRec.PFCfg
import PFGlobalFlowElementLinkingCfg
30 from METReconstruction.METAssociatorCfg
import METAssociatorCfg
32 from METUtilities.METMakerConfig
import getMETMakerAlg
39 from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig
import L1CaloMonitorCfgHelper
40 helper = L1CaloMonitorCfgHelper(flags,CompFactory.JetEfficiencyMonitorAlgorithm,
'JetEfficiencyMonAlg')
41 groupName =
'JetEfficiencyMonitor'
42 JetEfficiencyMonAlg = helper.alg
43 JetEfficiencyMonAlg.PackageName = groupName
55 passedb4Prescale =
True
56 JetEfficiencyMonAlg.PassedBeforePrescale = passedb4Prescale
64 hltRandom_reference_triggers = [
'HLT_j0_perf_L1RD0_FILLED',
'HLT_j0_perf_pf_ftf_L1RD0_FILLED']
65 JetEfficiencyMonAlg.HLTRandomReferenceTriggers = hltRandom_reference_triggers
67 muon_reference_triggers = [
"L1_MU14FCH",
"L1_MU18VFCH",
"L1_MU8F_TAU20IM",
"L1_2MU8F",
"L1_MU8VF_2MU5VF",
"L1_3MU3VF",
"L1_MU5VF_3MU3VF",
"L1_4MU3V",
"L1_2MU5VF_3MU3V",
"L1_RD0_FILLED"]
68 JetEfficiencyMonAlg.MuonReferenceTriggers = muon_reference_triggers
70 JetEfficiencyMonAlg.BootstrapReferenceTrigger=
'L1_J15'
72 trigPath =
'Developer/JetEfficiency/'
73 ExpertTrigPath =
'Expert/Efficiency/'
74 distributionPath =
'Distributions/'
75 noRefPath =
'NoReferenceTrigger/'
76 muonRefPath =
'MuonReferenceTrigger/'
77 randomRefPath =
'RandomHLTReferenceTrigger/'
78 bsRefPath =
'BootstrapReferenceTrigger/'
85 gfex_SR_triggers = [
'L1_gJ20p0ETA25',
'L1_gJ50p0ETA25',
'L1_gJ100p0ETA25',
'L1_gJ400p0ETA25']
86 gfex_LR_triggers = [
'L1_gLJ80p0ETA25',
'L1_gLJ100p0ETA25',
'L1_gLJ140p0ETA25',
'L1_gLJ160p0ETA25']
88 jfex_SR_triggers = [
'L1_jJ30',
'L1_jJ40',
'L1_jJ50',
'L1_jJ60',
'L1_jJ80',
'L1_jJ90',
'L1_jJ125',
'L1_jJ140',
'L1_jJ160',
'L1_jJ180']
89 jfex_LR_triggers = [
'L1_SC111-CjJ40']
92 all_SR_singletriggers = single_triggers + gfex_SR_triggers + jfex_SR_triggers
93 all_LR_singletriggers = LR_triggers + gfex_LR_triggers + jfex_LR_triggers
96 JetEfficiencyMonAlg.SmallRadiusJetTriggers_phase1 = [trigger
for trigger
in all_SR_singletriggers
if trigger
in l1menu]
97 JetEfficiencyMonAlg.LargeRadiusJetTriggers_phase1 = [trigger
for trigger
in all_LR_singletriggers
if trigger
in l1menu]
99 JetEfficiencyMonAlg.SmallRadiusJetTriggers_gFEX = [trigger
for trigger
in gfex_SR_triggers
if trigger
not in l1menu]
100 JetEfficiencyMonAlg.LargeRadiusJetTriggers_gFEX = [trigger
for trigger
in gfex_LR_triggers
if trigger
not in l1menu]
103 if len(JetEfficiencyMonAlg.SmallRadiusJetTriggers_gFEX ) == 0: JetEfficiencyMonAlg.mygFexSRJetRoIContainer =
""
104 if len(JetEfficiencyMonAlg.LargeRadiusJetTriggers_gFEX ) == 0: JetEfficiencyMonAlg.mygFexLRJetRoIContainer =
""
107 reference_paths = {
"Muon" : muonRefPath,
"RandomHLT": randomRefPath,
"No": noRefPath,
"Bootstrap": bsRefPath}
108 references = [
"Muon",
"No",
"Bootstrap"]
113 trigger_group_list = {
"gfex_SR_triggers" : gfex_SR_triggers,
114 "gfex_LR_triggers" : gfex_LR_triggers,
115 "jfex_SR_triggers" : jfex_SR_triggers,
116 "jfex_LR_triggers" : jfex_LR_triggers }
117 properties_per_trigger_group = {
"gfex_SR_triggers" : sr_props,
"jfex_SR_triggers" : sr_props,
118 "gfex_LR_triggers" : lr_props,
"jfex_LR_triggers" : lr_props }
119 pathadd_per_trigger_group = {
"gfex_SR_triggers" :
"gFEX/",
"jfex_SR_triggers" :
"jFEX/",
120 "gfex_LR_triggers" :
"gFEX/",
"jfex_LR_triggers" :
"jFEX/" }
121 trigger_groups =
list(trigger_group_list.keys())
123 xlabel_for_prop = {
"SRpt" :
'pT [MeV]',
"SReta" :
'#eta',
"LRpt" :
'pT [MeV]',
"LReta" :
'#eta'}
124 nbins = {
"SRpt": 220,
"SReta" :32,
"LRpt": 220,
"LReta" :32}
125 binmin = {
"SRpt": -50,
"SReta" :-3.3,
"LRpt": -50,
"LReta" :-3.3}
126 binmax = {
"SRpt": 1800*GeV,
"SReta" :3.3,
"LRpt": 1800*GeV,
"LReta" :3.3}
129 plotDistrubutions =
False
130 if plotDistrubutions:
131 helper.defineHistogram(
'raw_pt',title=
'pT for all leading offline jets (with no trigger requirments);PT [MeV];Events', fillGroup=groupName, path=trigPath + distributionPath, xbins=nbins[
"SRpt"], xmin=binmin[
"SRpt"], xmax=binmax[
"SRpt"])
133 helper.defineHistogram(
'raw_eta', title=
'Eta Distribution for all leading offline jets (with no trigger requirments);#eta; Count', fillGroup=groupName, path=trigPath + distributionPath, xbins=nbins[
"SReta"], xmin=binmin[
"SReta"], xmax=binmax[
"SReta"])
136 for tgroup
in trigger_groups:
137 for t
in trigger_group_list[tgroup]:
140 thresholdConfig = {
"Plateau":plateau_dict.get(t,[0.99,0.95])}
142 xMaxConfig =
min(thresholdConfig[
"Threshold"][1]*2.5, binmax[
"SRpt"])
144 helper.defineDQAlgorithm(
"JetEfficiency_"+t,
145 hanConfig={
"libname":
"libdqm_algorithms.so",
"name":
"Simple_fermi_Fit_TEff",
"xmax":xMaxConfig,
"ImproveFit":1},
146 thresholdConfig=thresholdConfig
148 for p
in properties_per_trigger_group[tgroup]:
152 if t
in l1menu: eff_plot_title = t+
';'+xlabel_for_prop[p]+
'; Efficiency '
153 elif t
not in l1menu
and t
in (gfex_SR_triggers + gfex_LR_triggers): eff_plot_title = t+
' Emulated;'+xlabel_for_prop[p]+
'; Efficiency '
154 else: eff_plot_title = t+
' NOT in Menu;'+xlabel_for_prop[p]+
'; Efficiency '
157 if r ==
"Muon" and p
in [
"SRpt",
"LRpt"]:
158 helper.defineHistogram(f
"bool_{r}_{t}, val_{p};{p}_{t}", type=
'TEfficiency', title=eff_plot_title, fillGroup=groupName, path=ExpertTrigPath + pathadd_per_trigger_group[tgroup]+ reference_paths[r], xbins=nbins[p], xmin=binmin[p], xmax=binmax[p], hanConfig={
"algorithm":
"JetEfficiency_"+t}, opt=
'kAlwaysCreate')
160 helper.defineHistogram(f
"bool_{r}_{t}, val_{p};{p}_{t}", type=
'TEfficiency', title=eff_plot_title, fillGroup=groupName, path=trigPath + pathadd_per_trigger_group[tgroup]+ reference_paths[r], xbins=nbins[p], xmin=binmin[p], xmax=binmax[p], opt=
'kAlwaysCreate')
164 acc = helper.result()
166 print(
"flags.DQ.Environment = " + flags.DQ.Environment )
171 Finds and returns the threshold values of the closest existing trigger.
174 closest_index = np.abs(extracted_values - trigger_value).argmin()
175 return [lower_bounds[closest_index], upper_bounds[closest_index]]
179 Estimates the DQ monitoring threshold range for a given trigger name based on given threshold_dict,
180 treating jet types (gJ, gLJ, jJ, and jLJ) as separate for extrapolation.
181 If interpolation fails, it returns the closest existing trigger values.
186 match = re.search(
r'(gJ|gLJ|jJ|jLJ)(\d+)', trigger_name)
190 trigger_type, trigger_value = match.groups()
191 trigger_value =
int(trigger_value)
194 extracted_values = []
198 for key, (low, high)
in threshold_dict.items():
199 key_match = re.search(
r'(gJ|gLJ|jJ|jLJ)(\d+)', key)
200 if key_match
and key_match.group(1) == trigger_type:
201 extracted_values.append(
int(key_match.group(2)))
202 lower_bounds.append(low)
203 upper_bounds.append(high)
205 if not extracted_values:
208 extracted_values = np.array(extracted_values)
209 lower_bounds = np.array(lower_bounds)
210 upper_bounds = np.array(upper_bounds)
213 lower_pred = np.interp(trigger_value, extracted_values, lower_bounds, left=lower_bounds[0], right=lower_bounds[-1])
214 upper_pred = np.interp(trigger_value, extracted_values, upper_bounds, left=upper_bounds[0], right=upper_bounds[-1])
216 return [lower_pred, upper_pred]
220 Returns the threshold from threshold_dict if it exists.
221 Otherwise, predicts the thresholds using estimate_thresold.
223 if trigger_name
in threshold_dict:
224 return threshold_dict[trigger_name]
226 print(
"WARNING, trigger " + trigger_name +
" doesn't have predifined thresholds for DQ Algorithm. Estimating thresholds with a fit, or using thresholds from closest exisiting trigger.")
227 print(
"Please add thresholds to the threshold_dict for trigger " + trigger_name)
233 threshold_dict = {
"L1_gJ20p0ETA25" : [55e3, 75e3],
234 "L1_gJ50p0ETA25" : [110e3, 180e3],
235 "L1_gJ100p0ETA25" : [195e3, 3000e3],
236 "L1_gJ400p0ETA25" : [620e3, 900e3],
237 "L1_gLJ80p0ETA25" : [125e3, 200e3],
238 "L1_gLJ100p0ETA25" : [150e3, 240e3],
239 "L1_gLJ140p0ETA25" : [210e3, 315e3],
240 "L1_gLJ160p0ETA25" : [240e3, 260e3],
241 "L1_jJ30" : [50e3, 85e3],
242 "L1_jJ40" : [55e3, 90e3],
243 "L1_jJ50" : [60e3, 100e3],
244 "L1_jJ60" : [90e3, 130e3],
245 "L1_jJ80" : [90e3, 155e3],
246 "L1_jJ90" : [110e3, 185e3],
247 "L1_jJ125" : [145e3, 230e3],
248 "L1_jJ140" : [160e3, 225e3],
249 "L1_jJ160" : [180e3, 260e3],
250 "L1_jJ180" : [235e3, 320e3],
251 "L1_SC111-CjJ40": [195e3, 300e3],
255 if __name__==
'__main__':
257 from AthenaCommon.Logging
import log
262 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
267 inputs = glob.glob(
'/eos/atlas/atlastier0/rucio/data18_13TeV/physics_Main/00354311/data18_13TeV.00354311.physics_Main.recon.ESD.f1129/data18_13TeV.00354311.physics_Main.recon.ESD.f1129._lb0013._SFO-8._0001.1')
270 flags.Input.Files = inputs
271 flags.Output.HISTFileName =
'ExampleMonitorOutput_LVL1.root'
277 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
278 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
283 cfg.merge(JetEfficiencyMonitorCfg)
287 JetEfficiencyMonitorCfg.getEventAlgo(
'JetEfficiencyMonAlg').OutputLevel = 1