ATLAS Offline Software
Loading...
Searching...
No Matches
egammaSwToolConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3""" Configure cluster correction """
4
5from AthenaCommon.Logging import logging
6from AthenaConfiguration.ComponentFactory import CompFactory
7import GaudiKernel.GaudiHandles as GaudiHandles
8from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9
10
12 "Add attributes ClusterCorrectionToolsXX to egammaSwTool object"
13
14 acc = ComponentAccumulator()
15 from CaloClusterCorrection.CaloSwCorrections import (
16 make_CaloSwCorrectionsCfg)
17
18 clusterTypes = dict(
19 Ele35='ele35', Ele55='ele55', Ele37='ele37',
20 Gam35='gam35_unconv', Gam55='gam55_unconv', Gam37='gam37_unconv',
21 Econv35='gam35_conv', Econv55='gam55_conv', Econv37='gam37_conv'
22 )
23
24 version = flags.Egamma.Calib.SuperClusterCorrectionVersion
25 suffix = 'EGSuperCluster'
26 attrPref = 'ClusterCorrectionToolsSuperCluster'
27
28 for attrName, clName in clusterTypes.items():
29 attrName = attrPref + attrName
30 if not hasattr(swTool, attrName):
31 continue
32 toolsAcc = make_CaloSwCorrectionsCfg(
33 flags, clName, suffix=suffix,
34 version=version,
35 cells_name=flags.Egamma.Keys.Input.CaloCells)
36 tools = acc.popToolsAndMerge(toolsAcc)
37 setattr(swTool, attrName, GaudiHandles.PrivateToolHandleArray(tools))
38
39 return acc
40
41
42def egammaSwToolCfg(flags, name='egammaSwTool', **kwargs):
43
44 mlog = logging.getLogger(name)
45 mlog.debug('Start configuration')
46
47 acc = ComponentAccumulator()
48
49 egswtool = CompFactory.egammaSwTool(name, **kwargs)
50
51 # For now, the correction is called, but this might change.
52 utilsAcc = _configureClusterCorrections(flags, egswtool)
53 acc.merge(utilsAcc)
54
55 acc.setPrivateTools(egswtool)
56 return acc
57
58
59if __name__ == "__main__":
60
61 from AthenaConfiguration.AllConfigFlags import initConfigFlags
62 from AthenaConfiguration.ComponentAccumulator import printProperties
63 from AthenaConfiguration.TestDefaults import defaultTestFiles
64 flags = initConfigFlags()
65 flags.Input.Files = defaultTestFiles.RDO_RUN2
66 flags.fillFromArgs()
67 flags.lock()
68 flags.dump()
69
70 cfg = ComponentAccumulator()
71 mlog = logging.getLogger("egammaSwToolConfigTest")
72 mlog.info("Configuring egammaSwTool: ")
73 printProperties(mlog, cfg.popToolsAndMerge(
74 egammaSwToolCfg(flags)),
75 nestLevel=1,
76 printDefaults=True)
77
78 f = open("egammaswtool.pkl", "wb")
79 cfg.store(f)
80 f.close()
_configureClusterCorrections(flags, swTool)
egammaSwToolCfg(flags, name='egammaSwTool', **kwargs)