ATLAS Offline Software
Loading...
Searching...
No Matches
InDetTrackSystematicsToolsConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2# Configuration of InDetTrackSystematicsTools package
3from AnaAlgorithm.DualUseConfig import isAthena
4if isAthena:
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7from AthenaConfiguration.Enums import LHCPeriod
8from Campaigns.Utils import Campaign
9from AthenaCommon.Logging import logging
10
11def InDetTrackTruthOriginToolCfg(flags, name="InDetTrackTruthOriginTool", **kwargs):
12 acc = ComponentAccumulator()
13
14 log = logging.getLogger("InDetTrackTruthOriginTool")
15 # this might fail if we're in AthAnalysis
16 try:
17 kwargs.setdefault("isFullPileUpTruth", flags.Digitization.PileUp
18 and flags.Digitization.DigiSteeringConf in ['StandardPileUpToolsAlg',
19 'StandardInTimeOnlyTruthPileUpToolsAlg',
20 'StandardInTimeOnlyGeantinoTruthPileUpToolsAlg'])
21 except AttributeError:
22 # assume this should be false if we're unable to load flags (temporary solution)
23 kwargs.setdefault("isFullPileUpTruth", False)
24 log.warning("Unable to load digi flags, assuming isFullPileUpTruth=False. Normal if you're in AthAnalysis.")
25
26 acc.setPrivateTools(
27 CompFactory.InDet.InDetTrackTruthOriginTool(name, **kwargs))
28 return acc
29
30def InDetTrackTruthFilterToolCfg(flags, name="InDetTrackTruthFilterTool", **kwargs):
31 acc = ComponentAccumulator()
32
33 if "trackOriginTool" not in kwargs:
34 kwargs.setdefault("trackOriginTool", acc.popToolsAndMerge(
36
37 # 2022 recommendations (MC23a)
38 if flags.Input.MCCampaign in [Campaign.MC23a, Campaign.MC23d, Campaign.MC23e]:
39 kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root")
40 kwargs.setdefault("fFakeLoose", 0.40)
41 kwargs.setdefault("fFakeTight", 1.00)
42 # Run 2 recommendations (MC20)
43 elif flags.GeoModel.Run is LHCPeriod.Run2:
44 kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root")
45 kwargs.setdefault("fFakeLoose", 0.10)
46 kwargs.setdefault("fFakeTight", 1.00)
47 else:
48 raise ValueError(f"InDetTrackTruthFilterTool: Recommendations not yet available for campaign {flags.Input.MCCampaign}! Please check the configuration and contact Tracking CP if you believe this message is in error.")
49
50 acc.setPrivateTools(
51 CompFactory.InDet.InDetTrackTruthFilterTool(name, **kwargs))
52 return acc
53
54def JetTrackFilterToolCfg(flags, name="JetTrackFilterTool", **kwargs):
55 acc = ComponentAccumulator()
56
57 if "trackOriginTool" not in kwargs:
58 kwargs.setdefault("trackOriginTool", acc.popToolsAndMerge(
60
61 # TIDE fake rate recommendations:
62 # Run 3 (MC23): https://indico.cern.ch/event/1587937/#40-fake-tracks-in-the-jet-core
63 if flags.GeoModel.Run >= LHCPeriod.Run3:
64 kwargs.setdefault("FakeUncertainty", 0.25)
65 # Run 2 (MC20): https://cds.cern.ch/record/2859907
66 else:
67 kwargs.setdefault("FakeUncertainty", 0.35)
68
69 # TIDE FLost recommendations:
70 # Run 3 (MC23)
71 if flags.GeoModel.Run >= LHCPeriod.Run3:
72 # 2022/23 (MC23a/d): https://indico.cern.ch/event/1531052/#38-flost-update
73 if flags.Input.MCCampaign in [Campaign.MC23a, Campaign.MC23d]:
74 kwargs.setdefault("FLostUncertainty", 0.24)
75 # 2024 (MC23e): https://indico.cern.ch/event/1662051/#46-update-on-2024-flost-measur
76 elif flags.Input.MCCampaign is Campaign.MC23e:
77 kwargs.setdefault("FLostUncertainty", 0.32)
78 else:
79 raise ValueError(f"JetTrackFilterTool: Recommendations not yet available for campaign {flags.Input.MCCampaign}! Please check the configuration and contact Tracking CP if you believe this message is in error.")
80 # Run 2 (MC20)
81 else:
82 kwargs.setdefault("FLostUncertainty", 0.24)
83
84 acc.setPrivateTools(CompFactory.InDet.JetTrackFilterTool(name, **kwargs))
85 return acc
86
87def InclusiveTrackFilterToolCfg(flags, name="InclusiveTrackFilterTool", **kwargs):
88 acc = ComponentAccumulator()
89
90 # 2022 recommendations (MC23a)
91 if flags.Input.MCCampaign is Campaign.MC23a:
92 kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/LargeD0TrackingRecommendations_mc23a.root")
93 elif flags.Input.MCCampaign is Campaign.MC23d:
94 kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/LargeD0TrackingRecommendations_mc23d.root")
95 elif flags.Input.MCCampaign is Campaign.MC23e:
96 kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/LargeD0TrackingRecommendations_mc23e.root")
97 # Run 2 recommendations (MC20)
98 elif flags.GeoModel.Run is LHCPeriod.Run2:
99 kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_24.0_2023-v00/LargeD0TrackingRecommendations_20230824.root")
100 else:
101 raise ValueError(f"InclusiveTrackFilterTool: Recommendations not yet available for campaign {flags.Input.MCCampaign}! Please check the configuration and contact Tracking CP if you believe this message is in error.")
102
103 acc.setPrivateTools(
104 CompFactory.InDet.InclusiveTrackFilterTool(name, **kwargs))
105 return acc
106
107def InDetTrackSmearingToolCfg(flags, name="InDetTrackSmearingTool", **kwargs):
108 acc = ComponentAccumulator()
109
110 # 2022 recommendations (MC23a)
111 if flags.Input.MCCampaign is Campaign.MC23a:
112 kwargs.setdefault("calibFileIP_CTIDE", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/2022_d0z0_smearing_factors_v2.root")
113 # 2023 recommendations (MC23d)
114 elif flags.Input.MCCampaign is Campaign.MC23d:
115 kwargs.setdefault("calibFileIP_CTIDE", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/2023_d0z0_smearing_factors_v2.root")
116 # 2024 recommendations (MC23e)
117 elif flags.Input.MCCampaign is Campaign.MC23e:
118 kwargs.setdefault("calibFileIP_CTIDE", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/2024_d0z0_smearing_factors.root")
119 # Run 2 recommendations (MC20)
120 elif flags.GeoModel.Run is LHCPeriod.Run2:
121 kwargs.setdefault("calibFileIP_CTIDE", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/d0z0_smearing_factors_Run2_v2.root")
122 elif "calibFileIP_CTIDE" not in kwargs:
123 raise ValueError(f"InDetTrackSmearingTool: Recommendations not yet available for campaign {flags.Input.MCCampaign}! Please check the configuration and contact Tracking CP if you believe this message is in error.")
124
125 acc.setPrivateTools(
126 CompFactory.InDet.InDetTrackSmearingTool(name, **kwargs))
127 return acc
128
130 """Return calibFiles/runNumberBounds kwargs for InDetTrackBiasingTool.
131
132 Selects campaign-specific calibration files and (for multi-period
133 campaigns) run-number boundaries. Raises ValueError for unknown
134 campaigns or geometries.
135 """
136 c2 = "InDetTrackSystematicsTools/CalibData_22.0_2022-v00"
137 c3 = "InDetTrackSystematicsTools/CalibData_25.2_2025-v00"
138 if flags.GeoModel.Run is LHCPeriod.Run2:
139 if flags.Input.MCCampaign is Campaign.MC20a:
140 # 2015 + 2016 recommendations (MC20a)
141 return {
142 "calibFiles": [
143 f"{c2}/REL22_REPRO_2015.root",
144 f"{c2}/REL22_REPRO_2016_1stPart.root",
145 f"{c2}/REL22_REPRO_2016_2ndPart.root",
146 ],
147 "runNumberBounds": [0, 296938, 301912, 999999],
148 }
149 elif flags.Input.MCCampaign is Campaign.MC20d:
150 # 2017 recommendations (MC20d)
151 return {
152 "calibFiles": [
153 f"{c2}/REL22_REPRO_2017_1stPart.root",
154 f"{c2}/REL22_REPRO_2017_2ndPart.root",
155 ],
156 "runNumberBounds": [0, 334842, 999999],
157 }
158 elif flags.Input.MCCampaign is Campaign.MC20e:
159 # 2018 recommendations (MC20e)
160 return {
161 "calibFiles": [
162 f"{c2}/REL22_REPRO_2018_1stPart.root",
163 f"{c2}/REL22_REPRO_2018_2ndPart.root",
164 ],
165 "runNumberBounds": [0, 353000, 999999],
166 }
167 else:
168 raise ValueError(
169 'No biasing recommendations found for campaign "'
170 + flags.Input.MCCampaign.value
171 + '" in Run 2. Please check the configuration.'
172 )
173 elif flags.GeoModel.Run is LHCPeriod.Run3:
174 if flags.Input.MCCampaign is Campaign.MC23a:
175 # 2022 recommendations (MC23a)
176 return {
177 "calibFiles": [
178 f"{c3}/2022_d0z0qoverp_biasing_factor.root",
179 ]
180 }
181 elif flags.Input.MCCampaign is Campaign.MC23d:
182 # 2023 recommendations (MC23d)
183 return {
184 "calibFiles": [
185 f"{c3}/2023_d0z0qoverp_biasing_factor.root",
186 ]
187 }
188 elif flags.Input.MCCampaign is Campaign.MC23e:
189 # 2024 recommendations (MC23e)
190 return {
191 "calibFiles": [
192 f"{c3}/2024_d0z0qoverp_biasing_factor.root",
193 ]
194 }
195 else:
196 raise ValueError(
197 'No biasing recommendations found for campaign "'
198 + flags.Input.MCCampaign.value
199 + '" in Run 3. Please check the configuration.'
200 )
201 else:
202 raise ValueError(
203 'No biasing recommendations found for geometry "'
204 + flags.GeoModel.Run.value
205 + '". Please check the configuration.'
206 )
207
208
209def InDetTrackBiasingToolCfg(flags, name="InDetTrackBiasingTool",
210 **kwargs):
211 acc = ComponentAccumulator()
212 kwargs.setdefault("isMC", flags.Input.isMC)
213 if "calibFiles" not in kwargs:
214 kwargs.update(InDetTrackBiasingCalibKwargs(flags))
215 acc.setPrivateTools(
216 CompFactory.InDet.InDetTrackBiasingTool(name, **kwargs))
217 return acc
218
219def TrackSystematicsAlgCfg(flags, name="InDetTrackSystematicsAlg", **kwargs):
220 acc = ComponentAccumulator()
221
222 if "TrackFilterToolLRT" not in kwargs:
223 kwargs.setdefault("TrackFilterToolLRT", acc.popToolsAndMerge(
225
226 if "TrackFilterToolSTD" not in kwargs:
227 kwargs.setdefault("TrackFilterToolSTD", acc.popToolsAndMerge(
229
230 acc.addEventAlgo(CompFactory.InDet.TrackSystematicsAlg(name, **kwargs))
231 return acc
232
233
234def TrackSmearingAlgCfg(flags, syst, input_tracks, output_tracks,
235 bias_kwargs={}):
236 """Shallow-copy input_tracks and apply smearing/biasing for one syst.
237
238 syst is a single smearing variation string (TRK_RES_*, TRK_BIAS_*), or
239 empty for a nominal (un-smeared) copy. Produces output_tracks as a
240 shallow copy with modified d0/z0/qoverp values.
241
242 Any extra keyword arguments are forwarded to InDetTrackBiasingToolCfg
243 as calibration kwargs (calibFiles, runNumberBounds, ...). If none are
244 supplied, InDetTrackBiasingCalibKwargs(flags) is called to derive them;
245 exceptions from that call propagate to the caller.
246 """
247 ca = ComponentAccumulator()
248
249 smearingTool = ca.popToolsAndMerge(InDetTrackSmearingToolCfg(flags))
250 ca.addPublicTool(smearingTool)
251
252 # Only configure the biasing tool for TRK_BIAS_* systematics.
253 # The tool reads RandomRunNumber unconditionally (needs PRW), so
254 # configuring it for nominal or RES systematics would require PRW
255 # to be scheduled even when no biasing is needed.
256 biasingTool = None
257 if 'BIAS' in syst or bias_kwargs:
258 if not bias_kwargs:
259 bias_kwargs = InDetTrackBiasingCalibKwargs(flags)
260 if bias_kwargs:
261 biasingTool = ca.popToolsAndMerge(
262 InDetTrackBiasingToolCfg(flags, **bias_kwargs))
263 ca.addPublicTool(biasingTool)
264
265 alg = CompFactory.InDet.TrackSmearingAlg(
266 f'TrackSmearingAlg_{output_tracks}',
267 SmearingTool=smearingTool,
268 InputTrackContainer=input_tracks,
269 OutputTrackContainer=output_tracks,
270 SystematicVariation=syst,
271 )
272 if biasingTool is not None:
273 alg.BiasingTool = biasingTool
274
275 ca.addEventAlgo(alg)
276 return ca
277
278
280 flags, syst, jet_collection,
281 in_ghost_tracks, out_ghost_tracks):
282 """Filter ghost-track links on jets for one filter systematic.
283
284 syst is a single filter variation string (TRK_EFF_*, TRK_FAKE_RATE_*).
285 Reads in_ghost_tracks decoration from jet_collection, applies filter
286 tools per-track (dispatching LRT vs STD by patternRecoInfo bit 49),
287 and writes surviving links to out_ghost_tracks.
288 """
289 assert syst, "JetTrackFilteringAlgCfg called with empty syst"
290
291 ca = ComponentAccumulator()
292
293 is_larged0 = 'LARGED0' in syst
294 is_tide = 'TIDE' in syst
295
296 alg = CompFactory.InDet.JetTrackFilteringAlg(
297 f'JetTrackFilteringAlg_{out_ghost_tracks}',
298 JetCollection=jet_collection,
299 InGhostTracks=in_ghost_tracks,
300 OutGhostTracks=out_ghost_tracks,
301 SystematicVariation=syst,
302 )
303 if not is_larged0:
304 alg.STDFilterTool = ca.popToolsAndMerge(
306 )
307 ca.addPublicTool(alg.STDFilterTool)
308 if is_larged0:
309 alg.LRTFilterTool = ca.popToolsAndMerge(
311 )
312 ca.addPublicTool(alg.LRTFilterTool)
313 if is_tide:
314 alg.JetFilterTool = ca.popToolsAndMerge(
316 )
317 ca.addPublicTool(alg.JetFilterTool)
318
319 ca.addEventAlgo(alg)
320 return ca
InDetTrackTruthOriginToolCfg(flags, name="InDetTrackTruthOriginTool", **kwargs)
InDetTrackSmearingToolCfg(flags, name="InDetTrackSmearingTool", **kwargs)
TrackSmearingAlgCfg(flags, syst, input_tracks, output_tracks, bias_kwargs={})
InDetTrackBiasingToolCfg(flags, name="InDetTrackBiasingTool", **kwargs)
InDetTrackTruthFilterToolCfg(flags, name="InDetTrackTruthFilterTool", **kwargs)
TrackSystematicsAlgCfg(flags, name="InDetTrackSystematicsAlg", **kwargs)
JetTrackFilteringAlgCfg(flags, syst, jet_collection, in_ghost_tracks, out_ghost_tracks)
JetTrackFilterToolCfg(flags, name="JetTrackFilterTool", **kwargs)
InclusiveTrackFilterToolCfg(flags, name="InclusiveTrackFilterTool", **kwargs)