ATLAS Offline Software
Loading...
Searching...
No Matches
InDetPhysValDecorationConfig.py
Go to the documentation of this file.
2# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3#
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7from TrkConfig.TrkConfigFlags import PerigeeExpression
8
9def canAddDecorator(flags):
10 '''
11 check whether the decorator can be added.
12
13 A decorator can be added if a track particle converter alg is in the sequence or
14 if ESDs or AODs are read.
15 '''
16
17 if not (flags.Detector.GeometryID or flags.Detector.GeometryITk):
18 return False
19
20 return (flags.PhysVal.IDPVM.runDecoration and
21 ("StreamESD" in flags.Input.ProcessingTags or
22 "StreamAOD" in flags.Input.ProcessingTags or
23 (len(flags.Input.ProcessingTags) > 0 and
24 # Look for substring StreamDAOD in first processing tag to cover
25 # all DAOD flavors
26 "StreamDAOD" in flags.Input.ProcessingTags[0])))
27
28
30 flags, name="InDetPhysHitDecoratorAlg", **kwargs):
31 if flags.Detector.GeometryITk:
32 return ITkPhysHitDecoratorAlgCfg(flags, name, **kwargs)
33
34 '''
35 create decoration algorithm which decorates track particles with the unbiased hit residuals and pulls.
36 '''
37 acc = ComponentAccumulator()
38
39 if 'InDetTrackHoleSearchTool' not in kwargs:
40 from InDetConfig.InDetTrackHoleSearchConfig import (
41 InDetTrackHoleSearchToolCfg)
42 kwargs.setdefault("InDetTrackHoleSearchTool",
43 acc.popToolsAndMerge(InDetTrackHoleSearchToolCfg(flags)))
44
45 if 'Updator' not in kwargs:
46 from TrkConfig.TrkMeasurementUpdatorConfig import InDetUpdatorCfg
47 kwargs.setdefault("Updator", acc.popToolsAndMerge(InDetUpdatorCfg(flags)))
48
49 if 'LorentzAngleTool' not in kwargs:
50 from SiLorentzAngleTool.PixelLorentzAngleConfig import (
51 PixelLorentzAngleToolCfg)
52 kwargs.setdefault("LorentzAngleTool", acc.popToolsAndMerge(
53 PixelLorentzAngleToolCfg(flags)))
54
55 if 'ResidualPullCalculator' not in kwargs:
56 from TrkConfig.TrkResidualPullCalculatorConfig import (
57 ResidualPullCalculatorCfg)
58 kwargs.setdefault("ResidualPullCalculator", acc.addPublicTool(
59 acc.popToolsAndMerge(ResidualPullCalculatorCfg(flags))))
60
61 kwargs.setdefault("useTRT", flags.Detector.EnableTRT)
62
63 acc.addEventAlgo(CompFactory.InDetPhysHitDecoratorAlg(name, **kwargs))
64 return acc
65
66
67def ITkPhysHitDecoratorAlgCfg(flags, name="ITkPhysHitDecoratorAlg", **kwargs):
68 '''
69 create decoration algorithm which decorates track particles with the unbiased hit residuals and pulls.
70
71 '''
72 acc = ComponentAccumulator()
73
74 if 'InDetTrackHoleSearchTool' not in kwargs:
75 from InDetConfig.InDetTrackHoleSearchConfig import (
76 ITkTrackHoleSearchToolCfg)
77 kwargs.setdefault("InDetTrackHoleSearchTool", acc.popToolsAndMerge(
78 ITkTrackHoleSearchToolCfg(flags)))
79
80 if 'Updator' not in kwargs:
81 from TrkConfig.TrkMeasurementUpdatorConfig import ITkUpdatorCfg
82 kwargs.setdefault("Updator", acc.popToolsAndMerge(ITkUpdatorCfg(flags)))
83
84 if 'LorentzAngleTool' not in kwargs:
85 from SiLorentzAngleTool.ITkPixelLorentzAngleConfig import (
86 ITkPixelLorentzAngleToolCfg)
87 kwargs.setdefault("LorentzAngleTool", acc.popToolsAndMerge(
88 ITkPixelLorentzAngleToolCfg(flags)))
89
90 if 'ResidualPullCalculator' not in kwargs:
91 from TrkConfig.TrkResidualPullCalculatorConfig import (
92 ResidualPullCalculatorCfg)
93 kwargs.setdefault("ResidualPullCalculator", acc.addPublicTool(
94 acc.popToolsAndMerge(ResidualPullCalculatorCfg(flags))))
95
96 acc.addEventAlgo(CompFactory.InDetPhysHitDecoratorAlg(name, **kwargs))
97 return acc
98
99
101 flags, name="ParameterErrDecoratorAlg", **kwargs):
102 '''
103 create decoration algorithm which decorates track particles with the uncertainties of the track parameters.
104 '''
105 kwargs.setdefault("TrackParticleContainerName", "InDetTrackParticles")
106 acc = ComponentAccumulator()
107 acc.addEventAlgo(CompFactory.ParameterErrDecoratorAlg(name, **kwargs))
108 return acc
109
110
112 flags, name="InDetPhysValTruthDecoratorAlg", **kwargs):
113 '''
114 create decoration algorithm which decorates truth particles with track parameters at the perigee.
115 '''
116 acc = ComponentAccumulator()
117
118 from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
119 extrapolator = acc.popToolsAndMerge(AtlasExtrapolatorCfg(flags))
120 acc.addPublicTool(extrapolator) # TODO: migrate to private?
121 kwargs.setdefault("Extrapolator", extrapolator)
122
123 if flags.Detector.GeometryITk:
124 kwargs.setdefault("PixelClusterContainerName", "ITkPixelMeasurements")
125 kwargs.setdefault("SCTClusterContainerName", "ITkStripMeasurements")
126 else: # A temporary solution until we have ACTS Run 3 dedeicated one
127 kwargs.setdefault("PixelClusterContainerName", "PixelMeasurements")
128 kwargs.setdefault("SCTClusterContainerName", "SCT_Measurements")
129
130 kwargs.setdefault("decorateTime", flags.Reco.EnableHGTDExtension)
131
132 kwargs.setdefault('TruthParticleIndexDecoration',
133 'origTruthIndex' if flags.PhysVal.IDPVM.doTechnicalEfficiency else '')
134 kwargs.setdefault('UseTruthPVAsPerigee',
135 flags.Tracking.perigeeExpression is PerigeeExpression.Vertex)
136
137 acc.addEventAlgo(CompFactory.InDetPhysValTruthDecoratorAlg(name, **kwargs))
138 return acc
139
140
141def TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs):
142 '''
143 create decoration algorithm which decorates truth particles with origin and type from truth classifier.
144 '''
145 acc = ComponentAccumulator()
146 acc.addEventAlgo(CompFactory.TruthClassDecoratorAlg(name, **kwargs))
147 return acc
148
149
150def TrackDecoratorsCfg(flags, **kwargs):
151 '''
152 Get track particle decorators needed for the InDetPhysValMonitoring tool
153 '''
154 acc = ComponentAccumulator()
155
156 if "CombinedInDetTracks" in flags.Input.Collections:
157 acc.merge(InDetPhysHitDecoratorAlgCfg(flags, **kwargs))
158
159 acc.merge(ParameterErrDecoratorAlgCfg(flags, **kwargs))
160
161 return acc
162
163
164def GSFTrackDecoratorsCfg(flags, **kwargs):
165 kwargs.setdefault("TrackParticleContainerName", "GSFTrackParticles")
166 return TrackDecoratorsCfg(flags, **kwargs)
167
168
169def AddDecoratorCfg(flags, **kwargs):
170 '''
171 Add the track particle decoration algorithm to the top sequence.
172 The algorithm is to be run on RAW/RDO since it depends on full hit information
173 which is generally not available at later stages. The decorations added by this
174 algorithm are used by InDetPhysValMonitoring tool.
175 '''
176 acc = ComponentAccumulator()
177
178 acc.merge(TrackDecoratorsCfg(flags, **kwargs))
179
180 if flags.Tracking.doTruth:
181 from BeamSpotConditions.BeamSpotConditionsConfig import (
182 BeamSpotCondAlgCfg)
183 acc.merge(BeamSpotCondAlgCfg(flags))
184 acc.merge(InDetPhysValTruthDecoratorAlgCfg(flags))
185
186 if flags.PhysVal.IDPVM.doValidateGSFTracks:
187 acc.merge(AddGSFTrackDecoratorAlgCfg(flags))
188
189 return acc
190
191
192def AddGSFTrackDecoratorAlgCfg(flags, **kwargs):
193 # Search egamma algorithm and add the GSF TrackParticle decorator
194 acc = ComponentAccumulator()
195
196 if flags.PhysVal.IDPVM.doValidateGSFTracks:
197 acc.merge(GSFTrackDecoratorsCfg(flags))
198
199 for col in flags.PhysVal.IDPVM.validateExtraTrackCollections:
200 acc.merge(TrackDecoratorsCfg(
201 flags, TrackParticleContainerName=col))
202
203
204def AddDecoratorIfNeededCfg(flags, **kwargs):
205 '''
206 Add the InDet decoration algorithm if it has not been ran yet.
207 '''
208
209 acc = ComponentAccumulator()
210
211 if not canAddDecorator(flags):
212 print('DEBUG addDecoratorIfNeeded ? Stage is too early or too late for running the decoration. Needs reconstructed tracks. Try again during next stage ?')
213 return acc
214
215 acc.merge(AddDecoratorCfg(flags, **kwargs))
216
217 return acc
void print(char *figname, TCanvas *c1)
TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs)
ParameterErrDecoratorAlgCfg(flags, name="ParameterErrDecoratorAlg", **kwargs)
InDetPhysHitDecoratorAlgCfg(flags, name="InDetPhysHitDecoratorAlg", **kwargs)
InDetPhysValTruthDecoratorAlgCfg(flags, name="InDetPhysValTruthDecoratorAlg", **kwargs)
ITkPhysHitDecoratorAlgCfg(flags, name="ITkPhysHitDecoratorAlg", **kwargs)