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.popToolsAndMerge(
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(
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  kwargs.setdefault("InDetTrackHoleSearchTool", acc.popToolsAndMerge(
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(
87 
88  acc.addEventAlgo(CompFactory.InDetPhysHitDecoratorAlg(name, **kwargs))
89  return acc
90 
91 
93  flags, name="ParameterErrDecoratorAlg", **kwargs):
94  '''
95  create decoration algorithm which decorates track particles with the uncertainties of the track parameters.
96  '''
97  acc = ComponentAccumulator()
98  acc.addEventAlgo(CompFactory.ParameterErrDecoratorAlg(name, **kwargs))
99  return acc
100 
101 
103  flags, name="InDetPhysValTruthDecoratorAlg", **kwargs):
104  '''
105  create decoration algorithm which decorates truth particles with track parameters at the perigee.
106  '''
107  acc = ComponentAccumulator()
108 
109  from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
110  extrapolator = acc.popToolsAndMerge(AtlasExtrapolatorCfg(flags))
111  acc.addPublicTool(extrapolator) # TODO: migrate to private?
112  kwargs.setdefault("Extrapolator", extrapolator)
113 
114  if flags.Detector.GeometryITk:
115  kwargs.setdefault("PixelClusterContainerName", "ITkPixelClusters")
116  kwargs.setdefault("SCTClusterContainerName", "ITkStripClusters")
117 
118  kwargs.setdefault('TruthParticleIndexDecoration',
119  'origTruthIndex' if flags.PhysVal.IDPVM.doTechnicalEfficiency else '')
120 
121  acc.addEventAlgo(CompFactory.InDetPhysValTruthDecoratorAlg(name, **kwargs))
122  return acc
123 
124 
125 def TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs):
126  '''
127  create decoration algorithm which decorates truth particles with origin and type from truth classifier.
128  '''
129  acc = ComponentAccumulator()
130  acc.addEventAlgo(CompFactory.TruthClassDecoratorAlg(name, **kwargs))
131  return acc
132 
133 
134 def TrackDecoratorsCfg(flags, **kwargs):
135  '''
136  Get track particle decorators needed for the InDetPhysValMonitoring tool
137  '''
138  acc = ComponentAccumulator()
139 
140  if "CombinedInDetTracks" in flags.Input.Collections:
141  acc.merge(InDetPhysHitDecoratorAlgCfg(flags, **kwargs))
142 
143  acc.merge(ParameterErrDecoratorAlgCfg(flags, **kwargs))
144 
145  return acc
146 
147 
148 def GSFTrackDecoratorsCfg(flags, **kwargs):
149  kwargs.setdefault("TrackParticleContainerName", "GSFTrackParticles")
150  return TrackDecoratorsCfg(flags, **kwargs)
151 
152 
153 def AddDecoratorCfg(flags, **kwargs):
154  '''
155  Add the track particle decoration algorithm to the top sequence.
156  The algorithm is to be run on RAW/RDO since it depends on full hit information
157  which is generally not available at later stages. The decorations added by this
158  algorithm are used by InDetPhysValMonitoring tool.
159  '''
160  acc = ComponentAccumulator()
161 
162  acc.merge(TrackDecoratorsCfg(flags))
163 
164  if flags.Input.isMC:
165  from BeamSpotConditions.BeamSpotConditionsConfig import (
166  BeamSpotCondAlgCfg)
167  acc.merge(BeamSpotCondAlgCfg(flags))
168  acc.merge(InDetPhysValTruthDecoratorAlgCfg(flags))
169 
170  if flags.PhysVal.IDPVM.doValidateGSFTracks:
171  acc.merge(AddGSFTrackDecoratorAlgCfg(flags))
172 
173  return acc
174 
175 
176 def AddGSFTrackDecoratorAlgCfg(flags, **kwargs):
177  # Search egamma algorithm and add the GSF TrackParticle decorator
178  acc = ComponentAccumulator()
179 
180  if flags.PhysVal.IDPVM.doValidateGSFTracks:
181  acc.merge(GSFTrackDecoratorsCfg(flags))
182 
183  for col in flags.PhysVal.IDPVM.validateExtraTrackCollections:
184  acc.merge(TrackDecoratorsCfg(
185  flags, TrackParticleContainerName=col))
186 
187 
189  '''
190  Add the InDet decoration algorithm if it has not been ran yet.
191  '''
192 
193  acc = ComponentAccumulator()
194 
195  if not canAddDecorator(flags):
196  print('DEBUG addDecoratorIfNeeded ? Stage is too early or too late for running the decoration. Needs reconstructed tracks. Try again during next stage ?')
197  return acc
198 
199  acc.merge(AddDecoratorCfg(flags))
200 
201  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:92
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:134
InDetPhysValDecorationConfig.AddDecoratorCfg
def AddDecoratorCfg(flags, **kwargs)
Definition: InDetPhysValDecorationConfig.py:153
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:102
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
InDetPhysValDecorationConfig.TruthClassDecoratorAlgCfg
def TruthClassDecoratorAlgCfg(flags, name="TruthClassDecoratorAlg", **kwargs)
Definition: InDetPhysValDecorationConfig.py:125
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
python.InDetTrackHoleSearchConfig.InDetTrackHoleSearchToolCfg
def InDetTrackHoleSearchToolCfg(flags, name='InDetHoleSearchTool', **kwargs)
Definition: InDetTrackHoleSearchConfig.py:8
InDetPhysValDecorationConfig.GSFTrackDecoratorsCfg
def GSFTrackDecoratorsCfg(flags, **kwargs)
Definition: InDetPhysValDecorationConfig.py:148
InDetPhysValDecorationConfig.ITkPhysHitDecoratorAlgCfg
def ITkPhysHitDecoratorAlgCfg(flags, name="ITkPhysHitDecoratorAlg", **kwargs)
Definition: InDetPhysValDecorationConfig.py:65
InDetPhysValDecorationConfig.AddGSFTrackDecoratorAlgCfg
def AddGSFTrackDecoratorAlgCfg(flags, **kwargs)
Definition: InDetPhysValDecorationConfig.py:176
python.TrkResidualPullCalculatorConfig.ResidualPullCalculatorCfg
def ResidualPullCalculatorCfg(flags, name='ResidualPullCalculator', **kwargs)
Definition: TrkResidualPullCalculatorConfig.py:6
InDetPhysValDecorationConfig.AddDecoratorIfNeededCfg
def AddDecoratorIfNeededCfg(flags)
Definition: InDetPhysValDecorationConfig.py:188