4 Instantiate the electron or photon isolation
7 from AthenaCommon.Logging
import logging
8 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory
import CompFactory
13 mlog = logging.getLogger(name)
14 mlog.info(
'Starting '+name+
' configuration')
19 if name.find(
'photon') >= 0:
22 elif name.find(
'electron') >= 0:
26 mlog.error(
'Name '+name+
' should contain electron or photon')
29 from xAODPrimitives.xAODIso
import xAODIso
as isoPar
30 from IsolationAlgs.IsoToolsConfig
import (
31 TrackIsolationToolCfg, ElectronTrackIsolationToolCfg,
32 EGammaCaloIsolationToolCfg)
38 if flags.Detector.EnableID
or flags.Detector.EnableITk:
39 isoType.append([ isoPar.ptcone30, isoPar.ptcone20 ])
40 isoCor.append([ isoPar.coreTrackPtr ])
42 if 'TrackIsolationTool' not in kwargs:
44 kwargs[
'TrackIsolationTool'] = acc.popToolsAndMerge(
47 kwargs[
'TrackIsolationTool'] = acc.popToolsAndMerge(
50 if flags.Detector.EnableCalo
and not noCalo:
52 [ isoPar.topoetcone20, isoPar.topoetcone30, isoPar.topoetcone40 ])
54 [ isoPar.core57cells, isoPar.ptCorrection, isoPar.pileupCorrection ])
56 if flags.HeavyIon.Egamma.doSubtractedClusters:
57 isoCor[-1] = [ x
for x
in isoCor[-1]
if x != isoPar.pileupCorrection ]
59 if 'CaloTopoIsolationTool' not in kwargs:
60 kwargs[
'CaloTopoIsolationTool'] = acc.popToolsAndMerge(
63 kwargs[f
'{pref}IsoTypes'] = isoType
64 kwargs[f
'{pref}CorTypes'] = isoCor
65 kwargs[f
'{pref}CorTypesExtra'] = isoExCor
67 kwargs[
'name'] = suff+
'IsolationBuilder'
69 acc.addEventAlgo(CompFactory.IsolationBuilder(**kwargs))
71 mlog.info(suff+
" isolation configured")
77 mlog = logging.getLogger(name)
78 mlog.info(
'Starting '+name+
' configuration')
82 from xAODPrimitives.xAODIso
import xAODIso
as isoPar
83 from IsolationAlgs.IsoToolsConfig
import (
84 TrackIsolationToolCfg, MuonCaloIsolationToolCfg)
90 if flags.Detector.EnableID
or flags.Detector.EnableITk:
91 isoType.append([ isoPar.ptcone40, isoPar.ptcone30, isoPar.ptcone20 ])
92 isoCor.append([ isoPar.coreTrackPtr ])
94 if 'TrackIsolationTool' not in kwargs:
95 kwargs[
'TrackIsolationTool'] = acc.popToolsAndMerge(
98 if flags.Detector.EnableCalo
and not noCalo:
100 [ isoPar.topoetcone20, isoPar.topoetcone30, isoPar.topoetcone40 ])
101 isoCor.append([ isoPar.coreCone, isoPar.pileupCorrection ])
103 if flags.HeavyIon.Egamma.doSubtractedClusters:
104 isoCor[-1] = [ x
for x
in isoCor[-1]
if x != isoPar.pileupCorrection ]
106 if (
'CaloTopoIsolationTool' not in kwargs)
or (
107 'PFlowIsolationTool' not in kwargs):
109 if 'CaloTopoIsolationTool' not in kwargs:
110 kwargs[
'CaloTopoIsolationTool'] = cisoTool
111 if flags.Reco.EnablePFlow
and 'PFlowIsolationTool' not in kwargs:
113 [ isoPar.neflowisol20, isoPar.neflowisol30, isoPar.neflowisol40 ])
114 isoCor.append([ isoPar.coreCone, isoPar.pileupCorrection ])
117 if flags.HeavyIon.Egamma.doSubtractedClusters:
118 isoCor[-1] = [ x
for x
in isoCor[-1]
if x != isoPar.pileupCorrection ]
120 kwargs[
'PFlowIsolationTool'] = cisoTool
122 kwargs[
'MuIsoTypes'] = isoType
123 kwargs[
'MuCorTypes'] = isoCor
124 kwargs[
'MuCorTypesExtra'] = isoExCor
125 kwargs[
'name'] =
'muonIsolationBuilder'
127 acc.addEventAlgo(CompFactory.IsolationBuilder(**kwargs))
129 mlog.info(
"muon isolation configured")
134 if __name__ ==
"__main__":
135 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
136 from AthenaConfiguration.ComponentAccumulator
import printProperties
137 from AthenaConfiguration.TestDefaults
import defaultTestFiles
138 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
140 flags.Input.Files = defaultTestFiles.RDO_RUN2
141 flags.Output.doWriteESD =
True
142 flags.Output.doWriteAOD =
True
145 mlog = logging.getLogger(
"isolationConfigTest")
146 mlog.info(
"Configuring photon isolation: ")
153 acc.getEventAlgo(
"photonIsolationBuilder"),
157 acc.getEventAlgo(
"electronIsolationBuilder"),
161 acc.getEventAlgo(
"muonIsolationBuilder"),
165 with open(
"isolationconfig.pkl",
"wb")
as f: