5 '''@file InDetPhysValMonitoringConfig.py
8 @brief Main CA-based python configuration for InDetPhysValMonitoring
11 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory
import CompFactory
16 suffixes = [
'Tracks',
'TrackParticles']
17 for suffix
in suffixes:
18 if track_collection_name.endswith(suffix):
19 return track_collection_name.removesuffix(suffix)
20 return track_collection_name
25 if flags.Detector.GeometryID:
26 if flags.PhysVal.IDPVM.doValidateLargeD0Tracks
or flags.PhysVal.IDPVM.doValidateMergedLargeD0Tracks:
27 kwargs.setdefault(
"DefinitionSource",
"InDetPVMPlotDefLRT.xml")
29 kwargs.setdefault(
"DefinitionSource",
"InDetPVMPlotDefRun2.xml")
30 elif flags.Detector.GeometryITk:
31 kwargs.setdefault(
"DefinitionSource",
"InDetPVMPlotDefITK.xml")
32 kwargs.setdefault(
"DefinitionFormat",
"text/xml")
33 histoSvc = CompFactory.HistogramDefinitionSvc(**kwargs)
34 acc.addService(histoSvc)
39 flags, name="InDetRttTruthSelectionTool", **kwargs):
42 kwargs.setdefault(
"requireStable",
True)
43 kwargs.setdefault(
"requireCharged",
True)
44 kwargs.setdefault(
"selectedCharge", flags.PhysVal.IDPVM.selectedCharge)
45 kwargs.setdefault(
"requireOnlyPrimary",
46 True if kwargs.pop(
"OnlyDressPrimaryTracks",
True)
48 kwargs.setdefault(
"maxProdVertRadius",
49 flags.PhysVal.IDPVM.maxProdVertRadius)
51 if flags.Detector.GeometryID:
52 if flags.PhysVal.IDPVM.doValidateLargeD0Tracks
or flags.PhysVal.IDPVM.doValidateMergedLargeD0Tracks:
53 kwargs.setdefault(
"maxEta", 3.0)
55 kwargs.setdefault(
"maxEta", 2.5)
56 elif flags.Detector.GeometryITk:
57 kwargs.setdefault(
"maxEta", 4.0)
59 kwargs.setdefault(
"minPt", flags.PhysVal.IDPVM.truthMinPt)
60 kwargs.setdefault(
"ancestorList", flags.PhysVal.IDPVM.ancestorIDs)
61 kwargs.setdefault(
"requireSiHit", flags.PhysVal.IDPVM.requiredSiHits)
63 if "radiusCylinder" in kwargs
or "zDisc" in kwargs:
64 from TrkConfig.AtlasExtrapolatorConfig
import AtlasExtrapolatorCfg
66 acc.addPublicTool(extrapolator)
67 kwargs.setdefault(
"Extrapolator", extrapolator)
69 kwargs.setdefault(
"Extrapolator",
None)
71 acc.setPrivateTools(CompFactory.AthTruthSelectionTool(name, **kwargs))
78 from GoodRunsLists.GoodRunsListsDictionary
import getGoodRunsLists
81 cvmfs =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/'
83 '2015': cvmfs + GRLDict[
'GRL2015'],
84 '2016': cvmfs + GRLDict[
'GRL2016'],
85 '2017': cvmfs + GRLDict[
'GRL2017_Triggerno17e33prim'],
86 '2018': cvmfs + GRLDict[
'GRL2018_Triggerno17e33prim'],
87 '2022': cvmfs + GRLDict[
'GRL2022'],
88 '2023': cvmfs + GRLDict[
'GRL2023'],
89 '2024': cvmfs + GRLDict[
'GRL2024_EtoI']
92 acc.setPrivateTools(CompFactory.GoodRunsListSelectionTool(
93 name=
"GoodRunsListSelectionTool",
94 GoodRunsListVec=[grldict[p]
for p
in flags.PhysVal.IDPVM.GRL],
102 acc.setPrivateTools(CompFactory.InDetVertexTruthMatchTool(**kwargs))
107 from InDetPhysValMonitoring.InDetPhysValDecorationConfig
import (
108 AddDecoratorIfNeededCfg)
110 kwargs.setdefault(
"useTrackSelection",
False)
111 kwargs.setdefault(
"EnableLumi",
False)
114 kwargs.setdefault(
'VertexContainerName', flags.PhysVal.IDPVM.PrimaryVertexContainer)
117 if flags.PhysVal.IDPVM.hardScatterStrategy
in [2, 3]:
119 from InDetPhysValMonitoring.addRecoJetsConfig
import (
120 AddRecoJetsIfNotExistingCfg)
122 flags, flags.PhysVal.IDPVM.jetsNameForHardScatter))
125 if flags.PhysVal.IDPVM.hardScatterStrategy == 3:
126 from InDetConfig.InDetGNNHardScatterSelectionConfig
import (
131 if flags.PhysVal.IDPVM.hardScatterStrategy == 4:
132 from DerivationFrameworkHiggs.HIGG1D1CustomVertexConfig
import DiPhotonVertexCfg
135 if flags.PhysVal.IDPVM.GRL:
136 kwargs.setdefault(
"useGRL",
True)
137 kwargs.setdefault(
'GoodRunsListSelectionTool', acc.popToolsAndMerge(
140 kwargs.setdefault(
"doIDTIDEPlots", flags.PhysVal.IDPVM.doIDTIDE)
142 if flags.PhysVal.IDPVM.doValidateTracksInJets:
143 kwargs.setdefault(
"JetContainerName", flags.PhysVal.IDPVM.jetCollection)
144 kwargs.setdefault(
"FillTrackInJetPlots",
True)
145 kwargs.setdefault(
'JetAbsEtaMin', 0)
146 kwargs.setdefault(
'JetAbsEtaMax', flags.PhysVal.IDPVM.JetAbsEtaMax)
147 kwargs.setdefault(
'JetPtMin', flags.PhysVal.IDPVM.JetPtMin)
148 kwargs.setdefault(
'JetPtMax', flags.PhysVal.IDPVM.JetPtMax)
149 kwargs.setdefault(
'maxTrkJetDR', flags.PhysVal.IDPVM.maxTrkJetDR)
150 kwargs.setdefault(
"FillTrackInBJetPlots",
151 flags.PhysVal.IDPVM.doValidateTracksInBJets)
153 kwargs.setdefault(
"JetContainerName",
'')
154 kwargs.setdefault(
"FillTrackInJetPlots",
False)
157 if flags.Input.isMC
and not flags.PhysVal.IDPVM.doRecoOnly:
158 kwargs.setdefault(
"TruthParticleContainerName",
"TruthParticles")
159 if 'TruthSelectionTool' not in kwargs:
160 kwargs.setdefault(
"TruthSelectionTool", acc.popToolsAndMerge(
163 doHyyHSSelection = flags.PhysVal.IDPVM.hardScatterStrategy == 4
164 if 'hardScatterSelectionTool' not in kwargs:
165 from InDetConfig.InDetHardScatterSelectionToolConfig
import (
166 InDetHardScatterSelectionToolCfg)
167 kwargs.setdefault(
"hardScatterSelectionTool", acc.popToolsAndMerge(
170 RedoHardScatter=
not doHyyHSSelection,
171 SelectionMode=flags.PhysVal.IDPVM.hardScatterStrategy,
173 JetContainer=flags.PhysVal.IDPVM.jetsNameForHardScatter,
174 VertexContainer=flags.PhysVal.IDPVM.PrimaryVertexContainer
178 assert flags.PhysVal.IDPVM.PrimaryVertexContainer ==
'HggPrimaryVertices'
180 kwargs.setdefault(
"FillTruthToRecoNtuple",
181 flags.PhysVal.IDPVM.doValidateTruthToRecoNtuple)
182 kwargs.setdefault(
"doTruthOriginPlots",
183 flags.PhysVal.IDPVM.doTruthOriginPlots)
184 kwargs.setdefault(
"doDuplicatePlots",
185 flags.PhysVal.IDPVM.doDuplicatePlots)
186 kwargs.setdefault(
"doPerAuthorPlots",
187 flags.PhysVal.IDPVM.doPerAuthorPlots)
188 kwargs.setdefault(
"doHitLevelPlots",
189 flags.PhysVal.IDPVM.doHitLevelPlots)
192 if not flags.PhysVal.IDPVM.doIDTIDE:
193 kwargs.setdefault(
"useVertexTruthMatchTool",
True)
194 kwargs.setdefault(
"VertexTruthMatchTool", acc.popToolsAndMerge(
197 if "trackTruthOriginTool" not in kwargs:
198 from InDetTrackSystematicsTools.InDetTrackSystematicsToolsConfig
import InDetTrackTruthOriginToolCfg
199 kwargs.setdefault(
"trackTruthOriginTool", acc.popToolsAndMerge(
203 if flags.PhysVal.IDPVM.setTruthStrategy
in [
'All',
'PileUp']:
204 if not(
"xAOD::TruthPileupEventContainer#TruthPileupEvents"
205 in flags.Input.TypedCollections):
206 print(
'WARNING Truth Strategy for InDetPhysValMonitoring set to %s but TruthPileupEvents are missing in the input' % (flags.PhysVal.IDPVM.setTruthStrategy))
207 kwargs.setdefault(
"PileupSwitch",
208 flags.PhysVal.IDPVM.setTruthStrategy)
210 elif flags.PhysVal.IDPVM.setTruthStrategy !=
'HardScatter':
211 print(
'WARNING Truth Strategy for for InDetPhysValMonitoring set to invalid option %s; valid flags are ["HardScatter", "All", "PileUp"]' % (
212 flags.PhysVal.IDPVM.setTruthStrategy))
216 kwargs.setdefault(
"TruthParticleContainerName",
'')
217 kwargs.setdefault(
"TruthVertexContainerName",
'')
218 kwargs.setdefault(
"TruthEvents",
'')
219 kwargs.setdefault(
"TruthPileupEvents",
'')
220 kwargs.setdefault(
"TruthSelectionTool",
None)
221 kwargs.setdefault(
"FillTruthToRecoNtuple",
False)
223 if flags.Detector.GeometryITk:
225 kwargs.setdefault(
"doTRTExtensionPlots",
False)
226 kwargs.setdefault(
"isITk",
True)
228 if flags.PhysVal.IDPVM.doTechnicalEfficiency:
229 kwargs.setdefault(
"fillTechnicalEfficiency",
True)
230 kwargs.setdefault(
"EtaBins", flags.Tracking.ITkMainPass.etaBins
if flags.Detector.GeometryITk
232 kwargs.setdefault(
"MinNumberClusters", flags.Tracking.ITkMainPass.minClusters
if flags.Detector.GeometryITk
233 else [flags.Tracking.MainPass.minClusters])
236 if flags.PhysVal.IDPVM.doPhysValOutput:
237 kwargs.setdefault(
"DetailLevel", 100)
239 elif flags.PhysVal.IDPVM.doExpertOutput:
240 kwargs.setdefault(
"DetailLevel", 200)
243 if flags.PhysVal.IDPVM.doIDTIDE:
244 kwargs.setdefault(
"doIDTIDEPlots",
True)
245 kwargs.setdefault(
"JetContainerName",
'AntiKt4EMPFlowJets')
246 kwargs.setdefault(
"FillTrackInJetPlots",
True)
249 kwargs.setdefault(
'JetAbsEtaMin', 0)
250 kwargs.setdefault(
'JetAbsEtaMax',
251 flags.PhysVal.IDPVM.JetAbsEtaMax)
252 kwargs.setdefault(
'maxTrkJetDR',
253 flags.PhysVal.IDPVM.maxTrkJetDR)
255 kwargs.setdefault(
'JetPtMin', 100)
256 kwargs.setdefault(
'JetPtMax', 5000)
258 kwargs.setdefault(
"doPRW", flags.PhysVal.IDPVM.doPRW)
260 acc.setPrivateTools(CompFactory.InDetPhysValMonitoringTool(**kwargs))
267 if 'TrackSelectionTool' not in kwargs:
268 from InDetConfig.InDetTrackSelectionToolConfig
import (
269 InDetTrackSelectionTool_Loose_Cfg)
270 kwargs.setdefault(
"TrackSelectionTool", acc.popToolsAndMerge(
273 kwargs.setdefault(
"SubFolder",
'Loose/')
274 kwargs.setdefault(
"useTrackSelection",
True)
277 flags, name=
"InDetPhysValMonitoringToolLoose", **kwargs)))
284 if 'TrackSelectionTool' not in kwargs:
285 from InDetConfig.InDetTrackSelectionToolConfig
import (
286 InDetTrackSelectionTool_TightPrimary_Cfg)
287 kwargs.setdefault(
"TrackSelectionTool", acc.popToolsAndMerge(
290 kwargs.setdefault(
"SubFolder",
'TightPrimary/')
291 kwargs.setdefault(
"useTrackSelection",
True)
294 flags, name=
"InDetPhysValMonitoringToolTightPrimary", **kwargs)))
301 if 'TrackSelectionTool' not in kwargs:
302 from InDetConfig.InDetTrackSelectionToolConfig
import (
303 InDetTrackSelectionTool_HILoose_Cfg)
304 kwargs.setdefault(
"TrackSelectionTool", acc.popToolsAndMerge(
307 kwargs.setdefault(
"SubFolder",
'HILoose/')
308 kwargs.setdefault(
"useTrackSelection",
True)
311 flags, name=
"InDetPhysValMonitoringToolHILoose", **kwargs)))
316 kwargs.setdefault(
"SubFolder",
'GSF/')
317 kwargs.setdefault(
"TrackParticleContainerName",
'GSFTrackParticles')
318 kwargs.setdefault(
"useTrackSelection",
True)
320 flags, name=
"InDetPhysValMonitoringToolGSF", **kwargs)
326 kwargs.setdefault(
"TruthSelectionTool", acc.popToolsAndMerge(
328 flags, name=
"AthTruthSelectionToolForIDPVM_Electrons",
332 kwargs.setdefault(
"onlyFillTruthMatched",
True)
333 kwargs.setdefault(
"SubFolder",
'Electrons/')
336 flags, name=
'InDetPhysValMonitoringToolElectrons', **kwargs)))
343 kwargs.setdefault(
"TruthSelectionTool", acc.popToolsAndMerge(
345 flags, name=
"AthTruthSelectionToolForIDPVM_Muons",
349 kwargs.setdefault(
"onlyFillTruthMatched",
True)
350 kwargs.setdefault(
"SubFolder",
'Muons/')
353 flags, name=
'InDetPhysValMonitoringToolMuons', **kwargs)))
360 kwargs.setdefault(
"SubFolder",
'LRT/')
361 kwargs.setdefault(
"TruthSelectionTool", acc.popToolsAndMerge(
363 kwargs.setdefault(
"TrackParticleContainerName",
364 'InDetLargeD0TrackParticles'
365 if flags.Tracking.storeSeparateLargeD0Container
else
366 'InDetTrackParticles')
367 kwargs.setdefault(
"useTrackSelection",
True)
370 flags, name=
'InDetPhysValMonitoringToolLargeD0', **kwargs)))
377 kwargs.setdefault(
"SubFolder",
'LRTMerged/')
378 kwargs.setdefault(
"TruthSelectionTool", acc.popToolsAndMerge(
380 kwargs.setdefault(
"TrackParticleContainerName",
381 'InDetWithLRTTrackParticles'
382 if flags.Tracking.storeSeparateLargeD0Container
else
383 'InDetTrackParticles')
384 kwargs.setdefault(
"useTrackSelection",
True)
387 flags, name=
'InDetPhysValMonitoringToolMergedLargeD0', **kwargs)))
392 kwargs.setdefault(
"SubFolder",
'LowPtRoI/')
393 kwargs.setdefault(
"TruthSelectionTool", acc.popToolsAndMerge(
395 kwargs.setdefault(
"TrackParticleContainerName",
396 'InDetLowPtRoITrackParticles')
398 flags, name=
'InDetPhysValMonitoringToolLowPtRoI', **kwargs)))
406 if flags.PhysVal.IDPVM.doValidateMergedLargeD0Tracks:
407 from DerivationFrameworkInDet.InDetToolsConfig
import InDetLRTMergeCfg
411 InDetPhysValMonitoringToolCfg),
412 (flags.PhysVal.IDPVM.doValidateMuonMatchedTracks,
413 InDetPhysValMonitoringToolMuonsCfg),
414 (flags.PhysVal.IDPVM.doValidateElectronMatchedTracks,
415 InDetPhysValMonitoringToolElectronsCfg),
416 (flags.PhysVal.IDPVM.doValidateLargeD0Tracks,
417 InDetLargeD0PhysValMonitoringToolCfg),
418 (flags.PhysVal.IDPVM.doValidateMergedLargeD0Tracks,
419 InDetMergedLargeD0PhysValMonitoringToolCfg),
420 (flags.PhysVal.IDPVM.doValidateLowPtRoITracks,
421 InDetLowPtRoIPhysValMonitoringToolCfg),
422 (flags.PhysVal.IDPVM.doValidateLooseTracks,
423 InDetPhysValMonitoringToolLooseCfg),
424 (flags.PhysVal.IDPVM.doValidateTightPrimaryTracks,
425 InDetPhysValMonitoringToolTightPrimaryCfg),
426 (flags.PhysVal.IDPVM.doValidateHILoose,
427 InDetPhysValMonitoringToolHILooseCfg),
428 (flags.PhysVal.IDPVM.doValidateGSFTracks,
429 InDetPhysValMonitoringToolGSFCfg)
433 for enabled, creator
in mons:
435 tools.append(acc.popToolsAndMerge(creator(flags)))
437 for col
in flags.PhysVal.IDPVM.validateExtraTrackCollections:
440 flags, name=
'InDetPhysValMonitoringTool'+prefix,
441 SubFolder=prefix+
'Tracks/',
442 TrackParticleContainerName=prefix+
'TrackParticles'
445 from PhysValMonitoring.PhysValMonitoringConfig
import PhysValMonitoringCfg