ATLAS Offline Software
Loading...
Searching...
No Matches
ITkTrackRecoConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.Enums import Format
5from TrkConfig.TrackingPassFlags import printActiveConfig
6from AthenaCommon.Constants import WARNING, INFO
7
8_flags_set = [] # For caching
9_extensions_list = [] # For caching, possible legacy / validate Passes/Configurations
10_actsExtensions = ['Acts', 'ActsLegacy', 'ActsConversion', 'ActsLargeRadius', 'ActsLowPt', 'ActsValidateF100', 'ActsValidateF150', 'ActsValidateLargeRadiusStandalone'] # Possible Acts Alone Passes/Configurations
11_outputExtensions = [] # Passes/Configurations to be passed to the output job option
12
14 global _flags_set
15 if _flags_set:
16 return _flags_set
17
18 flags_set = []
19
20 # Primary Pass(es)
21 from TrkConfig.TrkConfigFlags import TrackingComponent
22 validation_configurations = {
23 TrackingComponent.ActsValidateClusters : "ActsValidateClusters",
24 TrackingComponent.ActsValidateSpacePoints : "ActsValidateSpacePoints",
25 TrackingComponent.ActsValidateSeeds : "ActsValidateSeeds",
26 TrackingComponent.ActsValidateConversionSeeds : "ActsValidateConversionSeeds",
27 TrackingComponent.ActsValidateLargeRadiusSeeds: "ActsValidateLargeRadiusSeeds",
28 TrackingComponent.ActsValidateLargeRadiusStandalone: "ActsValidateLargeRadiusStandalone",
29 TrackingComponent.ActsValidateTracks : "ActsValidateTracks",
30 TrackingComponent.ActsValidateAmbiguityResolution : "ActsValidateAmbiguityResolution",
31 TrackingComponent.ActsValidateF100 : "ActsValidateF100",
32 TrackingComponent.ActsValidateF150 : "ActsValidateF150",
33 }
34
35 # Athena Pass
36 if TrackingComponent.AthenaChain in flags.Tracking.recoChain:
37 flags_set += [flags.cloneAndReplace(
38 "Tracking.ActiveConfig",
39 f"Tracking.{flags.Tracking.ITkPrimaryPassConfig.value}Pass")]
40
41 # Acts Pass - Legacy like
42 if TrackingComponent.ActsLegacyChain in flags.Tracking.recoChain:
43 flags_set += [flags.cloneAndReplace(
44 "Tracking.ActiveConfig",
45 "Tracking.ITkActsLegacyPass")]
46
47 # Acts Pass - Fast Tracking based
48 if TrackingComponent.ActsChain in flags.Tracking.recoChain:
49 flags_set += [flags.cloneAndReplace(
50 "Tracking.ActiveConfig",
51 "Tracking.ITkActsPass")]
52
53 # Acts Heavy Ion Pass
54 if TrackingComponent.ActsHeavyIon in flags.Tracking.recoChain:
55 flags_set += [flags.cloneAndReplace(
56 "Tracking.ActiveConfig",
57 "Tracking.ITkActsHeavyIonPass")]
58
59 # GNN pass
60 if TrackingComponent.GNNChain in flags.Tracking.recoChain:
61 flags_set += [flags.cloneAndReplace(
62 "Tracking.ActiveConfig",
63 "Tracking.ITkGNNPass")]
64
65 # Acts Conversion Pass
66 if flags.Detector.EnableCalo and flags.Acts.doITkConversion and \
67 TrackingComponent.ActsValidateConversionSeeds not in flags.Tracking.recoChain:
68 flags_set += [flags.cloneAndReplace(
69 "Tracking.ActiveConfig",
70 "Tracking.ITkActsConversionPass")]
71
72 # Acts Large Radius Pass
73 if flags.Acts.doLargeRadius:
74 flags_set += [flags.cloneAndReplace(
75 "Tracking.ActiveConfig",
76 "Tracking.ITkActsLargeRadiusPass")]
77
78 # Acts Low Pt Pass
79 if flags.Acts.doLowPt:
80 flags_set += [flags.cloneAndReplace(
81 "Tracking.ActiveConfig",
82 "Tracking.ITkActsLowPtPass")]
83
84 # Acts Validation Passes
85 for [configuration, key] in validation_configurations.items():
86 if configuration in flags.Tracking.recoChain:
87 toAdd = eval(f"flags.cloneAndReplace('Tracking.ActiveConfig', 'Tracking.ITk{key}Pass')")
88 flags_set += [toAdd]
89
90 # Photon conversion tracking reco
91 if flags.Detector.EnableCalo and flags.Tracking.doITkConversion:
92 flagsConv = flags.cloneAndReplace("Tracking.ActiveConfig",
93 "Tracking.ITkConversionPass")
94 flags_set += [flagsConv]
95
96 # LRT
97 if flags.Tracking.doLargeD0:
98 if flags.Tracking.useITkFTF:
99 flagsLRT = flags.cloneAndReplace("Tracking.ActiveConfig",
100 "Tracking.ITkFTFLargeD0Pass")
101 elif flags.Tracking.doITkFastTracking:
102 flagsLRT = flags.cloneAndReplace("Tracking.ActiveConfig",
103 "Tracking.ITkLargeD0FastPass")
104 else:
105 flagsLRT = flags.cloneAndReplace("Tracking.ActiveConfig",
106 "Tracking.ITkLargeD0Pass")
107 flags_set += [flagsLRT]
108
109
110 if TrackingComponent.FPGAChain in flags.Tracking.recoChain:
111 flags_set += [flags.cloneAndReplace(
112 "Tracking.ActiveConfig",
113 "Tracking.ITkFPGAPass")]
114
115 # LowPt
116 if flags.Tracking.doLowPt:
117 flagsLowPt = flags.cloneAndReplace("Tracking.ActiveConfig",
118 "Tracking.ITkLowPtPass")
119 flags_set += [flagsLowPt]
120
121 _flags_set = flags_set # Put into cache
122
123 return flags_set
124
125
127 flags_set = CombinedTrackingPassFlagSets(flags)
128 extension = flags_set[-1].Tracking.ActiveConfig.extension
129 ClusterSplitProbContainer = "ITkAmbiguityProcessorSplitProb" + extension
130 return ClusterSplitProbContainer
131
132
134 TrackContainer: str ="",
135 ClusterSplitProbContainer: str = "") -> ComponentAccumulator:
136 result = ComponentAccumulator()
137 extension = flags.Tracking.ActiveConfig.extension
138 if flags.hasCategory("TrackOverlay.ActiveConfig"):
139 doTrackOverlay = getattr(flags.TrackOverlay.ActiveConfig, "doTrackOverlay", None)
140 else:
141 doTrackOverlay = flags.Overlay.doTrackOverlay
142
143 if doTrackOverlay:
144 # schedule merger to combine signal and background tracks
145 InputTracks = [flags.Overlay.SigPrefix+TrackContainer,
146 flags.Overlay.BkgPrefix+TrackContainer]
147 AssociationMapName = ("PRDtoTrackMapMerge_Resolved" +
148 extension + "Tracks")
149 MergerOutputTracks = TrackContainer
150
151 from TrkConfig.TrkTrackCollectionMergerConfig import TrackCollectionMergerAlgCfg
152 result.merge(TrackCollectionMergerAlgCfg(
153 flags,
154 name="TrackCollectionMergerAlgCfg"+extension,
155 InputCombinedTracks=InputTracks,
156 OutputCombinedTracks=MergerOutputTracks,
157 AssociationMapName=AssociationMapName))
158
159 # Run truth, but only do this for non ACTS workflows
160 if flags.Tracking.doTruth and extension not in _actsExtensions:
161 from InDetConfig.ITkTrackTruthConfig import ITkTrackTruthCfg
162 result.merge(ITkTrackTruthCfg(
163 flags,
164 Tracks=TrackContainer,
165 DetailedTruth=TrackContainer+"DetailedTruth",
166 TracksTruth=TrackContainer+"TruthCollection"))
167
168 # Create track particles from all the different track collections
169 # We have different algorithms depending on the EDM being used
170 if extension not in _actsExtensions:
171 # Workflows that use Trk Tracks
172 from xAODTrackingCnv.xAODTrackingCnvConfig import ITkTrackParticleCnvAlgCfg
173 result.merge(ITkTrackParticleCnvAlgCfg(
174 flags,
175 name=extension + "TrackParticleCnvAlg",
176 TrackContainerName=TrackContainer,
177 xAODTrackParticlesFromTracksContainerName=(
178 "InDet" + extension + "TrackParticles"),
179 ClusterSplitProbabilityName=(
180 "" if flags.Tracking.doITkFastTracking else
181 ClusterSplitProbContainer),
182 AssociationMapName=""))
183 else:
184 # Workflows that use Acts Tracks
185 from ActsConfig.ActsTrackFindingConfig import ActsTrackToTrackParticleCnvAlgCfg
186 # The following few lines will disappear once we have imposed a proper nomenclature for our algorithms and collection
187 prefix = flags.Tracking.ActiveConfig.extension
188 result.merge(ActsTrackToTrackParticleCnvAlgCfg(flags, f"{prefix}ResolvedTrackToAltTrackParticleCnvAlg",
189 ACTSTracksLocation=[TrackContainer],
190 TrackParticlesOutKey=f'InDet{prefix}TrackParticles'))
191
192 if flags.Tracking.doTruth :
193 from ActsConfig.ActsTruthConfig import ActsTrackParticleTruthDecorationAlgCfg
194 result.merge(ActsTrackParticleTruthDecorationAlgCfg(flags,
195 name=f'{TrackContainer}ParticleTruthDecorationAlg',
196 TrackToTruthAssociationMaps = [f'{TrackContainer}ToTruthParticleAssociation'],
197 TrackParticleContainerName = f'InDet{prefix}TrackParticles'
198 ))
199 return result
200
201
202# Returns CA + ClusterSplitProbContainer
204 previousActsExtension: str = None,
205 InputCombinedITkTracks: list[str] = None,
206 InputCombinedActsTracks: list[str] = None,
207 InputExtendedITkTracks: list[str] = None,
208 StatTrackCollections: list[str] = None,
209 StatTrackTruthCollections: list[str] = None,
210 ClusterSplitProbContainer: str = ""):
211 # We use these lists to store the collections from all the tracking passes, thus keeping the history
212 # of previous passes. None of these lists is allowed to be a None
213 assert InputCombinedITkTracks is not None and isinstance(InputCombinedITkTracks, list)
214 assert InputCombinedActsTracks is not None and isinstance(InputCombinedActsTracks, list)
215 assert InputExtendedITkTracks is not None and isinstance(InputExtendedITkTracks, list)
216 assert StatTrackCollections is not None and isinstance(StatTrackCollections, list)
217 assert StatTrackTruthCollections is not None and isinstance(StatTrackTruthCollections ,list)
218
219 # Get the tracking pass extension name
220 extension = flags.Tracking.ActiveConfig.extension
221
222 result = ComponentAccumulator()
223 if flags.hasCategory("TrackOverlay.ActiveConfig"):
224 doTrackOverlay = getattr(flags.TrackOverlay.ActiveConfig, "doTrackOverlay", None)
225 else:
226 doTrackOverlay = flags.Overlay.doTrackOverlay
227
228 # Define collection name(s)
229 # This is the track collection AFTER the ambiguity resolution
230 TrackContainer = "Resolved" + extension + "Tracks"
231 # For Acts we have another convention, with the extention as the first element in the name
232 if extension in _actsExtensions:
233 TrackContainer = extension + "ResolvedTracks" if flags.Acts.doAmbiguityResolution else extension + "Tracks"
234 if doTrackOverlay and extension == "Conversion":
235 TrackContainer = flags.Overlay.SigPrefix + TrackContainer
236
237 # This is the track collection BEFORE the ambiguity resolution
238 SiSPSeededTracks = "SiSPSeeded" + extension + "Tracks"
239 # For ACTS the name is totally different
240 if extension in _actsExtensions:
241 SiSPSeededTracks = extension + "Tracks"
242
243 # This performs track finding
244 from InDetConfig.ITkTrackingSiPatternConfig import ITkTrackingSiPatternCfg
245 result.merge(ITkTrackingSiPatternCfg(
246 flags,
247 previousActsExtension=previousActsExtension,
248 InputCollections=InputExtendedITkTracks,
249 ResolvedTrackCollectionKey=TrackContainer,
250 SiSPSeededTrackCollectionKey=SiSPSeededTracks,
251 ClusterSplitProbContainer=ClusterSplitProbContainer))
252 StatTrackCollections += [SiSPSeededTracks, TrackContainer]
253 StatTrackTruthCollections += [SiSPSeededTracks+"TruthCollection",
254 TrackContainer+"TruthCollection"]
255
256 if doTrackOverlay and extension == "Conversion":
257 TrackContainer = "Resolved" + extension + "Tracks"
259 flags,
260 TrackContainer=TrackContainer,
261 ClusterSplitProbContainer=ClusterSplitProbContainer))
262
263 if flags.Tracking.ActiveConfig.storeSeparateContainer:
264 # If we do not want the track collection to be merged with another collection
265 # then we immediately create the track particles from it
266 # This happens inside ITkStoreTrackSeparateContainerCfg
267
268 # Track container, for ACTS workflow, depends on whether we activated the ambiguity resolution or not
269 inputTrack = TrackContainer
270 if extension in _actsExtensions and not flags.Tracking.ActiveConfig.doActsAmbiguityResolution:
271 inputTrack = SiSPSeededTracks
272
274 flags,
275 TrackContainer=inputTrack,
276 ClusterSplitProbContainer=ClusterSplitProbContainer))
277 else:
278 # ClusterSplitProbContainer is used for removing measurements used in previous passes
279 # For ACTS this is still not possible, TO BE IMPLEMENTED
280 ClusterSplitProbContainer = (
281 "ITkAmbiguityProcessorSplitProb" + extension)
282 # Collect all the Trk Track collections to be then merged in a single big collection
283 # Merging will be done later, and after that we create track particles from the merged collection
284 if extension not in _actsExtensions:
285 InputCombinedITkTracks += [TrackContainer]
286 else:
287 InputCombinedActsTracks += [TrackContainer]
288
289 # This is only used in this same function for the Track-PRD association
290 # Not yet supported for ACTS tracks
291 if extension not in _actsExtensions:
292 InputExtendedITkTracks += [TrackContainer]
293
294 return result, ClusterSplitProbContainer
295
296
298 InputCombinedITkTracks: list[str] = None,
299 ActsTrackContainerName="InDetActsTrackParticles") -> ComponentAccumulator:
300 # Inputs must not be None
301 assert InputCombinedITkTracks is not None and isinstance(InputCombinedITkTracks, list)
302
303 acc = ComponentAccumulator()
304 if len(InputCombinedITkTracks) == 0:
305 return acc
306
307 # Schedule Track particle creation
308 from ActsConfig.ActsTrackFindingConfig import ActsTrackToTrackParticleCnvAlgCfg
309 acc.merge(ActsTrackToTrackParticleCnvAlgCfg(flags, "ActsCombinedTrackToTrackParticleCnvAlg",
310 ACTSTracksLocation=InputCombinedITkTracks,
311 TrackParticlesOutKey=ActsTrackContainerName))
312 if flags.Tracking.doTruth :
313 from ActsConfig.ActsTruthConfig import ActsTrackParticleTruthDecorationAlgCfg
314 track_to_truth_maps=[]
315 for track_container in InputCombinedITkTracks :
316 track_to_truth_maps += [f'{track_container}ToTruthParticleAssociation']
317 # note: suppress stat dumps from ActsTrackParticleTruthDecorationAlg if there is only
318 # a single input collection, because it duplicates in that case the output of
319 # the TrackFindingValidationAlg
320 acc.merge(ActsTrackParticleTruthDecorationAlgCfg(
321 flags,
322 name=f'{ActsTrackContainerName}TruthDecorationAlg',
323 TrackToTruthAssociationMaps = track_to_truth_maps,
324 TrackParticleContainerName = ActsTrackContainerName,
325 OutputLevel=WARNING if len(InputCombinedITkTracks)==1 else INFO,
326 ComputeTrackRecoEfficiency=False if len(InputCombinedITkTracks)==1 else True
327 ))
328 return acc
329
331 InputCombinedITkTracks: list[str] = None,
332 StatTrackCollections: list[str] = None,
333 StatTrackTruthCollections: list[str] = None):
334 # None of the input collection is supposed to be None
335 assert InputCombinedITkTracks is not None and isinstance(InputCombinedITkTracks, list)
336 assert StatTrackCollections is not None and isinstance(StatTrackCollections, list)
337 assert StatTrackTruthCollections is not None and isinstance(StatTrackTruthCollections, list)
338
339 # If there are no tracks return directly
340 result = ComponentAccumulator()
341 if len(InputCombinedITkTracks) == 0:
342 return result
343
344 if flags.hasCategory("TrackOverlay.ActiveConfig"):
345 doTrackOverlay = getattr(flags.TrackOverlay.ActiveConfig, "doTrackOverlay", None)
346 else:
347 doTrackOverlay = flags.Overlay.doTrackOverlay
348
349 TrackContainer = "CombinedITkTracks"
350 if doTrackOverlay:
351 #schedule merge to combine signal and background tracks
352 InputCombinedITkTracks += [flags.Overlay.BkgPrefix + TrackContainer]
353
354 from TrkConfig.TrkConfigFlags import TrackingComponent
355 doGNNWithoutAmbiReso = (TrackingComponent.GNNChain in flags.Tracking.recoChain and (not flags.Tracking.GNN.doAmbiResolution))
356 skipClusterMerge = doGNNWithoutAmbiReso or flags.Tracking.doITkFastTracking
357 # This merges track collections
358 from TrkConfig.TrkTrackCollectionMergerConfig import (
359 ITkTrackCollectionMergerAlgCfg)
360 result.merge(ITkTrackCollectionMergerAlgCfg(
361 flags,
362 InputCombinedTracks=InputCombinedITkTracks,
363 OutputCombinedTracks=TrackContainer,
364 AssociationMapName=(
365 "" if skipClusterMerge else
366 f"PRDtoTrackMapMerge_{TrackContainer}")))
367
368 if flags.Tracking.doTruth:
369 from InDetConfig.ITkTrackTruthConfig import ITkTrackTruthCfg
370 result.merge(ITkTrackTruthCfg(
371 flags,
372 Tracks=TrackContainer,
373 DetailedTruth=f"{TrackContainer}DetailedTruth",
374 TracksTruth=f"{TrackContainer}TruthCollection"))
375
376 StatTrackCollections += [TrackContainer]
377 StatTrackTruthCollections += [f"{TrackContainer}TruthCollection"]
378
379 if flags.Tracking.doSlimming:
380 from TrkConfig.TrkTrackSlimmerConfig import TrackSlimmerCfg
381 result.merge(TrackSlimmerCfg(
382 flags,
383 TrackLocation=[TrackContainer]))
384
385 splitProbName = ITkClusterSplitProbabilityContainerName(flags)
386
387 # This creates track particles
388 if flags.Tracking.perigeeExpression == "BeamLine":
389 from xAODTrackingCnv.xAODTrackingCnvConfig import ITkTrackParticleCnvAlgCfg
390 result.merge(ITkTrackParticleCnvAlgCfg(
391 flags,
392 ClusterSplitProbabilityName=(
393 "" if skipClusterMerge else
394 splitProbName),
395 AssociationMapName=(
396 "" if skipClusterMerge else
397 f"PRDtoTrackMapMerge_{TrackContainer}"),
398 isActsAmbi = 'ActsValidateResolvedTracks' in splitProbName or \
399 'ActsValidateAmbiguityResolution' in splitProbName or \
400 'ActsValidateScoreBasedAmbiguityResolution' in splitProbName or \
401 'ActsConversion' in splitProbName or \
402 'ActsLargeRadius' in splitProbName or \
403 'ActsValidateLargeRadiusStandalone' in splitProbName or \
404 'ActsLowPt' in splitProbName or \
405 ('Acts' in splitProbName and 'Validate' not in splitProbName) ))
406
407 return result
408
409
410def ITkStatsCfg(flags, StatTrackCollections=None,
411 StatTrackTruthCollections=None):
412 result = ComponentAccumulator()
413
414 from InDetConfig.InDetRecStatisticsConfig import (
415 ITkRecStatisticsAlgCfg)
416 result.merge(ITkRecStatisticsAlgCfg(
417 flags,
418 TrackCollectionKeys=StatTrackCollections,
419 TrackTruthCollectionKeys=(
420 StatTrackTruthCollections if flags.Tracking.doTruth else [])))
421
422 if flags.Tracking.doTruth:
423 from InDetConfig.InDetTrackClusterAssValidationConfig import (
424 ITkTrackClusterAssValidationCfg)
425 result.merge(ITkTrackClusterAssValidationCfg(
426 flags,
427 TracksLocation=StatTrackCollections))
428
429 return result
430
431
433 result = ComponentAccumulator()
434
435 #Add the truth origin to the truth particles
436 from InDetConfig.InDetPrepRawDataToxAODConfig import ITkActsPrepDataToxAODCfg
437 result.merge(ITkActsPrepDataToxAODCfg(flags))
438
439 return result
440
442 result = ComponentAccumulator()
443
444 if flags.Tracking.doTIDE_AmbiTrackMonitoring:
445 from InDetConfig.InDetPrepRawDataToxAODConfig import (
446 ITkPixelPrepDataToxAOD_ExtraTruthCfg as PixelPrepDataToxAODCfg,
447 ITkStripPrepDataToxAOD_ExtraTruthCfg as StripPrepDataToxAODCfg)
448 else:
449 from InDetConfig.InDetPrepRawDataToxAODConfig import (
450 ITkPixelPrepDataToxAODCfg as PixelPrepDataToxAODCfg,
451 ITkStripPrepDataToxAODCfg as StripPrepDataToxAODCfg)
452
453 result.merge(PixelPrepDataToxAODCfg(
454 flags,
455 ClusterSplitProbabilityName=(
456 "" if flags.Tracking.doITkFastTracking else
458 result.merge(StripPrepDataToxAODCfg(flags))
459
460 from DerivationFrameworkInDet.InDetToolsConfig import (
461 ITkTSOS_CommonKernelCfg)
462 # Set up one algorithm for each output tracking container
463 # Always done for default pass
464 # Done for other passes if pass requests to store track seeds OR track candidates OR requests separate container
465 # Input handling/configuration of algorithm for specific cases is done in TSOS_CommonKernelCfg
466 listOfExtensionsRequesting = [
467 e for e in _extensions_list if (e == '')
468 or (flags.Tracking[f"ITk{e}Pass"].storeTrackSeeds) # Store Si track seeds
469 or (flags.Tracking[f"ITk{e}Pass"].storeSiSPSeededTracks) # Store Si candidate tracks
470 or (flags.Tracking[f"ITk{e}Pass"].storeSeparateContainer) ] # Particular tracking pass requesting separate container from main pass
471
472 result.merge(ITkTSOS_CommonKernelCfg(
473 flags, listOfExtensions = listOfExtensionsRequesting))
474
475 if flags.Tracking.doStoreTrackSeeds:
476 from DerivationFrameworkInDet.InDetToolsConfig import (
477 ITkSiSPSeedsTSOS_CommonKernelCfg)
478 # Setup one algorithm for each output tracking container
479 listOfExtensionsRequesting = [
480 e for e in _extensions_list if (e == '') or
481 flags.Tracking[f"ITk{e}Pass"].storeTrackSeeds ]
482 result.merge(ITkSiSPSeedsTSOS_CommonKernelCfg(
483 flags, listOfExtensions = listOfExtensionsRequesting))
484
485 if flags.Tracking.doStoreSiSPSeededTracks:
486 listOfExtensionsRequesting = [
487 e for e in _extensions_list if (e=='') or
488 flags.Tracking[f"ITk{e}Pass"].storeSiSPSeededTracks ]
489 from DerivationFrameworkInDet.InDetToolsConfig import (
490 ITkSiSPTSOS_CommonKernelCfg)
491 result.merge(ITkSiSPTSOS_CommonKernelCfg(flags, listOfExtensions = listOfExtensionsRequesting))
492
493 if flags.Input.isMC:
494 listOfExtensionsRequesting = [
495 e for e in _extensions_list if (e=='') or
496 (flags.Tracking[f"ITk{e}Pass"].storeSiSPSeededTracks and
497 flags.Tracking[f"ITk{e}Pass"].storeSeparateContainer) ]
498 from InDetPhysValMonitoring.InDetPhysValDecorationConfig import (
499 ITkPhysHitDecoratorAlgCfg)
500 for extension in listOfExtensionsRequesting:
501 result.merge(ITkPhysHitDecoratorAlgCfg(
502 flags,
503 name=f"ITkPhysHit{extension}DecoratorAlg",
504 TrackParticleContainerName=f"InDet{extension}TrackParticles"))
505
506 return result
507
508
509
512
513
514def ITkTrackRecoCfg(flags) -> ComponentAccumulator:
515 """Configures complete ITk tracking """
516
517 from InDetConfig.ITkActsHelpers import primaryPassUsesActs
518 if primaryPassUsesActs(flags):
519 from InDetConfig.ITkActsTrackRecoConfig import ITkActsTrackRecoCfg
520 return ITkActsTrackRecoCfg(flags)
521
522 result = ComponentAccumulator()
523
524 if flags.Input.Format is Format.BS:
525 # TODO: ITk BS providers
526 raise RuntimeError("ByteStream inputs not supported")
527
528 # Get all the requested tracking passes
529 flags_set = CombinedTrackingPassFlagSets(flags)
530
531 # Store the names of several collections from all the different passes
532 # These collections will then be used for different purposes
533
534 # Tracks to be ultimately merged in InDetTrackParticle collection
535 InputCombinedITkTracks = []
536 # Same but for ACTS collection
537 InputCombinedActsTracks = []
538 # Includes also tracks which end in standalone TrackParticle collections
539 InputExtendedITkTracks = []
540 # Cluster split prob container for measurement removal
541 ClusterSplitProbContainer = ""
542 # To be passed to the InDetRecStatistics alg
543 StatTrackCollections = []
544 StatTrackTruthCollections = []
545 # Record previous ACTS extension
546 previousActsExtension = None
547
548 from InDetConfig.SiliconPreProcessing import ITkRecPreProcessingSiliconCfg
549
550 for current_flags in flags_set:
551 printActiveConfig(current_flags)
552
553
554 extension = current_flags.Tracking.ActiveConfig.extension
555 if extension not in _actsExtensions:
556 _extensions_list.append(extension)
557
558 # Add the extension to the output job option
559 _outputExtensions.append(extension)
560
561 # Data Preparation
562 # According to the tracking pass we have different data preparation
563 # sequences. We may have:
564 # (1) Full Athena data preparation
565 # (2) Full Acts data preparation
566 # (3) Hybrid configurations with EDM converters
567 result.merge(ITkRecPreProcessingSiliconCfg(current_flags,
568 previousActsExtension=previousActsExtension))
569
570 # Track Reconstruction
571 # This includes track finding and ambiguity resolution
572 # The output is the component accumulator to be added to the sequence
573 # and the name of the cluster split prob container that is used for
574 # removing measurements used by previous passes
575 # This last object will also assure the proper sequence of the tracking passes
576 # since it will create a data dependency from the prevous pass
577 acc, ClusterSplitProbContainer = ITkTrackRecoPassCfg(
578 current_flags,
579 previousActsExtension,
580 InputCombinedITkTracks=InputCombinedITkTracks,
581 InputCombinedActsTracks=InputCombinedActsTracks,
582 InputExtendedITkTracks=InputExtendedITkTracks,
583 StatTrackCollections=StatTrackCollections,
584 StatTrackTruthCollections=StatTrackTruthCollections,
585 ClusterSplitProbContainer=ClusterSplitProbContainer)
586 result.merge(acc)
587
588 # Store ACTS extension
589 if 'Acts' in extension:
590 previousActsExtension = extension
591
592 # This merges the track collection in InputCombinedITkTracks
593 # and creates a track particle collection from that
594 if InputCombinedITkTracks:
595
596 result.merge(
597 ITkTrackFinalCfg(flags,
598 InputCombinedITkTracks=InputCombinedITkTracks,
599 StatTrackCollections=StatTrackCollections,
600 StatTrackTruthCollections=StatTrackTruthCollections))
601
602
603
604
605 # Now handle ACTS tracks instead if present in the event
606 if InputCombinedActsTracks:
607
608 # The name of the Acts xAOD container name depends on what
609 # workflow has been executed, which we get by checking
610 # the size of the track containers.
611
612 ActsTrackContainerName = "InDetTrackParticles" if not InputCombinedITkTracks else "InDetActsTrackParticles"
613 ActsPrimaryVertices = "PrimaryVertices" if not InputCombinedITkTracks else "ActsPrimaryVertices"
614
615 result.merge(ITkActsTrackFinalCfg(flags,
616 InputCombinedITkTracks=InputCombinedActsTracks,
617 ActsTrackContainerName=ActsTrackContainerName))
618
619 # Perform vertex finding
620 if flags.Tracking.doVertexFinding:
621
622 from InDetConfig.InDetPriVxFinderConfig import primaryVertexFindingCfg
623
624 # Schedule the usual vertex finding for Athena workflow(s)
625 # ONLY schedule this if there are Athena Legacy Track collections
626 if InputCombinedITkTracks:
627 result.merge(primaryVertexFindingCfg(flags))
628
629 # Schedule the same vertex finding for Acts workflow(s)
630 # For now this is separate from the Athena counterpart, but in the
631 # end the difference will not be needed anymore
632 # ONLY schedule this if there are ACTS Track collections
633 if InputCombinedActsTracks:
634 result.merge(primaryVertexFindingCfg(flags,
635 name="ActsPriVxFinderAlg",
636 TracksName=ActsTrackContainerName,
637 vxCandidatesOutputName=ActsPrimaryVertices))
638
639 # Post Processing
640 # This is mainly for validation support
641 print("-------- POST PROCESSING --------")
642 for current_flags in flags_set:
643 extension = current_flags.Tracking.ActiveConfig.extension
644 print(f"- Running post-processing for extension: {extension}")
645
646 # Persistify the Seeds
647 # This is done for the InDet EDM, while for ACTS seeds the persistification
648 # support is done while scheduling the seeding algorithms
649 # This means that here we only care about the legacy seeds, that are
650 # produced whem the legacy Track Finding is scheduled
651 # - flags.Tracking.ActiveConfig.doAthenaTrack
652 # This also covers the case of the Acts->InDet Seed conversion, since that
653 # runs the legacy track finding as well
654 #
655 # At the end of this we have a track collection (segments from the seeds)
656 # and the corresponding track particle collection
657 if current_flags.Tracking.ActiveConfig.doAthenaTrack:
658 if current_flags.Tracking.doStoreTrackSeeds:
659 from InDetConfig.ITkPersistificationConfig import ITkTrackSeedsFinalCfg
660 result.merge(ITkTrackSeedsFinalCfg(current_flags))
661
662 # Persistify Track from Track Finding
663 # Currently this is only possible for Trk Tracks
664 # For legacy tracking passes the CKF Trk Tracks are always produced
665 # - flags.Tracking.ActiveConfig.doAthenaTrack
666 # For hybrid ACTS-Athena tracking passes they are produced only after Track EDM conversion
667 # - flags.Tracking.ActiveConfig.doActsToAthenaTrack
668 if current_flags.Tracking.ActiveConfig.doAthenaTrack or current_flags.Tracking.ActiveConfig.doActsToAthenaTrack:
669 if current_flags.Tracking.doStoreSiSPSeededTracks:
670 from InDetConfig.ITkPersistificationConfig import ITkSiSPSeededTracksFinalCfg
671 result.merge(ITkSiSPSeededTracksFinalCfg(current_flags))
672
673 if flags.Tracking.doStats:
674 if _extensions_list:
675 result.merge(ITkStatsCfg(
676 flags_set[0], # Use cuts from primary pass
677 StatTrackCollections=StatTrackCollections,
678 StatTrackTruthCollections=StatTrackTruthCollections))
679
680
681
682 if flags.Tracking.writeExtendedSi_PRDInfo:
683 if _extensions_list:
684 result.merge(ITkExtendedPRDInfoCfg(flags))
685
686 #Acts algorithm
687 else:
688 result.merge(ITkActsExtendedPRDInfoCfg(flags))
689
690 # output
691 from InDetConfig.ITkTrackOutputConfig import ITkTrackRecoOutputCfg
692 result.merge(ITkTrackRecoOutputCfg(flags, _outputExtensions))
693 result.printConfig(withDetails = False, summariseProps = False)
694 return result
695
696
697if __name__ == "__main__":
698 from AthenaConfiguration.AllConfigFlags import initConfigFlags
699 flags = initConfigFlags()
700
701 # Disable calo for this test
702 flags.Detector.EnableCalo = False
703
704 from AthenaConfiguration.TestDefaults import defaultTestFiles
705 flags.Input.Files = defaultTestFiles.RDO_RUN4
706
707 import sys
708 if "--doFTF" in sys.argv:
709 flags.Tracking.useITkFTF = True
710 flags.Tracking.doITkFastTracking = True
711
712 flags.lock()
713
714 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
715 top_acc = MainServicesCfg(flags)
716
717 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
718 top_acc.merge(PoolReadCfg(flags))
719
720 if flags.Input.isMC and flags.Output.doGEN_AOD2xAOD:
721 from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
722 top_acc.merge(GEN_AOD2xAODCfg(flags))
723
724 top_acc.merge(ITkTrackRecoCfg(flags))
725
726 from AthenaCommon.Constants import DEBUG
727 top_acc.foreach_component("AthEventSeq/*").OutputLevel = DEBUG
728 top_acc.printConfig(withDetails=True, summariseProps=True)
729 top_acc.store(open("ITkTrackReco.pkl", "wb"))
730
731 if "--norun" not in sys.argv:
732 sc = top_acc.run(5)
733 if sc.isFailure():
734 sys.exit(-1)
void print(char *figname, TCanvas *c1)
ITkTrackFinalCfg(flags, list[str] InputCombinedITkTracks=None, list[str] StatTrackCollections=None, list[str] StatTrackTruthCollections=None)
ComponentAccumulator ITkActsTrackFinalCfg(flags, list[str] InputCombinedITkTracks=None, ActsTrackContainerName="InDetActsTrackParticles")
ITkTrackRecoPassCfg(flags, str previousActsExtension=None, list[str] InputCombinedITkTracks=None, list[str] InputCombinedActsTracks=None, list[str] InputExtendedITkTracks=None, list[str] StatTrackCollections=None, list[str] StatTrackTruthCollections=None, str ClusterSplitProbContainer="")
ComponentAccumulator ITkTrackRecoCfg(flags)
Main ITk tracking config #####################.
ComponentAccumulator ITkStoreTrackSeparateContainerCfg(flags, str TrackContainer="", str ClusterSplitProbContainer="")
ITkStatsCfg(flags, StatTrackCollections=None, StatTrackTruthCollections=None)