5 '''@file InDetTrackPerfMonConfig.py
8 @brief Main CA-based python configuration for InDetTrackPerfMonTool
11 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory
import CompFactory
13 from AthenaCommon.Logging
import logging
18 Tool to read the plots definitions from an input file in JSON format
20 log = logging.getLogger(
"JsonPlotsDefReadTool" )
24 from InDetTrackPerfMon.ConfigUtils
import getPlotsDefList
26 log.debug(
"Loading the following plot definitions:" )
27 for plotDef
in plotsDefList : log.debug(
"\t-> %s", plotDef )
29 kwargs.setdefault(
"PlotsDefs", plotsDefList )
32 CompFactory.IDTPM.JsonPlotsDefReadTool( name, **kwargs ) )
38 CA-based configuration for the Tool to read the plots definition
40 log = logging.getLogger(
"PlotsDefReadTool" )
42 if flags.PhysVal.IDTPM.plotsDefFormat ==
"JSON" :
44 flags, name =
"JsonPlotsDefReadTool" +
45 flags.PhysVal.IDTPM.currentTrkAna.anaTag, **kwargs )
47 log.error(
"Non supported plots definition file type %s",
48 flags.PhysVal.IDTPM.plotsDefFormat )
54 CA-based configuration for the PlotsDefinition Service
58 if "PlotsDefReadTool" not in kwargs:
59 kwargs.setdefault(
"PlotsDefReadTool", acc.popToolsAndMerge(
63 CompFactory.PlotsDefinitionSvc( name, **kwargs ) )
69 Tool to write TrackAnalysisInfo to StoreGate
73 kwargs.setdefault(
"AnaTag", flags.PhysVal.IDTPM.currentTrkAna.anaTag )
75 acc.setPrivateTools( CompFactory.IDTPM.TrackAnalysisInfoWriteTool( name, **kwargs ) )
81 CA-based configuration for the TrackAnalysisDefinition Service
85 kwargs.setdefault(
"DirName", flags.PhysVal.IDTPM.DirName )
86 kwargs.setdefault(
"sortPlotsByChain", flags.PhysVal.IDTPM.sortPlotsByChain )
87 kwargs.setdefault(
"SubFolder", flags.PhysVal.IDTPM.currentTrkAna.SubFolder )
88 kwargs.setdefault(
"TrkAnaTag", flags.PhysVal.IDTPM.currentTrkAna.anaTag )
90 kwargs.setdefault(
"TestType", flags.PhysVal.IDTPM.currentTrkAna.TestType )
91 kwargs.setdefault(
"RefType", flags.PhysVal.IDTPM.currentTrkAna.RefType )
93 kwargs.setdefault(
"pileupSwitch", flags.PhysVal.IDTPM.currentTrkAna.pileupSwitch )
94 kwargs.setdefault(
"hasFullPileupTruth",
95 (
"xAOD::TruthPileupEventContainer#TruthPileupEvents" in flags.Input.TypedCollections ) )
97 from InDetTrackPerfMon.ConfigUtils
import getTag
98 kwargs.setdefault(
"TestTag",
getTag( flags, flags.PhysVal.IDTPM.currentTrkAna.TestType ) )
99 kwargs.setdefault(
"RefTag",
getTag( flags, flags.PhysVal.IDTPM.currentTrkAna.RefType ) )
101 kwargs.setdefault(
"MatchingType", flags.PhysVal.IDTPM.currentTrkAna.MatchingType )
102 kwargs.setdefault(
"MatchingTruthProb", flags.PhysVal.IDTPM.currentTrkAna.truthProbCut )
104 if ( (
"Trigger" in flags.PhysVal.IDTPM.currentTrkAna.TestType
and "EFTrigger" not in flags.PhysVal.IDTPM.currentTrkAna.TestType)
or
105 (
"Trigger" in flags.PhysVal.IDTPM.currentTrkAna.RefType
and "EFTrigger" not in flags.PhysVal.IDTPM.currentTrkAna.RefType ) ):
106 kwargs.setdefault(
"ChainNames", flags.PhysVal.IDTPM.currentTrkAna.ChainNames )
108 kwargs.setdefault(
"plotTrackParameters", flags.PhysVal.IDTPM.currentTrkAna.plotTrackParameters )
109 kwargs.setdefault(
"plotTrackMultiplicities", flags.PhysVal.IDTPM.currentTrkAna.plotTrackMultiplicities )
110 kwargs.setdefault(
"plotEfficiencies", flags.PhysVal.IDTPM.currentTrkAna.plotEfficiencies )
111 kwargs.setdefault(
"plotTechnicalEfficiencies", flags.PhysVal.IDTPM.currentTrkAna.plotTechnicalEfficiencies )
112 kwargs.setdefault(
"plotResolutions", flags.PhysVal.IDTPM.currentTrkAna.plotResolutions )
113 kwargs.setdefault(
"plotFakeRates", flags.PhysVal.IDTPM.currentTrkAna.plotFakeRates )
114 kwargs.setdefault(
"unlinkedAsFakes", flags.PhysVal.IDTPM.currentTrkAna.unlinkedAsFakes )
115 kwargs.setdefault(
"plotDuplicateRates", flags.PhysVal.IDTPM.currentTrkAna.plotDuplicateRates )
116 kwargs.setdefault(
"plotHitsOnTracks", flags.PhysVal.IDTPM.currentTrkAna.plotHitsOnTracks )
117 kwargs.setdefault(
"plotHitsOnTracksReference", flags.PhysVal.IDTPM.currentTrkAna.plotHitsOnTracksReference )
118 kwargs.setdefault(
"plotHitsOnMatchedTracks", flags.PhysVal.IDTPM.currentTrkAna.plotHitsOnMatchedTracks )
119 kwargs.setdefault(
"plotHitsOnFakeTracks", flags.PhysVal.IDTPM.currentTrkAna.plotHitsOnFakeTracks )
120 kwargs.setdefault(
"plotVertexParameters", flags.PhysVal.IDTPM.currentTrkAna.plotVertexParameters )
121 kwargs.setdefault(
"useSelectedVertexTracks", flags.PhysVal.IDTPM.currentTrkAna.useSelectedVertexTracks )
122 kwargs.setdefault(
"plotOfflineElectrons", flags.PhysVal.IDTPM.currentTrkAna.plotOfflineElectrons )
123 kwargs.setdefault(
"ResolutionMethod", flags.PhysVal.IDTPM.currentTrkAna.ResolutionMethod )
124 kwargs.setdefault(
"isITk", flags.Detector.GeometryITk )
126 kwargs.setdefault(
"EtaBins", flags.Tracking.ITkMainPass.etaBins
if flags.Detector.GeometryITk
else [-1, 9999.])
127 kwargs.setdefault(
"MinSilHits", flags.Tracking.ITkMainPass.minClusters
if flags.Detector.GeometryITk
else [flags.Tracking.MainPass.minClusters])
129 trkAnaSvc = CompFactory.TrackAnalysisDefinitionSvc( name, **kwargs )
130 acc.addService( trkAnaSvc )
136 Main IDTPM tool instance CA-based configuration
140 kwargs.setdefault(
"OfflineTrkParticleContainerName",
141 flags.PhysVal.IDTPM.currentTrkAna.OfflineTrkKey )
142 kwargs.setdefault(
"TruthParticleContainerName",
143 flags.PhysVal.IDTPM.currentTrkAna.TruthPartKey )
145 kwargs.setdefault(
"OfflineVertexContainerName",
146 flags.PhysVal.IDTPM.currentTrkAna.OfflineVtxKey )
147 kwargs.setdefault(
"TruthVertexContainerName",
148 flags.PhysVal.IDTPM.currentTrkAna.TruthVtxKey )
150 kwargs.setdefault(
"AnaTag", flags.PhysVal.IDTPM.currentTrkAna.anaTag )
152 if flags.Output.doWriteAOD_IDTPM :
153 kwargs.setdefault(
"writeOut",
True )
154 kwargs.setdefault(
"TrkAnaInfoKey",
155 "TrkAnaInfo"+flags.PhysVal.IDTPM.currentTrkAna.anaTag )
157 if "TrackAnalysisInfoWriteTool" not in kwargs :
158 kwargs.setdefault(
"TrackAnalysisInfoWriteTool", acc.popToolsAndMerge(
160 name=
"TrackAnalysisInfoWriteTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
164 name=
"TrkAnaDefSvc"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) )
168 name=
"PlotsDefSvc"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) )
172 if ( (
"Truth" in flags.PhysVal.IDTPM.currentTrkAna.RefType )
or
173 (
"Truth" in flags.PhysVal.IDTPM.currentTrkAna.TestType ) ):
174 from InDetTrackPerfMon.InDetAlgorithmConfig
import TruthHitDecoratorAlgCfg, TruthDecoratorAlgCfg
179 if ( ( flags.PhysVal.IDTPM.currentTrkAna.SelectOfflineObject )
and
180 (
"Truth" not in flags.PhysVal.IDTPM.currentTrkAna.SelectOfflineObject ) ):
181 from InDetTrackPerfMon.InDetAlgorithmConfig
import OfflineObjectDecoratorAlgCfg
185 if "TrackQualitySelectionTool" not in kwargs:
186 from InDetTrackPerfMon.InDetSelectionConfig
import TrackQualitySelectionToolCfg
187 kwargs.setdefault(
"TrackQualitySelectionTool", acc.popToolsAndMerge(
189 name=
"TrackQualitySelectionTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
191 if "VertexQualitySelectionTool" not in kwargs:
192 from InDetTrackPerfMon.InDetSelectionConfig
import VertexQualitySelectionToolCfg
193 kwargs.setdefault(
"VertexQualitySelectionTool", acc.popToolsAndMerge(
195 name=
"VertexQualitySelectionTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
197 if ( (
"Trigger" in flags.PhysVal.IDTPM.currentTrkAna.TestType )
or
198 (
"Trigger" in flags.PhysVal.IDTPM.currentTrkAna.RefType ) ):
200 kwargs.setdefault(
"TriggerTrkParticleContainerName",
201 flags.PhysVal.IDTPM.currentTrkAna.TrigTrkKey )
203 kwargs.setdefault(
"TriggerVertexContainerName",
204 flags.PhysVal.IDTPM.currentTrkAna.TrigVtxKey )
206 if (
"EFTrigger" not in flags.PhysVal.IDTPM.currentTrkAna.TestType
and
207 "EFTrigger" not in flags.PhysVal.IDTPM.currentTrkAna.RefType ):
209 if "TrigDecisionTool" not in kwargs:
210 from TrigDecisionTool.TrigDecisionToolConfig
import TrigDecisionToolCfg
211 kwargs.setdefault(
"TrigDecisionTool",
214 if "RoiSelectionTool" not in kwargs:
215 from InDetTrackPerfMon.InDetSelectionConfig
import RoiSelectionToolCfg
216 kwargs.setdefault(
"RoiSelectionTool", acc.popToolsAndMerge(
218 name=
"RoiSelectionTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
220 if "TrackRoiSelectionTool" not in kwargs:
221 from InDetTrackPerfMon.InDetSelectionConfig
import TrackRoiSelectionToolCfg
222 kwargs.setdefault(
"TrackRoiSelectionTool", acc.popToolsAndMerge(
224 name=
"TrackRoiSelectionTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
226 if "VertexRoiSelectionTool" not in kwargs:
227 from InDetTrackPerfMon.InDetSelectionConfig
import VertexRoiSelectionToolCfg
228 kwargs.setdefault(
"VertexRoiSelectionTool", acc.popToolsAndMerge(
230 name=
"VertexRoiSelectionTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
232 if "TrackMatchingTool" not in kwargs:
233 from InDetTrackPerfMon.InDetMatchingConfig
import TrackMatchingToolCfg
235 if matchToolCfg
is not None :
236 kwargs.setdefault(
"doMatch",
True )
237 kwargs.setdefault(
"TrackMatchingTool", acc.popToolsAndMerge( matchToolCfg ) )
239 acc.setPrivateTools( CompFactory.InDetTrackPerfMonTool( name, **kwargs ) )
245 CA-based configuration of all tool instances (= TrackAnalyses)
247 log = logging.getLogger(
"InDetTrackPerfMonCfg" )
253 for trkAnaName
in flags.PhysVal.IDTPM.trkAnaNames :
255 flags_thisTrkAna = flags.cloneAndReplace(
"PhysVal.IDTPM.currentTrkAna",
256 "PhysVal.IDTPM."+trkAnaName )
258 if flags_thisTrkAna.PhysVal.IDTPM.currentTrkAna.enabled:
259 log.debug(
"Scheduling TrackAnalysis: %s",
260 flags_thisTrkAna.PhysVal.IDTPM.currentTrkAna.anaTag )
264 name=
"InDetTrackPerfMonTool"+
265 flags_thisTrkAna.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
267 from PhysValMonitoring.PhysValMonitoringConfig
import PhysValMonitoringCfg
271 if flags.Output.doWriteAOD_IDTPM :
272 from InDetTrackPerfMon.InDetOutputConfig
import InDetOutputCfg