3 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory
import CompFactory
6 from AthenaCommon
import Logging
7 metlog = Logging.logging.getLogger(
'METConfig')
9 from GaudiKernel.Constants
import INFO
17 'LRTEle' :
'LRTElectrons',
20 'LCJet' :
'AntiKt4LCTopoJets',
21 'EMJet' :
'AntiKt4EMTopoJets',
22 'PFlowJet' :
'AntiKt4EMPFlowJets',
23 'PFlowJetHR':
'AntiKt4EMPFlowJets',
25 'MuonLRT' :
'MuonsLRT',
27 'Clusters' :
'CaloCalTopoClusters',
28 'Tracks' :
'InDetTrackParticles',
29 'PFlowObj' :
'CHSGParticleFlowObjects',
30 'PFlowObjHR':
'CHSGParticleFlowObjects',
31 'PrimVxColl':
'PrimaryVertices',
32 'Truth' :
'TruthEvents',
35 prefix =
'METAssocConfig: '
45 def getAssociator(configFlags, config,suffix,doPFlow=False,doRecoil=False,
47 trkisotool=None,caloisotool=None,
52 doModClus = (modConstKey!=
"" and not doPFlow)
54 modLCClus = modClusColls[
'LC{0}Clusters'.
format(modConstKey)]
55 modEMClus = modClusColls[
'EM{0}Clusters'.
format(modConstKey)]
58 if config.objType ==
'Ele':
59 tool = CompFactory.getComp(
"met::METElectronAssociator")(
'MET_ElectronAssociator_'+suffix,TCMatchMethod=1)
60 if config.objType ==
'LRTEle':
61 tool = CompFactory.getComp(
"met::METElectronAssociator")(
'MET_LRTElectronAssociator_'+suffix,TCMatchMethod=1)
62 if config.objType ==
'Gamma':
63 tool = CompFactory.getComp(
"met::METPhotonAssociator")(
'MET_PhotonAssociator_'+suffix,TCMatchMethod=1)
64 if config.objType ==
'Tau':
65 tool = CompFactory.getComp(
"met::METTauAssociator")(
'MET_TauAssociator_'+suffix)
66 if config.objType ==
'LCJet':
67 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_LCJetAssocTool_'+suffix)
68 if config.objType ==
'EMJet':
69 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_EMJetAssocTool_'+suffix)
70 if config.objType ==
'PFlowJet':
71 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_PFlowJetAssocTool_'+suffix)
72 if config.objType ==
'PFlowJetHR':
73 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_PFlowJetAssocTool_HR_'+suffix)
74 if config.objType ==
'CustomJet':
75 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_CustomJetAssocTool_'+suffix)
76 if config.objType ==
'Muon':
77 tool = CompFactory.getComp(
"met::METMuonAssociator")(
'MET_MuonAssociator_'+suffix)
78 if config.objType ==
'MuonLRT':
79 tool = CompFactory.getComp(
"met::METMuonAssociator")(
'MET_MuonLRTAssociator_'+suffix)
80 if config.objType ==
'Soft':
81 tool = CompFactory.getComp(
"met::METSoftAssociator")(
'MET_SoftAssociator_'+suffix)
82 tool.DecorateSoftConst =
True
84 tool.LCModClusterKey = modLCClus
85 tool.EMModClusterKey = modEMClus
86 if config.objType ==
'Truth':
87 tool = CompFactory.getComp(
"met::METTruthAssociator")(
'MET_TruthAssociator_'+suffix)
88 tool.RecoJetKey = config.inputKey
92 tool.FlowElementCollection = modConstKey
if modConstKey!=
"" else defaultInputKey[
"PFlowObjHR"]
94 tool.FlowElementCollection = modConstKey
if modConstKey!=
"" else defaultInputKey[
"PFlowObj"]
96 tool.UseModifiedClus = doModClus
97 if doRecoil
and (config.objType ==
'Muon' or config.objType ==
'Ele'):
99 tool.UseFELinks =
False if config.objType ==
'MuonLRT' or config.objType ==
'LRTEle' else useFELinks
101 if config.inputKey ==
'' and defaultInputKey[config.objType] !=
'':
102 tool.InputCollection = defaultInputKey[config.objType]
103 config.inputKey = tool.InputCollection
104 elif hasattr(tool,
'InputCollection'):
105 tool.InputCollection = config.inputKey
107 tool.ClusColl = modLCClus
108 if 'EMTopo' in suffix: tool.ClusColl = modEMClus
109 tool.TrkColl = defaultInputKey[
'Tracks']
110 tool.UseTracks = configFlags.MET.UseTracks
111 tool.TrackSelectorTool = trkseltool
112 tool.TrackIsolationTool = trkisotool
113 tool.CaloIsolationTool = caloisotool
123 else:
return 'MET_Core_'+self.
suffix,
'MET_Reference_'+self.
suffix
126 return 'METAssoc_'+self.
suffix
129 metlog.info(
"{} Setting up associators for MET config {}".
format(prefix,self.
suffix))
130 for config
in buildconfigs:
132 metlog.error(
"{} Config {} already contains a associator of type {}".
format(prefix,self.
suffix,config.objType))
146 metlog.info(
"{} Added {} tool named {}".
format(prefix,config.objType,associator.name))
148 def __init__(self,suffix,inputFlags,buildconfigs=[],
149 doPFlow=False, doRecoil=False, doTruth=False,
157 modConstKey_tmp = modConstKey
158 modClusColls_tmp = modClusColls
162 if modConstKey_tmp ==
"": modConstKey_tmp =
"CHSGParticleFlowObjects"
164 if modConstKey_tmp ==
"": modConstKey_tmp =
"OriginCorr"
165 if modClusColls_tmp == {}: modClusColls_tmp = {
'LCOriginCorrClusters':
'LCOriginTopoClusters',
166 'EMOriginCorrClusters':
'EMOriginTopoClusters'}
168 metlog.info(
"{} Creating MET TruthAssoc config {}".
format(prefix,suffix))
170 metlog.info(
"{} Creating MET Assoc config {}".
format(prefix,suffix))
183 self.
trkseltool=CompFactory.getComp(
"InDet::InDetTrackSelectionTool")(
"IDTrkSel_METAssoc",
184 CutLevel=
"TightPrimary",
189 self.
trkisotool = CompFactory.getComp(
"xAOD::TrackIsolationTool")(
"TrackIsolationTool_MET")
191 from TrkConfig.AtlasExtrapolatorConfig
import AtlasExtrapolatorCfg
193 CaloExtensionTool= CompFactory.getComp(
"Trk::ParticleCaloExtensionTool")(Extrapolator = self.
accumulator.popToolsAndMerge(extrapCfg))
194 CaloCellAssocTool = CompFactory.getComp(
"Rec::ParticleCaloCellAssociationTool")(ParticleCaloExtensionTool = CaloExtensionTool)
195 self.
caloisotool = CompFactory.getComp(
"xAOD::CaloIsolationTool")(
"CaloIsolationTool_MET",
196 saveOnlyRequestedCorrections=
True,
197 ParticleCaloExtensionTool = CaloExtensionTool,
198 ParticleCaloCellAssociationTool = CaloCellAssocTool)
207 if topconfig.doTruth:
208 assocTool = CompFactory.getComp(
"met::METAssociationTool")(
'MET_TruthAssociationTool_'+topconfig.suffix,
209 METAssociators = topconfig.assoclist,
210 METSuffix = topconfig.suffix)
212 assocTool = CompFactory.getComp(
"met::METAssociationTool")(
'MET_AssociationTool_'+topconfig.suffix,
213 METAssociators = topconfig.assoclist,
214 METSuffix = topconfig.suffix,
224 if configs=={}
and tools==[]:
225 metlog.info(
"{} Empty list of MET association configs provided. None will be reconstructed.".
format(prefix))
226 for key,conf
in configs.items():
227 metlog.info(
"{} Generate METAssocTool for MET_{}".
format(prefix,key))
229 assocTools.append(assoctool)
231 for tool
in assocTools:
232 metlog.info(
"{} Added METAssocTool {} to alg {}".
format(prefix,tool.name,algName))
233 assocAlg = CompFactory.getComp(
"met::METRecoAlg")(name=algName,
234 RecoTools=assocTools)