ATLAS Offline Software
Loading...
Searching...
No Matches
PFCfg.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2from AthenaConfiguration.ComponentFactory import CompFactory
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.Enums import LHCPeriod
5
6def PFTrackSelectorAlgCfg(inputFlags,algName,useCaching=True):
7 PFTrackSelectorFactory=CompFactory.PFTrackSelector
8 PFTrackSelector=PFTrackSelectorFactory(algName)
9
10 result = ComponentAccumulator()
11
12 if inputFlags.PF.useActsExtrapolation:
13 #do something
14 from ActsConfig.ActsGeometryConfig import ActsExtrapolationToolCfg
15 ActsExtrapolationTool = result.popToolsAndMerge(ActsExtrapolationToolCfg(inputFlags,MaxSteps=10000))
16 PFTrackCaloExtensionTool=CompFactory.PFTrackCaloExtensionTool
17 TrackCaloExtensionTool=PFTrackCaloExtensionTool("PFTrackCaloExtensionTool_ACTS",ExtrapolationTool=ActsExtrapolationTool)
18 PFTrackSelector.trackExtrapolatorTool = TrackCaloExtensionTool
19 else:
20
21 from TrackToCalo.TrackToCaloConfig import ParticleCaloExtensionToolCfg
22 pcExtensionTool = result.popToolsAndMerge(ParticleCaloExtensionToolCfg(inputFlags))
23
24 eflowTrackCaloExtensionTool=CompFactory.eflowTrackCaloExtensionTool
25 TrackCaloExtensionTool=eflowTrackCaloExtensionTool(TrackCaloExtensionTool=pcExtensionTool)
26 if (not useCaching):
27 TrackCaloExtensionTool.PFParticleCache = ""
28
29 PFTrackSelector.trackExtrapolatorTool = TrackCaloExtensionTool
30
31 from InDetTrackSelectionTool.InDetTrackSelectionToolConfig import (
32 PFTrackSelectionToolCfg)
33 PFTrackSelector.trackSelectionTool = result.popToolsAndMerge(PFTrackSelectionToolCfg(inputFlags))
34
35 # P->T conversion extra dependencies
36 if inputFlags.Detector.GeometryITk:
37 PFTrackSelector.ExtraInputs = {
38 ("InDetDD::SiDetectorElementCollection", "ConditionStore+ITkPixelDetectorElementCollection"),
39 ("InDetDD::SiDetectorElementCollection", "ConditionStore+ITkStripDetectorElementCollection"),
40 }
41 else:
42 PFTrackSelector.ExtraInputs = {
43 ("InDetDD::SiDetectorElementCollection", "ConditionStore+PixelDetectorElementCollection"),
44 ("InDetDD::SiDetectorElementCollection", "ConditionStore+SCT_DetectorElementCollection"),
45 ("InDetDD::TRT_DetElementContainer", "ConditionStore+TRT_DetElementContainer"),
46 }
47
48 result.addEventAlgo (PFTrackSelector, primary=True)
49
50 return result
51
52def getPFClusterSelectorTool(inputFlags,clustersin,calclustersin,algName):
53
54 PFClusterSelectorToolFactory = CompFactory.PFClusterSelectorTool
55 PFClusterSelectorTool = PFClusterSelectorToolFactory(algName)
56 if clustersin is not None:
57 PFClusterSelectorTool.clustersName = clustersin
58 if calclustersin is not None:
59 PFClusterSelectorTool.calClustersName = calclustersin
60
61 if inputFlags.PF.useTruthCheating:
62 if inputFlags.PF.useTrackClusterTruthMatching:
63 PFClusterSelectorTool.CaloClusterReadDecorHandleKey_NLeadingTruthParticles = "CaloTopoClusters." + inputFlags.Calo.TopoCluster.CalibrationHitDecorationName
64
65 if inputFlags.PF.useTopoTowers:
66 PFClusterSelectorTool.clustersName="CaloTopoSignal"
67 PFClusterSelectorTool.calClustersName="CaloCalTopoSignal"
68
69 return PFClusterSelectorTool
70
71def getPFTrackClusterMatchingTool(inputFlags,matchCut,distanceType,clusterPositionType,name):
72 PFTrackClusterMatchingTool = CompFactory.PFTrackClusterMatchingTool
73 MatchingTool = PFTrackClusterMatchingTool(name)
74 MatchingTool.ClusterPositionType = clusterPositionType
75 MatchingTool.DistanceType = distanceType
76 MatchingTool.MatchCut = matchCut*matchCut
77 return MatchingTool
78
79
80def getPFUnifiedCellLevelMatchingTool(inputFlags,toolName):
81 if inputFlags.PF.useTruthCheating and inputFlags.PF.useTrackClusterTruthMatching:
82 PFUnifiedCellLevelMatchingToolFactory = CompFactory.PFUnifiedMatchingTruthTool
83 PFUnifiedCellLevelMatchingTool = PFUnifiedCellLevelMatchingToolFactory(toolName+"_truthCheating")
84 PFUnifiedCellLevelMatchingTool.CaloClusterReadDecorHandleKey_NLeadingTruthParticles = "CaloTopoClusters." + inputFlags.Calo.TopoCluster.CalibrationHitDecorationName
85 else:
86 PFUnifiedCellLevelMatchingToolFactory = CompFactory.PFUnifiedMatchingTool
87 PFUnifiedCellLevelMatchingTool = PFUnifiedCellLevelMatchingToolFactory(toolName)
88
89 if inputFlags.GeoModel.Run <= LHCPeriod.Run3:
90 eflowCellEOverPTool_Run2_mc20_JetETMiss = CompFactory.eflowCellEOverPTool_Run2_mc20_JetETMiss
91 PFUnifiedCellLevelMatchingTool.eflowCellEOverPTool = eflowCellEOverPTool_Run2_mc20_JetETMiss()
92 else:
93 PFCellEOverPTool = CompFactory.PFCellEOverPTool
94 PFUnifiedCellLevelMatchingTool.eflowCellEOverPTool = PFCellEOverPTool("PFCellEOverPTool", referenceFileLocation = inputFlags.PF.EOverP_CellOrdering_ReferenceLocation)
95 #this should always be false for any reference derived, except eflowCellEOverPTool_mc12_HLLHC.h or eflowCellEOverPTool_Run2_mc20_JetETMiss.h
96 PFUnifiedCellLevelMatchingTool.useLegacyEBinIndex=False
97
98 if(inputFlags.PF.EOverPMode):
99 PFUnifiedCellLevelMatchingTool.nClusterMatchesToUse = -1
100 PFUnifiedCellLevelMatchingTool.PFTrackClusterMatchingTool = getPFTrackClusterMatchingTool(inputFlags,0.2,"EtaPhiSquareDistance","PlainEtaPhi","CalObjBldMatchingTool")
101 else:
102 PFUnifiedCellLevelMatchingTool.nClusterMatchesToUse = 1
103 PFUnifiedCellLevelMatchingTool.PFTrackClusterMatchingTool = getPFTrackClusterMatchingTool(inputFlags,1.64,"EtaPhiSquareSignificance","GeomCenterEtaPhi","CalObjBldMatchingTool")
104
105 PFUnifiedCellLevelMatchingTool.PFTrackClusterMatchingTool_02 = getPFTrackClusterMatchingTool(inputFlags,0.2,"EtaPhiSquareDistance","PlainEtaPhi","MatchingTool_Pull_02")
106
107 PFUnifiedCellLevelMatchingTool.addCPData = inputFlags.PF.addCPData
108
109 return PFUnifiedCellLevelMatchingTool
110
111
113 if inputFlags.PF.useTruthCheating and inputFlags.PF.useTruthForChargedShowerSubtraction:
114 PFUnifiedCellLevelSubtractionOnlyToolFactory = CompFactory.PFUnifiedSubtractionOnlyTruthTool
115 PFUnifiedCellLevelSubtractionOnlyTool = PFUnifiedCellLevelSubtractionOnlyToolFactory(toolName+"_truthCheating", useNNEnergy = inputFlags.PF.useMLEOverP)
116 PFUnifiedCellLevelSubtractionOnlyTool.PFSimulateTruthShowerTool = CompFactory.PFSimulateTruthShowerTool("PFSimulateTruthShowerTool")
117 else:
118 PFUnifiedCellLevelSubtractionOnlyToolFactory = CompFactory.PFUnifiedSubtractionOnlyTool
119 PFUnifiedCellLevelSubtractionOnlyTool = PFUnifiedCellLevelSubtractionOnlyToolFactory(toolName, useNNEnergy = inputFlags.PF.useMLEOverP)
120
121 if inputFlags.GeoModel.Run <= LHCPeriod.Run3:
122 eflowCellEOverPTool_Run2_mc20_JetETMiss = CompFactory.eflowCellEOverPTool_Run2_mc20_JetETMiss
123 PFUnifiedCellLevelSubtractionOnlyTool.eflowCellEOverPTool = eflowCellEOverPTool_Run2_mc20_JetETMiss()
124 else:
125 PFCellEOverPTool = CompFactory.PFCellEOverPTool
126 PFUnifiedCellLevelSubtractionOnlyTool.eflowCellEOverPTool = PFCellEOverPTool("PFCellEOverPTool", referenceFileLocation = inputFlags.PF.EOverP_CellOrdering_ReferenceLocation)
127 #this should always be false for any reference derived, except eflowCellEOverPTool_mc12_HLLHC.h or eflowCellEOverPTool_Run2_mc20_JetETMiss.h
128 PFUnifiedCellLevelSubtractionOnlyTool.useLegacyEBinIndex=False
129
130 if(inputFlags.PF.EOverPMode):
131 PFUnifiedCellLevelSubtractionOnlyTool.CalcEOverP = True
132
133 PFUnifiedCellLevelSubtractionOnlyTool.addCPData = inputFlags.PF.addCPData
134
135 if inputFlags.PF.useMLEOverP:
136 PFEnergyPredictorTool = CompFactory.PFEnergyPredictorTool("PFCellLevelEnergyPredcictorTool",ModelPath = inputFlags.PF.EOverP_NN_Model)
137 PFUnifiedCellLevelSubtractionOnlyTool.NNEnergyPredictorTool = PFEnergyPredictorTool
138
139
140 return PFUnifiedCellLevelSubtractionOnlyTool
141
142
143
144
146 # RecoverSplitShowers is gated off when useTruthCheating is set (see getOfflinePFAlgorithm),
147 # so the truth-matching variant of this factory is unreachable by construction.
148 PFUnifiedRecoverSplitShowersMatchingToolFactory = CompFactory.PFUnifiedMatchingTool
149 PFUnifiedRecoverSplitShowersMatchingTool = PFUnifiedRecoverSplitShowersMatchingToolFactory(toolName)
150
151 if inputFlags.GeoModel.Run <= LHCPeriod.Run3:
152 eflowCellEOverPTool_Run2_mc20_JetETMiss = CompFactory.eflowCellEOverPTool_Run2_mc20_JetETMiss
153 PFUnifiedRecoverSplitShowersMatchingTool.eflowCellEOverPTool = eflowCellEOverPTool_Run2_mc20_JetETMiss("eflowCellEOverPTool_Run2_mc20_JetETMiss_Recover")
154 else:
155 PFCellEOverPTool = CompFactory.PFCellEOverPTool
156 PFUnifiedRecoverSplitShowersMatchingTool.eflowCellEOverPTool = PFCellEOverPTool("PFCellEOverPTool_Recover", referenceFileLocation = inputFlags.PF.EOverP_CellOrdering_ReferenceLocation)
157 #this should always be false for any reference derived, except eflowCellEOverPTool_mc12_HLLHC.h or eflowCellEOverPTool_Run2_mc20_JetETMiss.h
158 PFUnifiedRecoverSplitShowersMatchingTool.useLegacyEBinIndex=False
159
160 PFUnifiedRecoverSplitShowersMatchingTool.RecoverSplitShowers = True
161
162 return PFUnifiedRecoverSplitShowersMatchingTool
163
164
165
167 # RecoverSplitShowers is gated off when useTruthCheating is set (see getOfflinePFAlgorithm),
168 # so the truth-cheating variant of this factory is unreachable by construction.
169 PFUnifiedRecoverSplitShowersSubtractionOnlyToolFactory = CompFactory.PFUnifiedSubtractionOnlyTool
170 PFUnifiedRecoverSplitShowersSubtractionOnlyTool = PFUnifiedRecoverSplitShowersSubtractionOnlyToolFactory(toolName, useNNEnergy = inputFlags.PF.useMLEOverP)
171
172 if inputFlags.GeoModel.Run <= LHCPeriod.Run3:
173 eflowCellEOverPTool_Run2_mc20_JetETMiss = CompFactory.eflowCellEOverPTool_Run2_mc20_JetETMiss
174 PFUnifiedRecoverSplitShowersSubtractionOnlyTool.eflowCellEOverPTool = eflowCellEOverPTool_Run2_mc20_JetETMiss("eflowCellEOverPTool_Run2_mc20_JetETMiss_Recover")
175 else:
176 PFCellEOverPTool = CompFactory.PFCellEOverPTool
177 PFUnifiedRecoverSplitShowersSubtractionOnlyTool.eflowCellEOverPTool = PFCellEOverPTool("PFCellEOverPTool_Recover", referenceFileLocation = inputFlags.PF.EOverP_CellOrdering_ReferenceLocation)
178 #this should always be false for any reference derived, except eflowCellEOverPTool_mc12_HLLHC.h or eflowCellEOverPTool_Run2_mc20_JetETMiss.h
179 PFUnifiedRecoverSplitShowersSubtractionOnlyTool.useLegacyEBinIndex=False
180
181 PFUnifiedRecoverSplitShowersSubtractionOnlyTool.RecoverSplitShowers = True
182
183 if inputFlags.PF.useMLEOverP:
184 PFEnergyPredictorTool = CompFactory.PFEnergyPredictorTool("PFRecoverSplitShowersEnergyPredcictorTool",ModelPath = inputFlags.PF.EOverP_NN_Model)
185 PFUnifiedRecoverSplitShowersSubtractionOnlyTool.NNEnergyPredictorTool = PFEnergyPredictorTool
186
187 return PFUnifiedRecoverSplitShowersSubtractionOnlyTool
188
189
190
192 result=ComponentAccumulator()
193 PFMomentCalculatorToolFactory = CompFactory.PFUnifiedMomentCalculatorTool
194
195 PFMomentCalculatorTool = PFMomentCalculatorToolFactory("PFMomentCalculatorTool")
196
197 from CaloRec.CaloTopoClusterConfig import getTopoMoments
198 PFClusterMomentsMaker = result.popToolsAndMerge(getTopoMoments(inputFlags))
199 PFMomentCalculatorTool.CaloClusterMomentsMaker = PFClusterMomentsMaker
200
201 PFClusterCollectionTool = CompFactory.PFClusterCollectionTool
202 PFMomentCalculatorTool.PFClusterCollectionTool = PFClusterCollectionTool("PFClusterCollectionTool")
203
204 if(inputFlags.PF.useCalibHitTruthClusterMoments):
205 PFMomentCalculatorTool.UseCalibHitTruth=True
206 from CaloRec.CaloTopoClusterConfig import getTopoCalibMoments
207 PFMomentCalculatorTool.CaloCalibClusterMomentsMaker2 = getTopoCalibMoments(inputFlags)
208
209 result.setPrivateTools(PFMomentCalculatorTool)
210 return result
211
213
214 PFLCCalibTool = CompFactory.PFUnifiedLCCalibTool("PFLCCalibTool")
215
216 PFClusterCollectionTool = CompFactory.PFClusterCollectionTool
217 PFLCCalibTool.eflowRecClusterCollectionTool = PFClusterCollectionTool("PFClusterCollectionTool_LCCalib")
218 PFLCCalibTool.UseLocalWeight = False
219
220 from CaloRec.CaloTopoClusterConfig import getTopoClusterLocalCalibTools
221 lcCalibToolList = getTopoClusterLocalCalibTools(inputFlags)
222
223 PFLCCalibTool.CaloClusterLocalCalib=lcCalibToolList[0]
224 PFLCCalibTool.CaloClusterLocalCalibOOCC=lcCalibToolList[1]
225 PFLCCalibTool.CaloClusterLocalCalibOOCCPi0=lcCalibToolList[2]
226 PFLCCalibTool.CaloClusterLocalCalibDM=lcCalibToolList[3]
227
228 return PFLCCalibTool
229
230def getChargedFlowElementCreatorAlgorithm(inputFlags,chargedFlowElementOutputName,nameSuffix="",eflowCaloObjectContainerName="eflowCaloObjects"):
231 FlowElementChargedCreatorAlgorithmFactory = CompFactory.PFChargedFlowElementCreatorAlgorithm
232 FlowElementChargedCreatorAlgorithm = FlowElementChargedCreatorAlgorithmFactory("PFChargedFlowElementCreatorAlgorithm"+nameSuffix)
233 FlowElementChargedCreatorAlgorithm.eflowCaloObjectContainerName = eflowCaloObjectContainerName
234 if chargedFlowElementOutputName:
235 FlowElementChargedCreatorAlgorithm.FlowElementOutputName=chargedFlowElementOutputName
236 if(inputFlags.PF.EOverPMode):
237 FlowElementChargedCreatorAlgorithm.FlowElementOutputName="EOverPChargedParticleFlowObjects"
238 FlowElementChargedCreatorAlgorithm.EOverPMode = True
239 if inputFlags.PF.addCPData:
240 FlowElementChargedCreatorAlgorithm.addCPData = True
241
242 return FlowElementChargedCreatorAlgorithm
243
244def getNeutralFlowElementCreatorAlgorithm(inputFlags,neutralFlowElementOutputName,nameSuffix="",eflowCaloObjectContainerName="eflowCaloObjects"):
245 FlowElementNeutralCreatorAlgorithmFactory = CompFactory.PFNeutralFlowElementCreatorAlgorithm
246 FlowElementNeutralCreatorAlgorithm = FlowElementNeutralCreatorAlgorithmFactory("PFNeutralFlowElementCreatorAlgorithm"+nameSuffix)
247 FlowElementNeutralCreatorAlgorithm.eflowCaloObjectContainerName = eflowCaloObjectContainerName
248 if neutralFlowElementOutputName:
249 FlowElementNeutralCreatorAlgorithm.FlowElementOutputName=neutralFlowElementOutputName
250 if(inputFlags.PF.EOverPMode):
251 FlowElementNeutralCreatorAlgorithm.FlowElementOutputName="EOverPNeutralParticleFlowObjects"
252 if(inputFlags.PF.useCalibHitTruthClusterMoments and inputFlags.PF.addClusterMoments):
253 FlowElementNeutralCreatorAlgorithm.UseCalibHitTruth=True
254 if inputFlags.PF.addCPData:
255 FlowElementNeutralCreatorAlgorithm.addCPData = True
256
257 return FlowElementNeutralCreatorAlgorithm
258
259def getLCNeutralFlowElementCreatorAlgorithm(inputFlags,neutralFlowElementOutputName):
260 LCFlowElementNeutralCreatorAlgorithmFactory = CompFactory.PFLCNeutralFlowElementCreatorAlgorithm
261 LCFlowElementNeutralCreatorAlgorithm = LCFlowElementNeutralCreatorAlgorithmFactory("PFLCNeutralFlowElementCreatorAlgorithm")
262 if neutralFlowElementOutputName:
263 LCFlowElementNeutralCreatorAlgorithm.FELCOutputName=neutralFlowElementOutputName
264 if(inputFlags.PF.EOverPMode):
265 LCFlowElementNeutralCreatorAlgorithm.FEInputContainerName="EOverPNeutralParticleFlowObjects"
266 LCFlowElementNeutralCreatorAlgorithm.FELCOutputName="EOverPLCNeutralParticleFlowObjects"
267
268 return LCFlowElementNeutralCreatorAlgorithm
269
270# Factory function to create the ML-based neutral flow element creator algorithm
271def getPFOClusterMLCorrectionAlgorithmCfg(inputFlags, inputNameBase = "JetETMiss", outputNameBase = "JetETMissClusterMLCorrected"):
272 alg = CompFactory.PFOClusterMLCorrectionAlgorithm("PFOClusterMLCorrectionAlgorithm")
273 suffix = "ParticleFlowObjects"
274 alg.NeutralPFlowInputContainer = inputNameBase + "Neutral" + suffix
275 alg.ChargedPFlowInputContainer = inputNameBase + "Charged" + suffix
276 alg.NeutralPFlowOutputContainer = outputNameBase + "Neutral" + suffix
277 alg.ChargedPFlowOutputContainer = outputNameBase + "Charged" + suffix
278
279 return alg
280
281def getNeutralPFOClusterMLCorrectionToolCfg(inputFlags, toolName="NeutralPFOClusterMLCorrectionTool", **kwargs):
282 if toolName == "NeutralPFOClusterMLCorrectionTool":
283 tool = CompFactory.NeutralPFOClusterMLCorrectionTool(toolName, **kwargs)
284 else:
285 raise ValueError(f"Unknown tool name: {toolName}")
286
287 ca = ComponentAccumulator()
288 ca.setPrivateTools(tool)
289 return ca
290
291
292
293
294def getEGamFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs):
295
296 kwargs.setdefault("neutral_FE_cont_name", "")
297 kwargs.setdefault("charged_FE_cont_name", "")
298 kwargs.setdefault("doTCC", False)
299 kwargs.setdefault("useGlobal", False)
300
301 PFEGamFlowElementLinkerAlgorithmFactory=CompFactory.PFEGamFlowElementAssoc
302 if not algName:
303 algName = "PFEGamFlowElementAssoc"
304 PFEGamFlowElementLinkerAlgorithm=PFEGamFlowElementLinkerAlgorithmFactory(algName)
305
306 #set an an alternate name if needed
307 #this uses some gaudi core magic, namely that you can change the name of the handle as it is a callable attribute, despite the attribute not being explicitly listed in the header
308 #for a key of type SG::WriteDecorHandle<xAOD::SomeCont>someKey{this,"SpecificContainerName","myContainerName","other-labels"}
309 #setting algorithm.SpecificContainerName="myNewContainerName" changes parameter "myContainerName"
310 #(also applies to ReadHandles)
311 if kwargs['neutral_FE_cont_name']:
312 PFEGamFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer = kwargs['neutral_FE_cont_name']
313
314 if kwargs['charged_FE_cont_name']:
315 PFEGamFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer = kwargs['charged_FE_cont_name']
316
317 if kwargs['doTCC']:
318 # ReadHandles to change
319 PFEGamFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer="TrackCaloClustersNeutral"
320 PFEGamFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer="TrackCaloClustersCharged"
321
322 #Now to change the writeHandles
323 # first the Electron -> FE links
324 EL_NFE_Link=str(PFEGamFlowElementLinkerAlgorithm.ElectronNeutralFEDecorKey)
325 PFEGamFlowElementLinkerAlgorithm.ElectronNeutralFEDecorKey=EL_NFE_Link.replace("FELinks","TCCLinks")
326 EL_CFE_Link=str(PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey)
327 PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey=EL_CFE_Link.replace("FELinks","TCCLinks")
328 #then the converse case (FE -> Electron)
329
330 PFEGamFlowElementLinkerAlgorithm.ChargedFEElectronDecorKey="TCC_ElectronLinks"
331 PFEGamFlowElementLinkerAlgorithm.NeutralFEElectronDecorKey="TCC_ElectronLinks"
332
333
334 # first the Photon -> FE links
335 PH_NFE_Link=str(PFEGamFlowElementLinkerAlgorithm.PhotonNeutralFEDecorKey)
336 PFEGamFlowElementLinkerAlgorithm.PhotonNeutralFEDecorKey=PH_NFE_Link.replace("FELinks","TCCLinks")
337 PH_CFE_Link=str(PFEGamFlowElementLinkerAlgorithm.PhotonChargedFEDecorKey)
338 PFEGamFlowElementLinkerAlgorithm.PhotonChargedFEDecorKey=PH_CFE_Link.replace("FELinks","TCCLinks")
339 #then the converse case (FE -> Photons)
340
341 PFEGamFlowElementLinkerAlgorithm.ChargedFEPhotonDecorKey="TCC_PhotonLinks"
342 PFEGamFlowElementLinkerAlgorithm.NeutralFEPhotonDecorKey="TCC_PhotonLinks"
343
344 if kwargs['useGlobal']:
345 # ReadHandles to change
346 PFEGamFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer="GlobalNeutralParticleFlowObjects"
347 PFEGamFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer="GlobalChargedParticleFlowObjects"
348
349 #Now to change the writeHandles
350 # first the Electron -> FE links
351 EL_NFE_Link=str(PFEGamFlowElementLinkerAlgorithm.ElectronNeutralFEDecorKey)
352 PFEGamFlowElementLinkerAlgorithm.ElectronNeutralFEDecorKey=EL_NFE_Link.replace("FELinks","GlobalFELinks")
353 EL_CFE_Link=str(PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey)
354 PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey=EL_CFE_Link.replace("FELinks","GlobalFELinks")
355 #then the converse case (FE -> Electron)
356
357 PFEGamFlowElementLinkerAlgorithm.ChargedFEElectronDecorKey="GlobalFE_ElectronLinks"
358 PFEGamFlowElementLinkerAlgorithm.NeutralFEElectronDecorKey="GlobalFE_ElectronLinks"
359
360
361 # first the Photon -> FE links
362 PH_NFE_Link=str(PFEGamFlowElementLinkerAlgorithm.PhotonNeutralFEDecorKey)
363 PFEGamFlowElementLinkerAlgorithm.PhotonNeutralFEDecorKey=PH_NFE_Link.replace("FELinks","GlobalFELinks")
364 PH_CFE_Link=str(PFEGamFlowElementLinkerAlgorithm.PhotonChargedFEDecorKey)
365 PFEGamFlowElementLinkerAlgorithm.PhotonChargedFEDecorKey=PH_CFE_Link.replace("FELinks","GlobalFELinks")
366 #then the converse case (FE -> Photons)
367
368 PFEGamFlowElementLinkerAlgorithm.ChargedFEPhotonDecorKey="TCC_PhotonLinks"
369 PFEGamFlowElementLinkerAlgorithm.NeutralFEPhotonDecorKey="TCC_PhotonLinks"
370
371
372
373 return PFEGamFlowElementLinkerAlgorithm
374
375def getMuonFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs):
376
377 kwargs.setdefault("neutral_FE_cont_name", "")
378 kwargs.setdefault("charged_FE_cont_name", "")
379 kwargs.setdefault("LinkNeutralFEClusters", True)
380 kwargs.setdefault("doTCC", False)
381 kwargs.setdefault("useGlobal", False)
382
383 useMuonTopoClusters = False
384 from AthenaConfiguration.Enums import ProductionStep
385 # set 'useMuonTopoClusters=True' if running on AOD, as do not have calorimeter cells for CaloCalTopoCluster
386 # Assumes that in production workflows this only happens in "Derivation" or if DQ environment is AOD
387 if inputFlags.Common.ProductionStep in [ProductionStep.Derivation] or inputFlags.DQ.Environment == "AOD":
388 useMuonTopoClusters = True
389
390
391 PFMuonFlowElementLinkerAlgorithmFactory=CompFactory.PFMuonFlowElementAssoc
392 if not algName:
393 algName="PFMuonFlowElementAssoc"
394 PFMuonFlowElementLinkerAlgorithm=PFMuonFlowElementLinkerAlgorithmFactory(algName)
395
396 #set an an alternate name if needed
397 #this uses some gaudi core magic, namely that you can change the name of the handle as it is a callable attribute, despite the attribute not being explicitly listed in the header as such
398 #for a key of type SG::WriteDecorHandle<xAOD::SomeCont>someKey{this,"SpecificContainerName","myContainerName","other-labels"}
399 #setting algorithm.SpecificContainerName="myNewContainerName" changes parameter "myContainerName" to "myNewContainerName"
400 if kwargs['neutral_FE_cont_name']:
401 #update the readhandle
402 PFMuonFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer = kwargs['neutral_FE_cont_name']
403 #update the write handle for the link
404
405 if kwargs['charged_FE_cont_name']:
406 PFMuonFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer = kwargs['charged_FE_cont_name']
407
408 PFMuonFlowElementLinkerAlgorithm.LinkNeutralFEClusters = kwargs['LinkNeutralFEClusters']
409 PFMuonFlowElementLinkerAlgorithm.useMuonTopoClusters = useMuonTopoClusters
410
411 #prototype on AOD with the linkers already defined - so need to rename the output links to something besides their default name.
412
413 #Track Calo cluster (TCC) specific configuration. Input is differently named FE container, and in the AOD step specifically
414 if kwargs['doTCC']:
415 #input containers are TrackCaloClustersCharged and TrackCaloClustersNeutral, so rename them
416 #service_key="StoreGateSvc+"
417 service_key=""
418 PFMuonFlowElementLinkerAlgorithm.MuonContainer=service_key+"Muons"
419 PFMuonFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer=service_key+"TrackCaloClustersCharged"
420 PFMuonFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer=service_key+"TrackCaloClustersNeutral"
421
422 #Output
423 #rename the FE_MuonLinks as TCC_MuonLinks
424 #rename output containers
425 PFMuonFlowElementLinkerAlgorithm.MuonContainer_chargedFELinks="chargedTCCLinks"
426 PFMuonFlowElementLinkerAlgorithm.MuonContainer_neutralFELinks="neutralTCCLinks"
427 PFMuonFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer_FE_MuonLinks="TCC_MuonLinks"
428 PFMuonFlowElementLinkerAlgorithm.JetETMissChargedFlowElements_FE_MuonLinks="TCC_MuonLinks"
429 PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_ChargedFE_ennergy_matched_muon="TCC_efrac_matched_muon"
430 # several variables relating to Neutral Flow Elements/TCCs to Muons for debug. perhaps at some point these should be removed by default
431 PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_nMatchedMuons="TCC_nMatchedMuons"
432 PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_FE_efrac_matched_muon="TCC_efrac_matched_muon"
433
434 PFMuonFlowElementLinkerAlgorithm.MuonContainer_muon_efrac_matched_FE="muon_efrac_matched_TCC"
435 # this is because the algorithm adds this debug container which we don't need
436 PFMuonFlowElementLinkerAlgorithm.MuonContainer_ClusterInfo_deltaR="deltaR_muon_clus_TCCalg"
437
438 if kwargs['useGlobal']:
439 PFMuonFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer="GlobalChargedParticleFlowObjects"
440 PFMuonFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer="GlobalNeutralParticleFlowObjects"
441
442 PFMuonFlowElementLinkerAlgorithm.MuonContainer_chargedFELinks="chargedGlobalFELinks"
443 PFMuonFlowElementLinkerAlgorithm.MuonContainer_neutralFELinks="neutralGlobalFELinks"
444
445 PFMuonFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer_FE_MuonLinks="GlobalFE_MuonLinks"
446 PFMuonFlowElementLinkerAlgorithm.JetETMissChargedFlowElements_FE_MuonLinks="GlobalFE_MuonLinks"
447 PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_ChargedFE_ennergy_matched_muon="GlobalFE_efrac_matched_muon"
448
449 PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_nMatchedMuons="GlobalFE_nMatchedMuons"
450 PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_FE_efrac_matched_muon="GlobalFE_efrac_matched_muon"
451
452 PFMuonFlowElementLinkerAlgorithm.MuonContainer_muon_efrac_matched_FE="muon_efrac_matched_GlobalFE"
453 # this is because the algorithm adds this debug container which we don't need
454 PFMuonFlowElementLinkerAlgorithm.MuonContainer_ClusterInfo_deltaR="deltaR_muon_clus_GlobalFEalg"
455
456 if kwargs['LinkNeutralFEClusters'] and not useMuonTopoClusters:
457 # We dereference links to cells, so make sure we have the
458 # dependency.
459 PFMuonFlowElementLinkerAlgorithm.ExtraInputs.add(('CaloCellContainer', inputFlags.Egamma.Keys.Input.CaloCells))
460
461 if kwargs['LinkNeutralFEClusters']:
462 if kwargs['doTCC']:
463 # since the cells are deleted on AOD, if you try to run the link between NFE and Muon on AOD, it will crash. Terminate to catch this.
464 # This is a known bug to rectify soon
465 from AthenaCommon.Logging import logging
466 msg=logging.getLogger("PFCfg.py::getMuonFlowElementAssocAlgorithm")
467 msg.error("Neutral FE from AOD configured to be linked with Muon. This link will fail due to missing CaloCells in the AOD")
468 msg.info("Terminating job")
469 exit(0)
470
471
472 return PFMuonFlowElementLinkerAlgorithm
473
474def getTauFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs):
475
476 kwargs.setdefault("neutral_FE_cont_name", "")
477 kwargs.setdefault("charged_FE_cont_name", "")
478 kwargs.setdefault("doTCC", False)
479 kwargs.setdefault("useGlobal", False)
480
481 PFTauFlowElementLinkerAlgorithmFactory=CompFactory.PFTauFlowElementAssoc
482 if not algName:
483 algName = "PFTauFlowElementAssoc"
484
485 PFTauFlowElementLinkerAlgorithm=PFTauFlowElementLinkerAlgorithmFactory(algName)
486
487 #set an an alternate name if needed
488 #this uses some gaudi core magic, namely that you can change the name of the handle as it is a callable attribute, despite the attribute not being explicitly listed in the header
489 #for a key of type SG::WriteDecorHandle<xAOD::SomeCont>someKey{this,"SpecificContainerName","myContainerName","other-labels"}
490 #setting algorithm.SpecificContainerName="myNewContainerName" changes parameter "myContainerName"
491 #(also applies to ReadHandles)
492 if kwargs['neutral_FE_cont_name']:
493 PFTauFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer = kwargs['neutral_FE_cont_name']
494
495 if kwargs['charged_FE_cont_name']:
496 PFTauFlowElementLinkerAlgorithm.JetETMissChargedFlowElementContainer = kwargs['charged_FE_cont_name']
497
498 if kwargs['doTCC']:
499 PFTauFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer="TrackCaloClustersNeutral"
500 PFTauFlowElementLinkerAlgorithm.JetETMissChargedFlowElementContainer="TrackCaloClustersCharged"
501
502 PFTauFlowElementLinkerAlgorithm.TauNeutralFEDecorKey="neutralTCCLinks"
503 PFTauFlowElementLinkerAlgorithm.TauChargedFEDecorKey="chargedTCCLinks"
504
505 PFTauFlowElementLinkerAlgorithm.NeutralFETauDecorKey="TCC_TauLinks"
506 PFTauFlowElementLinkerAlgorithm.ChargedFETauDecorKey="TCC_TauLinks"
507
508 #This allows to set the links on the global particle flow containers created by JetPFlowSelectionAlg in JetRecTools
509 if kwargs['useGlobal']:
510 PFTauFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer="GlobalNeutralParticleFlowObjects"
511 PFTauFlowElementLinkerAlgorithm.JetETMissChargedFlowElementContainer="GlobalChargedParticleFlowObjects"
512
513 PFTauFlowElementLinkerAlgorithm.TauNeutralFEDecorKey="neutralGlobalFELinks"
514 PFTauFlowElementLinkerAlgorithm.TauChargedFEDecorKey="chargedGlobalFELinks"
515
516 PFTauFlowElementLinkerAlgorithm.NeutralFETauDecorKey="GlobalFE_TauLinks"
517 PFTauFlowElementLinkerAlgorithm.ChargedFETauDecorKey="GlobalFE_TauLinks"
518
519 return PFTauFlowElementLinkerAlgorithm
520
521def getOfflinePFAlgorithm(inputFlags, **kwargs):
522 result=ComponentAccumulator()
523
524 PFAlgorithm=CompFactory.PFAlgorithm
525 PFAlgorithm = PFAlgorithm("PFAlgorithm")
526
527 if inputFlags.HeavyIon.Egamma.doSubtractedClusters:
528 PFAlgorithm.PFClusterSelectorTool = getPFClusterSelectorTool(inputFlags,inputFlags.HeavyIon.Egamma.UncalibCaloTopoCluster,inputFlags.HeavyIon.Egamma.CaloTopoCluster,"PFClusterSelectorTool")
529 else:
530 topoClustersName="CaloTopoClusters"
531 PFAlgorithm.PFClusterSelectorTool = getPFClusterSelectorTool(inputFlags,topoClustersName,"CaloCalTopoClusters","PFClusterSelectorTool")
532
533 PFAlgorithm.useUnified = True
534 PFAlgorithm.UnifiedBaseTools = [getPFUnifiedCellLevelMatchingTool(inputFlags, "PFUnifiedCellLevelMatchingTool")]
535 PFAlgorithm.UnifiedBaseTools += [getPFUnifiedCellLevelSubtractionOnlyTool(inputFlags, "PFUnifiedCellLevelSubtractionOnlyTool")]
536 if not inputFlags.PF.EOverPMode and not inputFlags.PF.useTruthCheating:
537 PFAlgorithm.UnifiedBaseTools += [getPFUnifiedRecoverSplitShowersMatchingTool(inputFlags, "PFUnifiedRecoverSplitShowersMatchingTool")]
538 PFAlgorithm.UnifiedBaseTools += [getPFUnifiedRecoverSplitShowersSubtractionOnlyTool(inputFlags, "PFUnifiedRecoverSplitShowersSubtractionOnlyTool")]
539
540 PFUnifiedMomentCalculatorTools=result.popToolsAndMerge(getPFUnifiedMomentCalculatorTool(inputFlags))
541 PFAlgorithm.UnifiedBaseTools += [PFUnifiedMomentCalculatorTools]
542 PFAlgorithm.UnifiedBaseTools += [getPFUnifiedLCCalibTool(inputFlags)]
543 if inputFlags.PF.EOverPMode:
544 PFAlgorithm.UnifiedBaseTools += [CompFactory.PFUnifiedRadialEnergyCalculatorTool()]
545
546 result.addEventAlgo(PFAlgorithm)
547 return result
548
549
550
551def PFGlobalFlowElementLinkingCfg(inputFlags, **kwargs):
552 result=ComponentAccumulator()
553
554 kwargs.setdefault("useGlobal", True)
555
556 result.addEventAlgo(getTauFlowElementAssocAlgorithm(inputFlags, algName="PFTauGlobalFlowElementAssoc", **kwargs))
557 result.addEventAlgo(getMuonFlowElementAssocAlgorithm(inputFlags, algName="PFMuonGlobalFlowElementAssoc", **kwargs))
558 result.addEventAlgo(getEGamFlowElementAssocAlgorithm(inputFlags, algName="PFEGamGlobalFlowElementAssoc", **kwargs))
559 return result
if(pathvar)
Class to store reference e/p mean and widths, as well as reference energy density radial profile fit ...
Inherits from IPFClusterCollectionTool and AthAlgTool.
Inherits from eflowTrackExtrapolatorBaseAlgTool and AthAlgTool.
This is the tool, which inherits from AthAlgTool, which clients can use for track-cluster matching.
Class to store reference e/p mean and widths, as well as reference energy density radial profile fit ...
Inherits from eflowTrackExtrapolatorBaseAlgTool and AthAlgTool.
getPFUnifiedLCCalibTool(inputFlags)
Definition PFCfg.py:212
getLCNeutralFlowElementCreatorAlgorithm(inputFlags, neutralFlowElementOutputName)
Definition PFCfg.py:259
getPFUnifiedRecoverSplitShowersMatchingTool(inputFlags, toolName)
Definition PFCfg.py:145
getNeutralPFOClusterMLCorrectionToolCfg(inputFlags, toolName="NeutralPFOClusterMLCorrectionTool", **kwargs)
Definition PFCfg.py:281
getPFClusterSelectorTool(inputFlags, clustersin, calclustersin, algName)
Definition PFCfg.py:52
getPFUnifiedMomentCalculatorTool(inputFlags)
Definition PFCfg.py:191
getChargedFlowElementCreatorAlgorithm(inputFlags, chargedFlowElementOutputName, nameSuffix="", eflowCaloObjectContainerName="eflowCaloObjects")
Definition PFCfg.py:230
getPFUnifiedCellLevelSubtractionOnlyTool(inputFlags, toolName)
Definition PFCfg.py:112
getEGamFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition PFCfg.py:294
getTauFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition PFCfg.py:474
PFGlobalFlowElementLinkingCfg(inputFlags, **kwargs)
Definition PFCfg.py:551
getOfflinePFAlgorithm(inputFlags, **kwargs)
Definition PFCfg.py:521
getPFOClusterMLCorrectionAlgorithmCfg(inputFlags, inputNameBase="JetETMiss", outputNameBase="JetETMissClusterMLCorrected")
Definition PFCfg.py:271
getPFUnifiedRecoverSplitShowersSubtractionOnlyTool(inputFlags, toolName)
Definition PFCfg.py:166
getPFTrackClusterMatchingTool(inputFlags, matchCut, distanceType, clusterPositionType, name)
Definition PFCfg.py:71
getPFUnifiedCellLevelMatchingTool(inputFlags, toolName)
Definition PFCfg.py:80
getNeutralFlowElementCreatorAlgorithm(inputFlags, neutralFlowElementOutputName, nameSuffix="", eflowCaloObjectContainerName="eflowCaloObjects")
Definition PFCfg.py:244
PFTrackSelectorAlgCfg(inputFlags, algName, useCaching=True)
Definition PFCfg.py:6
getMuonFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition PFCfg.py:375