3 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4 from AthenaConfiguration.Enums
import Format
5 from TrkConfig.TrackingPassFlags
import printActiveConfig
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",
31 if TrackingComponent.AthenaChain
in flags.Tracking.recoChain:
32 flags_set += [flags.cloneAndReplace(
33 "Tracking.ActiveConfig",
34 f
"Tracking.{flags.Tracking.ITkPrimaryPassConfig.value}Pass")]
37 if TrackingComponent.ActsChain
in flags.Tracking.recoChain:
38 flags_set += [flags.cloneAndReplace(
39 "Tracking.ActiveConfig",
40 "Tracking.ITkActsPass")]
43 if TrackingComponent.ActsHeavyIon
in flags.Tracking.recoChain:
44 flags_set += [flags.cloneAndReplace(
45 "Tracking.ActiveConfig",
46 "Tracking.ITkActsHeavyIonPass")]
49 if TrackingComponent.GNNChain
in flags.Tracking.recoChain:
50 flags_set += [flags.cloneAndReplace(
51 "Tracking.ActiveConfig",
52 "Tracking.ITkGNNPass")]
55 if flags.Acts.doLargeRadius:
56 flags_set += [flags.cloneAndReplace(
57 "Tracking.ActiveConfig",
58 "Tracking.ITkActsLargeRadiusPass")]
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")]
68 if flags.Acts.doLowPt:
69 flags_set += [flags.cloneAndReplace(
70 "Tracking.ActiveConfig",
71 "Tracking.ITkActsLowPtPass")]
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')")
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")
88 flagsLRT = flags.cloneAndReplace(
"Tracking.ActiveConfig",
89 "Tracking.ITkLargeD0Pass")
90 flags_set += [flagsLRT]
93 if TrackingComponent.FPGAChain
in flags.Tracking.recoChain:
94 flags_set += [flags.cloneAndReplace(
95 "Tracking.ActiveConfig",
96 "Tracking.ITkFPGAPass")]
99 if flags.Detector.EnableCalo
and flags.Tracking.doITkConversion:
100 flagsConv = flags.cloneAndReplace(
"Tracking.ActiveConfig",
101 "Tracking.ITkConversionPass")
102 flags_set += [flagsConv]
105 if flags.Tracking.doLowPt:
106 flagsLowPt = flags.cloneAndReplace(
"Tracking.ActiveConfig",
107 "Tracking.ITkLowPtPass")
108 flags_set += [flagsLowPt]
110 _flags_set = flags_set
117 extension = flags_set[-1].Tracking.ActiveConfig.extension
118 ClusterSplitProbContainer =
"ITkAmbiguityProcessorSplitProb" + extension
119 return ClusterSplitProbContainer
123 TrackContainer: str =
"",
124 ClusterSplitProbContainer: str =
"") -> ComponentAccumulator:
126 extension = flags.Tracking.ActiveConfig.extension
127 if hasattr(flags.TrackOverlay,
"ActiveConfig"):
128 doTrackOverlay = getattr(flags.TrackOverlay.ActiveConfig,
"doTrackOverlay",
None)
130 doTrackOverlay = flags.Overlay.doTrackOverlay
134 InputTracks = [flags.Overlay.SigPrefix+TrackContainer,
135 flags.Overlay.BkgPrefix+TrackContainer]
136 AssociationMapName = (
"PRDtoTrackMapMerge_Resolved" +
137 extension +
"Tracks")
138 MergerOutputTracks = TrackContainer
140 from TrkConfig.TrkTrackCollectionMergerConfig
import TrackCollectionMergerAlgCfg
143 name=
"TrackCollectionMergerAlgCfg"+extension,
144 InputCombinedTracks=InputTracks,
145 OutputCombinedTracks=MergerOutputTracks,
146 AssociationMapName=AssociationMapName))
149 if flags.Tracking.doTruth
and extension
not in [
'Acts',
'ActsConversion',
'ActsLargeRadius',
'ActsLowPt']:
150 from InDetConfig.ITkTrackTruthConfig
import ITkTrackTruthCfg
153 Tracks=TrackContainer,
154 DetailedTruth=TrackContainer+
"DetailedTruth",
155 TracksTruth=TrackContainer+
"TruthCollection"))
159 if extension
not in [
'Acts',
'ActsConversion',
'ActsLargeRadius',
'ActsLowPt']:
161 from xAODTrackingCnv.xAODTrackingCnvConfig
import ITkTrackParticleCnvAlgCfg
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=
""))
174 from ActsConfig.ActsTrackFindingConfig
import ActsTrackToTrackParticleCnvAlgCfg
176 prefix = flags.Tracking.ActiveConfig.extension
178 ACTSTracksLocation=TrackContainer,
179 TrackParticlesOutKey=f
'{TrackContainer}ParticlesAlt'))
181 if flags.Tracking.doTruth :
182 from ActsConfig.ActsTruthConfig
import ActsTrackParticleTruthDecorationAlgCfg
184 name=f
'{TrackContainer}ParticleTruthDecorationAlg',
185 TrackToTruthAssociationMaps = [f
'{TrackContainer}ToTruthParticleAssociation'],
186 TrackParticleContainerName = f
'{TrackContainer}ParticlesAlt'
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 =
""):
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)
209 extension = flags.Tracking.ActiveConfig.extension
212 if hasattr(flags.TrackOverlay,
"ActiveConfig"):
213 doTrackOverlay = getattr(flags.TrackOverlay.ActiveConfig,
"doTrackOverlay",
None)
215 doTrackOverlay = flags.Overlay.doTrackOverlay
219 TrackContainer =
"Resolved" + extension +
"Tracks"
221 if extension
in [
'Acts',
'ActsConversion',
'ActsLargeRadius',
'ActsLowPt']:
222 TrackContainer = extension +
"ResolvedTracks"
223 if doTrackOverlay
and extension ==
"Conversion":
224 TrackContainer = flags.Overlay.SigPrefix + TrackContainer
227 SiSPSeededTracks =
"SiSPSeeded" + extension +
"Tracks"
229 if extension
in [
'Acts',
'ActsConversion',
'ActsLargeRadius',
'ActsLowPt']:
230 SiSPSeededTracks = extension +
"Tracks"
233 from InDetConfig.ITkTrackingSiPatternConfig
import ITkTrackingSiPatternCfg
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"]
245 if doTrackOverlay
and extension ==
"Conversion":
246 TrackContainer =
"Resolved" + extension +
"Tracks"
249 TrackContainer=TrackContainer,
250 ClusterSplitProbContainer=ClusterSplitProbContainer))
252 if flags.Tracking.ActiveConfig.storeSeparateContainer:
258 inputTrack = TrackContainer
259 if extension
in [
'Acts',
'ActsConversion',
'ActsLargeRadius',
'ActsLowPt']
and not flags.Tracking.ActiveConfig.doActsAmbiguityResolution:
260 inputTrack = SiSPSeededTracks
264 TrackContainer=inputTrack,
265 ClusterSplitProbContainer=ClusterSplitProbContainer))
269 ClusterSplitProbContainer = (
270 "ITkAmbiguityProcessorSplitProb" + extension)
273 if extension
not in [
'Acts',
'ActsConversion',
'ActsLargeRadius',
'ActsLowPt']:
274 InputCombinedITkTracks += [TrackContainer]
276 InputCombinedActsTracks += [TrackContainer]
280 if extension
not in [
'Acts',
'ActsConversion',
'ActsLargeRadius',
'ActsLowPt']:
281 InputExtendedITkTracks += [TrackContainer]
283 return result, ClusterSplitProbContainer
287 InputCombinedITkTracks: list[str] =
None,
288 ActsTrackContainerName=
"ActsInDetTrackParticles") -> ComponentAccumulator:
290 assert InputCombinedITkTracks
is not None and isinstance(InputCombinedITkTracks, list)
293 if len(InputCombinedITkTracks) == 0:
297 from ActsConfig.ActsTrackFindingConfig
import ActsTrackToTrackParticleCnvAlgCfg
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']
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
320 InputCombinedITkTracks: list[str] =
None,
321 StatTrackCollections: list[str] =
None,
322 StatTrackTruthCollections: list[str] =
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)
330 if len(InputCombinedITkTracks) == 0:
333 if hasattr(flags.TrackOverlay,
"ActiveConfig"):
334 doTrackOverlay = getattr(flags.TrackOverlay.ActiveConfig,
"doTrackOverlay",
None)
336 doTrackOverlay = flags.Overlay.doTrackOverlay
338 TrackContainer =
"CombinedITkTracks"
341 InputCombinedITkTracks += [flags.Overlay.BkgPrefix + TrackContainer]
344 from TrkConfig.TrkTrackCollectionMergerConfig
import (
345 ITkTrackCollectionMergerAlgCfg)
348 InputCombinedTracks=InputCombinedITkTracks,
349 OutputCombinedTracks=TrackContainer,
351 "" if flags.Tracking.doITkFastTracking
else
352 f
"PRDtoTrackMapMerge_{TrackContainer}")))
354 if flags.Tracking.doTruth:
355 from InDetConfig.ITkTrackTruthConfig
import ITkTrackTruthCfg
358 Tracks=TrackContainer,
359 DetailedTruth=f
"{TrackContainer}DetailedTruth",
360 TracksTruth=f
"{TrackContainer}TruthCollection"))
362 StatTrackCollections += [TrackContainer]
363 StatTrackTruthCollections += [f
"{TrackContainer}TruthCollection"]
365 if flags.Tracking.doSlimming:
366 from TrkConfig.TrkTrackSlimmerConfig
import TrackSlimmerCfg
369 TrackLocation=[TrackContainer]))
374 from xAODTrackingCnv.xAODTrackingCnvConfig
import ITkTrackParticleCnvAlgCfg
377 ClusterSplitProbabilityName=(
378 "" if flags.Tracking.doITkFastTracking
else
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) ))
399 listOfExtensionsRequesting = [
400 e
for e
in _extensions_list
401 if (e ==
'' or flags.Tracking[f
"ITk{e}Pass"].storeTrackSeeds) ]
403 for extension
in listOfExtensionsRequesting:
404 TrackContainer =
"SiSPSeedSegments"+extension
406 if flags.Tracking.doTruth:
407 from InDetConfig.ITkTrackTruthConfig
import ITkTrackTruthCfg
410 Tracks=TrackContainer,
411 DetailedTruth=f
"{TrackContainer}DetailedTruth",
412 TracksTruth=f
"{TrackContainer}TruthCollection"))
414 from xAODTrackingCnv.xAODTrackingCnvConfig
import (
415 ITkTrackParticleCnvAlgCfg)
418 name=f
"{TrackContainer}CnvAlg",
419 TrackContainerName=TrackContainer,
420 xAODTrackParticlesFromTracksContainerName=(
421 f
"{TrackContainer}TrackParticles")))
429 primaryPassExtension = flags.Tracking[f
"{flags.Tracking.ITkPrimaryPassConfig.value}Pass"].extension
433 listOfExtensionsRequesting = [
434 e
for e
in _extensions_list
435 if (e==
'' or flags.Tracking[f
"ITk{e}Pass"].storeSiSPSeededTracks) ]
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}"
444 from xAODTrackingCnv.xAODTrackingCnvConfig
import (
445 ITkTrackParticleCnvAlgCfg)
448 name = f
"SiSPSeededTracks{extension}CnvAlg",
449 TrackContainerName = f
"SiSPSeeded{extension}Tracks",
450 xAODTrackParticlesFromTracksContainerName=(
451 f
"SiSPSeededTracks{extension}TrackParticles"),
453 "" if flags.Tracking.doITkFastTracking
else
454 AssociationMapNameKey))
460 StatTrackTruthCollections=None):
463 from InDetConfig.InDetRecStatisticsConfig
import (
464 ITkRecStatisticsAlgCfg)
467 TrackCollectionKeys=StatTrackCollections,
468 TrackTruthCollectionKeys=(
469 StatTrackTruthCollections
if flags.Tracking.doTruth
else [])))
471 if flags.Tracking.doTruth:
472 from InDetConfig.InDetTrackClusterAssValidationConfig
import (
473 ITkTrackClusterAssValidationCfg)
476 TracksLocation=StatTrackCollections))
484 if flags.Tracking.doTIDE_AmbiTrackMonitoring:
485 from InDetConfig.InDetPrepRawDataToxAODConfig
import (
486 ITkPixelPrepDataToxAOD_ExtraTruthCfg
as PixelPrepDataToxAODCfg,
487 ITkStripPrepDataToxAOD_ExtraTruthCfg
as StripPrepDataToxAODCfg)
489 from InDetConfig.InDetPrepRawDataToxAODConfig
import (
490 ITkPixelPrepDataToxAODCfg
as PixelPrepDataToxAODCfg,
491 ITkStripPrepDataToxAODCfg
as StripPrepDataToxAODCfg)
493 result.merge(PixelPrepDataToxAODCfg(
495 ClusterSplitProbabilityName=(
496 "" if flags.Tracking.doITkFastTracking
else
498 result.merge(StripPrepDataToxAODCfg(flags))
500 from DerivationFrameworkInDet.InDetToolsConfig
import (
501 ITkTSOS_CommonKernelCfg)
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)
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:
522 name=f
"ITkPhysHit{extension}DecoratorAlg",
523 TrackParticleContainerName=f
"InDet{extension}TrackParticles"))
534 """Configures complete ITk tracking """
537 if flags.Input.Format
is Format.BS:
539 raise RuntimeError(
"ByteStream inputs not supported")
548 InputCombinedITkTracks = []
550 InputCombinedActsTracks = []
552 InputExtendedITkTracks = []
554 ClusterSplitProbContainer =
""
556 StatTrackCollections = []
557 StatTrackTruthCollections = []
559 previousActsExtension =
None
561 from InDetConfig.SiliconPreProcessing
import ITkRecPreProcessingSiliconCfg
563 for current_flags
in flags_set:
566 extension = current_flags.Tracking.ActiveConfig.extension
567 _extensions_list.append(extension)
576 previousActsExtension=previousActsExtension))
587 previousActsExtension,
588 InputCombinedITkTracks=InputCombinedITkTracks,
589 InputCombinedActsTracks=InputCombinedActsTracks,
590 InputExtendedITkTracks=InputExtendedITkTracks,
591 StatTrackCollections=StatTrackCollections,
592 StatTrackTruthCollections=StatTrackTruthCollections,
593 ClusterSplitProbContainer=ClusterSplitProbContainer)
597 if 'Acts' in extension:
598 previousActsExtension = extension
602 if InputCombinedITkTracks:
606 InputCombinedITkTracks=InputCombinedITkTracks,
607 StatTrackCollections=StatTrackCollections,
608 StatTrackTruthCollections=StatTrackTruthCollections))
614 if InputCombinedActsTracks:
620 ActsTrackContainerName =
"InDetTrackParticles" if not InputCombinedITkTracks
else "ActsInDetTrackParticles"
621 ActsPrimaryVertices =
"PrimaryVertices" if not InputCombinedITkTracks
else "ActsPrimaryVertices"
624 InputCombinedITkTracks=InputCombinedActsTracks,
625 ActsTrackContainerName=ActsTrackContainerName))
629 if flags.Tracking.doStoreTrackSeeds:
632 if flags.Tracking.doStoreSiSPSeededTracks:
636 if flags.Tracking.doVertexFinding:
638 from InDetConfig.InDetPriVxFinderConfig
import primaryVertexFindingCfg
642 if InputCombinedITkTracks:
649 if InputCombinedActsTracks:
651 name=
"ActsPriVxFinderAlg",
652 TracksName=ActsTrackContainerName,
653 vxCandidatesOutputName=ActsPrimaryVertices))
656 if flags.Tracking.doStats:
659 StatTrackCollections=StatTrackCollections,
660 StatTrackTruthCollections=StatTrackTruthCollections))
662 if flags.Tracking.writeExtendedSi_PRDInfo:
667 from InDetConfig.ITkTrackOutputConfig
import ITkTrackRecoOutputCfg
669 result.printConfig(withDetails =
False, summariseProps =
False)
673 if __name__ ==
"__main__":
674 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
678 flags.Detector.EnableCalo =
False
680 from AthenaConfiguration.TestDefaults
import defaultTestFiles
681 flags.Input.Files = defaultTestFiles.RDO_RUN4
684 if "--doFTF" in sys.argv:
685 flags.Tracking.useITkFTF =
True
686 flags.Tracking.doITkFastTracking =
True
690 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
693 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
697 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
703 top_acc.foreach_component(
"AthEventSeq/*").OutputLevel = DEBUG
704 top_acc.printConfig(withDetails=
True, summariseProps=
True)
705 top_acc.store(
open(
"ITkTrackReco.pkl",
"wb"))
707 if "--norun" not in sys.argv: