ATLAS Offline Software
Loading...
Searching...
No Matches
ActsClusterizationInDetConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5from AthenaConfiguration.Enums import BeamType
6from ActsConfig.ActsUtilities import extractChildKwargs
7
8from ActsConfig.ActsClusterizationConfig import ActsClusterCacheCreatorAlgCfg
10 name: str = "ActsIDPixelClusteringTool",
11 **kwargs) -> ComponentAccumulator:
12 acc = ComponentAccumulator()
13
14 kwargs.setdefault("isITk", False)
15
16 from PixelConditionsAlgorithms.PixelConditionsConfig import PixelChargeCalibCondCfg, PixelOfflineCalibCondAlgCfg
17 acc.merge(PixelChargeCalibCondCfg(flags))
18 acc.merge(PixelOfflineCalibCondAlgCfg(flags))
19 kwargs.setdefault("PixelChargeCalibCondData", "PixelChargeCalibCondData")
20
21 if "PixelLorentzAngleTool" not in kwargs:
22 from SiLorentzAngleTool.PixelLorentzAngleConfig import PixelLorentzAngleToolCfg
23 kwargs.setdefault("PixelLorentzAngleTool", acc.popToolsAndMerge( PixelLorentzAngleToolCfg(flags) ))
24
25 kwargs.setdefault("CheckGanged", True)
26 kwargs.setdefault('UseWeightedPosition',False) # not (flags.Tracking.doPixelDigitalClustering or flags.Beam.Type is BeamType.Cosmics)
27 kwargs.setdefault('UseBroadErrors', True) #flags.Beam.Type is BeamType.Cosmics
28
29 acc.setPrivateTools(CompFactory.ActsTrk.PixelClusteringTool(name, **kwargs))
30 return acc
31
33 name: str = "ActsIDStripClusteringTool",
34 **kwargs) -> ComponentAccumulator:
35 acc = ComponentAccumulator()
36
37 kwargs.setdefault("isITk", False)
38
39 if 'LorentzAngleTool' not in kwargs:
40 from SiLorentzAngleTool.SCT_LorentzAngleConfig import SCT_LorentzAngleToolCfg
41 kwargs.setdefault("LorentzAngleTool", acc.popToolsAndMerge(SCT_LorentzAngleToolCfg(flags)))
42
43 if "conditionsTool" not in kwargs:
44 from SCT_ConditionsTools.SCT_ConditionsToolsConfig import SCT_ConditionsSummaryToolCfg
45 kwargs.setdefault("conditionsTool", acc.popToolsAndMerge(
46 SCT_ConditionsSummaryToolCfg(flags, withFlaggedCondTool=False)))
47
48 if "StripDetElStatus" not in kwargs :
49 from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConfig import (
50 SCT_DetectorElementStatusAlgWithoutFlaggedCfg)
51 acc.merge(SCT_DetectorElementStatusAlgWithoutFlaggedCfg(flags))
52 kwargs.setdefault("StripDetElStatus", "SCTDetectorElementStatusWithoutFlagged")
53
54 # Disable noisy modules suppression
55 kwargs.setdefault("maxFiredStrips", 384)
56 kwargs.setdefault("errorStrategy", 2) # use pitch
57
58 if flags.InDet.selectSCTIntimeHits:
59 coll_25ns = (flags.Beam.BunchSpacing <= 25 and
60 flags.Beam.Type is BeamType.Collisions)
61 kwargs.setdefault("timeBins", "01X" if coll_25ns else "X1X")
62
63 kwargs.setdefault("StripDetEleCollKey", "SCT_DetectorElementCollection")
64
65 acc.setPrivateTools(CompFactory.ActsTrk.StripClusteringTool(name, **kwargs))
66 return acc
67
69 name: str = 'ActsIDPixelClusterizationAlg',
70 *,
71 useCache: bool = False,
72 **kwargs) -> ComponentAccumulator:
73 acc = ComponentAccumulator()
74
75 kwargs.setdefault("IDHelper", "PixelID")
76 kwargs.setdefault("RDOContainerKey", "PixelRDOs")
77 kwargs.setdefault("ClustersKey", "PixelClusters")
78 kwargs.setdefault("DetEleCollKey", "PixelDetectorElementCollection")
79 # Regional selection
80 kwargs.setdefault('RoIs', 'ActsRegionOfInterest')
81
82 kwargs.setdefault('ClusterCacheBackend', 'ActsPixelClusterCache_Back')
83 kwargs.setdefault('ClusterCache', 'ActsPixelClustersCache')
84
85 if 'RegSelTool' not in kwargs:
86 from RegionSelector.RegSelToolConfig import regSelTool_Pixel_Cfg
87 kwargs.setdefault('RegSelTool', acc.popToolsAndMerge(regSelTool_Pixel_Cfg(flags)))
88
89 if 'ClusteringTool' not in kwargs:
90 kwargs.setdefault("ClusteringTool", acc.popToolsAndMerge(ActsIDPixelClusteringToolCfg(flags)))
91
92 if 'DetElStatus' not in kwargs:
93 from PixelConditionsAlgorithms.PixelConditionsConfig import PixelDetectorElementStatusAlgCfg
94 acc.merge(PixelDetectorElementStatusAlgCfg(flags))
95 kwargs.setdefault('DetElStatus', 'PixelDetectorElementStatus')
96
97 if not useCache:
98 acc.addEventAlgo(CompFactory.ActsTrk.PixelClusterizationAlg(name, **kwargs))
99 else:
100 acc.addEventAlgo(CompFactory.ActsTrk.PixelCacheClusterizationAlg(name, **kwargs))
101 return acc
102
104 name: str = 'ActsIDStripClusterizationAlg',
105 useCache: bool = False,
106 **kwargs) -> ComponentAccumulator:
107 acc = ComponentAccumulator()
108
109 kwargs.setdefault("RDOContainerKey", "SCT_RDOs")
110 kwargs.setdefault("ClustersKey", "SCT_Clusters")
111 kwargs.setdefault("IDHelper", "SCT_ID")
112 kwargs.setdefault("DetEleCollKey", "SCT_DetectorElementCollection")
113 # Regional selection
114 kwargs.setdefault('RoIs', 'ActsRegionOfInterest')
115
116 kwargs.setdefault('ClusterCacheBackend', 'ActsStripClusterCache_Back')
117 kwargs.setdefault('ClusterCache', 'ActsStripClustersCache')
118
119 if 'RegSelTool' not in kwargs:
120 from RegionSelector.RegSelToolConfig import regSelTool_SCT_Cfg
121 kwargs.setdefault('RegSelTool', acc.popToolsAndMerge(regSelTool_SCT_Cfg(flags)))
122
123 if 'DetElStatus' not in kwargs :
124 from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConfig import SCT_DetectorElementStatusAlgWithoutFlaggedCfg
125 acc.merge(SCT_DetectorElementStatusAlgWithoutFlaggedCfg(flags))
126 kwargs.setdefault("DetElStatus", "SCTDetectorElementStatusWithoutFlagged")
127
128 if 'ClusteringTool' not in kwargs:
129 kwargs.setdefault("ClusteringTool", acc.popToolsAndMerge(ActsIDStripClusteringToolCfg(flags)))
130
131 if not useCache:
132 acc.addEventAlgo(CompFactory.ActsTrk.StripClusterizationAlg(name, **kwargs))
133 else:
134 acc.addEventAlgo(CompFactory.ActsTrk.StripCacheClusterizationAlg(name, **kwargs))
135 return acc
136
138 name: str = "ActsIDPixelClusterPreparationAlg",
139 useCache: bool = False,
140 **kwargs) -> ComponentAccumulator:
141 acc = ComponentAccumulator()
142
143 kwargs.setdefault('InputCollection', 'PixelClusters')
144 kwargs.setdefault('DetectorElements', 'PixelDetectorElementCollection')
145
146 if 'RegSelTool' not in kwargs:
147 from RegionSelector.RegSelToolConfig import regSelTool_Pixel_Cfg
148 kwargs.setdefault('RegSelTool', acc.popToolsAndMerge(regSelTool_Pixel_Cfg(flags)))
149
150 if not useCache:
151 acc.addEventAlgo(CompFactory.ActsTrk.PixelClusterDataPreparationAlg(name, **kwargs))
152 else:
153 acc.addEventAlgo(CompFactory.ActsTrk.PixelClusterCacheDataPreparationAlg(name, **kwargs))
154 return acc
155
157 name: str = "ActsIDStripClusterPreparationAlg",
158 useCache: bool = False,
159 **kwargs) -> ComponentAccumulator:
160 acc = ComponentAccumulator()
161
162 kwargs.setdefault('InputCollection', 'SCT_Clusters')
163 kwargs.setdefault('DetectorElements', 'SCT_DetectorElementCollection')
164
165 if 'RegSelTool' not in kwargs:
166 from RegionSelector.RegSelToolConfig import regSelTool_SCT_Cfg
167 kwargs.setdefault('RegSelTool', acc.popToolsAndMerge(regSelTool_SCT_Cfg(flags)))
168
169 if not useCache:
170 acc.addEventAlgo(CompFactory.ActsTrk.StripClusterDataPreparationAlg(name, **kwargs))
171 else:
172 acc.addEventAlgo(CompFactory.ActsTrk.StripClusterCacheDataPreparationAlg(name, **kwargs))
173 return acc
174
176 *,
177 RoIs: str = "ActsRegionOfInterest",
178 **kwargs: dict) -> ComponentAccumulator:
179 assert isinstance(RoIs, str)
180 assert isinstance(kwargs, dict)
181
182 acc = ComponentAccumulator()
183
184 # Clusterization is a three step process at maximum:
185 # (1) Cache Creation
186 # (2) Clusterization algorithm (reconstruction of clusters)
187 # (3) Preparation of collection for downstream algorithms
188 # What step is scheduled depends on the tracking pass and the activation
189 # or de-activation of caching mechanism
190
191 kwargs.setdefault('processPixels', flags.Detector.EnablePixel)
192 kwargs.setdefault('processStrips', flags.Detector.EnableSCT)
193 kwargs.setdefault('runCacheCreation', flags.Acts.useCache)
194 kwargs.setdefault('runReconstruction', True)
195 kwargs.setdefault('runPreparation', flags.Acts.useCache)
196
197 # Step (1)
198 if kwargs['runCacheCreation']:
199 acc.merge(ActsClusterCacheCreatorAlgCfg(flags,
200 **extractChildKwargs(prefix='ClusterCacheCreatorAlg.', **kwargs)))
201
202 # Step (2)
203 if kwargs['runReconstruction']:
204 if kwargs['processPixels']:
205 acc.merge(ActsIDPixelClusterizationAlgCfg(flags,
206 RoIs=RoIs,
207 **extractChildKwargs(prefix='PixelClusterizationAlg.', **kwargs)))
208 if kwargs['processStrips']:
209 acc.merge(ActsIDStripClusterizationAlgCfg(flags,
210 RoIs=RoIs,
211 **extractChildKwargs(prefix='StripClusterizationAlg.', **kwargs)))
212
213 # Step (3)
214 if kwargs['runPreparation']:
215 if kwargs['processPixels']:
217 RoIs=RoIs,
218 **extractChildKwargs(prefix='PixelClusterPreparationAlg.', **kwargs)))
219
220 if kwargs['processStrips']:
222 RoIs=RoIs,
223 **extractChildKwargs(prefix='StripClusterPreparationAlg.', **kwargs)))
224
225 return acc
226
228 *,
229 previousActsExtension: str = None) -> ComponentAccumulator:
230 assert previousActsExtension is None or isinstance(previousActsExtension, str)
231
232 acc = ComponentAccumulator()
233
234 processPixels = flags.Detector.EnablePixel
235 processStrips = flags.Detector.EnableSCT
236
237 kwargs = dict()
238 kwargs.setdefault('processPixels', processPixels)
239 kwargs.setdefault('processStrips', processStrips)
240
241 # Clusterization is a three step process at maximum:
242 # (1) Cache Creation
243 # (2) Clusterization algorithm (reconstruction of clusters)
244 # (3) Preparation of collection for downstream algorithms
245 # What step is scheduled depends on the tracking pass and the activation
246 # or de-activation of caching mechanism.
247
248 # Secondary passes do not need cache creation, that has to be performed
249 # on the primary pass, and only if the caching is enabled.
250 # Reconstruction can run on secondary passes only if the caching is enabled,
251 # this is because we may need to process detector elements not processed
252 # on the primary pass.
253 # Preparation has to be performed on secondary passes always, and on primary
254 # pass only if cache is enabled. In the latter case it is useed to collect all
255 # the clusters from all views before passing them to the downstream algorithms
256
257
258 # Only Primary pass for the Inner Detector now
259 kwargs.setdefault('runCacheCreation', flags.Acts.useCache)
260 kwargs.setdefault('runReconstruction', True)
261 kwargs.setdefault('runPreparation', flags.Acts.useCache)
262
263 # Name of the RoI to be used
264 roisName = f'{flags.Tracking.ActiveConfig.extension}RegionOfInterest'
265 # Large Radius Tracking uses full scan RoI created in the primary pass
266 if flags.Tracking.ActiveConfig.extension == 'ActsLargeRadius':
267 roisName = 'ActsRegionOfInterest'
268
269 # Name of the Cluster container -> ITk + extension without "Acts" + Pixel or Strip + Clusters
270 # We also define the same collection from the main ACTS pass (primary)
271 primaryPixelClustersName = 'PixelClusters'
272 primaryStripClustersName = 'SCT_Clusters'
273 pixelClustersName = primaryPixelClustersName
274 stripClustersName = primaryStripClustersName
275
276 # Configuration for (1)
277 if kwargs['runCacheCreation']:
278 kwargs.setdefault('ClusterCacheCreatorAlg.name', f'{flags.Tracking.ActiveConfig.extension}ClusterCacheCreatorAlg')
279
280 # Configuration for (2)
281 if kwargs['runReconstruction']:
282 if kwargs['processPixels']:
283 kwargs.setdefault('PixelClusterizationAlg.name', f'{flags.Tracking.ActiveConfig.extension}PixelClusterizationAlg')
284 kwargs.setdefault('PixelClusterizationAlg.useCache', flags.Acts.useCache)
285 kwargs.setdefault('PixelClusterizationAlg.ClustersKey', pixelClustersName)
286 kwargs.setdefault('PixelClusterizationAlg.ClusterCache', f'{flags.Tracking.ActiveConfig.extension}PixelClustersCache')
287
288 if kwargs['processStrips']:
289 kwargs.setdefault('StripClusterizationAlg.name', f'{flags.Tracking.ActiveConfig.extension}StripClusterizationAlg')
290 kwargs.setdefault('StripClusterizationAlg.useCache', flags.Acts.useCache)
291 kwargs.setdefault('StripClusterizationAlg.ClustersKey', stripClustersName)
292 kwargs.setdefault('StripClusterizationAlg.ClusterCache', f'{flags.Tracking.ActiveConfig.extension}StripClustersCache')
293
294 # Configuration for (3)
295 if kwargs['runPreparation']:
296 if kwargs['processPixels']:
297 kwargs.setdefault('PixelClusterPreparationAlg.name', f'{flags.Tracking.ActiveConfig.extension}PixelClusterPreparationAlg')
298 kwargs.setdefault('PixelClusterPreparationAlg.useCache', flags.Acts.useCache)
299 kwargs.setdefault('PixelClusterPreparationAlg.OutputCollection', f'{pixelClustersName}_Cached' if kwargs['runReconstruction'] else pixelClustersName)
300 # The input is one between the collection (w/o cache) and the IDC (w/ cache)
301 if not flags.Acts.useCache:
302 # Take the collection from the reconstruction step. If not available take the collection from the primary pass
303 kwargs.setdefault('PixelClusterPreparationAlg.InputCollection', pixelClustersName if kwargs['runReconstruction'] else primaryPixelClustersName)
304 kwargs.setdefault('PixelClusterPreparationAlg.InputIDC', '')
305 else:
306 kwargs.setdefault('PixelClusterPreparationAlg.InputCollection', '')
307 kwargs.setdefault('PixelClusterPreparationAlg.InputIDC', f'{flags.Tracking.ActiveConfig.extension}PixelClustersCache')
308
309 if kwargs['processStrips']:
310 kwargs.setdefault('StripClusterPreparationAlg.name', f'{flags.Tracking.ActiveConfig.extension}StripClusterPreparationAlg')
311 kwargs.setdefault('StripClusterPreparationAlg.useCache', flags.Acts.useCache)
312 kwargs.setdefault('StripClusterPreparationAlg.OutputCollection', f'{stripClustersName}_Cached' if kwargs['runReconstruction'] else stripClustersName)
313 if not flags.Acts.useCache:
314 kwargs.setdefault('StripClusterPreparationAlg.InputCollection', stripClustersName if kwargs['runReconstruction'] else primaryStripClustersName)
315 kwargs.setdefault('StripClusterPreparationAlg.InputIDC', '')
316 else:
317 kwargs.setdefault('StripClusterPreparationAlg.InputCollection', '')
318 kwargs.setdefault('StripClusterPreparationAlg.InputIDC', f'{flags.Tracking.ActiveConfig.extension}StripClustersCache')
319 # Persistification
320 if flags.Acts.EDM.PersistifyClusters and kwargs['runReconstruction']:
321 toAOD = []
322 if kwargs['processPixels']:
323 pixel_cluster_shortlist = ['-validationMeasurementLink']
324 pixel_cluster_variables = '.'.join(pixel_cluster_shortlist)
325
326 pixelClusterCollection = kwargs['PixelClusterizationAlg.ClustersKey']
327 toAOD += [f'xAOD::PixelClusterContainer#{pixelClusterCollection}',
328 f'xAOD::PixelClusterAuxContainer#{pixelClusterCollection}Aux.{pixel_cluster_variables}']
329
330 if kwargs['processStrips']:
331 strip_cluster_shortlist = ['-validationMeasurementLink']
332 strip_cluster_variables = '.'.join(strip_cluster_shortlist)
333
334 stripClusterCollection = kwargs['StripClusterizationAlg.ClustersKey']
335 toAOD += [f"xAOD::StripClusterContainer#{stripClusterCollection}",
336 f"xAOD::StripClusterAuxContainer#{stripClusterCollection}Aux.{strip_cluster_variables}"]
337
338 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD
339 acc.merge(addToAOD(flags, toAOD))
340 acc.merge(ActsIDMainClusterizationCfg(flags, RoIs=roisName, **kwargs))
341 return acc
ComponentAccumulator ActsIDPixelClusterPreparationAlgCfg(flags, str name="ActsIDPixelClusterPreparationAlg", bool useCache=False, **kwargs)
ComponentAccumulator ActsIDMainClusterizationCfg(flags, *, str RoIs="ActsRegionOfInterest", **dict kwargs)
ComponentAccumulator ActsIDPixelClusteringToolCfg(flags, str name="ActsIDPixelClusteringTool", **kwargs)
ComponentAccumulator ActsIDStripClusterPreparationAlgCfg(flags, str name="ActsIDStripClusterPreparationAlg", bool useCache=False, **kwargs)
ComponentAccumulator ActsIDPixelClusterizationAlgCfg(flags, str name='ActsIDPixelClusterizationAlg', *, bool useCache=False, **kwargs)
ComponentAccumulator ActsIDStripClusteringToolCfg(flags, str name="ActsIDStripClusteringTool", **kwargs)
ComponentAccumulator ActsIDClusterizationCfg(flags, *, str previousActsExtension=None)
ComponentAccumulator ActsIDStripClusterizationAlgCfg(flags, str name='ActsIDStripClusterizationAlg', bool useCache=False, **kwargs)