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