ATLAS Offline Software
Loading...
Searching...
No Matches
ITkActsParticleCreationConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3
5 *,
6 TrackContainers: list[str],
7 TrackParticleContainer: str,
8 persistifyCollection: bool = True,
9 PerigeeExpression: str = None) -> ComponentAccumulator:
10 # This function does the following:
11 # - Creates track particles from a collection of track containers
12 # - Attaches truth decoration to the track particles
13 # - Persistifies the track particles
14 # The function will be called within the loop on the tracking passes, if the uses asks
15 # for collections to be stored in different containers, as well as just before the primary
16 # vertex reconstruction, on the ensamble of track collections requested during reconstruction
17 # (but always on the primary pass tracks)
18
19 assert isinstance(TrackContainers, list)
20 for container in TrackContainers:
21 assert isinstance(container, str)
22
23 # Set the perigee expression to be used for track particle creation
24 # This is used by Heavy Ion configuration
25 if PerigeeExpression is None:
26 PerigeeExpression = flags.Tracking.perigeeExpression
27
28 print("Storing track and track particle containers:")
29 print(f"- track collection(s): {TrackContainers}")
30 print(f"- track particle collection: {TrackParticleContainer}")
31
32 acc = ComponentAccumulator()
33
34 prefix = "ActsCombined" if not flags.hasCategory("Tracking.ActiveConfig") else flags.Tracking.ActiveConfig.extension
35 prefix += f"To{TrackParticleContainer}"
36 from ActsConfig.ActsEventCnvConfig import ActsTrackToTrackParticleCnvAlgCfg, xAODtoTrkConverterAlgCfg
37 acc.merge(ActsTrackToTrackParticleCnvAlgCfg(flags,
38 name = f"{prefix}TrackToTrackParticleCnvAlg",
39 ACTSTracksLocation = TrackContainers,
40 TrackParticlesOutKey = TrackParticleContainer,
41 PerigeeExpression = PerigeeExpression))
42
44 if "Temporary" not in TrackParticleContainer and \
45 "Seed" not in TrackParticleContainer:
46 acc.merge(xAODtoTrkConverterAlgCfg(flags,
47 name=f"{prefix}TrackParticleToTrkCnvAlg",
48 TrackParticles = TrackParticleContainer,
49 OutTrackContainer="Combined{tracks}Tracks".format(tracks =
50 TrackParticleContainer[:TrackParticleContainer.rfind("Track")]) ))
51 if flags.Tracking.doTruth :
52 from AthenaCommon.Constants import WARNING, INFO
53 track_to_truth_maps = []
54 from ActsConfig.ActsTruthConfig import ActsTrackParticleTruthDecorationAlgCfg
55 for trackContainer in TrackContainers:
56 track_to_truth_maps.append(f"{trackContainer}ToTruthParticleAssociation")
57 acc.merge(ActsTrackParticleTruthDecorationAlgCfg(flags,
58 name = f'{prefix}TruthDecorationAlg',
59 TrackToTruthAssociationMaps = track_to_truth_maps,
60 TrackParticleContainerName = TrackParticleContainer,
61 OutputLevel = WARNING if len(TrackContainers)==1 else INFO,
62 ComputeTrackRecoEfficiency = False if len(TrackContainers)==1 else True))
63
64 # Additional decorations
65 if flags.Acts.storeTrackStateInfo:
66 from ActsConfig.ActsObjectDecorationConfig import ActsMeasurementToTrackParticleDecorationAlgCfg
67 acc.merge(ActsMeasurementToTrackParticleDecorationAlgCfg(flags,
68 name = f"ActsMeasurementTo{TrackParticleContainer}DecorationAlg",
69 TrackParticleKey = TrackParticleContainer))
70
71 if flags.Acts.Particles.doAnalysis:
72 from ActsConfig.ActsAnalysisConfig import ActsResidualAnalysisAlgCfg
73 acc.merge(ActsResidualAnalysisAlgCfg(flags,
74 name = f"Acts{TrackParticleContainer}ResidualAnalysisAlg",
75 TrackParticles = TrackParticleContainer))
76
77 # Persistification
78 # By default this is always happening, but in the case the perigee strategy is set
79 # to Vertex we need to create a temporary track particle collection wrt the BeamLine
80 # which does not need to be persistified
81 if persistifyCollection:
82 from ActsConfig.ActsPersistificationConfig import PersistifyTrackParticles
83 acc.merge(PersistifyTrackParticles(flags,
84 trackParticleCollections=[TrackParticleContainer]))
85 return acc
86
87
88def ITkActsTrackParticlePersistificationCfg(flags) -> ComponentAccumulator:
89 acc = ComponentAccumulator()
90 # Particle creation and persistification
91 # Tracks from CKF and SiSPSeededTracks{extension}TrackParticles
92 if flags.Tracking.ActiveConfig.storeSiSPSeededTracks:
93 # Naming convention for track particles: SiSPSeededTracks{extension}TrackParticles
94 TrackParticleContainer = f'SiSPSeededTracks{flags.Tracking.ActiveConfig.extension}TrackParticles'
95 acc.merge(ITkActsTrackParticleCreationCfg(flags,
96 TrackContainers = [f"{flags.Tracking.ActiveConfig.extension}Tracks"],
97 TrackParticleContainer = TrackParticleContainer))
98
99
100 # Track from CKF or ambiguity resolution if we want separate containers
101 # In case no ambiguity resolution is scheduled, the CKF tracks will be used instead of those from the ambiguity resolution
102 if flags.Tracking.ActiveConfig.storeSeparateContainer:
103 # If we do not want the track collection to be merged with another collection
104 # then we immediately create the track particles from it
105 # Naming convention for track particles: InDet{extension}TrackParticles
106 # (unless the pass overrides it via storedTrackParticlesExtension)
107 acts_tracks = f"{flags.Tracking.ActiveConfig.extension}Tracks" if not flags.Acts.doAmbiguityResolution else f"{flags.Tracking.ActiveConfig.extension}ResolvedTracks"
108 from InDetConfig.ITkActsHelpers import separateTrackParticleContainerName
109 TrackParticles = separateTrackParticleContainerName(flags)
110 acc.merge(ITkActsTrackParticleCreationCfg(flags,
111 TrackContainers = [acts_tracks],
112 TrackParticleContainer = TrackParticles))
113
114 return acc
void print(char *figname, TCanvas *c1)
ComponentAccumulator ITkActsTrackParticleCreationCfg(flags, *, list[str] TrackContainers, str TrackParticleContainer, bool persistifyCollection=True, str PerigeeExpression=None)
ComponentAccumulator ITkActsTrackParticlePersistificationCfg(flags)