ATLAS Offline Software
Loading...
Searching...
No Matches
METChainConfiguration.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon.Logging import logging
4
5logging.getLogger().info("Importing %s", __name__)
6log = logging.getLogger(__name__)
7
8from ..Config.ChainConfigurationBase import ChainConfigurationBase
9from .ConfigHelpers import recoKeys, AlgConfig
10from ..Menu.SignatureDicts import METChainParts_Default
11
12
13def extractMETRecoDict(chainDict, fillDefaults=True):
14 """ Extract the keys relevant to reconstruction from a provided dictionary
15
16 If fillDefaults is True then any missing keys will be taken from the
17 METChainParts_Default dictionary.
18 """
19 if fillDefaults:
20 return {k: chainDict.get(k, METChainParts_Default[k]) for k in recoKeys}
21 else:
22 return {k: chainDict[k] for k in recoKeys if k in chainDict}
23
24
25# ----------------------------------------------------------------
26# Class to configure chain
27# ----------------------------------------------------------------
28class METChainConfiguration(ChainConfigurationBase):
29 def __init__(self, chainDict):
30 ChainConfigurationBase.__init__(self, chainDict)
31 # Only some subset of keys in the METChainParts dictionary describe
32 # reconstruction details - only these keys are passed down into the menu
33 # sequence (the actual hypo tool is created later)
34 self.recoDict = extractMETRecoDict(self.chainPart)
35
36 # ----------------------
37 # Assemble the chain depending on information from chainName
38 # ----------------------
39 def assembleChainImpl(self, flags):
40 log.debug("Assembling chain for %s", self.chainName)
41 conf = AlgConfig.fromRecoDict(**self.recoDict)
42 steps = conf.make_accumulator_steps(flags, self.dict)
43
44 return self.buildChain(steps)
extractMETRecoDict(chainDict, fillDefaults=True)