ATLAS Offline Software
Loading...
Searching...
No Matches
IsolationSteeringConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3""" Instantiate the isolation """
4
5from AthenaCommon.Logging import logging
6from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7
8def IsolationSteeringCfg(flags, name = 'IsolationSteering'):
9
10 mlog = logging.getLogger(name)
11 mlog.info('Starting Isolation steering')
12
13 acc = ComponentAccumulator()
14
15 from IsolationAlgs.IsoDensityConfig import (
16 EMTopoInputAlgCfg, NFlowInputAlgCfg, DensityForIsoAlgCfg)
17 if flags.Reco.EnableEgamma or flags.Reco.EnableCombinedMuon:
18 if flags.Detector.EnableCalo:
19 # do not compute density if HI with subtracted clusters
20 # since no pu correction in this case
21 if not flags.HeavyIon.Egamma.doSubtractedClusters:
22 acc.merge(EMTopoInputAlgCfg(flags))
23 acc.merge(DensityForIsoAlgCfg(flags))
24 acc.merge(DensityForIsoAlgCfg(flags,name='ForwardDensityForTopoIso'))
25 # should be switch off also for HI, but if done, crash sowewhere else...
26 if flags.Reco.EnablePFlow:
27 acc.merge(NFlowInputAlgCfg(flags))
28 acc.merge(DensityForIsoAlgCfg(flags,name='CentralDensityForNFlowIso'))
29 acc.merge(DensityForIsoAlgCfg(flags,name='ForwardDensityForNFlowIso'))
30
31 from IsolationAlgs.IsolationBuilderConfig import egIsolationCfg, muIsolationCfg
32 if flags.Reco.EnableEgamma:
33 acc.merge(egIsolationCfg(flags,name = 'photonIsolation'))
34 acc.merge(egIsolationCfg(flags,name = 'electronIsolation'))
35 if flags.Reco.EnableCombinedMuon:
36 acc.merge(muIsolationCfg(flags,name = 'muonIsolation'))
37
38 # Add density related containers to the output stream
39 if flags.Output.doWriteESD or flags.Output.doWriteAOD:
40 from IsolationAlgs.IsoOutputConfig import IsoOutputCfg
41 acc.merge(IsoOutputCfg(flags))
42
43 return acc
44
45if __name__ == "__main__":
46 from AthenaConfiguration.AllConfigFlags import initConfigFlags
47 from AthenaConfiguration.ComponentAccumulator import printProperties
48 from AthenaConfiguration.TestDefaults import defaultTestFiles
49 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
50 flags = initConfigFlags()
51 flags.Input.Files = defaultTestFiles.RDO_RUN2
52 flags.Output.doWriteESD = True # To test the ESD parts
53 flags.Output.doWriteAOD = True # To test the AOD parts
54 flags.lock()
55
56 mlog = logging.getLogger("isolationConfigTest")
57 mlog.info("Configuring isolation: ")
58
59 acc = MainServicesCfg(flags)
60 acc.merge(IsolationSteeringCfg(flags))
61 acc.printConfig(withDetails=True,
62 printDefaults=True)
63 printProperties(mlog,
64 acc.getEventAlgo('photonIsolationBuilder'),
65 nestLevel=1,
66 printDefaults=True)
67
68 with open("isolationconfig.pkl", "wb") as f:
69 acc.store(f)
IsolationSteeringCfg(flags, name='IsolationSteering')