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 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', flags.Tracking.perigeeExpression=="Vertex")
135
136 acc.addEventAlgo(CompFactory.InDetPhysValTruthDecoratorAlg(name, **kwargs))
137 return acc
138
139
140def TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs):
141 '''
142 create decoration algorithm which decorates truth particles with origin and type from truth classifier.
143 '''
144 acc = ComponentAccumulator()
145 acc.addEventAlgo(CompFactory.TruthClassDecoratorAlg(name, **kwargs))
146 return acc
147
148
149def TrackDecoratorsCfg(flags, **kwargs):
150 '''
151 Get track particle decorators needed for the InDetPhysValMonitoring tool
152 '''
153 acc = ComponentAccumulator()
154
155 if "CombinedInDetTracks" in flags.Input.Collections:
156 acc.merge(InDetPhysHitDecoratorAlgCfg(flags, **kwargs))
157
158 acc.merge(ParameterErrDecoratorAlgCfg(flags, **kwargs))
159
160 return acc
161
162
163def GSFTrackDecoratorsCfg(flags, **kwargs):
164 kwargs.setdefault("TrackParticleContainerName", "GSFTrackParticles")
165 return TrackDecoratorsCfg(flags, **kwargs)
166
167
168def AddDecoratorCfg(flags, **kwargs):
169 '''
170 Add the track particle decoration algorithm to the top sequence.
171 The algorithm is to be run on RAW/RDO since it depends on full hit information
172 which is generally not available at later stages. The decorations added by this
173 algorithm are used by InDetPhysValMonitoring tool.
174 '''
175 acc = ComponentAccumulator()
176
177 acc.merge(TrackDecoratorsCfg(flags, **kwargs))
178
179 if flags.Tracking.doTruth:
180 from BeamSpotConditions.BeamSpotConditionsConfig import (
181 BeamSpotCondAlgCfg)
182 acc.merge(BeamSpotCondAlgCfg(flags))
183 acc.merge(InDetPhysValTruthDecoratorAlgCfg(flags))
184
185 if flags.PhysVal.IDPVM.doValidateGSFTracks:
186 acc.merge(AddGSFTrackDecoratorAlgCfg(flags))
187
188 return acc
189
190
191def AddGSFTrackDecoratorAlgCfg(flags, **kwargs):
192 # Search egamma algorithm and add the GSF TrackParticle decorator
193 acc = ComponentAccumulator()
194
195 if flags.PhysVal.IDPVM.doValidateGSFTracks:
196 acc.merge(GSFTrackDecoratorsCfg(flags))
197
198 for col in flags.PhysVal.IDPVM.validateExtraTrackCollections:
199 acc.merge(TrackDecoratorsCfg(
200 flags, TrackParticleContainerName=col))
201
202
203def AddDecoratorIfNeededCfg(flags, **kwargs):
204 '''
205 Add the InDet decoration algorithm if it has not been ran yet.
206 '''
207
208 acc = ComponentAccumulator()
209
210 if not canAddDecorator(flags):
211 print('DEBUG addDecoratorIfNeeded ? Stage is too early or too late for running the decoration. Needs reconstructed tracks. Try again during next stage ?')
212 return acc
213
214 acc.merge(AddDecoratorCfg(flags, **kwargs))
215
216 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)