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 DeviceDetectorDescriptionCondAlgCfg
6from ActsConfig.ActsConfigFlags import DeviceTritonMode, HostCKFInput
7from ActsGPUDataPreparation.ActsGPUDataPreparationConfig import DeviceClusterizationAlgCfg
8
9class DataLocation(FlagEnum):
10 HOST = "host" # Athena objects on CPU
11 DEVICE = "device" # Traccc buffers on GPU
12
13def ITkActsDeviceTrackRecoCfg(flags, *, previousExtension=None):
14 acc = ComponentAccumulator()
15
16 tritonMode = flags.Acts.Device.tritonMode
17 doDeviceSteps = (flags.Acts.Device.doClusterization,
18 flags.Acts.Device.doSeeding,
19 flags.Acts.Device.doTrackReconstruction)
20 if tritonMode is DeviceTritonMode.Server and not all(doDeviceSteps):
21 raise ValueError("Acts.Device.tritonMode=Server runs the full chain on "
22 "the device: Acts.Device.doClusterization, doSeeding and "
23 "doTrackReconstruction must all be True.")
24 if tritonMode is DeviceTritonMode.Client and any(doDeviceSteps):
25 raise ValueError("Acts.Device.tritonMode=Client sends the event to the "
26 "Triton server instead of running on the device: "
27 "Acts.Device.doClusterization, doSeeding and doTrackReconstruction "
28 "must all be False.")
29
30 # Bring up shared device infrastructure once, upfront
31 print(f"Setting up GPU algorithms with {flags.Device.Backend.value} backend")
32
33 acc.merge(DeviceDetectorDescriptionCondAlgCfg(flags))
34
35 if tritonMode is DeviceTritonMode.Client:
36 from TracccTritonClient.TracccTritonClientConfig import TritonTracccTrackMakerCfg
37 acc.merge(TritonTracccTrackMakerCfg(flags))
38 acc.merge(ITkActsDeviceTrackRecoPostProcessingCfg(flags, previousExtension=previousExtension))
39 return acc
40
41 # --- Clusterization ---
42 if flags.Acts.Device.doClusterization and tritonMode is DeviceTritonMode.Server:
43 # The cells are recorded by the Triton backend from the client request
44 acc.merge(DeviceClusterizationAlgCfg(flags,
45 InputTracccCells="TracccCellCollection",
46 OutputTracccMeasurements="TracccMeasurementCollection",
47 OutputTracccClusters="TracccClusterCollection",
48 RetrieveClusterCells=True))
49 clustersLocation = DataLocation.DEVICE
50
51 elif flags.Acts.Device.doClusterization:
52
53 #TODO: remove this once MC is fixed
54 if not flags.Tracking.doPixelDigitalClustering:
55 raise ValueError("clusterization on device is not compatible "
56 "with analog clustering at the moment due to incorrent "
57 "ToT values for Pixel hits in the simulation data.")
58
59 # Create RoI for secondary passes (e.g. LargeD0) to reuse
60 from ActsConfig.ActsRegionsOfInterestConfig import ActsRegionsOfInterestCreatorAlgCfg
61 acc.merge(ActsRegionsOfInterestCreatorAlgCfg(flags,
62 name=f"{flags.Tracking.ActiveConfig.extension}RegionsOfInterestCreatorAlg"))
63
64 # PLR has no device clustering; run it on the host as a sidecar
65 if flags.Detector.EnablePLR:
66 from ActsConfig.ActsClusterizationConfig import ActsPLRClusterizationAlgCfg
67 acc.merge(ActsPLRClusterizationAlgCfg(
68 flags,
69 name=f"{flags.Tracking.ActiveConfig.extension}PLRClusterizationAlg",
70 RoIs=f"{flags.Tracking.ActiveConfig.extension}RegionOfInterest"))
71
72 print("Performing clusterization on device")
73
74 # setup RDO converter
75 if flags.Acts.EDM.PhaseII :
76 from ActsConfig.ActsPhaseIIRawDataEdmConfig import (
77 PhaseIIPixelRawDataContainerCfg,
78 PhaseIIStripRawDataContainerCfg,
79 )
80 acc.merge(PhaseIIPixelRawDataContainerCfg(flags))
81 acc.merge(PhaseIIStripRawDataContainerCfg(flags))
82 from ActsGPUEventCnv.ActsGPUEventCnvConfig import PhaseIIRDOtoTracccCellConverterAlgCfg
83 acc.merge(PhaseIIRDOtoTracccCellConverterAlgCfg(flags,
84 TracccCells = "TracccCellCollection",
85 ))
86 else:
87 from ActsGPUEventCnv.ActsGPUEventCnvConfig import RDOtoTracccCellConverterAlgCfg
88 acc.merge(RDOtoTracccCellConverterAlgCfg(flags,
89 TracccCells = "TracccCellCollection",
90 ))
91
92 # setup traccc clusterization
93 acc.merge(DeviceClusterizationAlgCfg(flags,
94 InputTracccCells="TracccCellCollection",
95 OutputTracccMeasurements="TracccMeasurementCollection",
96 OutputTracccClusters="TracccClusterCollection",
97 RetrieveClusterCells=flags.Tracking.doTruth,
98 previousExtension=previousExtension))
99 clustersLocation = DataLocation.DEVICE
100
101 else:
102 from InDetConfig.ITkActsDataPreparationConfig import ITkActsDataPreparationCfg
103 acc.merge(ITkActsDataPreparationCfg(flags, previousExtension=previousExtension))
104 clustersLocation = DataLocation.HOST
105
106 # --- Seeding ---
107 if flags.Acts.Device.doSeeding:
108
109 if clustersLocation is not DataLocation.DEVICE:
110 raise ValueError("Device seeding requires device clusterization "
111 "(flags.Acts.Device.doClusterization=True): it reads the "
112 "traccc measurement collection straight out of device memory "
113 "and there is currently no host->device measurement converter.")
114
115 # Pixel space point formation on device
116 from ActsGPUDataPreparation.ActsGPUDataPreparationConfig import DeviceSPFormationAlgCfg
117 acc.merge(DeviceSPFormationAlgCfg(flags,
118 name="DeviceSPFormationAlg",
119 InputTracccMeasurements="TracccMeasurementCollection",
120 OutputTracccPixelSpacepoints="TracccPixelSpacepointCollection"))
121
122 from ActsConfig.ActsConfigFlags import SeedingStrategy
123
124 print(f"Performing seeding on device with seeding strategy set to {flags.Acts.Device.seedingStrategy}")
125 if flags.Acts.Device.seedingStrategy is SeedingStrategy.Gbts:
126 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import DeviceGBTSSeedingAlgCfg
127 acc.merge(DeviceGBTSSeedingAlgCfg(flags,
128 name="DeviceGBTSSeedingAlg",
129 InputTracccPixelSpacepoints="TracccPixelSpacepointCollection",
130 InputTracccMeasurements="TracccMeasurementCollection",
131 OutputTracccPixelSeeds="TracccPixelSeedCollection"))
132 else:
133 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import DeviceTripletSeedingAlgCfg
134 acc.merge(DeviceTripletSeedingAlgCfg(flags,
135 name="DeviceTripletSeedingAlg",
136 InputTracccPixelSpacepoints="TracccPixelSpacepointCollection",
137 OutputTracccPixelSeeds="TracccPixelSeedCollection"))
138
139 seedsLocation = DataLocation.DEVICE
140
141 else:
142
143 # If clusterization was on device, need to copy them to host first
144 # and schedule space point formation
145 if clustersLocation is DataLocation.DEVICE:
146 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccMeasurementConverterAlgCfg
147 acc.merge(TracccMeasurementConverterAlgCfg(flags,
148 InputMeasurements="TracccMeasurementCollection",
149 InputClusters="TracccClusterCollection",
150 InputCells="TracccCellCollection",
151 ConvertClustersWithCells = flags.Tracking.doTruth,
152 OutputPixelSpacePoints="ITkPixelSpacePoints",
153 OutputPixelClusters="ITkPixelClusters",
154 OutputStripClusters="ITkStripClusters"
155 ))
156
157 from ActsConfig.ActsSpacePointFormationConfig import ActsStripSpacePointFormationAlgCfg
158 acc.merge(ActsStripSpacePointFormationAlgCfg(flags,
159 name=f"{flags.Tracking.ActiveConfig.extension}StripSpacePointFormationAlg",
160 StripClusters="ITkStripClusters",
161 StripSpacePoints="ITkStripSpacePoints",
162 StripOverlapSpacePoints="ITkStripOverlapSpacePoints"))
163
164 clustersLocation = DataLocation.HOST
165
166 # Truth (as configured in ITkActsDataPreparationCfg)
167 # this truth must only be done if you do PRD and SpacePointformation
168 # If you only do the latter (== running on ESD) then the needed input (simdata)
169 # is not in ESD but the resulting truth (clustertruth) is already there ...
170 if flags.Tracking.doTruth:
171 from ActsConfig.ActsTruthConfig import ActsTruthAssociationAlgCfg, ActsTruthParticleHitCountAlgCfg
172 acc.merge(ActsTruthAssociationAlgCfg(flags))
173 acc.merge(ActsTruthParticleHitCountAlgCfg(flags))
174
175 from ActsConfig.ActsSeedingConfig import ActsSeedingCfg
176 acc.merge(ActsSeedingCfg(flags))
177 seedsLocation = DataLocation.HOST
178
179
180 # --- Track Reconstruction ---
181 if flags.Acts.Device.doTrackReconstruction:
182
183 if clustersLocation is not DataLocation.DEVICE or seedsLocation is not DataLocation.DEVICE:
184 raise ValueError("Device track reconstruction requires device clusterization "
185 "(flags.Acts.Device.doClusterization=True) and device seeding "
186 "(flags.Acts.Device.doSeeding=True): it reads the traccc measurement "
187 "and seed collections straight out of device memory and there is "
188 "currently no host->device converter for these yet.")
189
190
191 from ActsGPUMagField.ActsGPUMagFieldConfig import JSONDeviceMagFieldProviderSvcCfg
192 acc.merge(JSONDeviceMagFieldProviderSvcCfg(flags,
193 DeviceMagFieldObjectName="TracccMagneticField",
194 HostMagFieldObjectName="TracccHostMagField",
195 ))
196
197 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import DeviceTrkParamEstimationAlgCfg, DeviceTrackFindingAlgCfg
198 acc.merge(DeviceTrkParamEstimationAlgCfg(flags,
199 InputTracccSpacepoints="TracccPixelSpacepointCollection",
200 InputTracccMeasurements="TracccMeasurementCollection",
201 InputTracccSeeds="TracccPixelSeedCollection",
202 InputTracccMagField="TracccMagneticField",
203 OutputTracccTrackParameters="TracccTrackParameterCollection",
204 ))
205
206 acc.merge(DeviceTrackFindingAlgCfg(flags,
207 InputTracccMeasurements="TracccMeasurementCollection",
208 InputTracccMagField="TracccMagneticField",
209 InputTracccTrackParameters="TracccTrackParameterCollection",
210 InputTracccDetectorGeometry="TracccDeviceDetectorGeometry",
211 OutputTracccTracks="TracccTrackCollection",
212 ))
213
214 # The Triton backend returns the raw tracks to be converted by the client
215 if tritonMode is DeviceTritonMode.Server:
216 return acc
217
218 if clustersLocation is not DataLocation.DEVICE:
219 acc.merge(TracccMeasurementConverterAlgCfg(flags,
220 InputMeasurements="TracccMeasurementCollection",
221 InputClusters="TracccClusterCollection",
222 InputCells="TracccCellCollection",
223 ConvertClustersWithCells = flags.Tracking.doTruth,
224 OutputPixelClusters="ITkPixelClusters",
225 OutputPixelSpacePoints="ITkPixelSpacePoints",
226 OutputMeasToPixelSP="ITkTracccMeasToPixelSP",
227 OutputMeasToStripCl="ITkTracccMeasToStripCl",
228 OutputStripClusters="ITkStripClusters",
229 GeoIdMapping="TracccGeoIdMapping",
230 ))
231
232 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccTrackConverterAlgCfg, TracccMeasurementConverterAlgCfg
233 if clustersLocation is DataLocation.DEVICE:
234 acc.merge(TracccMeasurementConverterAlgCfg(flags,
235 InputMeasurements="TracccMeasurementCollection",
236 InputClusters="TracccClusterCollection",
237 InputCells="TracccCellCollection",
238 ConvertClustersWithCells = flags.Tracking.doTruth,
239 OutputPixelClusters="ITkPixelClusters",
240 OutputPixelSpacePoints="ITkPixelSpacePoints",
241 OutputMeasToPixelSP="ITkTracccMeasToPixelSP",
242 OutputMeasToStripCl="ITkTracccMeasToStripCl",
243 OutputStripClusters="ITkStripClusters"
244 ))
245
246 # Strip clusters were just produced above, but nothing forms strip
247 # space points on the device path — mirror the host-side flow
248 if flags.Tracking.ActiveConfig.useITkStripSeeding or (flags.Acts.SpacePoints.doStrip and not flags.Tracking.ActiveConfig.isSecondaryPass):
249 from ActsConfig.ActsSpacePointFormationConfig import ActsStripSpacePointFormationAlgCfg
250 acc.merge(ActsStripSpacePointFormationAlgCfg(flags,
251 name=f"{flags.Tracking.ActiveConfig.extension}StripSpacePointFormationAlg",
252 StripClusters="ITkStripClusters",
253 StripSpacePoints="ITkStripSpacePoints",
254 StripOverlapSpacePoints="ITkStripOverlapSpacePoints"))
255
256 acc.merge(TracccTrackConverterAlgCfg(flags,
257 InputPixelClusters="ITkPixelClusters",
258 InputStripClusters="ITkStripClusters",
259 InputMeasToPixelSP="ITkTracccMeasToPixelSP",
260 InputMeasToStripCl="ITkTracccMeasToStripCl",
261 InputTracks="TracccTrackCollection",
262 OutputTracks=f"{flags.Tracking.ActiveConfig.extension}Tracks",
263 ))
264
265
266
267 else:
268
269 # If clusterization was on device, need to copy the measurements to host first
270 if clustersLocation is DataLocation.DEVICE:
271 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccMeasurementConverterAlgCfg
272 acc.merge(TracccMeasurementConverterAlgCfg(flags,
273 InputMeasurements="TracccMeasurementCollection",
274 InputClusters="TracccClusterCollection",
275 InputCells="TracccCellCollection",
276 ConvertClustersWithCells = flags.Tracking.doTruth,
277 OutputPixelClusters="ITkPixelClusters",
278 OutputPixelSpacePoints="ITkPixelSpacePoints",
279 OutputMeasToPixelSP="ITkTracccMeasToPixelSP",
280 OutputMeasToStripCl="ITkTracccMeasToStripCl",
281 OutputStripClusters="ITkStripClusters"
282 ))
283 from ActsConfig.ActsSpacePointFormationConfig import ActsStripSpacePointFormationAlgCfg
284 acc.merge(ActsStripSpacePointFormationAlgCfg(flags,
285 name=f"{flags.Tracking.ActiveConfig.extension}StripSpacePointFormationAlg",
286 StripClusters="ITkStripClusters",
287 StripSpacePoints="ITkStripSpacePoints",
288 StripOverlapSpacePoints="ITkStripOverlapSpacePoints"))
289 clustersLocation = DataLocation.HOST
290
291 ckfKwargs = {}
292 if (seedsLocation is DataLocation.DEVICE and
293 flags.Acts.Device.hostCKFInput is HostCKFInput.TrackParameters):
294 # The seed track parameters are estimated on the device, and handed
295 # to the CKF with the measurements of each seed instead of seeds&SPs.
296 # Pixel seeds only for now.
297 if flags.Tracking.ActiveConfig.useITkStripSeeding:
298 print("Acts.Device.hostCKFInput=TrackParameters: the host CKF "
299 "starts from the device pixel seeds only, strip seeding is not run")
300
301 acc.merge(ITkActsDeviceSeedParametersCfg(flags))
302 ckfKwargs = dict(
303 SeedLabels=["PPP"],
304 SeedContainerKeys=[],
305 TrackParamsEstimationTool=[],
306 InitialParametersKeys=["ITkTracccSeedParameters"],
307 SeedMeasurementsKeys=["ITkTracccSeedMeasurements"])
308 seedsLocation = DataLocation.HOST
309
310 elif seedsLocation is DataLocation.DEVICE:
311 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccSeedConverterAlgCfg
312
313 acc.merge(TracccSeedConverterAlgCfg(flags,
314 name="TracccSeedConverterAlg",
315 InputSpacepointsDevice="TracccPixelSpacepointCollection",
316 InputSpacepoints="ITkPixelSpacePoints",
317 InputMeasToPixelSP="ITkTracccMeasToPixelSP",
318 InputSeeds="TracccPixelSeedCollection",
319 OutputSeeds=f'{flags.Tracking.ActiveConfig.extension}PixelSeeds'))
320 seedsLocation = DataLocation.HOST
321
322 # CKF
323 # default ACTS offline chain has strip seeding enabled,
324 # but the device path does not support strip seeding yet,
325 # throw exception if the user has enabled strip seeding
326
327 if flags.Tracking.ActiveConfig.useITkStripSeeding:
328 raise ValueError("Strip seeding is enabled in the configuration, but it is not supported on the device path. Turn it off using Tracking.ITkActsPass.useITkStripSeeding flag.")
329
330 from ActsConfig.ActsTrackFindingConfig import ActsTrackFindingCfg
331 acc.merge(ActsTrackFindingCfg(flags, **ckfKwargs))
332
333 # Ambiguity Resolution
334 if flags.Acts.doAmbiguityResolution:
335 from ActsConfig.ActsTrackFindingConfig import ActsAmbiguityResolutionCfg
336 acc.merge(ActsAmbiguityResolutionCfg(flags))
337
338 acc.merge(ITkActsDeviceTrackRecoPostProcessingCfg(flags, previousExtension=previousExtension))
339 return acc
340
341
343 *,
344 spacepoints="TracccPixelSpacepointCollection",
345 measurements="TracccMeasurementCollection",
346 seeds="TracccPixelSeedCollection",
347 trackParameters="TracccTrackParameterCollection",
348 outputParameters="ITkTracccSeedParameters",
349 outputSeedMeasurements="ITkTracccSeedMeasurements"):
350 """Device seeds -> track parameters estimated on the device -> initial
351 parameters and seed measurements for the host CKF (InitialParametersKeys
352 and SeedMeasurementsKeys of ActsTrackFindingCfg).
353
354 Needs the host xAOD clusters and the measurement index maps of
355 TracccMeasurementConverterAlg (ITkPixelClusters, ITkStripClusters,
356 ITkTracccMeasToPixelSP, ITkTracccMeasToStripCl)."""
357 acc = ComponentAccumulator()
358
359 from ActsGPUMagField.ActsGPUMagFieldConfig import JSONDeviceMagFieldProviderSvcCfg
360 acc.merge(JSONDeviceMagFieldProviderSvcCfg(flags,
361 DeviceMagFieldObjectName="TracccMagneticField",
362 HostMagFieldObjectName="TracccHostMagField",
363 ))
364
365 # The host CKF gets the same initial covariance as from the CPU parameter
366 # estimation: the defaults of the CPU TrackParamsEstimationTool, and the
367 # same variance inflation flag (the traccc defaults differ, e.g. 1 degree
368 # instead of 0.1 degree for phi and theta)
369 from AthenaConfiguration.ComponentFactory import CompFactory
370 cpuTpe = CompFactory.ActsTrk.TrackParamsEstimationTool
371 cpuCovariance = {name: cpuTpe.getDefaultProperty(name)
372 for name in ("sigmaLoc0", "sigmaLoc1", "sigmaPhi", "sigmaTheta",
373 "sigmaQOverP", "sigmaT0", "initialSigmaPtRel")}
374
375 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import DeviceTrkParamEstimationAlgCfg
376 acc.merge(DeviceTrkParamEstimationAlgCfg(flags,
377 InputTracccSpacepoints=spacepoints,
378 InputTracccMeasurements=measurements,
379 InputTracccSeeds=seeds,
380 InputTracccMagField="TracccMagneticField",
381 OutputTracccTrackParameters=trackParameters,
382 sigmaQOverPt=0., # the CPU tool has no q/pt term
383 initialVarInflation=flags.Acts.initialVarInflation,
384 **cpuCovariance,
385 ))
386
387 # The track parameters (reduced covariance) and the measurement indices of
388 # each seed, packed on the device into one buffer: the host needs a single
389 # copy, and neither the device space points nor the seeds are copied to the host.
390 from ActsGPUEventCnv.ActsGPUEventCnvConfig import (
391 TracccTrkParamDeviceConverterAlgCfg, TracccTrkParamConverterAlgCfg)
392 packedTrkParams = f"{seeds}PackedTrkParams"
393 acc.merge(TracccTrkParamDeviceConverterAlgCfg(flags,
394 InputTrackParameters=trackParameters,
395 InputSpacepoints=spacepoints,
396 InputSeeds=seeds,
397 OutputPackedTrkParams=packedTrkParams,
398 ))
399
400 acc.merge(TracccTrkParamConverterAlgCfg(flags,
401 InputPackedTrkParams=packedTrkParams,
402 InputPixelClusters="ITkPixelClusters",
403 InputStripClusters="ITkStripClusters",
404 InputMeasToPixelSP="ITkTracccMeasToPixelSP",
405 InputMeasToStripCl="ITkTracccMeasToStripCl",
406 OutputTrackParameters=outputParameters,
407 OutputSeedMeasurements=outputSeedMeasurements,
408 ))
409
410 return acc
411
412
413def ITkActsDeviceTrackRecoPostProcessingCfg(flags, *, previousExtension=None):
414 """PRD association and truth for the tracks of the primary pass, once
415 they are converted back to the host."""
416 acc = ComponentAccumulator()
417
418 # PRD association
419 from ActsConfig.ActsPrdAssociationConfig import ActsPrdAssociationAlgCfg
420 acc.merge(ActsPrdAssociationAlgCfg(flags,
421 name = f'{flags.Tracking.ActiveConfig.extension}PrdAssociationAlg',
422 previousActsExtension = previousExtension))
423
424 # Truth
425 if flags.Tracking.doTruth:
426
427 # schedule association of measurements to truth particles
428 from ActsConfig.ActsTruthConfig import ActsTruthAssociationAlgCfg, ActsTruthParticleHitCountAlgCfg
429 acc.merge(ActsTruthAssociationAlgCfg(flags))
430 acc.merge(ActsTruthParticleHitCountAlgCfg(flags))
431 if flags.Acts.doTruthInspection:
432 from ActsConfig.ActsInspectTruthContentConfig import ActsInspectTruthContentAlgCfg
433 acc.merge(ActsInspectTruthContentAlgCfg(flags))
434
435 # Run truth on CKF tracks
436 # This is only necessary if we are asking for these tracks to be persistified with the
437 # - flag: Tracking.ActiveConfig.storeSiSPSeededTracks set to True OR
438 # - flag: flags.Acts.doAmbiguityResolution set to False
439 if flags.Tracking.ActiveConfig.storeSiSPSeededTracks or not flags.Acts.doAmbiguityResolution:
440 from ActsConfig.ActsTruthConfig import ActsTrackToTruthAssociationAlgCfg, ActsTrackFindingValidationAlgCfg
441 acts_tracks = f"{flags.Tracking.ActiveConfig.extension}Tracks"
442 acc.merge(ActsTrackToTruthAssociationAlgCfg(flags,
443 name = f"{acts_tracks}TrackToTruthAssociationAlg",
444 ACTSTracksLocation = acts_tracks,
445 AssociationMapOut = f"{acts_tracks}ToTruthParticleAssociation"))
446
447 acc.merge(ActsTrackFindingValidationAlgCfg(flags,
448 name = f"{acts_tracks}TrackFindingValidationAlg",
449 TrackToTruthAssociationMap = f"{acts_tracks}ToTruthParticleAssociation"))
450
451 # Run truth on the tracks from ambiguity resolution. This is only necessary if
452 # - flag: flags.Acts.doAmbiguityResolution set to True
453 if flags.Acts.doAmbiguityResolution:
454 acts_tracks = f"{flags.Tracking.ActiveConfig.extension}ResolvedTracks"
455 from ActsConfig.ActsTruthConfig import ActsTrackToTruthAssociationAlgCfg, ActsTrackFindingValidationAlgCfg
456 acc.merge(ActsTrackToTruthAssociationAlgCfg(flags,
457 name = f"{acts_tracks}TrackToTruthAssociationAlg",
458 ACTSTracksLocation = acts_tracks,
459 AssociationMapOut = f"{acts_tracks}ToTruthParticleAssociation"))
460
461 acc.merge(ActsTrackFindingValidationAlgCfg(flags,
462 name = f"{acts_tracks}TrackFindingValidationAlg",
463 TrackToTruthAssociationMap = f"{acts_tracks}ToTruthParticleAssociation"))
464
465 # Extract track parameters from device seeds if requested
466 if flags.Tracking.ActiveConfig.storeTrackSeeds and flags.Acts.Device.doSeeding: # for clustering only pipelines this is controlled via the ActsSeedingConfig file
467 from ActsConfig.ActsSeedingConfig import ActsStoreTrackSeedsCfg
468 from ActsConfig.ActsAnalysisConfig import ActsPixelSeedsToTrackParamsAlgCfg, ActsStripSeedsToTrackParamsAlgCfg
469 processPixels = flags.Tracking.ActiveConfig.useITkPixelSeeding
470 processStrips = flags.Tracking.ActiveConfig.useITkStripSeeding
471
472 prefix = flags.Tracking.ActiveConfig.extension
473
474 if flags.Acts.Device.doTrackReconstruction:
475 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccSeedConverterAlgCfg
476 acc.merge(TracccSeedConverterAlgCfg(flags,
477 name="TracccSeedConverterAlg",
478 InputSpacepointsDevice="TracccPixelSpacepointCollection",
479 InputSpacepoints="ITkPixelSpacePoints",
480 InputMeasToPixelSP="ITkTracccMeasToPixelSP",
481 InputSeeds="TracccPixelSeedCollection",
482 OutputSeeds=f'{flags.Tracking.ActiveConfig.extension}PixelSeeds'))
483
484 # Create track parameters before ActsStoreTrackSeedsCfg (following ActsSeedingCfg pattern)
485 if processPixels:
486 acc.merge(ActsPixelSeedsToTrackParamsAlgCfg(
487 flags,
488 name = prefix + 'PixelSeedsToTrackParamsAlg',
489 InputSeedContainerKey = prefix + 'PixelSeeds',
490 OutputTrackParamsCollectionKey = prefix + 'PixelEstimatedTrackParams'))
491 if processStrips:
492 acc.merge(ActsStripSeedsToTrackParamsAlgCfg(
493 flags,
494 name = prefix + 'StripSeedsToTrackParamsAlg',
495 InputSeedContainerKey = prefix + 'StripSeeds',
496 OutputTrackParamsCollectionKey = prefix + 'StripEstimatedTrackParams'))
497
498 if processPixels:
499 acc.merge(ActsStoreTrackSeedsCfg(flags,processPixels=True, processStrips=False))
500 if processStrips:
501 acc.merge(ActsStoreTrackSeedsCfg(flags,processPixels=False, processStrips=True))
502 if processPixels and processStrips:
503 acc.merge(ActsStoreTrackSeedsCfg(flags,processPixels=True, processStrips=True))
504
505 return acc
506
507
508def ITkActsDeviceSecondaryPassTrackRecoCfg(flags, *, previousExtension=None):
509 """Secondary tracking pass with data preparation on the host and
510 seeding and track finding on the device.
511
512 The clusters and space points of the pass are prepared on the host from
513 the objects of the previous pass (PRD association), converted to traccc
514 measurements and spacepoints, and the seeds and tracks are reconstructed
515 on the device. The tracks are converted back to an ACTS track container
516 named as for the host reconstruction of the pass.
517 """
518 acc = ComponentAccumulator()
519
520 if previousExtension is None:
521 raise ValueError("A secondary pass on the device requires a previous pass")
522
523 extension = flags.Tracking.ActiveConfig.extension
524 prefix = f"ITk{extension.replace('Acts', '')}"
525 pixelClusters = f"{prefix}PixelClusters"
526 stripClusters = f"{prefix}StripClusters"
527
528 if flags.Tracking.ActiveConfig.useITkPixelSeeding:
529 raise ValueError("Pixel seeding on the device is not supported for secondary passes")
530 if not flags.Tracking.ActiveConfig.useITkStripSeeding:
531 raise ValueError("Secondary pass on the device requires strip seeding")
532
533 print(f"Setting up GPU algorithms for the {extension} pass with {flags.Device.Backend.value} backend")
534
535 # Setup traccc detector description objects — loads all device detector description data into detStore
536 acc.merge(DeviceDetectorDescriptionCondAlgCfg(flags))
537
538 from ActsGPUMagField.ActsGPUMagFieldConfig import JSONDeviceMagFieldProviderSvcCfg
539 acc.merge(JSONDeviceMagFieldProviderSvcCfg(flags,
540 DeviceMagFieldObjectName="TracccMagneticField",
541 HostMagFieldObjectName="TracccHostMagField",
542 ))
543
544 # --- Data preparation on the host ---
545 from InDetConfig.ITkActsDataPreparationConfig import ITkActsDataPreparationCfg
546 acc.merge(ITkActsDataPreparationCfg(flags, previousExtension=previousExtension))
547
548 # --- Conversion to traccc ---
549 measurements = f"Traccc{extension}MeasurementCollection"
550 measToPixelCluster = f"Traccc{extension}MeasToPixelCluster"
551 measToStripCluster = f"Traccc{extension}MeasToStripCluster"
552 stripSpacepoints = f"Traccc{extension}StripSpacepointCollection"
553
554 from ActsGPUEventCnv.ActsGPUEventCnvConfig import (
555 xAODToTracccMeasurementConverterAlgCfg,
556 xAODToTracccSpacePointConverterAlgCfg,
557 )
558 acc.merge(xAODToTracccMeasurementConverterAlgCfg(flags,
559 name=f"{extension}MeasurementConverterAlg",
560 InputPixelClusters=pixelClusters,
561 InputStripClusters=stripClusters,
562 OutputTracccMeasurements=measurements,
563 OutputMeasToPixelCluster=measToPixelCluster,
564 OutputMeasToStripCluster=measToStripCluster,
565 ))
566
567 stripSpacePoints = [f"{prefix}StripSpacePoints"]
568 if extension != "ActsConversion":
569 stripSpacePoints += [f"{prefix}StripOverlapSpacePoints"]
570 acc.merge(xAODToTracccSpacePointConverterAlgCfg(flags,
571 name=f"{extension}StripSpacePointConverterAlg",
572 InputSpacePoints=stripSpacePoints,
573 InputMeasToCluster=measToStripCluster,
574 OutputTracccSpacepoints=stripSpacepoints,
575 ))
576
577 # --- Seeding ---
578 seeds = f"Traccc{extension}StripSeedCollection"
579 from ActsGPUPatternRecognition.ActsGPUPatternRecognitionConfig import (
580 DeviceLargeRadiusStripTripletSeedingAlgCfg,
581 DeviceTrkParamEstimationAlgCfg,
582 DeviceLargeRadiusTrackFindingAlgCfg,
583 )
584 acc.merge(DeviceLargeRadiusStripTripletSeedingAlgCfg(flags,
585 name=f"{extension}DeviceStripTripletSeedingAlg",
586 InputTracccPixelSpacepoints=stripSpacepoints,
587 OutputTracccPixelSeeds=seeds,
588 ))
589
590 # --- Track Reconstruction ---
591 trackParameters = f"Traccc{extension}TrackParameterCollection"
592 tracccTracks = f"Traccc{extension}TrackCollection"
593 acc.merge(DeviceTrkParamEstimationAlgCfg(flags,
594 name=f"{extension}DeviceTrkParamEstimationAlg",
595 InputTracccSpacepoints=stripSpacepoints,
596 InputTracccMeasurements=measurements,
597 InputTracccSeeds=seeds,
598 InputTracccMagField="TracccMagneticField",
599 OutputTracccTrackParameters=trackParameters,
600 ))
601
602 acc.merge(DeviceLargeRadiusTrackFindingAlgCfg(flags,
603 name=f"{extension}DeviceTrackFindingAlg",
604 InputTracccMeasurements=measurements,
605 InputTracccMagField="TracccMagneticField",
606 InputTracccTrackParameters=trackParameters,
607 InputTracccDetectorGeometry="TracccDeviceDetectorGeometry",
608 OutputTracccTracks=tracccTracks,
609 ))
610
611 # The measurement to cluster maps hold the index of the cluster in its
612 # owning container, so the tracks are resolved against the primary pass
613 # cluster containers rather than the views of this pass
614 from ActsGPUEventCnv.ActsGPUEventCnvConfig import TracccTrackConverterAlgCfg
615 acc.merge(TracccTrackConverterAlgCfg(flags,
616 name=f"{extension}TracccTrackConverterAlg",
617 InputPixelClusters="ITkPixelClusters",
618 InputStripClusters="ITkStripClusters",
619 InputMeasToPixelSP=measToPixelCluster,
620 InputMeasToStripCl=measToStripCluster,
621 InputTracks=tracccTracks,
622 OutputTracks=f"{extension}Tracks",
623 GeoIdMapping="TracccGeometryIdMapping",
624 HostDetectorName="TracccHostDetectorGeometry",
625 ))
626
627 # Ambiguity Resolution
628 if flags.Acts.doAmbiguityResolution:
629 from ActsConfig.ActsTrackFindingConfig import ActsAmbiguityResolutionCfg
630 acc.merge(ActsAmbiguityResolutionCfg(flags))
631
632 # PRD association
633 from ActsConfig.ActsPrdAssociationConfig import ActsPrdAssociationAlgCfg
634 acc.merge(ActsPrdAssociationAlgCfg(flags,
635 name = f'{extension}PrdAssociationAlg',
636 previousActsExtension = previousExtension))
637
638 # Truth
639 if flags.Tracking.doTruth:
640 from ActsConfig.ActsTruthConfig import ActsTrackToTruthAssociationAlgCfg, ActsTrackFindingValidationAlgCfg
641 if flags.Tracking.ActiveConfig.storeSiSPSeededTracks or not flags.Acts.doAmbiguityResolution:
642 acts_tracks = f"{extension}Tracks"
643 acc.merge(ActsTrackToTruthAssociationAlgCfg(flags,
644 name = f"{acts_tracks}TrackToTruthAssociationAlg",
645 ACTSTracksLocation = acts_tracks,
646 AssociationMapOut = f"{acts_tracks}ToTruthParticleAssociation"))
647 acc.merge(ActsTrackFindingValidationAlgCfg(flags,
648 name = f"{acts_tracks}TrackFindingValidationAlg",
649 TrackToTruthAssociationMap = f"{acts_tracks}ToTruthParticleAssociation"))
650
651 if flags.Acts.doAmbiguityResolution:
652 acts_tracks = f"{extension}ResolvedTracks"
653 acc.merge(ActsTrackToTruthAssociationAlgCfg(flags,
654 name = f"{acts_tracks}TrackToTruthAssociationAlg",
655 ACTSTracksLocation = acts_tracks,
656 AssociationMapOut = f"{acts_tracks}ToTruthParticleAssociation"))
657 acc.merge(ActsTrackFindingValidationAlgCfg(flags,
658 name = f"{acts_tracks}TrackFindingValidationAlg",
659 TrackToTruthAssociationMap = f"{acts_tracks}ToTruthParticleAssociation"))
660
661 return acc
void print(char *figname, TCanvas *c1)
ITkActsDeviceTrackRecoCfg(flags, *, previousExtension=None)
ITkActsDeviceTrackRecoPostProcessingCfg(flags, *, previousExtension=None)
ITkActsDeviceSeedParametersCfg(flags, *, spacepoints="TracccPixelSpacepointCollection", measurements="TracccMeasurementCollection", seeds="TracccPixelSeedCollection", trackParameters="TracccTrackParameterCollection", outputParameters="ITkTracccSeedParameters", outputSeedMeasurements="ITkTracccSeedMeasurements")
ITkActsDeviceSecondaryPassTrackRecoCfg(flags, *, previousExtension=None)