ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
egamma
egammaAlgs
python
egammaAODFixesConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
4
from
AthenaConfiguration.ComponentFactory
import
CompFactory
5
from
AthenaConfiguration.AccumulatorCache
import
AccumulatorCache
6
from
AthenaConfiguration.Enums
import
LHCPeriod
7
from
RecJobTransforms.AODFixHelper
import
releaseInRange
8
from
AthenaCommon.Logging
import
logging
9
10
def
getfunc
():
11
from
inspect
import
currentframe, getframeinfo
12
caller = currentframe().f_back
13
func_name = getframeinfo(caller)[2]
14
caller = caller.f_back
15
func = caller.f_locals.get(
16
func_name, caller.f_globals.get(
17
func_name))
18
19
return
func
20
21
@AccumulatorCache
22
def
listOfRecoReleases
(flags):
23
msg=logging.getLogger(
"listOfRecoReleases"
)
24
from
PyUtils.AMITagHelperConfig
import
inputAMITags
25
listOfTags = inputAMITags(flags)
26
listOfRecoTags = []
27
nr = 0
28
nf = 0
29
for
ie,e
in
enumerate(listOfTags):
30
# no idea why it can return an empty string...
31
msg.debug(
'tag %s at position %i'
,e,ie)
32
if
not
len(e):
33
continue
34
if
e[0] ==
'r'
:
35
nr += 1
36
listOfRecoTags.append(e)
37
if
e[0] ==
'f'
:
38
nf += 1
39
listOfRecoTags.append(e)
40
41
msg.info(
'List of tags %s %s %s'
,
' '
.join(listOfTags),
', of reco tags '
,
' '
.join(listOfRecoTags))
42
# use case : a DRAW file was produced at T0 (f-tag), and recoed in reprocessing (r-tag)
43
if
nf >= 1
and
nr >= 1:
44
msg.info(
'Both r- and f-tags are present, will remove the f ones'
)
45
listOfRecoTags = [ e
for
e
in
listOfRecoTags
if
e[0] ==
'r'
]
46
47
if
len(listOfRecoTags) == 0:
48
return
[]
49
50
import
pyAMI.client
51
import
pyAMI.atlas.api
as
AtlasAPI
52
53
client = pyAMI.client.Client(
'atlas'
)
54
55
relList =
set
()
56
for
e
in
listOfRecoTags:
57
msg.info(
'Testing %s'
,e)
58
d = AtlasAPI.get_ami_tag(client,e)
59
if
len(d):
60
msg.info(
'List length %d'
,len(d))
61
if
'transformation'
in
d[0]
and
d[0][
'transformation'
].
find
(
'Merge'
) >= 0:
62
msg.info(
'it is a merging tag; skip'
)
63
continue
64
if
'cacheName'
in
d[0]: relList.add(
'Athena-'
+d[0][
'cacheName'
])
65
66
return
list(relList)
67
68
def
doFixTime
(flags,relNum = None):
69
return
releaseInRange(flags,
"Athena-23.0.12"
,
"Athena-23.0.200"
,relNum)
or
\
70
releaseInRange(flags,
"Athena-24.0.0"
,
"Athena-24.0.200"
,relNum)
or
\
71
releaseInRange(flags,
"Athena-25.0.0"
,
"Athena-25.0.200"
,relNum)
72
73
def
runAODFix
(flags, correctCluster = True, checkRelWithAMI = False):
74
75
msg=logging.getLogger(
"GetDecisionToRunAODFix"
)
76
77
ALToFix = flags.Input.AODFixesDone.find(
'AmbiguityLinks'
) < 0
78
TimeToFix = flags.Input.AODFixesDone.find(
'egammatopoIsoFix'
) < 0
79
80
if
flags.GeoModel.Run >= LHCPeriod.Run3:
81
doFix_meta =
doFixTime
(flags)
and
TimeToFix
82
else
:
83
doFix_meta=
False
84
doAmbiguityFix_meta = releaseInRange(flags,
"Athena-24.0.0"
,
"Athena-24.0.83"
)
and
ALToFix
85
86
doFix = doFix_meta
87
doAmbiguityFix = doAmbiguityFix_meta
88
89
if
checkRelWithAMI:
90
doFixFromAMITags = []
91
inputReleaseFromAMITags =
listOfRecoReleases
(flags)
92
if
len(inputReleaseFromAMITags) == 0:
93
pass
94
msg.info(
'Release list %s'
,
' '
.join(inputReleaseFromAMITags))
95
for
e
in
inputReleaseFromAMITags:
96
doF =
doFixTime
(flags,e)
and
TimeToFix
97
doAF = releaseInRange(flags,
"Athena-24.0.0"
,
"Athena-24.0.83"
,e)
and
ALToFix
98
doFixFromAMITags.append((doF,doAF))
99
msg.info(
'doFix from AMI tags = %s'
,doFixFromAMITags)
100
101
for
ie,e
in
enumerate(doFixFromAMITags):
102
if
e[0] != doFix
or
e[1] != doAmbiguityFix:
103
msg.warning(
'Inconsistent information from AMI reco tag release %s and input release %s'
, \
104
inputReleaseFromAMITags[ie],flags.Input.Release)
105
if
ie == 0:
106
msg.warning(
'Will use the release number first in the list'
)
107
doFix = e[0]
108
doAmbiguityFix = e[1]
109
110
name =
''
111
if
doFix:
112
if
doAmbiguityFix:
113
name +=
'egammaAmbiguityLinksFix'
114
# no timing cut in HI reco, so not these fixes
115
if
not
flags.Reco.EnableHI:
116
name +=
' egammatopoIsoFix'
117
if
correctCluster:
118
name +=
' egClusterL2_3Fix'
119
else
:
120
doFix = doAmbiguityFix
121
122
return
doFix, name
123
124
def
egammaAODFixesCfg
(flags, correctCluster = True):
125
126
msg=logging.getLogger(
"egammaAODFixes"
)
127
#first check if we need to apply this AODFix
128
doFix, name =
runAODFix
(flags, correctCluster)
129
msg.info(
'Decision for egamma AOD fix = %s'
,doFix)
130
if
not
doFix:
131
return
None
132
else
:
133
if
name!=
''
:
134
msg.info(
'Will apply fixes = %s'
,name)
135
else
:
136
msg.info(
'Range is ok but there are no fix to apply'
)
137
return
None
138
139
# I do this because there are in fact two AOD fixes here:
140
# one for ambiguity links, one for timing issue (topoetcone + cluster fixes)
141
# sometimes, the ambiguity link fix is not needed, need to now this
142
getfunc
().__name__ = name
143
144
result=ComponentAccumulator()
145
146
# No fix if nothing relevant in input
147
hasElectrons =
"Electrons"
in
flags.Input.Collections
148
hasPhotons =
"Photons"
in
flags.Input.Collections
149
if
not
hasElectrons
and
not
hasPhotons:
150
return
None
151
152
# TO BE FIXED
153
# if only one collection is present, this will crash
154
155
#Use the AddressRemappingSvc to rename the input object
156
from
SGComps.AddressRemappingConfig
import
InputRenameCfg
157
if
hasElectrons:
158
result.merge(InputRenameCfg(
"xAOD::ElectronContainer"
,
"Electrons"
,
"old_Electrons"
))
159
result.merge(InputRenameCfg(
"xAOD::ElectronAuxContainer"
,
"ElectronsAux."
,
"old_ElectronsAux."
))
160
if
hasPhotons:
161
result.merge(InputRenameCfg(
"xAOD::PhotonContainer"
,
"Photons"
,
"old_Photons"
))
162
result.merge(InputRenameCfg(
"xAOD::PhotonAuxContainer"
,
"PhotonsAux."
,
"old_PhotonsAux."
))
163
164
kwargs = dict()
165
kwargs[
'CorrectCluster'
] = correctCluster
166
kwargs[
'FixAmbiguityLinks'
] = (name.find(
'egammaAmbiguityLinksFix'
) >= 0)
167
if
correctCluster:
168
# First some detector config
169
# 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.)
170
from
LArBadChannelTool.LArBadChannelConfig
import
LArBadChannelCfg
171
result.merge(LArBadChannelCfg(flags))
172
#from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
173
#result.merge( TileBadChannelsCondAlgCfg(flags, **kwargs) )
174
from
CaloBadChannelTool.CaloBadChanToolConfig
import
CaloBadChanToolCfg
175
result.popToolsAndMerge( CaloBadChanToolCfg(flags) )
176
from
LArGeoAlgsNV.LArGMConfig
import
LArGMCfg
177
result.merge(LArGMCfg(flags))
178
# then the AODFix itself
179
result.merge(InputRenameCfg(
"xAOD::CaloClusterContainer"
,
"egammaClusters"
,
"old_egammaClusters"
))
180
result.merge(InputRenameCfg(
"xAOD::CaloClusterAuxContainer"
,
"egammaClustersAux."
,
"old_egammaClustersAux."
))
181
result.merge(InputRenameCfg(
"CaloClusterCellLinkContainer"
,
"egammaClusters_links"
,
"old_egammaClusters_links"
))
182
kwargs[
'CaloDetDescrManager'
] =
'CaloDetDescrManager'
183
from
egammaTools.egammaSwToolConfig
import
egammaSwToolCfg
184
kwargs[
'ClusterCorrectionTool'
] = result.popToolsAndMerge(egammaSwToolCfg(flags))
185
from
egammaMVACalib.egammaMVACalibConfig
import
egammaMVASvcCfg
186
kwargs[
'MVACalibSvc'
] = result.getPrimaryAndMerge(egammaMVASvcCfg(flags))
187
kwargs[
'EGammaClustersOutputName'
] = flags.Egamma.Keys.Output.CaloClusters
188
kwargs[
'EGammaClustersInputName'
] = f
'old_{flags.Egamma.Keys.Output.CaloClusters}'
189
190
kwargs[
'IsoLeakCorrectionTool'
] = CompFactory.CP.IsolationCorrectionTool(
191
LogLogFitForLeakage =
True
)
192
193
#Re-run the required algorithms
194
result.addEventAlgo(CompFactory.egammaAODFixes(**kwargs))
195
196
return
result
197
198
199
set
STL class.
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
egammaAODFixesConfig.egammaAODFixesCfg
egammaAODFixesCfg(flags, correctCluster=True)
Definition
egammaAODFixesConfig.py:124
egammaAODFixesConfig.doFixTime
doFixTime(flags, relNum=None)
Definition
egammaAODFixesConfig.py:68
egammaAODFixesConfig.listOfRecoReleases
listOfRecoReleases(flags)
Definition
egammaAODFixesConfig.py:22
egammaAODFixesConfig.runAODFix
runAODFix(flags, correctCluster=True, checkRelWithAMI=False)
Definition
egammaAODFixesConfig.py:73
egammaAODFixesConfig.getfunc
getfunc()
Definition
egammaAODFixesConfig.py:10
Generated on
for ATLAS Offline Software by
1.17.0