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
18 'LRTEle' :
'LRTElectrons',
21 'LCJet' :
'AntiKt4LCTopoJets',
22 'EMJet' :
'AntiKt4EMTopoJets',
23 'PFlowJet' :
'AntiKt4EMPFlowJets',
25 'MuonLRT' :
'MuonsLRT',
27 'Clusters' :
'CaloCalTopoClusters',
28 'Tracks' :
'InDetTrackParticles',
29 'PFlowObj' :
'CHSGParticleFlowObjects',
30 'PrimVxColl':
'PrimaryVertices',
31 'Truth' :
'TruthEvents',
34 prefix =
'METAssocConfig: '
46 trkisotool=None,caloisotool=None,
51 doModClus = (modConstKey!=
"" and not doPFlow)
53 modLCClus = modClusColls[
'LC{0}Clusters'.
format(modConstKey)]
54 modEMClus = modClusColls[
'EM{0}Clusters'.
format(modConstKey)]
57 if config.objType ==
'Ele':
58 tool = CompFactory.getComp(
"met::METElectronAssociator")(
'MET_ElectronAssociator_'+suffix,TCMatchMethod=1)
59 if config.objType ==
'LRTEle':
60 tool = CompFactory.getComp(
"met::METElectronAssociator")(
'MET_LRTElectronAssociator_'+suffix,TCMatchMethod=1)
61 if config.objType ==
'Gamma':
62 tool = CompFactory.getComp(
"met::METPhotonAssociator")(
'MET_PhotonAssociator_'+suffix,TCMatchMethod=1)
63 if config.objType ==
'Tau':
64 tool = CompFactory.getComp(
"met::METTauAssociator")(
'MET_TauAssociator_'+suffix)
65 if config.objType ==
'LCJet':
66 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_LCJetAssocTool_'+suffix)
67 if config.objType ==
'EMJet':
68 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_EMJetAssocTool_'+suffix)
69 if config.objType ==
'PFlowJet':
70 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_PFlowJetAssocTool_'+suffix)
71 if config.objType ==
'CustomJet':
72 tool = CompFactory.getComp(
"met::METJetAssocTool")(
'MET_CustomJetAssocTool_'+suffix)
73 if config.objType ==
'Muon':
74 tool = CompFactory.getComp(
"met::METMuonAssociator")(
'MET_MuonAssociator_'+suffix)
75 if config.objType ==
'MuonLRT':
76 tool = CompFactory.getComp(
"met::METMuonAssociator")(
'MET_MuonLRTAssociator_'+suffix)
77 if config.objType ==
'Soft':
78 tool = CompFactory.getComp(
"met::METSoftAssociator")(
'MET_SoftAssociator_'+suffix)
79 tool.DecorateSoftConst =
True
81 tool.LCModClusterKey = modLCClus
82 tool.EMModClusterKey = modEMClus
83 if config.objType ==
'Truth':
84 tool = CompFactory.getComp(
"met::METTruthAssociator")(
'MET_TruthAssociator_'+suffix)
85 tool.RecoJetKey = config.inputKey
88 tool.FlowElementCollection = modConstKey
if modConstKey!=
"" else defaultInputKey[
"PFlowObj"]
90 tool.UseModifiedClus = doModClus
91 tool.UseFELinks =
False if config.objType ==
'MuonLRT' or config.objType ==
'LRTEle' else useFELinks
93 if config.inputKey ==
'' and defaultInputKey[config.objType] !=
'':
94 tool.InputCollection = defaultInputKey[config.objType]
95 config.inputKey = tool.InputCollection
96 elif hasattr(tool,
'InputCollection'):
97 tool.InputCollection = config.inputKey
99 tool.ClusColl = modLCClus
100 if 'EMTopo' in suffix: tool.ClusColl = modEMClus
101 tool.TrkColl = defaultInputKey[
'Tracks']
102 tool.UseTracks = configFlags.MET.UseTracks
103 tool.TrackSelectorTool = trkseltool
104 tool.TrackIsolationTool = trkisotool
105 tool.CaloIsolationTool = caloisotool
115 else:
return 'MET_Core_'+self.
suffix,
'MET_Reference_'+self.
suffix
118 return 'METAssoc_'+self.
suffix
121 metlog.info(
"{} Setting up associators for MET config {}".
format(prefix,self.
suffix))
122 for config
in buildconfigs:
124 metlog.error(
"{} Config {} already contains a associator of type {}".
format(prefix,self.
suffix,config.objType))
137 metlog.info(
"{} Added {} tool named {}".
format(prefix,config.objType,associator.name))
139 def __init__(self,suffix,inputFlags,buildconfigs=[],
140 doPFlow=False, doTruth=False,
148 modConstKey_tmp = modConstKey
149 modClusColls_tmp = modClusColls
153 if modConstKey_tmp ==
"": modConstKey_tmp =
"CHSGParticleFlowObjects"
155 if modConstKey_tmp ==
"": modConstKey_tmp =
"OriginCorr"
156 if modClusColls_tmp == {}: modClusColls_tmp = {
'LCOriginCorrClusters':
'LCOriginTopoClusters',
157 'EMOriginCorrClusters':
'EMOriginTopoClusters'}
159 metlog.info(
"{} Creating MET TruthAssoc config {}".
format(prefix,suffix))
161 metlog.info(
"{} Creating MET Assoc config {}".
format(prefix,suffix))
173 self.
trkseltool=CompFactory.getComp(
"InDet::InDetTrackSelectionTool")(
"IDTrkSel_METAssoc",
174 CutLevel=
"TightPrimary",
179 self.
trkisotool = CompFactory.getComp(
"xAOD::TrackIsolationTool")(
"TrackIsolationTool_MET")
181 from TrkConfig.AtlasExtrapolatorConfig
import AtlasExtrapolatorCfg
183 CaloExtensionTool= CompFactory.getComp(
"Trk::ParticleCaloExtensionTool")(Extrapolator = self.
accumulator.popToolsAndMerge(extrapCfg))
184 CaloCellAssocTool = CompFactory.getComp(
"Rec::ParticleCaloCellAssociationTool")(ParticleCaloExtensionTool = CaloExtensionTool)
185 self.
caloisotool = CompFactory.getComp(
"xAOD::CaloIsolationTool")(
"CaloIsolationTool_MET",
186 saveOnlyRequestedCorrections=
True,
187 ParticleCaloExtensionTool = CaloExtensionTool,
188 ParticleCaloCellAssociationTool = CaloCellAssocTool)
197 if topconfig.doTruth:
198 assocTool = CompFactory.getComp(
"met::METAssociationTool")(
'MET_TruthAssociationTool_'+topconfig.suffix,
199 METAssociators = topconfig.assoclist,
200 METSuffix = topconfig.suffix)
202 assocTool = CompFactory.getComp(
"met::METAssociationTool")(
'MET_AssociationTool_'+topconfig.suffix,
203 METAssociators = topconfig.assoclist,
204 METSuffix = topconfig.suffix,
214 if configs=={}
and tools==[]:
215 metlog.info(
"{} Empty list of MET association configs provided. None will be reconstructed.".
format(prefix))
216 for key,conf
in six.iteritems(configs):
217 metlog.info(
"{} Generate METAssocTool for MET_{}".
format(prefix,key))
219 assocTools.append(assoctool)
221 for tool
in assocTools:
222 metlog.info(
"{} Added METAssocTool {} to alg {}".
format(prefix,tool.name,algName))
223 assocAlg = CompFactory.getComp(
"met::METRecoAlg")(name=algName,
224 RecoTools=assocTools)