ATLAS Offline Software
Loading...
Searching...
No Matches
JetTriggerAnalysisConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3# AnaAlgorithm import(s):
4from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
5from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
6from AthenaConfiguration.Enums import LHCPeriod
7from Campaigns.Utils import Campaign
8from TriggerAnalysisAlgorithms.TriggerAnalysisConfig import TriggerAnalysisBlock
9from TriggerAnalysisAlgorithms.TriggerAnalysisSFConfig import trigger_set
10
11
12class JetTriggerMatchingBlock (ConfigBlock):
13
14 def __init__ (self) :
15 super (JetTriggerMatchingBlock, self).__init__ ()
16 self.addOption ('triggerChainsPerYear', {}, type=dict,
17 info="a dictionary with key (string) the year and value (list of "
18 "strings) the trigger chains.")
19 self.addOption ('includeAllYearsPerRun', False, type=bool,
20 info="all configured years in the LHC run will "
21 "be included in all jobs.")
22 self.addOption ('removeHLTPrefix', True, type=bool,
23 info="remove the HLT prefix from trigger chain names.")
24 self.addOption ('containerName', '', type=str,
25 info="the input jet container, with a possible selection, in "
26 "the format `container` or `container.selection`.")
27 self.addOption ('runL1Matching', True, type=bool,
28 info="Add L1 matching decorations")
29 self.addOption ('runHLTMatching', True, type=bool,
30 info="Add HLT matching decorations")
31 self.addOption ('l1dR', 0.4, type=float,
32 info="ΔR cone for the L1 (jFEX) trigger matching "
33 "(sets CP::JetTriggerDecoratorAlg.l1dR). Default 0.4 "
34 "matches the algorithm's own default.")
35 self.addOption ('hltDR', 0.4, type=float,
36 info="ΔR cone for the HLT trigger matching "
37 "(sets CP::JetTriggerDecoratorAlg.hltDR). Default 0.4 "
38 "matches the algorithm's own default.")
39
40 def instanceName (self) :
41 """Return the instance name for this block"""
42 return self.containerName
43
44 def makeAlgs (self, config) :
45
46 triggers = trigger_set(config, self.triggerChainsPerYear,
47 self.includeAllYearsPerRun)
48 decisionTool = TriggerAnalysisBlock.makeTriggerDecisionTool(config)
49
50 for chain in triggers:
51 chain_noHLT = chain.replace("HLT_", "")
52 chain_out = chain_noHLT if self.removeHLTPrefix else chain
53 chain_out = chain_out.replace("-","_").replace(".","p")
54
55 alg = config.createAlgorithm( 'CP::JetTriggerDecoratorAlg',
56 'JetTriggerDecoratorAlg_' + chain_out )
57
58 alg.trigger = chain
59
60 # To add missing HLT jets -- only for buggy triggers
61 # These extra jets are added because of bug in trigger navigation
62 # Will be removed once bug fixed at DAOD level
63 alg.triggerBugList = [
64 "HLT_j80c_020jvt_j55c_020jvt_j28c_020jvt_j20c_020jvt_SHARED_2j20c_020jvt_bdl1d77_pf_ftf_presel2c20XX2c20b85_L1J45p0ETA21_3J15p0ETA25",
65 "HLT_j75c_020jvt_j50c_020jvt_j25c_020jvt_j20c_020jvt_SHARED_2j20c_020jvt_bgn177_pf_ftf_presel2c20XX2c20b85_L1J45p0ETA21_3J15p0ETA25"
66 ]
67
68 alg.TrigDecisionTool = f"{decisionTool.getType()}/{decisionTool.getName()}"
69
70 alg.doL1Matching = self.runL1Matching
71 alg.doHLTMatching = self.runHLTMatching
72 alg.jets = config.readName (self.containerName)
73
74 # Phase-I L1Calo (jFEX) vs legacy L1Calo is not a user choice — it is
75 # fixed by the data-taking year (data 2024+) and the MC campaign
76 # (mc23e/mc23g). Determine it automatically from the config metadata.
77 if config.dataType() is DataType.Data:
78 usePhaseIL1 = config.dataYear() >= 2024
79 else:
80 usePhaseIL1 = config.campaign() in (Campaign.MC23e, Campaign.MC23g)
81 alg.usePhaseIL1 = usePhaseIL1
82 alg.l1dR = self.l1dR
83 alg.hltDR = self.hltDR
84
85 if config.geometry() is LHCPeriod.Run2 and self.runHLTMatching:
86 # Configuration adapted from
87 # https://gitlab.cern.ch/atlas/athena/-/blob/main/Trigger/TrigEmulation/TrigBtagEmulationTool/python/TrigBtagEmulationToolConfig.py
88
89 alg.useEmulationTool = True
90 config.addPrivateTool( 'trigEmulationTool',
91 'Trig::TrigBtagEmulationTool' )
92
93 from TrigBtagEmulationTool.TrigBtagEmulationToolHelpers import (
94 TrigBtagEmulation_kwargs)
95 tool_kwargs = TrigBtagEmulation_kwargs(config.flags, [chain])
96 for prop, value in tool_kwargs.items():
97 setattr(alg.trigEmulationTool, prop, value)
98
99 alg.trigEmulationTool.TrigDecisionTool = (
100 f"{decisionTool.getType()}/{decisionTool.getName()}")
101
102 config.addPrivateTool( 'trigEmulationTool.JM_a4tcemsubjes_CNT',
103 'Trig::JetManagerTool' )
104 a4tcemsubjesJet = ('HLT_xAOD__JetContainer_a4tcemsubjesFS'
105 if config.campaign() is Campaign.MC20a or config.dataYear()==2016
106 else 'HLT_xAOD__JetContainer_a4tcemsubjesISFS')
107 alg.trigEmulationTool.JM_a4tcemsubjes_CNT.JetContainerName = a4tcemsubjesJet
108 alg.trigEmulationTool.JM_a4tcemsubjes_CNT.LHCPeriod = 2
109
110 config.addPrivateTool( 'trigEmulationTool.JM_Split_CNT',
111 'Trig::JetManagerTool' )
112 alg.trigEmulationTool.JM_Split_CNT.JetContainerName = 'HLT_xAOD__JetContainer_SplitJet'
113 alg.trigEmulationTool.JM_Split_CNT.LHCPeriod = 2
114
115 if not(config.campaign() is Campaign.MC20a or config.dataYear()==2016):
116 config.addPrivateTool( 'trigEmulationTool.JM_GSC_CNT',
117 'Trig::JetManagerTool' )
118 alg.trigEmulationTool.JM_GSC_CNT.JetContainerName = 'HLT_xAOD__JetContainer_GSCJet'
119 alg.trigEmulationTool.JM_GSC_CNT.LHCPeriod = 2
120
122 alg.L1Et = "match_" + chain_out + "_L1et_%SYS%"
123 alg.L1Eta = "match_" + chain_out + "_L1eta_%SYS%"
124 alg.L1Phi = "match_" + chain_out + "_L1phi_%SYS%"
125 alg.L1DR = "match_" + chain_out + "_L1dr_%SYS%"
126 alg.L1Threshold = "match_" + chain_out + "_L1thresholds_%SYS%"
127 for var in ["L1et", "L1eta", "L1phi", "L1dr", "L1thresholds"]:
128 config.addOutputVar (self.containerName,
129 "match_" + chain_out + "_" + var + "_%SYS%",
130 "match_" + chain_out + "_" + var, noSys=True)
131
132 if self.runHLTMatching:
133 alg.HLTPt = "match_" + chain_out + "_HLTpt_%SYS%"
134 alg.HLTEta = "match_" + chain_out + "_HLTeta_%SYS%"
135 alg.HLTPhi = "match_" + chain_out + "_HLTphi_%SYS%"
136 alg.HLTDR = "match_" + chain_out + "_HLTdr_%SYS%"
137 alg.HLTThreshold = "match_" + chain_out + "_HLTthresholds_%SYS%"
138 for var in ["HLTpt", "HLTeta", "HLTphi", "HLTdr", "HLTthresholds"]:
139 config.addOutputVar (self.containerName,
140 "match_" + chain_out + "_" + var + "_%SYS%",
141 "match_" + chain_out + "_" + var, noSys=True)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312