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
7
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 acc.addEventAlgo(CompFactory.InDetPhysHitDecoratorAlg(name, **kwargs))
62 return acc
63
64
65def ITkPhysHitDecoratorAlgCfg(flags, name="ITkPhysHitDecoratorAlg", **kwargs):
66 '''
67 create decoration algorithm which decorates track particles with the unbiased hit residuals and pulls.
68
69 '''
70 acc = ComponentAccumulator()
71
72 if 'InDetTrackHoleSearchTool' not in kwargs:
73 from InDetConfig.InDetTrackHoleSearchConfig import (
74 ITkTrackHoleSearchToolCfg)
75 kwargs.setdefault("InDetTrackHoleSearchTool", acc.popToolsAndMerge(
76 ITkTrackHoleSearchToolCfg(flags)))
77
78 if 'Updator' not in kwargs:
79 from TrkConfig.TrkMeasurementUpdatorConfig import ITkUpdatorCfg
80 kwargs.setdefault("Updator", acc.popToolsAndMerge(ITkUpdatorCfg(flags)))
81
82 if 'LorentzAngleTool' not in kwargs:
83 from SiLorentzAngleTool.ITkPixelLorentzAngleConfig import (
84 ITkPixelLorentzAngleToolCfg)
85 kwargs.setdefault("LorentzAngleTool", acc.popToolsAndMerge(
86 ITkPixelLorentzAngleToolCfg(flags)))
87
88 if 'ResidualPullCalculator' not in kwargs:
89 from TrkConfig.TrkResidualPullCalculatorConfig import (
90 ResidualPullCalculatorCfg)
91 kwargs.setdefault("ResidualPullCalculator", acc.addPublicTool(
92 acc.popToolsAndMerge(ResidualPullCalculatorCfg(flags))))
93
94 acc.addEventAlgo(CompFactory.InDetPhysHitDecoratorAlg(name, **kwargs))
95 return acc
96
97
99 flags, name="ParameterErrDecoratorAlg", **kwargs):
100 '''
101 create decoration algorithm which decorates track particles with the uncertainties of the track parameters.
102 '''
103 kwargs.setdefault("TrackParticleContainerName", "InDetTrackParticles")
104 acc = ComponentAccumulator()
105 acc.addEventAlgo(CompFactory.ParameterErrDecoratorAlg(name, **kwargs))
106 return acc
107
108
110 flags, name="InDetPhysValTruthDecoratorAlg", **kwargs):
111 '''
112 create decoration algorithm which decorates truth particles with track parameters at the perigee.
113 '''
114 acc = ComponentAccumulator()
115
116 from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
117 extrapolator = acc.popToolsAndMerge(AtlasExtrapolatorCfg(flags))
118 acc.addPublicTool(extrapolator) # TODO: migrate to private?
119 kwargs.setdefault("Extrapolator", extrapolator)
120
121 if flags.Detector.GeometryITk:
122 kwargs.setdefault("PixelClusterContainerName", "ITkPixelMeasurements")
123 kwargs.setdefault("SCTClusterContainerName", "ITkStripMeasurements")
124 else: # A temporary solution until we have ACTS Run 3 dedeicated one
125 kwargs.setdefault("PixelClusterContainerName", "PixelMeasurements")
126 kwargs.setdefault("SCTClusterContainerName", "SCT_Measurements")
127
128 kwargs.setdefault('TruthParticleIndexDecoration',
129 'origTruthIndex' if flags.PhysVal.IDPVM.doTechnicalEfficiency else '')
130
131 acc.addEventAlgo(CompFactory.InDetPhysValTruthDecoratorAlg(name, **kwargs))
132 return acc
133
134
135def TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs):
136 '''
137 create decoration algorithm which decorates truth particles with origin and type from truth classifier.
138 '''
139 acc = ComponentAccumulator()
140 acc.addEventAlgo(CompFactory.TruthClassDecoratorAlg(name, **kwargs))
141 return acc
142
143
144def TrackDecoratorsCfg(flags, **kwargs):
145 '''
146 Get track particle decorators needed for the InDetPhysValMonitoring tool
147 '''
148 acc = ComponentAccumulator()
149
150 if "CombinedInDetTracks" in flags.Input.Collections:
151 acc.merge(InDetPhysHitDecoratorAlgCfg(flags, **kwargs))
152
153 acc.merge(ParameterErrDecoratorAlgCfg(flags, **kwargs))
154
155 return acc
156
157
158def GSFTrackDecoratorsCfg(flags, **kwargs):
159 kwargs.setdefault("TrackParticleContainerName", "GSFTrackParticles")
160 return TrackDecoratorsCfg(flags, **kwargs)
161
162
163def AddDecoratorCfg(flags, **kwargs):
164 '''
165 Add the track particle decoration algorithm to the top sequence.
166 The algorithm is to be run on RAW/RDO since it depends on full hit information
167 which is generally not available at later stages. The decorations added by this
168 algorithm are used by InDetPhysValMonitoring tool.
169 '''
170 acc = ComponentAccumulator()
171
172 acc.merge(TrackDecoratorsCfg(flags, **kwargs))
173
174 if flags.Tracking.doTruth:
175 from BeamSpotConditions.BeamSpotConditionsConfig import (
176 BeamSpotCondAlgCfg)
177 acc.merge(BeamSpotCondAlgCfg(flags))
178 acc.merge(InDetPhysValTruthDecoratorAlgCfg(flags))
179
180 if flags.PhysVal.IDPVM.doValidateGSFTracks:
181 acc.merge(AddGSFTrackDecoratorAlgCfg(flags))
182
183 return acc
184
185
186def AddGSFTrackDecoratorAlgCfg(flags, **kwargs):
187 # Search egamma algorithm and add the GSF TrackParticle decorator
188 acc = ComponentAccumulator()
189
190 if flags.PhysVal.IDPVM.doValidateGSFTracks:
191 acc.merge(GSFTrackDecoratorsCfg(flags))
192
193 for col in flags.PhysVal.IDPVM.validateExtraTrackCollections:
194 acc.merge(TrackDecoratorsCfg(
195 flags, TrackParticleContainerName=col))
196
197
198def AddDecoratorIfNeededCfg(flags, **kwargs):
199 '''
200 Add the InDet decoration algorithm if it has not been ran yet.
201 '''
202
203 acc = ComponentAccumulator()
204
205 if not canAddDecorator(flags):
206 print('DEBUG addDecoratorIfNeeded ? Stage is too early or too late for running the decoration. Needs reconstructed tracks. Try again during next stage ?')
207 return acc
208
209 acc.merge(AddDecoratorCfg(flags, **kwargs))
210
211 return acc
void print(char *figname, TCanvas *c1)
TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs)
InDetPhysHitDecoratorAlgCfg(flags, name="InDetPhysHitDecoratorAlg", **kwargs)
ITkPhysHitDecoratorAlgCfg(flags, name="ITkPhysHitDecoratorAlg", **kwargs)
ParameterErrDecoratorAlgCfg(flags, name="ParameterErrDecoratorAlg", **kwargs)
InDetPhysValTruthDecoratorAlgCfg(flags, name="InDetPhysValTruthDecoratorAlg", **kwargs)