38 """ Get the track-to-calo extension after a preselection
40 Returns the component accumulator, the preselected track collection and the extension cache
42 result = ComponentAccumulator()
43 pretracks_name = f
"HLTPFPreselTracks_{tracktype}"
44 cache_name = f
"HLTPFTrackExtensionCache_{tracktype}"
46 from InDetTrackSelectionTool.InDetTrackSelectionToolConfig
import (
47 PFTrackSelectionToolCfg)
48 result.addEventAlgo(CompFactory.PFTrackPreselAlg(
49 f
"HLTPFTrackPresel_{tracktype}",
51 OutputTracks=pretracks_name,
52 TrackSelTool=result.popToolsAndMerge(PFTrackSelectionToolCfg(flags))
57 monTool_trackExtrap.HistPath =
'TrackCaloExtrapolation_general'
59 from TrackToCalo.TrackToCaloConfig
import HLTPF_ParticleCaloExtensionToolCfg
60 result.addEventAlgo(CompFactory.Trk.PreselCaloExtensionBuilderAlg(
61 f
"HLTPFTrackExtension_{tracktype}",
62 ParticleCaloExtensionTool=result.popToolsAndMerge(
63 HLTPF_ParticleCaloExtensionToolCfg(flags, MonTool=monTool_trackExtrap)),
64 InputTracks=pretracks_name,
65 OutputCache=cache_name,
68 return result, pretracks_name, cache_name
71 """ Create the muon calo tagging configuration
73 Return the component accumulator and the tracks with muons removed
75 from TrkConfig.AtlasExtrapolatorConfig
import TrigPFlowExtrapolatorCfg
76 result = ComponentAccumulator()
77 extrapolator = result.popToolsAndMerge(TrigPFlowExtrapolatorCfg(flags))
78 output_tracks = f
"PFMuonCaloTagTracks_{tracktype}"
80 from TrackToCalo.TrackToCaloConfig
import (
81 HLTPF_ParticleCaloExtensionToolCfg,
82 HLTPF_ParticleCaloCellAssociationToolCfg)
84 caloext = result.popToolsAndMerge(HLTPF_ParticleCaloExtensionToolCfg(flags))
85 calocellassoc = result.popToolsAndMerge(HLTPF_ParticleCaloCellAssociationToolCfg(
87 ParticleCaloExtensionTool=caloext,
92 CompFactory.PFTrackMuonCaloTaggingAlg(
93 f
"PFTrackMuonCaloTaggingAlg_{tracktype}",
94 InputTracks = tracksin,
95 InputCaloExtension = extcache,
97 OutputTracks = output_tracks,
98 MinPt = flags.Trigger.FSHad.PFOMuonRemovalMinPt,
99 MuonScoreTool = CompFactory.CaloMuonScoreTool(
101 ParticleCaloCellAssociationTool = calocellassoc
103 LooseTagTool=CompFactory.CaloMuonTag(
"LooseCaloMuonTag", TagMode=
"Loose"),
104 TightTagTool=CompFactory.CaloMuonTag(
"TightCaloMuonTag", TagMode=
"Tight"),
105 DepositInCaloTool=CompFactory.TrackDepositInCaloTool(
106 ExtrapolatorHandle=extrapolator,
107 ParticleCaloCellAssociationTool = calocellassoc,
108 ParticleCaloExtensionTool = caloext
113 return result, output_tracks
115def MuonIsoTagCfg(flags, tracktype, tracksin, verticesin, extcache, clustersin):
116 """ Create the muon iso tagging configuration
118 Return the component accumulator and the tracks with muons removed
120 result = ComponentAccumulator()
121 output_tracks = f
"PFMuonIsoTagTracks_{tracktype}"
123 from TrackToCalo.TrackToCaloConfig
import HLTPF_ParticleCaloExtensionToolCfg
126 CompFactory.PFTrackMuonIsoTaggingAlg(
127 f
"PFTrackMuonIsoTaggingalg_{tracktype}",
128 InputTracks = tracksin,
129 InputClusters = clustersin,
130 InputVertices = verticesin,
131 OutputTracks = output_tracks,
132 MinPt = flags.Trigger.FSHad.PFOMuonRemovalMinPt,
133 TrackIsoTool = CompFactory.xAOD.TrackIsolationTool(
134 TrackParticleLocation=tracksin,
137 CaloIsoTool = CompFactory.xAOD.CaloIsolationTool(
138 ParticleCaloExtensionTool=result.popToolsAndMerge(
139 HLTPF_ParticleCaloExtensionToolCfg(flags)),
140 InputCaloExtension=extcache,
141 ParticleCaloCellAssociationTool=
"",
142 saveOnlyRequestedCorrections=
True,
147 return result, output_tracks
152 result = ComponentAccumulator()
154 muon_mode = inputFlags.Trigger.FSHad.PFOMuonRemoval
155 if muon_mode ==
"None":
160 inputFlags, tracktype, tracksin
162 result.merge(ext_acc)
163 if muon_mode ==
"Calo":
165 raise ValueError(
"Cells must be provided for the 'Calo' muon mode!")
167 inputFlags, tracktype, pretracks, extension_cache, cellsin
169 elif muon_mode ==
"Iso":
171 inputFlags, tracktype, pretracks, verticesin, extension_cache, clustersin
174 raise ValueError(f
"Invalid muon removal mode '{muon_mode}'")
175 result.merge(tag_acc)
177 from InDetTrackSelectionTool.InDetTrackSelectionToolConfig
import (
178 PFTrackSelectionToolCfg)
179 from TrackToCalo.TrackToCaloConfig
import HLTPF_ParticleCaloExtensionToolCfg
182 from eflowRec
import PFOnlineMon
184 monTool_extrapolator.HistPath =
'TrackExtrapolator'
187 CompFactory.PFTrackSelector(
188 f
"PFTrackSelector_{tracktype}",
189 trackExtrapolatorTool = CompFactory.eflowTrackCaloExtensionTool(
190 "HLTPF_eflowTrkCaloExt",
191 TrackCaloExtensionTool=result.popToolsAndMerge(
192 HLTPF_ParticleCaloExtensionToolCfg(inputFlags)),
193 PFParticleCache = extension_cache,
194 MonTool_TrackCaloExtension = monTool_extrapolator
196 trackSelectionTool = result.popToolsAndMerge(PFTrackSelectionToolCfg(inputFlags)),
200 VertexContainer=verticesin,
201 eflowRecTracksOutputName=f
"eflowRecTracks_{tracktype}",
220 PFCellLevelSubtractionToolFactory = CompFactory.PFSubtractionTool
221 PFCellLevelSubtractionTool = PFCellLevelSubtractionToolFactory(toolName,useNNEnergy = inputFlags.PF.useMLEOverP)
223 if inputFlags.GeoModel.Run <= LHCPeriod.Run3:
224 eflowCellEOverPTool_Run2_mc20_JetETMiss = CompFactory.eflowCellEOverPTool_Run2_mc20_JetETMiss
227 PFCellEOverPTool = CompFactory.PFCellEOverPTool
228 PFCellLevelSubtractionTool.eflowCellEOverPTool =
PFCellEOverPTool(
"PFCellEOverPTool", referenceFileLocation = inputFlags.PF.EOverP_CellOrdering_ReferenceLocation)
230 PFCellLevelSubtractionTool.useLegacyEBinIndex=
False
232 if(inputFlags.PF.EOverPMode):
233 PFCellLevelSubtractionTool.CalcEOverP =
True
234 PFCellLevelSubtractionTool.nClusterMatchesToUse = -1
236 PFCellLevelSubtractionTool.nClusterMatchesToUse = 1
238 if(inputFlags.PF.EOverPMode):
239 PFCellLevelSubtractionTool.PFTrackClusterMatchingTool = getPFTrackClusterMatchingTool(inputFlags,0.2,
"EtaPhiSquareDistance",
"PlainEtaPhi",
"CalObjBldMatchingTool")
241 PFCellLevelSubtractionTool.PFTrackClusterMatchingTool = getPFTrackClusterMatchingTool(inputFlags,1.64,
"EtaPhiSquareSignificance",
"GeomCenterEtaPhi",
"CalObjBldMatchingTool")
243 PFCellLevelSubtractionTool.PFTrackClusterMatchingTool_02 = getPFTrackClusterMatchingTool(inputFlags,0.2,
"EtaPhiSquareDistance",
"PlainEtaPhi",
"MatchingTool_Pull_02")
245 if inputFlags.PF.useMLEOverP:
246 PFEnergyPredictorTool = CompFactory.PFEnergyPredictorTool(
"PFCellLevelEnergyPredcictorTool",ModelPath = inputFlags.PF.EOverP_NN_Model)
247 PFCellLevelSubtractionTool.NNEnergyPredictorTool = PFEnergyPredictorTool
248 PFCellLevelSubtractionTool.addCPData = inputFlags.PF.addCPData
250 if inputFlags.PF.useTruthCheating:
251 if inputFlags.PF.useTrackClusterTruthMatching:
252 PFCellLevelSubtractionTool.CaloClusterReadDecorHandleKey_NLeadingTruthParticles =
"CaloTopoClusters." + inputFlags.Calo.TopoCluster.CalibrationHitDecorationName
253 PFCellLevelSubtractionTool.useTrackClusterTruthMatching=
True
255 if inputFlags.PF.useTruthForChargedShowerSubtraction:
256 PFCellLevelSubtractionTool.useTruthForChargedShowerSubtraction =
True
257 PFCellLevelSubtractionTool.PFSimulateTruthShowerTool = CompFactory.PFSimulateTruthShowerTool(
"PFSimulateTruthShowerTool")
259 return PFCellLevelSubtractionTool
263 PFRecoverSplitShowersToolFactory = CompFactory.PFSubtractionTool
264 PFRecoverSplitShowersTool = PFRecoverSplitShowersToolFactory(toolName,useNNEnergy = inputFlags.PF.useMLEOverP)
266 if inputFlags.GeoModel.Run <= LHCPeriod.Run3:
267 eflowCellEOverPTool_Run2_mc20_JetETMiss = CompFactory.eflowCellEOverPTool_Run2_mc20_JetETMiss
270 PFCellEOverPTool = CompFactory.PFCellEOverPTool
271 PFRecoverSplitShowersTool.eflowCellEOverPTool =
PFCellEOverPTool(
"PFCellEOverPTool_Recover", referenceFileLocation = inputFlags.PF.EOverP_CellOrdering_ReferenceLocation)
273 PFRecoverSplitShowersTool.useLegacyEBinIndex=
False
275 PFRecoverSplitShowersTool.RecoverSplitShowers =
True
277 if inputFlags.PF.useMLEOverP:
278 PFEnergyPredictorTool = CompFactory.PFEnergyPredictorTool(
"PFRecoverSplitShowersEnergyPredcictorTool",ModelPath = inputFlags.PF.EOverP_NN_Model)
279 PFRecoverSplitShowersTool.NNEnergyPredictorTool = PFEnergyPredictorTool
281 return PFRecoverSplitShowersTool
285 result = ComponentAccumulator()
287 if inputFlags.PF.useClusterMoments:
320 MomentsNames = [
"CENTER_MAG"]
322 if inputFlags.Trigger.Jet.PFlowUnifiedChain:
323 from eflowRec.PFCfg
import getPFUnifiedMomentCalculatorTool
324 PFMomentCalculatorTool = result.popToolsAndMerge(
325 getPFUnifiedMomentCalculatorTool(inputFlags, MomentsNames))
326 result.setPrivateTools(PFMomentCalculatorTool)
329 PFMomentCalculatorTool = CompFactory.PFMomentCalculatorTool(
"PFMomentCalculatorTool")
331 from CaloRec.CaloTopoClusterConfig
import getTopoMoments
332 PFClusterMomentsMaker = result.popToolsAndMerge(getTopoMoments(inputFlags))
333 PFClusterMomentsMaker.MomentsNames = MomentsNames
334 PFMomentCalculatorTool.CaloClusterMomentsMaker = PFClusterMomentsMaker
336 PFClusterCollectionTool = CompFactory.PFClusterCollectionTool
339 if(inputFlags.PF.useCalibHitTruthClusterMoments):
340 PFMomentCalculatorTool.UseCalibHitTruth=
True
341 from CaloRec.CaloTopoClusterConfig
import getTopoCalibMoments
342 PFMomentCalculatorTool.CaloCalibClusterMomentsMaker2 = getTopoCalibMoments(inputFlags)
344 result.setPrivateTools(PFMomentCalculatorTool)
347def PFCfg(inputFlags, tracktype="", clustersin=None, calclustersin=None, tracksin=None, verticesin=None, cellsin=None):
349 result=ComponentAccumulator()
350 seqname = f
'HLTPFlow_{tracktype}'
351 result.addSequence(parOR(seqname))
354 if clustersin
is None:
355 clustersin=inputFlags.eflowRec.RawClusterColl
356 if calclustersin
is None:
357 calclustersin=inputFlags.eflowRec.CalClusterColl
359 tracksin = inputFlags.eflowRec.TrackColl
360 if verticesin
is None:
361 verticesin = inputFlags.eflowRec.VertexColl
365 result.merge(calogeocfg)
368 PFTrackSelector = selcfg.getPrimary()
372 PFTrackSelector.MonTool = monTool
374 result.merge( selcfg, seqname )
380 from eflowRec.PFCfg
import getPFClusterSelectorTool
382 PFTrackClusterMatchingTool_1 = CompFactory.PFTrackClusterMatchingTool(
"CalObjBldMatchingTool")
384 monTool_matching.HistPath =
'PFTrackClusterMatchingTool_1'
385 PFTrackClusterMatchingTool_1.MonTool_ClusterMatching = monTool_matching
389 if inputFlags.Trigger.Jet.PFlowUnifiedChain:
390 from eflowRec.PFCfg
import (getPFUnifiedCellLevelMatchingTool,
391 getPFUnifiedCellLevelSubtractionOnlyTool,
392 getPFUnifiedRecoverSplitShowersMatchingTool,
393 getPFUnifiedRecoverSplitShowersSubtractionOnlyTool)
395 cellMatchingTool = getPFUnifiedCellLevelMatchingTool(
397 "PFUnifiedCellLevelMatchingTool",
399 cellMatchingTool.PFTrackClusterMatchingTool = PFTrackClusterMatchingTool_1
401 recoverSplitShowersMatchingTool = getPFUnifiedRecoverSplitShowersMatchingTool(
403 "PFUnifiedRecoverSplitShowersMatchingTool",
405 recoverSplitShowersMatchingTool.PFTrackClusterMatchingTool = PFTrackClusterMatchingTool_1
412 getPFUnifiedCellLevelSubtractionOnlyTool(inputFlags,
"PFUnifiedCellLevelSubtractionOnlyTool"),
413 recoverSplitShowersMatchingTool,
414 getPFUnifiedRecoverSplitShowersSubtractionOnlyTool(inputFlags,
"PFUnifiedRecoverSplitShowersSubtractionOnlyTool"),
421 "PFCellLevelSubtractionTool",
423 cellSubtractionTool.PFTrackClusterMatchingTool=PFTrackClusterMatchingTool_1
427 "PFRecoverSplitShowersTool",
429 recoverSplitShowersTool.PFTrackClusterMatchingTool = PFTrackClusterMatchingTool_1
432 SubtractionToolList = [
434 recoverSplitShowersTool,
442 CompFactory.PFAlgorithm(
443 f
"PFAlgorithm_{tracktype}",
444 PFClusterSelectorTool = getPFClusterSelectorTool(
448 "PFClusterSelectorTool",
451 eflowRecTracksInputName = PFTrackSelector.eflowRecTracksOutputName,
452 eflowRecClustersOutputName = f
"eflowRecClusters_{tracktype}",
453 PFCaloClustersOutputName = f
"PFCaloCluster_{tracktype}",
454 eflowCaloObjectsOutputName = f
"eflowCaloObjects_{tracktype}",
463 chargedPFOArgs = dict(
464 inputFlags=inputFlags,
465 nameSuffix=f
"_{tracktype}",
466 chargedFlowElementOutputName=recordable(f
"HLT_{tracktype}ChargedParticleFlowObjects"),
467 eflowCaloObjectContainerName=f
"eflowCaloObjects_{tracktype}"
469 neutralPFOArgs = dict(
470 inputFlags=inputFlags,
471 nameSuffix=f
"_{tracktype}",
472 neutralFlowElementOutputName=recordable(f
"HLT_{tracktype}NeutralParticleFlowObjects"),
473 eflowCaloObjectContainerName=f
"eflowCaloObjects_{tracktype}"
475 from eflowRec.PFCfg
import getChargedFlowElementCreatorAlgorithm,getNeutralFlowElementCreatorAlgorithm
476 result.addEventAlgo(getNeutralFlowElementCreatorAlgorithm(**neutralPFOArgs), seqname)
477 result.addEventAlgo(getChargedFlowElementCreatorAlgorithm(**chargedPFOArgs), seqname)