3 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory
import CompFactory
6 from AthenaCommon
import Logging
7 metlog = Logging.logging.getLogger(
'METConfig')
16 'Jet' :
'AntiKt4EMTopoJets',
18 'SoftTrk' :
'InDetTrackParticles',
19 'SoftClus' :
'CaloCalTopoClusters',
20 'SoftPFlow':
'JetETMissNeutralParticleFlowObjects',
21 'PrimaryVx':
'PrimaryVertices',
22 'Truth' :
'TruthEvents',
24 'LCOCSoftClus':
'LCOriginTopoClusters',
25 'EMOCSoftClus':
'EMOriginTopoClusters',
35 'SoftClus' :
'SoftClus',
36 'SoftPFlow':
'SoftPFlow',
42 prefix =
'METRecoConfig: '
48 def __init__(self,objType='',outputKey='',inputKey=''):
53 def getBuilder(config,suffix,doTracks,doCells,doTriggerMET,doOriginCorrClus):
56 if config.objType ==
'SoftTrk':
57 tool = CompFactory.getComp(
"met::METSoftTermsTool")(
'MET_SoftTrkTool_'+suffix)
58 tool.InputComposition =
'Tracks'
59 tool.TrackKey = defaultInputKey[config.objType]
60 config.inputKey = defaultInputKey[config.objType]
61 if config.objType.endswith(
'SoftClus'):
62 tool = CompFactory.getComp(
"met::METSoftTermsTool")(
'MET_SoftClusTool_'+suffix)
63 tool.InputComposition =
'Clusters'
64 tool.CaloClusterKey = defaultInputKey[config.objType]
65 config.inputKey = defaultInputKey[config.objType]
66 if config.objType ==
'SoftPFlow':
67 tool = CompFactory.getComp(
"met::METSoftTermsTool")(
'MET_SoftPFlowTool_'+suffix)
68 tool.InputComposition =
'PFlow'
69 pfotool = CompFactory.RetrievePFOTool(
'MET_PFOTool_'+suffix)
70 tool.PFOTool = pfotool
72 tool = CompFactory.getComp(
"met::METTruthTool")(
'MET_TruthTool_'+config.objType)
73 tool.InputComposition = config.objType
74 tool.InputCollection = defaultInputKey[
'Truth']
75 config.inputKey = defaultInputKey[
'Truth']
76 config.outputKey = config.objType
78 tool = CompFactory.getComp(
"met::METCaloRegionsTool")(
'MET_CaloRegionsTool')
81 tool.DoTriggerMET = doTriggerMET
82 tool.CaloCellKey = defaultInputKey[
'Calo']
83 config.inputKey = defaultInputKey[
'Calo']
86 tool.DoTriggerMET =
False
87 tool.CaloClusterKey = defaultInputKey[
'SoftClus']
88 config.inputKey = defaultInputKey[
'SoftClus']
89 config.outputKey = config.objType
92 if config.inputKey ==
'':
93 tool.InputCollection = defaultInputKey[config.objType]
94 config.inputKey = tool.InputCollection
95 elif hasattr(tool,
'InputCollection'):
96 tool.InputCollection = config.inputKey
97 if not suffix==
'Calo':
98 if config.outputKey ==
'':
99 tool.MissingETKey = defaultOutputKey[config.objType]
100 config.outputKey = tool.MissingETKey
102 tool.MissingETKey = config.outputKey
113 def getRefiner(flags,config,suffix,trkseltool=None,trkvxtool=None,trkisotool=None,caloisotool=None):
116 if config.type ==
'TrackFilter':
117 tool = CompFactory.getComp(
"met::METTrackFilterTool")(
'MET_TrackFilterTool_'+suffix)
118 tool.InputPVKey = defaultInputKey[
'PrimaryVx']
119 tool.TrackSelectorTool=trkseltool
120 tool.TrackVxAssocTool=trkvxtool
122 tool.UseIsolationTools =
False
123 tool.TrackIsolationTool = trkisotool
124 tool.CaloIsolationTool = caloisotool
126 tool.DoPVSel = flags.MET.UseTracks
127 tool.DoVxSep = flags.MET.UseTracks
128 tool.MissingETKey = config.outputKey
135 if suffix ==
'Truth':
136 config.outputKey = config.objType
137 tool = CompFactory.getComp(
"met::METRegionsTool")(
'MET_'+config.outputKey+
'Regions_'+suffix)
138 tool.InputMETContainer =
'MET_'+suffix
139 tool.InputMETMap =
'METMap_'+suffix
140 tool.InputMETKey = config.outputKey
141 tool.RegionValues = [ 1.5, 3.2, 10 ]
152 return 'METMap_'+self.
suffix
155 metlog.info(
"{} Setting up builders for MET config {}".
format(prefix,self.
suffix))
156 for config
in buildconfigs:
158 metlog.error(
"{} Config {} already contains a builder of type {}".
format(prefix,self.
suffix,config.objType))
163 self.
builders[config.objType] = builder
165 metlog.info(
"{} Added {} tool named {}".
format(prefix,config.objType,builder.name))
168 metlog.info(
"{} Setting up refiners for MET config {}".
format(prefix,self.
suffix))
169 for config
in refconfigs:
172 metlog.error(
"Config {} already contains a refiner of type {}".
format(self.
suffix,config.type))
178 self.
refiners[config.type] = refiner
180 metlog.info(
"{} Added {} tool named {}".
format(prefix,config.type,refiner.name))
183 metlog.info(
"{} Setting up regions for MET config {}".
format(prefix,self.
suffix))
184 for config
in buildconfigs:
185 if config.objType
in self.
regions:
186 metlog.error(
"{} Config {} already contains a region tool of type {}".
format(prefix,self.
suffix,config.objType))
190 self.
regions[config.objType] = regions
192 metlog.info(
"{} Added {} region tool named {}".
format(prefix,config.objType,regions.name))
194 def __init__(self,suffix,inputFlags,buildconfigs=[],refconfigs=[],
195 doTracks=False,doSum=False,doRegions=False,
196 doCells=False,doTriggerMET=True,duplicateWarning=True,
197 doOriginCorrClus=False):
198 metlog.info(
"{} Creating MET config {}".
format(prefix,suffix))
223 self.
trkseltool=CompFactory.getComp(
"InDet::InDetTrackSelectionTool")(
"IDTrkSel_MET",
224 CutLevel=
"TightPrimary",
229 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig
import TTVAToolCfg
231 TTVAToolCfg(inputFlags,
"TrackVertexAssociationTool_MET", addDecoAlg=
True,
232 WorkingPoint=
"Nonprompt_All_MaxWeight", HardScatterLinkDeco=
""))
234 self.
trkisotool = CompFactory.getComp(
"xAOD::TrackIsolationTool")(
"TrackIsolationTool_MET")
237 from TrkConfig.AtlasExtrapolatorConfig
import AtlasExtrapolatorCfg
239 CaloExtensionTool= CompFactory.getComp(
"Trk::ParticleCaloExtensionTool")(Extrapolator = self.
accumulator.popToolsAndMerge(extrapCfg))
240 CaloCellAssocTool = CompFactory.getComp(
"Rec::ParticleCaloCellAssociationTool")(ParticleCaloExtensionTool = CaloExtensionTool)
241 self.
caloisotool = CompFactory.getComp(
"xAOD::CaloIsolationTool")(
"CaloIsolationTool_MET",
242 saveOnlyRequestedCorrections=
True,
243 ParticleCaloExtensionTool = CaloExtensionTool,
244 ParticleCaloCellAssociationTool = CaloCellAssocTool)
251 recoTool = CompFactory.getComp(
"met::METRecoTool")(
'MET_RecoTool_'+topconfig.suffix,
252 METBuilders = topconfig.buildlist,
253 METRefiners = topconfig.reflist,
254 METContainer = topconfig.outputCollection(),
255 METComponentMap = topconfig.outputMap(),
256 WarnIfDuplicate = topconfig.duplicateWarning)
258 recoTool.METFinalName = defaultOutputKey[
'Total']
264 regTool = CompFactory.getComp(
"met::METRecoTool")(
'MET_RegionTool_'+topconfig.suffix,
266 METRefiners = topconfig.reglist,
267 METContainer = topconfig.outputCollection()+
'Regions',
268 METComponentMap = topconfig.outputMap()+
'Regions',
269 WarnIfDuplicate = topconfig.duplicateWarning)
275 for key,conf
in configs.items():
276 metlog.info(
"{} Generate METRecoTool for MET_{}".
format(prefix,key))
278 recoTools.append(recotool)
281 recoTools.append(regiontool)
282 for tool
in recoTools:
283 metlog.info(
"{} Added METRecoTool {} to alg {}".
format(prefix,tool.name,algName))
284 recoAlg = CompFactory.getComp(
"met::METRecoAlg")(name=algName,RecoTools=recoTools)