ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrackRecoConfig.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
4def isPrimaryPass(flags) -> bool:
5 if not flags.hasCategory("Tracking.ActiveConfig"):
6 return False
7 # Support for non ACTS passes, that do not respect the convention
8 # This comes from Athena legacy passes
9 if flags.Tracking.ActiveConfig.extension in ["", "HeavyIon"]:
10 return True
11
12 return f"{flags.Tracking.ActiveConfig.extension}" == flags.Tracking.PrimaryPassConfig.value
13
14def extractTrackingPasses(flags) -> list:
15 # Function for extracting the requested tracking passes that need to be scheduled
16 trackingPasses = []
17
18 # Primary pass
19 trackingPasses += [flags.cloneAndReplace(
20 "Tracking.ActiveConfig",
21 f"Tracking.{flags.Tracking.PrimaryPassConfig.value}Pass")]
22
23 # Only have primary pass for the moment
24 print("List of scheduled passes:")
25 for trackingPass in trackingPasses:
26 print(f'- {trackingPass.Tracking.ActiveConfig.extension}')
27
28 return trackingPasses
29
30def getListOfGeneratedTrackParticles(flags) -> list[str]:
31 generateTrackCollections = ["InDetTrackParticles"]
32
33 # loop on tracking passes
34 scheduledTrackingPasses: list = extractTrackingPasses(flags)
35 for currentFlags in scheduledTrackingPasses:
36 # Add the seed tracks
37 if currentFlags.Tracking.ActiveConfig.storeTrackSeeds:
38 # pixel seeds
39 generatePixelSegments = currentFlags.Detector.EnablePixel
40 generateStripSegments = currentFlags.Detector.EnableStrip
41
42 if generatePixelSegments:
43 generateTrackCollections += [f'SiSPSeedSegments{currentFlags.Tracking.ActiveConfig.extension}PixelTrackParticles']
44 if generateStripSegments:
45 generateTrackCollections += [f'SiSPSeedSegments{currentFlags.Tracking.ActiveConfig.extension}StripTrackParticles']
46 if generatePixelSegments and generateStripSegments:
47 generateTrackCollections += [f'SiSPSeedSegments{currentFlags.Tracking.ActiveConfig.extension}TrackParticles']
48
49 # Add CKF tracks
50 if currentFlags.Tracking.ActiveConfig.storeSiSPSeededTracks:
51 generateTrackCollections += [f'SiSPSeededTracks{currentFlags.Tracking.ActiveConfig.extension}TrackParticles']
52
53 # Add tracks after ambi
54 # this is necessary only if ambiguity resolution is run and we
55 # store track particles in a separate container w.r.t InDetTrackParticles
56 if currentFlags.Acts.doAmbiguityResolution and currentFlags.Tracking.ActiveConfig.storeSeparateContainer:
57 generateTrackCollections += [f'InDet{currentFlags.Tracking.ActiveConfig.extension}TrackParticles']
58
59 print('Here is the list of generated track particle collections:')
60 for collection in generateTrackCollections:
61 print(f'- {collection}')
62
63 return generateTrackCollections
64
65def ActsTrackRecoCfg(flags) -> ComponentAccumulator:
66 # Main Job Option for ACTS Track Reconstruction with Inner Detector
67 print("Scheduling the ACTS Job Option for Inner Detector Track Reconstruction")
68
69 acc = ComponentAccumulator()
70
71 # Pre-Processing
72 # Retrieve all the tracking passes
73 scheduledTrackingPasses = extractTrackingPasses(flags)
74 # Keep track of previous pass (used for PRD mapping)
75 previousExtension = None
76
77 # Track Collections to be merged for main track particle collection
78 # This is the groups of tracks generated in tracking passes that do not store
79 # tracks in separate containers
80 InputCombinedTracks = []
81
82 # Container names
83 trackParticleContainerName = "InDetTrackParticles"
84 primaryVertices = "PrimaryVertices"
85
86 # Reconstruction
87 for currentFlags in scheduledTrackingPasses:
88 # Printing configuration
89 print(f"---- Preparing scheduling of algorithms for tracking pass: {currentFlags.Tracking.ActiveConfig.extension}")
90 print(f"---- - Is primary pass: {isPrimaryPass(currentFlags)}")
91 from TrkConfig.TrackingPassFlags import printActiveConfig
92 printActiveConfig(currentFlags)
93
94 # Data Preparation
95 # This includes Region-of-Interest creation, Cluster and Space Point formation
96 from InDetConfig.ActsDataPreparationConfig import ActsDataPreparationCfg
97 acc.merge(ActsDataPreparationCfg(currentFlags,
98 previousExtension = previousExtension))
99
100 # Track Reconstruction
101 # This includes Seeding, Track Finding (CKF) and Ambiguity Resolution
102 from InDetConfig.ActsPatternRecognitionConfig import ActsTrackReconstructionCfg
103 acc.merge(ActsTrackReconstructionCfg(currentFlags,
104 previousExtension = previousExtension))
105
106 # Update variables
107 previousExtension = currentFlags.Tracking.ActiveConfig.extension
108 if not currentFlags.Tracking.ActiveConfig.storeSeparateContainer or isPrimaryPass(currentFlags):
109 acts_tracks = f"{currentFlags.Tracking.ActiveConfig.extension}Tracks" if not currentFlags.Acts.doAmbiguityResolution else f"{currentFlags.Tracking.ActiveConfig.extension}ResolvedTracks"
110 InputCombinedTracks.append(acts_tracks)
111
112
113 # Track particle creation
114 print(f"Creating track particle collection '{trackParticleContainerName}' from combination of following track collection:")
115 for trackCollection in InputCombinedTracks:
116 print(f'- {trackCollection}')
117
118 # In case perigee expression is Vertex we have a situation where
119 # there is a first temporary track particle creation wrt BeamLine
120 # followed, after vertex reco, of a second particle creation wrt vertex
121 #
122 # The final track particle collection will still be the one defined in trackParticleContainerName
123 persistifyCollection = True
124 particleCollection = trackParticleContainerName
125 perigeeExpression = flags.Tracking.perigeeExpression
126 if flags.Tracking.perigeeExpression == "Vertex":
127 # We do not want to persistify this temporary collection
128 persistifyCollection = False
129 particleCollection = f"{trackParticleContainerName}Temporary"
130 perigeeExpression = "BeamLine"
131
132 # Track particles wrt BeamLine
133 from InDetConfig.ITkActsParticleCreationConfig import ITkActsTrackParticleCreationCfg
134 acc.merge(ITkActsTrackParticleCreationCfg(flags,
135 TrackContainers = InputCombinedTracks,
136 TrackParticleContainer = particleCollection,
137 persistifyCollection = persistifyCollection,
138 PerigeeExpression = perigeeExpression))
139
140 # Vertex reconstruction
141 if flags.Tracking.doVertexFinding:
142 from InDetConfig.ActsPriVxFinderConfig import primaryVertexFindingCfg
143 acc.merge(primaryVertexFindingCfg(flags,
144 name = "ActsPriVxFinderAlg",
145 TracksName = particleCollection,
146 vxCandidatesOutputName = primaryVertices))
147
148 # Track particles wrt Vertex
149 #
150 # In case perigee expression is Vertex we need to schedule the final
151 # track particle creation using the vertex
152 # The track collection(s) unchanged, only the final track particle container
153 # has a different name
154 if flags.Tracking.perigeeExpression == "Vertex":
155 assert flags.Tracking.doVertexFinding, \
156 f"Requested the computation of track particles wrt but flags.Tracking.doVertexFinding is set to {flags.Tracking.doVertexFinding}"
157 print('Requesting to compute the track particle collection wrt the Vertex')
158 acc.merge(ITkActsTrackParticleCreationCfg(flags,
159 TrackContainers = InputCombinedTracks,
160 TrackParticleContainer = trackParticleContainerName))
161
162 # Post-Processing
163 print('Starting Post-Processing')
164
165
166
169 if flags.Tracking.writeExtendedSi_PRDInfo:
170 # Get all the track particle collections being generated
171 # this covers the main tracking collection InDetTrackParticles
172 # as well as the converted seeds, tracks from CKF and all those
173 # track collection that do not get merged.
174 # This operation is necessary only if we desire to only persistify
175 # on-track PRD info, since we need to get all the measurements used by
176 # all tracks we want to persistify
177 generatedTrackParticleCollections = ["InDetTrackParticles"]
178 if flags.Tracking.PRDInfo.KeepOnlyOnTrackMeasurements:
179 generatedTrackParticleCollections = getListOfGeneratedTrackParticles(flags)
180
181 # Add the truth origin to the truth particles
182 # This handles:
183 # - Pixel detector
184 # - Strip detector
185 from InDetConfig.InDetPrepRawDataToxAODConfig import ActsPrepDataToxAODCfg
186 acc.merge(ActsPrepDataToxAODCfg(flags,
187 TrackParticles = generatedTrackParticleCollections))
188
189 # Create MSOS on final InDetTrackParticles collection
190 from ActsConfig.ActsObjectDecorationConfig import ActsInDetTrackStateOnSurfaceDecoratorAlgCfg
191 acc.merge(ActsInDetTrackStateOnSurfaceDecoratorAlgCfg(flags,
192 name=f"Acts{trackParticleContainerName}StateOnSurfaceDecoratorAlg",
193 TrackParticles=trackParticleContainerName))
194
195 # Run on the specific tracking passes
196 for currentFlags in scheduledTrackingPasses:
197 # Particle persistification for tracking pass
198 from InDetConfig.ITkActsParticleCreationConfig import ITkActsTrackParticlePersistificationCfg
199 acc.merge(ITkActsTrackParticlePersistificationCfg(currentFlags))
200
201 # Create MSOS for the intermediate track particle collections
202 # this may be the CKF and/or the ambi tracks and can only happen if
203 # - storeSiSPSeededTracks for this tracking pass is requested
204 # - storeSeparateContainer for this tracking pass is requested
205 if flags.Tracking.writeExtendedSi_PRDInfo:
206 from ActsConfig.ActsObjectDecorationConfig import ActsInDetTrackStateOnSurfaceDecoratorAlgCfg
207 # CKF tracks are called: SiSPSeededTracks{currentFlags.Tracking.ActiveConfig.extension}TrackParticles
208 if currentFlags.Tracking.ActiveConfig.storeSiSPSeededTracks:
209 TrackParticleCollectionForMsos = f'SiSPSeededTracks{currentFlags.Tracking.ActiveConfig.extension}TrackParticles'
210 acc.merge(ActsInDetTrackStateOnSurfaceDecoratorAlgCfg(currentFlags,
211 name=f"{TrackParticleCollectionForMsos}StateOnSurfaceDecoratorAlg",
212 TrackParticles=TrackParticleCollectionForMsos,
213 PixelMSOSs=f"SiSPSeeded{currentFlags.Tracking.ActiveConfig.extension}PixelMSOSs",
214 StripMSOSs=f"SiSPSeeded{currentFlags.Tracking.ActiveConfig.extension}StripMSOSs"))
215
216 if currentFlags.Tracking.ActiveConfig.storeSeparateContainer:
217 # track collection can be the CKF or the ambi depending
218 # on the presence of the ambiguity resolution algorithm
219 # but the track particle collection remains the same
220 # name: InDet{currentFlags.Tracking.ActiveConfig.extension}TrackParticles
221 TrackParticleCollectionForMsos = f'InDet{currentFlags.Tracking.ActiveConfig.extension}TrackParticles'
222 acc.merge(ActsInDetTrackStateOnSurfaceDecoratorAlgCfg(currentFlags,
223 name=f"{TrackParticleCollectionForMsos}StateOnSurfaceDecoratorAlg",
224 TrackParticles=TrackParticleCollectionForMsos,
225 PixelMSOSs=f"{currentFlags.Tracking.ActiveConfig.extension}PixelMSOSs",
226 StripMSOSs=f"{currentFlags.Tracking.ActiveConfig.extension}StripMSOSs"))
227 # Debug output
228 # from ActsConfig.ActsGeometryConfig import ActsWriteTrackingGeometryTransformsAlgCfg
229 # acc.merge(ActsWriteTrackingGeometryTransformsAlgCfg(flags,WriteFullTransform = False, OutputName = "transforms.csv"))
230 # from AthenaCommon.Constants import DEBUG, ALL, VERBOSE
231 # acc.foreach_component("*/TrackFindingAlg").OutputLevel = DEBUG
232 acc.printConfig(withDetails = True, summariseProps = True)
233 return acc
234
void print(char *figname, TCanvas *c1)
ComponentAccumulator ActsTrackRecoCfg(flags)
list[str] getListOfGeneratedTrackParticles(flags)