4 Instantiate more custom track isolation in derivation
7 from AthenaCommon.Logging
import logging
8 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory
import CompFactory
13 mlog = logging.getLogger(
'DerivationTrackIsoConfig')
14 mlog.info(
'Starting track isolation for derivation')
18 from xAODPrimitives.xAODIso
import xAODIso
as isoPar
20 ptcone_list = [ [ isoPar.ptcone40, isoPar.ptcone30, isoPar.ptcone20 ] ]
21 trkcor_list = [ [ isoPar.coreTrackPtr ] ]
23 if 'object_types' not in jwarg:
24 object_types = (
"Electrons",
"Photons",
"Muons")
26 object_types = jwarg[
'object_types']
29 WP =
'Nonprompt_All_MaxWeight'
34 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig
import isoTTVAToolCfg
35 ttvaCA = acc.popToolsAndMerge(
39 if 'postfix' in jwarg:
40 postfix = jwarg[
'postfix']
42 if 'ptCuts' not in jwarg:
45 ptCuts = jwarg[
'ptCuts']
47 do_egamma = any(x
in object_types
for x
in (
"Electrons",
"Photons"))
49 mlog.info(
'will isolate objects '+
" ".
join(object_types)+
' with TTVA WP = '+WP)
51 for track_pt
in ptCuts:
52 for loose_cone
in (
True,
False):
53 if loose_cone
and not do_egamma:
57 cone_str =
"LooseCone" if loose_cone
else ""
60 name = f
"{WP}TTVA{cone_str}_pt{track_pt}"
64 if "Electrons" in object_types:
65 kwargs[
"ElIsoTypes"] = ptcone_list
66 kwargs[
"ElCorTypes"] = trkcor_list
67 kwargs[
"ElCorTypesExtra"] = [[]]
68 kwargs[
"CustomConfigurationNameEl"] = name
69 if "Electrons" in object_types
and "LRT" in postfix:
70 kwargs[
"ElectronCollectionContainerName"] =
"LRTElectrons"
71 if "Photons" in object_types:
72 kwargs[
"PhIsoTypes"] = ptcone_list
73 kwargs[
"PhCorTypes"] = trkcor_list
74 kwargs[
"PhCorTypesExtra"] = [[]]
75 kwargs[
"CustomConfigurationNamePh"] = name
76 if "Muons" in object_types
and not loose_cone:
77 kwargs[
"MuIsoTypes"] = ptcone_list
78 kwargs[
"MuCorTypes"] = trkcor_list
79 kwargs[
"MuCorTypesExtra"] = [[]]
80 kwargs[
"CustomConfigurationNameMu"] = name
81 if "Muons" in object_types
and not loose_cone
and "LRT" in postfix:
82 kwargs[
"MuonCollectionContainerName"] =
"MuonsLRT"
88 toolkwargs[
'TTVATool'] = ttvaCA
91 from InDetConfig.InDetTrackSelectionToolConfig
import (
92 isoTrackSelectionToolCfg )
93 toolkwargs[
'TrackSelectionTool'] = acc.popToolsAndMerge(
97 toolkwargs[
'CoreTrackEtaRange'] = 0.01
99 from IsolationAlgs.IsoToolsConfig
import TrackIsolationToolCfg
100 kwargs[
'TrackIsolationTool'] = acc.popToolsAndMerge(
104 kwargs[
'name'] = f
"IsolationBuilder{WP}{cone_str}{track_pt}{postfix}"
105 acc.addEventAlgo(CompFactory.IsolationBuilder(**kwargs))
112 for track_pt
in 500, 1000:
113 for cone_str
in "",
"LooseCone":
114 name = f
"{WP}TTVA{cone_str}_pt{track_pt}"
115 iso_vars += [
"ptconeCorrBitset_"+name,
116 "ptconecoreTrackPtrCorrection_"+name ]
117 for cone_size
in 20, 30, 40:
118 for var_str
in "",
"var":
119 iso_vars.append(f
"pt{var_str}cone{cone_size}_{name}")
122 if __name__ ==
"__main__":
123 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
124 from AthenaConfiguration.ComponentAccumulator
import printProperties
125 from AthenaConfiguration.TestDefaults
import defaultTestFiles
126 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
128 flags.Input.Files = defaultTestFiles.RDO_RUN2
129 flags.Output.doWriteESD =
True
130 flags.Output.doWriteAOD =
True
133 mlog = logging.getLogger(
"derivationTrackIsolationConfigTest")
134 mlog.info(
"Configuring derivation track isolation: ")
139 for par
in (
'500',
'1000',
'LooseCone1000'):
140 print(
'------ Config for ',par,
' ----------')
141 name =
"IsolationBuilderNonprompt_All_MaxWeight"+par
143 acc.getEventAlgo(name),