ATLAS Offline Software
Loading...
Searching...
No Matches
egammaAODFixesConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5from RecJobTransforms.AODFixHelper import releaseInRange
6
7def getfunc():
8 from inspect import currentframe, getframeinfo
9 caller = currentframe().f_back
10 func_name = getframeinfo(caller)[2]
11 caller = caller.f_back
12 func = caller.f_locals.get(
13 func_name, caller.f_globals.get(
14 func_name))
15
16 return func
17
18def runAODFix(flags, correctCluster = True):
19 doFix = releaseInRange(flags,"Athena-24.0.0","Athena-24.0.200") or \
20 releaseInRange(flags,"Athena-25.0.0","Athena-25.0.200")
21
22 doAmbiguityFix = releaseInRange(flags,"Athena-24.0.0","Athena-24.0.83")
23
24 name = ''
25 if doAmbiguityFix:
26 name += 'egammaAmbiguityLinksFix'
27 name += ' egammatopoIsoFix'
28 if correctCluster:
29 name += ' egClusterL2_3Fix'
30 return doFix, name
31
32def egammaAODFixesCfg(flags, correctCluster = True):
33
34 #first check if we need to apply this AODFix
35 doFix, name = runAODFix(flags, correctCluster)
36 if not doFix:
37 return None
38 getfunc().__name__ = name
39
40 result=ComponentAccumulator()
41
42 # No fix if nothing relevant in input
43 hasElectrons = "Electrons" in flags.Input.Collections
44 hasPhotons = "Photons" in flags.Input.Collections
45 if not hasElectrons and not hasPhotons:
46 return None
47
48 # TO BE FIXED
49 # if only one collection is present, this will crash
50
51 #Use the AddressRemappingSvc to rename the input object
52 from SGComps.AddressRemappingConfig import InputRenameCfg
53 if hasElectrons:
54 result.merge(InputRenameCfg("xAOD::ElectronContainer", "Electrons", "old_Electrons"))
55 result.merge(InputRenameCfg("xAOD::ElectronAuxContainer", "ElectronsAux.", "old_ElectronsAux."))
56 if hasPhotons:
57 result.merge(InputRenameCfg("xAOD::PhotonContainer", "Photons", "old_Photons"))
58 result.merge(InputRenameCfg("xAOD::PhotonAuxContainer", "PhotonsAux.", "old_PhotonsAux."))
59
60 kwargs = dict()
61 kwargs['CorrectCluster'] = correctCluster
62 kwargs['FixAmbiguityLinks'] = (name.find('egammaAmbiguityLinksFix') >= 0)
63 if correctCluster:
64 # TO BE UNDERSTOOD : why is this explicitely needed here (without it : ERROR SG::ExcNoCondCont: Can't retrieve CondCont from ReadCondHandle for key ConditionStore+LArBadChannel. Can't retrieve.)
65 from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg
66 result.merge(LArBadChannelCfg(flags))
67 #from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
68 #result.merge( TileBadChannelsCondAlgCfg(flags, **kwargs) )
69 from CaloBadChannelTool.CaloBadChanToolConfig import CaloBadChanToolCfg
70 result.popToolsAndMerge( CaloBadChanToolCfg(flags) )
71 result.merge(InputRenameCfg("xAOD::CaloClusterContainer", "egammaClusters", "old_egammaClusters"))
72 result.merge(InputRenameCfg("xAOD::CaloClusterAuxContainer", "egammaClustersAux.", "old_egammaClustersAux."))
73 result.merge(InputRenameCfg("CaloClusterCellLinkContainer", "egammaClusters_links", "old_egammaClusters_links"))
74 kwargs['CaloDetDescrManager'] = 'CaloDetDescrManager'
75 from egammaTools.egammaSwToolConfig import egammaSwToolCfg
76 kwargs['ClusterCorrectionTool'] = result.popToolsAndMerge(egammaSwToolCfg(flags))
77 from egammaMVACalib.egammaMVACalibConfig import egammaMVASvcCfg
78 kwargs['MVACalibSvc'] = result.getPrimaryAndMerge(egammaMVASvcCfg(flags))
79 kwargs['EGammaClustersOutputName'] = flags.Egamma.Keys.Output.CaloClusters
80 kwargs['EGammaClustersInputName'] = f'old_{flags.Egamma.Keys.Output.CaloClusters}'
81
82 kwargs['IsoLeakCorrectionTool'] = CompFactory.CP.IsolationCorrectionTool(
83 LogLogFitForLeakage = True)
84
85 #Re-run the required algorithms
86 result.addEventAlgo(CompFactory.egammaAODFixes(**kwargs))
87
88 return result
89
90
91
egammaAODFixesCfg(flags, correctCluster=True)
runAODFix(flags, correctCluster=True)