ATLAS Offline Software
Loading...
Searching...
No Matches
TracccTritonClientConfig.py
Go to the documentation of this file.
2# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3#
4from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5from AthenaConfiguration.ComponentFactory import CompFactory
6
7writeOutput = True
8doTruth = True
9saveTracccEventsToCSV = False
10nEventsToSave = 10
11
12
13def TracccTritonToolCfg(flags, name="TracccTritonTool", **kwargs):
14 """Set up a TracccTritonTool tool and return"""
15
16 from AthTritonComps.TritonToolConfig import TritonToolCfg
17
18 acc = ComponentAccumulator()
19
20 kwargs.setdefault("TritonTool", acc.popToolsAndMerge(
21 TritonToolCfg(flags, flags.Tracking.Traccc.Triton.model,
22 url=flags.Tracking.Traccc.Triton.url,
23 port=flags.Tracking.Traccc.Triton.port,
24 ssl=(flags.Tracking.Traccc.Triton.port == 443))))
25
26 acc.setPrivateTools(CompFactory.TracccTritonTool(name, **kwargs))
27 return acc
28
29
30def addTruthClusterAssociations(acc, flags, prefix="", pixelKey=None, stripKey=None):
31 from ActsConfig.ActsTruthConfig import (
32 ActsPixelClusterToTruthAssociationAlgCfg,
33 ActsStripClusterToTruthAssociationAlgCfg,
34 ActsTruthParticleHitCountAlgCfg,
35 )
36 acc.merge(ActsPixelClusterToTruthAssociationAlgCfg(
37 flags,
38 name=f"{prefix}PixelClusterToTruthAssociationAlg",
39 InputTruthParticleLinks="xAODTruthLinks",
40 AssociationMapOut=f"{prefix}PixelClustersToTruthParticles",
41 Measurements=pixelKey,
42 ))
43 acc.merge(ActsStripClusterToTruthAssociationAlgCfg(
44 flags,
45 name=f"{prefix}StripClusterToTruthAssociationAlg",
46 InputTruthParticleLinks="xAODTruthLinks",
47 AssociationMapOut=f"{prefix}StripClustersToTruthParticles",
48 Measurements=stripKey,
49 ))
50 acc.merge(ActsTruthParticleHitCountAlgCfg(
51 flags,
52 name=f"{prefix}TruthParticleHitCountAlg",
53 PixelClustersToTruthAssociationMap=f"{prefix}PixelClustersToTruthParticles",
54 StripClustersToTruthAssociationMap=f"{prefix}StripClustersToTruthParticles",
55 TruthParticleHitCountsOut=f"{prefix}TruthParticleHitCounts",
56 ))
57 return acc
58
59
60def addTrackTruthDecorations(acc, flags, prefix, tracks_key):
61
62 from ActsConfig.ActsTruthConfig import (
63 ActsTrackToTruthAssociationAlgCfg,
64 ActsTrackFindingValidationAlgCfg,
65 ActsTrackParticleTruthDecorationAlgCfg,
66 )
67
68 # Track to truth association
69 acc.merge(ActsTrackToTruthAssociationAlgCfg(
70 flags,
71 name=f"{prefix}TrackToTruthAssociationAlg",
72 PixelClustersToTruthAssociationMap=f"{prefix}PixelClustersToTruthParticles",
73 StripClustersToTruthAssociationMap=f"{prefix}StripClustersToTruthParticles",
74 ACTSTracksLocation=tracks_key,
75 AssociationMapOut=f"{tracks_key}ToTruthParticleAssociation",
76 ))
77
78 # Validation
79 acc.merge(ActsTrackFindingValidationAlgCfg(
80 flags,
81 name=f"{prefix}TrackFindingValidationAlg",
82 TrackToTruthAssociationMap=f"{tracks_key}ToTruthParticleAssociation",
83 TruthParticleHitCounts=f"{prefix}TruthParticleHitCounts",
84 ))
85
86 # Decoration
87 acc.merge(ActsTrackParticleTruthDecorationAlgCfg(
88 flags,
89 name=f"{prefix}TrackParticleTruthDecorationAlg",
90 TrackToTruthAssociationMaps=[
91 f"{tracks_key}ToTruthParticleAssociation"],
92 TrackParticleContainerName=f"{prefix}TrackParticles",
93 TruthParticleHitCounts=f"{prefix}TruthParticleHitCounts",
94 ComputeTrackRecoEfficiency=True,
95 ))
96
97 return acc
98
99
100def TritonTracccTrackMakerCfg(flags, name="TritonTracccTrackMaker", **kwargs):
101 """Set up a TrackMaker algorithm and return it"""
102 acc = ComponentAccumulator()
103
104 prefix = "Traccc"
105 track_container_name = f'{prefix}Tracks'
106 track_particles_name = f"{prefix}TrackParticles"
107
108 # Configure the TracccTritonTool
109 kwargs.setdefault("TracccTritonTool", acc.popToolsAndMerge(TracccTritonToolCfg(flags,
110 SaveEventsToCSV=saveTracccEventsToCSV,
111 MaxEventsToSave=nEventsToSave)))
112
113 from ActsConfig.ActsGeometryConfig import ActsTrackingGeometrySvcCfg
114 kwargs.setdefault("TrackingGeometrySvc", acc.getPrimaryAndMerge(ActsTrackingGeometrySvcCfg(flags)))
115
116 # Pixel and strip geometry
117 from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg
118 acc.merge(ITkPixelReadoutGeometryCfg(flags))
119 from StripGeoModelXml.ITkStripGeoModelConfig import ITkStripReadoutGeometryCfg
120 acc.merge(ITkStripReadoutGeometryCfg(flags))
121
122 try:
123 if flags.Tracking.ActiveConfig.extension != "Acts":
124 raise RuntimeError(f"wrong tracking pass: {flags.Tracking.ActiveConfig.extension}")
125 except AttributeError:
126 flags = flags.cloneAndReplace("Tracking.ActiveConfig",
127 "Tracking.ITkActsPass")
128
129 # Main tracking alg
130 acc.addEventAlgo(CompFactory.TritonTracccTrackMaker(name, doTruth=doTruth, **kwargs))
131
132
134
135 from ActsConfig.ActsEventCnvConfig import ActsTrackToTrackParticleCnvAlgCfg
136 acc.merge(ActsTrackToTrackParticleCnvAlgCfg(flags,
137 name=f"{prefix}TrackToTrackParticleCnvAlg",
138 ACTSTracksLocation=[track_container_name],
139 TrackParticlesOutKey=track_particles_name))
140
141
142 pixel_key = "xAODPixelClustersFromInDetCluster"
143 strip_key = "xAODStripClustersFromInDetCluster"
144
145 # if doTruth:
146 if doTruth:
148 acc, flags, prefix=prefix, pixelKey=pixel_key, stripKey=strip_key)
149 addTrackTruthDecorations(acc, flags, prefix, track_container_name)
150
151
152 if writeOutput:
153
154 # Adding the output to the AOD file
155 inputList = []
156
157 inputList.append("xAOD::TruthParticleContainer#*")
158 inputList.append("xAOD::TruthParticleAuxContainer#*")
159 inputList.append("xAOD::TrackJacobianContainer#*")
160 inputList.append("xAOD::TrackJacobianAuxContainer#*")
161 inputList.append("xAOD::TrackMeasurementContainer#*")
162 inputList.append("xAOD::TrackMeasurementAuxContainer#*")
163 inputList.append("xAOD::TrackSurfaceContainer#*")
164 inputList.append("xAOD::TrackSurfaceAuxContainer#*")
165 inputList.append("xAOD::TrackParticleContainer#*")
166 inputList.append("xAOD::TrackParticleAuxContainer#*")
167
168 if doTruth:
169 inputList.append("xAOD::PixelClusterContainer#xAODPixelClustersFromInDetCluster")
170 inputList.append("xAOD::StripClusterContainer#xAODStripClustersFromInDetCluster")
171 inputList.append("xAOD::PixelClusterAuxContainer#xAODPixelClustersFromInDetClusterAux.")
172 inputList.append("xAOD::StripClusterAuxContainer#xAODStripClustersFromInDetClusterAux.")
173 else:
174 inputList.append("xAOD::PixelClusterContainer#*")
175 inputList.append("xAOD::StripClusterContainer#*")
176 inputList.append("xAOD::PixelClusterAuxContainer#*")
177 inputList.append("xAOD::StripClusterAuxContainer#*")
178
179 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
180 acc.merge(OutputStreamCfg(flags, 'AOD', ItemList=inputList))
181
182 return acc
addTrackTruthDecorations(acc, flags, prefix, tracks_key)
addTruthClusterAssociations(acc, flags, prefix="", pixelKey=None, stripKey=None)
TritonTracccTrackMakerCfg(flags, name="TritonTracccTrackMaker", **kwargs)
TracccTritonToolCfg(flags, name="TracccTritonTool", **kwargs)