ATLAS Offline Software
InDetCommonConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 # ********************************************************************
4 # InDetCommonConfig.py
5 # Configures all tools needed for ID track object selection
6 # and inserts them into a and writes
7 # results into SG. These may then be accessed along the train
8 # Component accumulator version
9 # ********************************************************************
10 
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 from AthenaConfiguration.Enums import BeamType
14 
15 
16 def InDetCommonCfg(flags, **kwargs):
17  """Main config for common ID track decorations"""
18 
19  acc = ComponentAccumulator()
20  CommonAugmentation = CompFactory.DerivationFramework.CommonAugmentation
21 
22  have_PV_container = (
23  flags.Beam.Type is not BeamType.Cosmics and
24  (any('PrimaryVertices' in elements for elements
25  in flags.Input.TypedCollections)))
26  if not have_PV_container and kwargs['DoVertexFinding']:
27  have_PV_container = (
28  any('PixelRDOs' in elements for elements
29  in flags.Input.TypedCollections) or
30  any('SCT_RDOs' in elements for elements in
31  flags.Input.TypedCollections))
32 
33  if have_PV_container:
34  # ====================================================================
35  # LABELLING TRACKS WITH OUTCOME OF SELECTOR TOOL
36  # ====================================================================
37  from DerivationFrameworkInDet.InDetToolsConfig import (
38  InDetTrackSelectionToolWrapperCfg)
39  DFCommonTrackSelection = acc.getPrimaryAndMerge(
41  flags,
42  name = "DFCommonTrackSelection",
43  CutLevel = "TightPrimary",
44  DecorationName = "DFCommonTightPrimary"))
45 
46  if kwargs['AddPseudoTracks']:
47  from DerivationFrameworkInDet.InDetToolsConfig import (
48  PseudoTrackSelectorCfg)
49  PseudoTrackSelectorTool = acc.getPrimaryAndMerge(
51  flags,
52  name = "PseudoTrackSelectorTool",
53  RecoTrackParticleLocation = "InDetTrackParticles",
54  PseudoTrackParticleLocation = "InDetPseudoTrackParticles",
55  OutputRecoReplacedWithPseudo = "InDetReplacedWithPseudoTrackParticles",
56  OutputRecoReplacedWithPseudoFromB = "InDetReplacedWithPseudoFromBTrackParticles",
57  OutputRecoReplacedWithPseudoNotFromB = "InDetReplacedWithPseudoNotFromBTrackParticles",
58  OutputRecoPlusPseudo = "InDetPlusPseudoTrackParticles",
59  OutputRecoPlusPseudoFromB = "InDetPlusPseudoFromBTrackParticles",
60  OutputRecoPlusPseudoNotFromB = "InDetPlusPseudoNotFromBTrackParticles",
61  OutputRecoNoFakes = "InDetNoFakesTrackParticles",
62  OutputRecoNoFakesFromB = "InDetNoFakesFromBTrackParticles",
63  OutputRecoNoFakesNotFromB = "InDetNoFakesNotFromBTrackParticles"))
64 
65  acc.addEventAlgo(CommonAugmentation(
66  "InDetSelectedPseudo",
67  AugmentationTools=[PseudoTrackSelectorTool]))
68 
69  # ====================================================================
70  # EXPRESSION OF Z0 AT THE PRIMARY VERTEX
71  # ====================================================================
72  from DerivationFrameworkInDet.InDetToolsConfig import (
73  TrackParametersAtPVCfg)
74  DFCommonZ0AtPV = acc.getPrimaryAndMerge(TrackParametersAtPVCfg(
75  flags,
76  name = "DFCommonZ0AtPV",
77  TrackParticleContainerName = "InDetTrackParticles",
78  VertexContainerName = "PrimaryVertices",
79  Z0SGEntryName = "DFCommonInDetTrackZ0AtPV"))
80 
81  # ====================================================================
82  # DECORATE THE HARDSCATTER VERTEX WITH A FLAG
83  # ====================================================================
84  from InDetConfig.InDetHardScatterSelectionToolConfig import (
85  InDetHardScatterSelectionToolCfg)
86  DFCommonHSSelectionTool = acc.popToolsAndMerge(
88  name="DFCommonHSSelectionTool"))
89  acc.addPublicTool(DFCommonHSSelectionTool)
90 
91  from DerivationFrameworkInDet.InDetToolsConfig import HardScatterVertexDecoratorCfg
92  acc.merge(HardScatterVertexDecoratorCfg(flags))
93 
94  # ====================================================================
95  # DECORATE THE TRACKS WITH USED-IN-FIT TTVA VARIABLES
96  # ====================================================================
97  from InDetConfig.InDetUsedInFitTrackDecoratorToolConfig import (
98  InDetUsedInFitTrackDecoratorToolCfg)
99  DFCommonUsedInFitDecoratorTool = acc.popToolsAndMerge(
101  flags,
102  name = "DFCommonUsedInFitDecoratorTool",
103  AMVFVerticesDecoName = "TTVA_AMVFVertices",
104  AMVFWeightsDecoName = "TTVA_AMVFWeights",
105  TrackContainer = "InDetTrackParticles",
106  VertexContainer = "PrimaryVertices"))
107  acc.addPublicTool(DFCommonUsedInFitDecoratorTool)
108 
109  from DerivationFrameworkInDet.InDetToolsConfig import (
110  UsedInVertexFitTrackDecoratorCfg)
111  DFCommonUsedInFitDecorator = acc.getPrimaryAndMerge(
113  flags,
114  name="DFCommonUsedInFitDecorator",
115  UsedInFitDecoratorTool=DFCommonUsedInFitDecoratorTool))
116 
117  if kwargs['AddPseudoTracks']:
118  PseudoTrackContainers = [
119  "InDetPseudoTrackParticles",
120  "InDetReplacedWithPseudoTrackParticles",
121  "InDetReplacedWithPseudoFromBTrackParticles",
122  "InDetReplacedWithPseudoNotFromBTrackParticles",
123  "InDetPlusPseudoTrackParticles",
124  "InDetPlusPseudoFromBTrackParticles",
125  "InDetPlusPseudoNotFromBTrackParticles",
126  "InDetNoFakesTrackParticles",
127  "InDetNoFakesFromBTrackParticles",
128  "InDetNoFakesNotFromBTrackParticles"
129  ]
130  PseudoTrackDecorators = []
131  for t in PseudoTrackContainers:
132  InDetDecorator = acc.popToolsAndMerge(
134  flags,
135  name="DFCommonUsedInFitDecoratorTool" +
136  t.replace('InDetPseudo', 'Pseudo').replace(
137  'InDet', 'Reco').replace('TrackParticles', ''),
138  AMVFVerticesDecoName="TTVA_AMVFVertices",
139  AMVFWeightsDecoName="TTVA_AMVFWeights",
140  TrackContainer=t,
141  VertexContainer="PrimaryVertices"))
142  DerivDecorator = acc.getPrimaryAndMerge(
144  flags,
145  name="DFCommonUsedInFitDecorator" +
146  t.replace('InDetPseudo', 'Pseudo').replace(
147  'InDet', 'Reco').replace('TrackParticles', ''),
148  UsedInFitDecoratorTool=InDetDecorator))
149  PseudoTrackDecorators.append(DerivDecorator)
150 
151  # Turned off by defult for the LRT tracks as they are not used. Added this option to turn it on for future studies.
152  if (kwargs['DecoLRTTTVA'] and kwargs['DoR3LargeD0'] and
153  kwargs['StoreSeparateLargeD0Container']):
154 
155  # ====================================================================
156  # DECORATE THE LRT TRACKS WITH USED-IN-FIT TTVA VARIABLES
157  # ====================================================================
158  DFCommonUsedInFitDecoratorToolLRT = acc.popToolsAndMerge(
160  flags,
161  name = "DFCommonUsedInFitDecoratorToolLRT",
162  AMVFVerticesDecoName = "TTVA_AMVFVertices",
163  AMVFWeightsDecoName = "TTVA_AMVFWeights",
164  TrackContainer = "InDetLargeD0TrackParticles",
165  VertexContainer = "PrimaryVertices"))
166 
167  DFCommonUsedInFitDecoratorLRT = acc.getPrimaryAndMerge(
169  flags,
170  name="DFCommonUsedInFitDecoratorLRT",
171  UsedInFitDecoratorTool=DFCommonUsedInFitDecoratorToolLRT))
172  # =======================================
173  # CREATE THE DERIVATION KERNEL ALGORITHM
174  # =======================================
175  for tool in [DFCommonTrackSelection,
176  DFCommonZ0AtPV,
177  DFCommonUsedInFitDecorator,
178  DFCommonUsedInFitDecoratorLRT]:
179  acc.addEventAlgo(CommonAugmentation("InDetCommonKernel"+tool.name,
180  AugmentationTools=[tool]))
181  else:
182  AugTools = [DFCommonTrackSelection,
183  DFCommonZ0AtPV,
184  DFCommonUsedInFitDecorator]
185  if kwargs['AddPseudoTracks']:
186  AugTools += PseudoTrackDecorators
187  for tool in AugTools:
188  acc.addEventAlgo(CommonAugmentation("InDetCommonKernel"+tool.name,
189  AugmentationTools=[tool]))
190 
191  # Add LRT merger job to the sequence when the LRT track particle is supposed to be made already
192  if (kwargs['MergeLRT'] and kwargs['DoR3LargeD0'] and
193  kwargs['StoreSeparateLargeD0Container']):
194  # ====================================================================
195  # Merge the LRT and standard track using track particle merger
196  # ====================================================================
197  from DerivationFrameworkInDet.InDetToolsConfig import InDetLRTMergeCfg
198  acc.merge(InDetLRTMergeCfg(flags))
199 
200  return acc
python.InDetHardScatterSelectionToolConfig.InDetHardScatterSelectionToolCfg
def InDetHardScatterSelectionToolCfg(flags, name="InDetHardScatterSelectionTool", **kwargs)
Definition: InDetHardScatterSelectionToolConfig.py:7
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.InDetToolsConfig.InDetTrackSelectionToolWrapperCfg
def InDetTrackSelectionToolWrapperCfg(flags, name, CutLevel="TightPrimary", **kwargs)
Definition: InDetToolsConfig.py:426
python.InDetToolsConfig.TrackParametersAtPVCfg
def TrackParametersAtPVCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:399
python.InDetToolsConfig.HardScatterVertexDecoratorCfg
def HardScatterVertexDecoratorCfg(flags, name="DFCommonHSDecorator", **kwargs)
Definition: InDetToolsConfig.py:46
python.InDetToolsConfig.PseudoTrackSelectorCfg
def PseudoTrackSelectorCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:409
python.InDetToolsConfig.InDetLRTMergeCfg
def InDetLRTMergeCfg(flags, name="InDetLRTMerge", **kwargs)
Definition: InDetToolsConfig.py:14
python.InDetCommonConfig.InDetCommonCfg
def InDetCommonCfg(flags, **kwargs)
Definition: InDetCommonConfig.py:16
UsedInVertexFitTrackDecoratorConfig.UsedInVertexFitTrackDecoratorCfg
def UsedInVertexFitTrackDecoratorCfg(flags, trackCont='InDetTrackParticles', vtxCont='PrimaryVertices')
Definition: UsedInVertexFitTrackDecoratorConfig.py:32
python.InDetUsedInFitTrackDecoratorToolConfig.InDetUsedInFitTrackDecoratorToolCfg
def InDetUsedInFitTrackDecoratorToolCfg(flags, name="InDetUsedInFitTrackDecoratorTool", **kwargs)
Definition: InDetUsedInFitTrackDecoratorToolConfig.py:7