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