ATLAS Offline Software
Loading...
Searching...
No Matches
ITkActsDeviceTrackRecoConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3from AthenaConfiguration.Enums import FlagEnum
4
5from ActsGPUGeometry.ActsGPUGeometryConfig import JSONDeviceDetectorDescriptionProviderSvcCfg
6
7class DataLocation(FlagEnum):
8 HOST = "host" # Athena objects on CPU
9 DEVICE = "device" # Traccc buffers on GPU
10
11def ITkActsDeviceTrackRecoCfg(flags, *, previousExtension=None):
12 acc = ComponentAccumulator()
13
14 # Bring up shared device infrastructure once, upfront
15 print(f"Setting up GPU algorithms with {flags.Device.Backend.value} backend")
16
17 # Setup traccc detector description objects — loads all device detector description data into detStore
18 acc.merge(JSONDeviceDetectorDescriptionProviderSvcCfg(flags,
19 HostConditionsObjectName="TracccHostCondConfig",
20 HostDigitizationObjectName="TracccHostDigitizationConfig",
21 DeviceConditionsObjectName="TracccDeviceCondConfig",
22 DeviceDigitizationObjectName="TracccDeviceDigitizationConfig",
23 ))
24
25 # --- Clusterization ---
26 if flags.Acts.Device.doClusterization:
27
28 #TODO: remove this once MC is fixed
29 if not flags.Tracking.doPixelDigitalClustering:
30 raise ValueError("clusterization on device is not compatible "
31 "with analog clustering at the moment due to incorrent "
32 "ToT values for Pixel hits in the simulation data.")
33
34 # Create RoI for secondary passes (e.g. LargeD0) to reuse
35 from ActsConfig.ActsRegionsOfInterestConfig import ActsRegionsOfInterestCreatorAlgCfg
36 acc.merge(ActsRegionsOfInterestCreatorAlgCfg(flags,
37 name=f"{flags.Tracking.ActiveConfig.extension}RegionsOfInterestCreatorAlg"))
38
39 print("Performing clusterization on device")
40
41 # setup RDO converter
42 if flags.Acts.EDM.PhaseII :
43 from ActsConfig.ActsPhaseIIRawDataEdmConfig import (
44 PhaseIIPixelRawDataContainerCfg,
45 PhaseIIStripRawDataContainerCfg,
46 )
47 acc.merge(PhaseIIPixelRawDataContainerCfg(flags))
48 acc.merge(PhaseIIStripRawDataContainerCfg(flags))
49 from ActsGPUEventCnv.ActsGPUEventCnvConfig import PhaseIIRDOtoTracccCellConverterAlgCfg
50 acc.merge(PhaseIIRDOtoTracccCellConverterAlgCfg(flags,
51 TracccCells = "TracccCellCollection",
52 ))
53 else:
54 from ActsGPUEventCnv.ActsGPUEventCnvConfig import RDOtoTracccCellConverterAlgCfg
55 acc.merge(RDOtoTracccCellConverterAlgCfg(flags,
56 TracccCells = "TracccCellCollection",
57 ))
58
59 # setup traccc clusterization
60 from ActsGPUDataPreparation.ActsGPUDataPreparationConfig import DeviceClusterizationAlgCfg
61 acc.merge(DeviceClusterizationAlgCfg(flags,
62 InputTracccCells="TracccCellCollection",
63 OutputTracccMeasurements="TracccMeasurementCollection",
64 OutputTracccClusters="TracccClusterCollection",
65 RetrieveClusterCells=flags.Tracking.doTruth,
66 previousExtension=previousExtension))
67 clustersLocation = DataLocation.DEVICE
68
69 else:
70 from InDetConfig.ITkActsDataPreparationConfig import ITkActsDataPreparationCfg
71 acc.merge(ITkActsDataPreparationCfg(flags, previousExtension=previousExtension))
72 clustersLocation = DataLocation.HOST
73
74 # --- Seeding ---
75 if flags.Acts.Device.doSeeding:
76
77 if clustersLocation is not DataLocation.DEVICE:
78 raise ValueError("Device seeding requires device clusterization "
79 "(flags.Acts.Device.doClusterization=True): it reads the "
80 "traccc measurement collection straight out of device memory "
81 "and there is currently no host->device measurement converter.")
82
83 # Pixel space point formation on device
84 from ActsGPUDataPreparation.ActsGPUDataPreparationConfig import DeviceSPFormationAlgCfg
85 acc.merge(DeviceSPFormationAlgCfg(flags,
86 name="DeviceSPFormationAlg",
87 InputTracccMeasurements="TracccMeasurementCollection",
88 OutputTracccPixelSpacepoints="TracccPixelSpacepointCollection"))
89
90 from ActsConfig.ActsConfigFlags import SeedingStrategy
91
92 print(f"Performing seeding on device with seeding strategy set to {flags.Acts.Device.seedingStrategy}")
93 if flags.Acts.Device.seedingStrategy in [SeedingStrategy.Gbts, SeedingStrategy.GbtsFtf]:
94 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import DeviceGBTSSeedingAlgCfg
95 acc.merge(DeviceGBTSSeedingAlgCfg(flags,
96 name="DeviceGBTSSeedingAlg",
97 InputTracccPixelSpacepoints="TracccPixelSpacepointCollection",
98 InputTracccMeasurements="TracccMeasurementCollection",
99 OutputTracccPixelSeeds="TracccPixelSeedCollection"))
100 else:
101 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import DeviceTripletSeedingAlgCfg
102 acc.merge(DeviceTripletSeedingAlgCfg(flags,
103 name="DeviceTripletSeedingAlg",
104 InputTracccPixelSpacepoints="TracccPixelSpacepointCollection",
105 OutputTracccPixelSeeds="TracccPixelSeedCollection"))
106
107 seedsLocation = DataLocation.DEVICE
108
109 else:
110
111 # If clusterization was on device, need to copy them to host first
112 # and schedule space point formation
113 if clustersLocation is DataLocation.DEVICE:
114 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccMeasurementConverterAlgCfg
115 acc.merge(TracccMeasurementConverterAlgCfg(flags,
116 InputMeasurements="TracccMeasurementCollection",
117 InputClusters="TracccClusterCollection",
118 InputCells="TracccCellCollection",
119 ConvertClustersWithCells = flags.Tracking.doTruth,
120 OutputPixelSpacePoints="ITkPixelSpacePoints",
121 OutputPixelClusters="ITkPixelClusters",
122 OutputStripClusters="ITkStripClusters"
123 ))
124
125 from ActsConfig.ActsSpacePointFormationConfig import ActsStripSpacePointFormationAlgCfg
126 acc.merge(ActsStripSpacePointFormationAlgCfg(flags,
127 name=f"{flags.Tracking.ActiveConfig.extension}StripSpacePointFormationAlg",
128 StripClusters="ITkStripClusters",
129 StripSpacePoints="ITkStripSpacePoints",
130 StripOverlapSpacePoints="ITkStripOverlapSpacePoints"))
131
132 clustersLocation = DataLocation.HOST
133
134 # Truth (as configured in ITkActsDataPreparationCfg)
135 # this truth must only be done if you do PRD and SpacePointformation
136 # If you only do the latter (== running on ESD) then the needed input (simdata)
137 # is not in ESD but the resulting truth (clustertruth) is already there ...
138 if flags.Tracking.doTruth:
139 from ActsConfig.ActsTruthConfig import ActsTruthAssociationAlgCfg, ActsTruthParticleHitCountAlgCfg
140 acc.merge(ActsTruthAssociationAlgCfg(flags))
141 acc.merge(ActsTruthParticleHitCountAlgCfg(flags))
142
143 from ActsConfig.ActsSeedingConfig import ActsSeedingCfg
144 acc.merge(ActsSeedingCfg(flags))
145 seedsLocation = DataLocation.HOST
146
147
148 # --- Track Reconstruction ---
149 if flags.Acts.Device.doTrackReconstruction:
150
151 if clustersLocation is not DataLocation.DEVICE or seedsLocation is not DataLocation.DEVICE:
152 raise ValueError("Device track reconstruction requires device clusterization "
153 "(flags.Acts.Device.doClusterization=True) and device seeding "
154 "(flags.Acts.Device.doSeeding=True): it reads the traccc measurement "
155 "and seed collections straight out of device memory and there is "
156 "currently no host->device converter for these yet.")
157
158
159 from ActsGPUMagField.ActsGPUMagFieldConfig import JSONDeviceMagFieldProviderSvcCfg
160 acc.merge(JSONDeviceMagFieldProviderSvcCfg(flags,
161 DeviceMagFieldObjectName="TracccMagneticField",
162 HostMagFieldObjectName="TracccHostMagField",
163 ))
164
165 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import DeviceTrkParamEstimationAlgCfg, DeviceTrackFindingAlgCfg
166 acc.merge(DeviceTrkParamEstimationAlgCfg(flags,
167 InputTracccSpacepoints="TracccPixelSpacepointCollection",
168 InputTracccMeasurements="TracccMeasurementCollection",
169 InputTracccSeeds="TracccPixelSeedCollection",
170 InputTracccMagField="TracccMagneticField",
171 OutputTracccTrackParameters="TracccTrackParameterCollection",
172 ))
173
174 acc.merge(DeviceTrackFindingAlgCfg(flags,
175 InputTracccMeasurements="TracccMeasurementCollection",
176 InputTracccMagField="TracccMagneticField",
177 InputTracccTrackParameters="TracccTrackParameterCollection",
178 InputTracccDetectorGeometry="TracccDeviceDetectorGeometry",
179 OutputTracccTracks="TracccTrackCollection",
180 ))
181
182 if clustersLocation is not DataLocation.DEVICE:
183 acc.merge(TracccMeasurementConverterAlgCfg(flags,
184 InputMeasurements="TracccMeasurementCollection",
185 InputClusters="TracccClusterCollection",
186 InputCells="TracccCellCollection",
187 ConvertClustersWithCells = flags.Tracking.doTruth,
188 OutputPixelClusters="ITkPixelClusters",
189 OutputPixelSpacePoints="ITkPixelSpacePoints",
190 OutputMeasToPixelSP="ITkTracccMeasToPixelSP",
191 OutputMeasToStripCl="ITkTracccMeasToStripCl",
192 OutputStripClusters="ITkStripClusters",
193 GeoIdMapping="TracccGeoIdMapping",
194 ))
195
196 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccTrackConverterAlgCfg, TracccMeasurementConverterAlgCfg
197 if clustersLocation is DataLocation.DEVICE:
198 acc.merge(TracccMeasurementConverterAlgCfg(flags,
199 InputMeasurements="TracccMeasurementCollection",
200 InputClusters="TracccClusterCollection",
201 InputCells="TracccCellCollection",
202 ConvertClustersWithCells = flags.Tracking.doTruth,
203 OutputPixelClusters="ITkPixelClusters",
204 OutputPixelSpacePoints="ITkPixelSpacePoints",
205 OutputMeasToPixelSP="ITkTracccMeasToPixelSP",
206 OutputMeasToStripCl="ITkTracccMeasToStripCl",
207 OutputStripClusters="ITkStripClusters"
208 ))
209
210 # Strip clusters were just produced above, but nothing forms strip
211 # space points on the device path — mirror the host-side flow
212 if flags.Tracking.ActiveConfig.useITkStripSeeding or (flags.Acts.SpacePoints.doStrip and not flags.Tracking.ActiveConfig.isSecondaryPass):
213 from ActsConfig.ActsSpacePointFormationConfig import ActsStripSpacePointFormationAlgCfg
214 acc.merge(ActsStripSpacePointFormationAlgCfg(flags,
215 name=f"{flags.Tracking.ActiveConfig.extension}StripSpacePointFormationAlg",
216 StripClusters="ITkStripClusters",
217 StripSpacePoints="ITkStripSpacePoints",
218 StripOverlapSpacePoints="ITkStripOverlapSpacePoints"))
219
220 acc.merge(TracccTrackConverterAlgCfg(flags,
221 InputPixelClusters="ITkPixelClusters",
222 InputStripClusters="ITkStripClusters",
223 InputMeasToPixelSP="ITkTracccMeasToPixelSP",
224 InputMeasToStripCl="ITkTracccMeasToStripCl",
225 InputTracks="TracccTrackCollection",
226 OutputTracks=f"{flags.Tracking.ActiveConfig.extension}Tracks",
227 ))
228
229
230
231 else:
232
233 # If clusterization was on device, need to copy the measurements to host first
234 if clustersLocation is DataLocation.DEVICE:
235 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccMeasurementConverterAlgCfg
236 acc.merge(TracccMeasurementConverterAlgCfg(flags,
237 InputMeasurements="TracccMeasurementCollection",
238 InputClusters="TracccClusterCollection",
239 InputCells="TracccCellCollection",
240 ConvertClustersWithCells = flags.Tracking.doTruth,
241 OutputPixelClusters="ITkPixelClusters",
242 OutputPixelSpacePoints="ITkPixelSpacePoints",
243 OutputMeasToPixelSP="ITkTracccMeasToPixelSP",
244 OutputMeasToStripCl="ITkTracccMeasToStripCl",
245 OutputStripClusters="ITkStripClusters"
246 ))
247 from ActsConfig.ActsSpacePointFormationConfig import ActsStripSpacePointFormationAlgCfg
248 acc.merge(ActsStripSpacePointFormationAlgCfg(flags,
249 name=f"{flags.Tracking.ActiveConfig.extension}StripSpacePointFormationAlg",
250 StripClusters="ITkStripClusters",
251 StripSpacePoints="ITkStripSpacePoints",
252 StripOverlapSpacePoints="ITkStripOverlapSpacePoints"))
253 clustersLocation = DataLocation.HOST
254
255 if seedsLocation is DataLocation.DEVICE:
256 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccSeedConverterAlgCfg
257
258 acc.merge(TracccSeedConverterAlgCfg(flags,
259 name="TracccSeedConverterAlg",
260 InputSpacepointsDevice="TracccPixelSpacepointCollection",
261 InputSpacepoints="ITkPixelSpacePoints",
262 InputMeasToPixelSP="ITkTracccMeasToPixelSP",
263 InputSeeds="TracccPixelSeedCollection",
264 OutputSeeds=f'{flags.Tracking.ActiveConfig.extension}PixelSeeds'))
265 seedsLocation = DataLocation.HOST
266
267 # CKF
268 from ActsConfig.ActsTrackFindingConfig import ActsTrackFindingCfg
269 acc.merge(ActsTrackFindingCfg(flags))
270
271 # Ambiguity Resolution
272 if flags.Acts.doAmbiguityResolution:
273 from ActsConfig.ActsTrackFindingConfig import ActsAmbiguityResolutionCfg
274 acc.merge(ActsAmbiguityResolutionCfg(flags))
275
276
277 # PRD association
278 from ActsConfig.ActsPrdAssociationConfig import ActsPrdAssociationAlgCfg
279 acc.merge(ActsPrdAssociationAlgCfg(flags,
280 name = f'{flags.Tracking.ActiveConfig.extension}PrdAssociationAlg',
281 previousActsExtension = previousExtension))
282
283 # Truth
284 if flags.Tracking.doTruth:
285
286 # schedule association of measurements to truth particles
287 from ActsConfig.ActsTruthConfig import ActsTruthAssociationAlgCfg, ActsTruthParticleHitCountAlgCfg
288 acc.merge(ActsTruthAssociationAlgCfg(flags))
289 acc.merge(ActsTruthParticleHitCountAlgCfg(flags))
290 if flags.Acts.doTruthInspection:
291 from ActsConfig.ActsInspectTruthContentConfig import ActsInspectTruthContentAlgCfg
292 acc.merge(ActsInspectTruthContentAlgCfg(flags))
293
294 # Run truth on CKF tracks
295 # This is only necessary if we are asking for these tracks to be persistified with the
296 # - flag: Tracking.ActiveConfig.storeSiSPSeededTracks set to True OR
297 # - flag: flags.Acts.doAmbiguityResolution set to False
298 if flags.Tracking.ActiveConfig.storeSiSPSeededTracks or not flags.Acts.doAmbiguityResolution:
299 from ActsConfig.ActsTruthConfig import ActsTrackToTruthAssociationAlgCfg, ActsTrackFindingValidationAlgCfg
300 acts_tracks = f"{flags.Tracking.ActiveConfig.extension}Tracks"
301 acc.merge(ActsTrackToTruthAssociationAlgCfg(flags,
302 name = f"{acts_tracks}TrackToTruthAssociationAlg",
303 ACTSTracksLocation = acts_tracks,
304 AssociationMapOut = f"{acts_tracks}ToTruthParticleAssociation"))
305
306 acc.merge(ActsTrackFindingValidationAlgCfg(flags,
307 name = f"{acts_tracks}TrackFindingValidationAlg",
308 TrackToTruthAssociationMap = f"{acts_tracks}ToTruthParticleAssociation"))
309
310 # Run truth on the tracks from ambiguity resolution. This is only necessary if
311 # - flag: flags.Acts.doAmbiguityResolution set to True
312 if flags.Acts.doAmbiguityResolution:
313 acts_tracks = f"{flags.Tracking.ActiveConfig.extension}ResolvedTracks"
314 from ActsConfig.ActsTruthConfig import ActsTrackToTruthAssociationAlgCfg, ActsTrackFindingValidationAlgCfg
315 acc.merge(ActsTrackToTruthAssociationAlgCfg(flags,
316 name = f"{acts_tracks}TrackToTruthAssociationAlg",
317 ACTSTracksLocation = acts_tracks,
318 AssociationMapOut = f"{acts_tracks}ToTruthParticleAssociation"))
319
320 acc.merge(ActsTrackFindingValidationAlgCfg(flags,
321 name = f"{acts_tracks}TrackFindingValidationAlg",
322 TrackToTruthAssociationMap = f"{acts_tracks}ToTruthParticleAssociation"))
323
324 # Extract track parameters from device seeds if requested
325 if flags.Tracking.ActiveConfig.storeTrackSeeds and flags.Acts.Device.doSeeding: # for clustering only pipelines this is controlled via the ActsSeedingConfig file
326 from ActsConfig.ActsSeedingConfig import ActsStoreTrackSeedsCfg
327 from ActsConfig.ActsAnalysisConfig import ActsPixelSeedsToTrackParamsAlgCfg, ActsStripSeedsToTrackParamsAlgCfg
328 processPixels = flags.Tracking.ActiveConfig.useITkPixelSeeding
329 processStrips = flags.Tracking.ActiveConfig.useITkStripSeeding
330
331 prefix = flags.Tracking.ActiveConfig.extension
332
333 if flags.Acts.Device.doTrackReconstruction:
334 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccSeedConverterAlgCfg
335 acc.merge(TracccSeedConverterAlgCfg(flags,
336 name="TracccSeedConverterAlg",
337 InputSpacepointsDevice="TracccPixelSpacepointCollection",
338 InputSpacepoints="ITkPixelSpacePoints",
339 InputMeasToPixelSP="ITkTracccMeasToPixelSP",
340 InputSeeds="TracccPixelSeedCollection",
341 OutputSeeds=f'{flags.Tracking.ActiveConfig.extension}PixelSeeds'))
342
343 # Create track parameters before ActsStoreTrackSeedsCfg (following ActsSeedingCfg pattern)
344 if processPixels:
345 acc.merge(ActsPixelSeedsToTrackParamsAlgCfg(
346 flags,
347 name = prefix + 'PixelSeedsToTrackParamsAlg',
348 InputSeedContainerKey = prefix + 'PixelSeeds',
349 OutputTrackParamsCollectionKey = prefix + 'PixelEstimatedTrackParams'))
350 if processStrips:
351 acc.merge(ActsStripSeedsToTrackParamsAlgCfg(
352 flags,
353 name = prefix + 'StripSeedsToTrackParamsAlg',
354 InputSeedContainerKey = prefix + 'StripSeeds',
355 OutputTrackParamsCollectionKey = prefix + 'StripEstimatedTrackParams'))
356
357 if processPixels:
358 acc.merge(ActsStoreTrackSeedsCfg(flags,processPixels=True, processStrips=False))
359 if processStrips:
360 acc.merge(ActsStoreTrackSeedsCfg(flags,processPixels=False, processStrips=True))
361 if processPixels and processStrips:
362 acc.merge(ActsStoreTrackSeedsCfg(flags,processPixels=True, processStrips=True))
363
364 return acc
void print(char *figname, TCanvas *c1)
ITkActsDeviceTrackRecoCfg(flags, *, previousExtension=None)