ATLAS Offline Software
InDetPhysValDecorationConfig.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 
8 
9 def 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", acc.addPublicTool(
43  acc.popToolsAndMerge(InDetTrackHoleSearchToolCfg(flags))))
44 
45  if 'Updator' not in kwargs:
46  from TrkConfig.TrkMeasurementUpdatorConfig import InDetUpdatorCfg
47  kwargs.setdefault("Updator", acc.addPublicTool(acc.popToolsAndMerge(InDetUpdatorCfg(flags))))
48 
49  if 'LorentzAngleTool' not in kwargs:
50  from SiLorentzAngleTool.PixelLorentzAngleConfig import (
51  PixelLorentzAngleToolCfg)
52  kwargs.setdefault("LorentzAngleTool", acc.popToolsAndMerge(
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 
65 def 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  ITkTrackHoleSearchTool = acc.popToolsAndMerge(
77  acc.addPublicTool(ITkTrackHoleSearchTool)
78  kwargs.setdefault("InDetTrackHoleSearchTool", ITkTrackHoleSearchTool)
79 
80  if 'Updator' not in kwargs:
81  from TrkConfig.TrkMeasurementUpdatorConfig import ITkUpdatorCfg
82  Updator = acc.popToolsAndMerge(ITkUpdatorCfg(flags))
83  acc.addPublicTool(Updator)
84  kwargs.setdefault("Updator", Updator)
85 
86  if 'LorentzAngleTool' not in kwargs:
87  from SiLorentzAngleTool.ITkPixelLorentzAngleConfig import (
88  ITkPixelLorentzAngleToolCfg)
89  kwargs.setdefault("LorentzAngleTool", acc.popToolsAndMerge(
91 
92  acc.addEventAlgo(CompFactory.InDetPhysHitDecoratorAlg(name, **kwargs))
93  return acc
94 
95 
97  flags, name="ParameterErrDecoratorAlg", **kwargs):
98  '''
99  create decoration algorithm which decorates track particles with the uncertainties of the track parameters.
100  '''
101  acc = ComponentAccumulator()
102  acc.addEventAlgo(CompFactory.ParameterErrDecoratorAlg(name, **kwargs))
103  return acc
104 
105 
107  flags, name="InDetPhysValTruthDecoratorAlg", **kwargs):
108  '''
109  create decoration algorithm which decorates truth particles with track parameters at the perigee.
110  '''
111  acc = ComponentAccumulator()
112 
113  from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
114  extrapolator = acc.popToolsAndMerge(AtlasExtrapolatorCfg(flags))
115  acc.addPublicTool(extrapolator) # TODO: migrate to private?
116  kwargs.setdefault("Extrapolator", extrapolator)
117 
118  if flags.Detector.GeometryITk:
119  kwargs.setdefault("PixelClusterContainerName", "ITkPixelClusters")
120  kwargs.setdefault("SCTClusterContainerName", "ITkStripClusters")
121 
122  kwargs.setdefault('TruthParticleIndexDecoration',
123  'origTruthIndex' if flags.PhysVal.IDPVM.doTechnicalEfficiency else '')
124 
125  acc.addEventAlgo(CompFactory.InDetPhysValTruthDecoratorAlg(name, **kwargs))
126  return acc
127 
128 
129 def TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs):
130  '''
131  create decoration algorithm which decorates truth particles with origin and type from truth classifier.
132  '''
133  acc = ComponentAccumulator()
134  acc.addEventAlgo(CompFactory.TruthClassDecoratorAlg(name, **kwargs))
135  return acc
136 
137 
138 def TrackDecoratorsCfg(flags, **kwargs):
139  '''
140  Get track particle decorators needed for the InDetPhysValMonitoring tool
141  '''
142  acc = ComponentAccumulator()
143 
144  if "CombinedInDetTracks" in flags.Input.Collections:
145  acc.merge(InDetPhysHitDecoratorAlgCfg(flags, **kwargs))
146 
147  acc.merge(ParameterErrDecoratorAlgCfg(flags, **kwargs))
148 
149  return acc
150 
151 
152 def GSFTrackDecoratorsCfg(flags, **kwargs):
153  kwargs.setdefault("TrackParticleContainerName", "GSFTrackParticles")
154  return TrackDecoratorsCfg(flags, **kwargs)
155 
156 
157 def AddDecoratorCfg(flags, **kwargs):
158  '''
159  Add the track particle decoration algorithm to the top sequence.
160  The algorithm is to be run on RAW/RDO since it depends on full hit information
161  which is generally not available at later stages. The decorations added by this
162  algorithm are used by InDetPhysValMonitoring tool.
163  '''
164  acc = ComponentAccumulator()
165 
166  acc.merge(TrackDecoratorsCfg(flags))
167 
168  if flags.Input.isMC:
169  from BeamSpotConditions.BeamSpotConditionsConfig import (
170  BeamSpotCondAlgCfg)
171  acc.merge(BeamSpotCondAlgCfg(flags))
172  acc.merge(InDetPhysValTruthDecoratorAlgCfg(flags))
173 
174  if flags.PhysVal.IDPVM.doValidateGSFTracks:
175  acc.merge(AddGSFTrackDecoratorAlgCfg(flags))
176 
177  return acc
178 
179 
180 def AddGSFTrackDecoratorAlgCfg(flags, **kwargs):
181  # Search egamma algorithm and add the GSF TrackParticle decorator
182  acc = ComponentAccumulator()
183 
184  if flags.PhysVal.IDPVM.doValidateGSFTracks:
185  acc.merge(GSFTrackDecoratorsCfg(flags))
186 
187  for col in flags.PhysVal.IDPVM.validateExtraTrackCollections:
188  acc.merge(TrackDecoratorsCfg(
189  flags, TrackParticleContainerName=col))
190 
191 
193  '''
194  Add the InDet decoration algorithm if it has not been ran yet.
195  '''
196 
197  acc = ComponentAccumulator()
198 
199  if not canAddDecorator(flags):
200  print('DEBUG addDecoratorIfNeeded ? Stage is too early or too late for running the decoration. Needs reconstructed tracks. Try again during next stage ?')
201  return acc
202 
203  acc.merge(AddDecoratorCfg(flags))
204 
205  return acc
python.TrkMeasurementUpdatorConfig.ITkUpdatorCfg
def ITkUpdatorCfg(flags, name='ITkUpdator', **kwargs)
Definition: TrkMeasurementUpdatorConfig.py:44
InDetPhysValDecorationConfig.ParameterErrDecoratorAlgCfg
def ParameterErrDecoratorAlgCfg(flags, name="ParameterErrDecoratorAlg", **kwargs)
Definition: InDetPhysValDecorationConfig.py:96
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.BeamSpotConditionsConfig.BeamSpotCondAlgCfg
def BeamSpotCondAlgCfg(flags, name="BeamSpotCondAlg", **kwargs)
Definition: BeamSpotConditionsConfig.py:7
InDetPhysValDecorationConfig.TrackDecoratorsCfg
def TrackDecoratorsCfg(flags, **kwargs)
Definition: InDetPhysValDecorationConfig.py:138
InDetPhysValDecorationConfig.AddDecoratorCfg
def AddDecoratorCfg(flags, **kwargs)
Definition: InDetPhysValDecorationConfig.py:157
python.PixelLorentzAngleConfig.PixelLorentzAngleToolCfg
def PixelLorentzAngleToolCfg(flags, name="PixelLorentzAngleTool", **kwargs)
Definition: PixelLorentzAngleConfig.py:13
python.ITkPixelLorentzAngleConfig.ITkPixelLorentzAngleToolCfg
def ITkPixelLorentzAngleToolCfg(flags, name="ITkPixelLorentzAngleTool", **kwargs)
Definition: ITkPixelLorentzAngleConfig.py:14
python.AtlasExtrapolatorConfig.AtlasExtrapolatorCfg
def AtlasExtrapolatorCfg(flags, name='AtlasExtrapolator')
Definition: AtlasExtrapolatorConfig.py:63
python.TrkMeasurementUpdatorConfig.InDetUpdatorCfg
def InDetUpdatorCfg(flags, name='InDetUpdator', **kwargs)
Definition: TrkMeasurementUpdatorConfig.py:26
InDetPhysValDecorationConfig.InDetPhysValTruthDecoratorAlgCfg
def InDetPhysValTruthDecoratorAlgCfg(flags, name="InDetPhysValTruthDecoratorAlg", **kwargs)
Definition: InDetPhysValDecorationConfig.py:106
InDetPhysValDecorationConfig.TruthClassDecoratorAlgCfg
def TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs)
Definition: InDetPhysValDecorationConfig.py:129
python.InDetTrackHoleSearchConfig.ITkTrackHoleSearchToolCfg
def ITkTrackHoleSearchToolCfg(flags, name='ITkHoleSearchTool', **kwargs)
Definition: InDetTrackHoleSearchConfig.py:56
InDetPhysValDecorationConfig.canAddDecorator
def canAddDecorator(flags)
Definition: InDetPhysValDecorationConfig.py:9
InDetPhysValDecorationConfig.InDetPhysHitDecoratorAlgCfg
def InDetPhysHitDecoratorAlgCfg(flags, name="InDetPhysHitDecoratorAlg", **kwargs)
Definition: InDetPhysValDecorationConfig.py:29
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.InDetTrackHoleSearchConfig.InDetTrackHoleSearchToolCfg
def InDetTrackHoleSearchToolCfg(flags, name='InDetHoleSearchTool', **kwargs)
Definition: InDetTrackHoleSearchConfig.py:8
InDetPhysValDecorationConfig.GSFTrackDecoratorsCfg
def GSFTrackDecoratorsCfg(flags, **kwargs)
Definition: InDetPhysValDecorationConfig.py:152
InDetPhysValDecorationConfig.ITkPhysHitDecoratorAlgCfg
def ITkPhysHitDecoratorAlgCfg(flags, name="ITkPhysHitDecoratorAlg", **kwargs)
Definition: InDetPhysValDecorationConfig.py:65
InDetPhysValDecorationConfig.AddGSFTrackDecoratorAlgCfg
def AddGSFTrackDecoratorAlgCfg(flags, **kwargs)
Definition: InDetPhysValDecorationConfig.py:180
python.TrkResidualPullCalculatorConfig.ResidualPullCalculatorCfg
def ResidualPullCalculatorCfg(flags, name='ResidualPullCalculator', **kwargs)
Definition: TrkResidualPullCalculatorConfig.py:6
InDetPhysValDecorationConfig.AddDecoratorIfNeededCfg
def AddDecoratorIfNeededCfg(flags)
Definition: InDetPhysValDecorationConfig.py:192