ATLAS Offline Software
Loading...
Searching...
No Matches
IsolationSelectionConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5
6def IsolationSelectionToolCfg(flags, name="IsolationSelectionTool", **kwargs):
7 acc = ComponentAccumulator()
8 acc.setPrivateTools(CompFactory.CP.IsolationSelectionTool(name, **kwargs))
9 return acc
10
11def MuonPhysValIsolationSelCfg(flags, **kwargs):
12 return IsolationSelectionToolCfg(flags,MuonWP="PflowTight_FixedRad")
13
14def IsoCloseByCorrectionToolCfg(flags, name="IsoCloseByCorrectionTool", ttva_wp = "", **kwargs):
15 acc = ComponentAccumulator()
16 kwargs.setdefault("IsolationSelectionTool", acc.popToolsAndMerge(MuonPhysValIsolationSelCfg(flags)))
17 from InDetTrackSelectionTool.InDetTrackSelectionToolConfig import (
18 isoTrackSelectionToolCfg)
19 kwargs.setdefault("TrackSelectionTool", acc.popToolsAndMerge(isoTrackSelectionToolCfg(flags, minPt=500)) )
20 if len(ttva_wp):
21 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig import isoTTVAToolCfg
22 kwargs.setdefault("TTVASelectionTool", acc.popToolsAndMerge(isoTTVAToolCfg(flags, WorkingPoint = ttva_wp)))
23 from TrackToCalo.TrackToCaloConfig import ParticleCaloExtensionToolCfg
24 kwargs.setdefault("ParticleCaloExtensionTool", acc.popToolsAndMerge(ParticleCaloExtensionToolCfg(flags)))
25 the_tool = CompFactory.CP.IsolationCloseByCorrectionTool(name, **kwargs)
26 acc.setPrivateTools(the_tool)
27 return acc
28
29
30def IsoCloseByCorrSkimmingAlgCfg(flags, suff = "", name="IsoCloseByCorrSkimmingAlg", ttva_wp = 'Nonprompt_All_MaxWeight', **kwargs):
31 result = ComponentAccumulator()
32 from ElectronPhotonSelectorTools.AsgElectronLikelihoodToolsConfig import AsgElectronLikelihoodToolCfg
33 from ElectronPhotonSelectorTools.ElectronLikelihoodToolMapping import electronLHmenu
34 from ElectronPhotonSelectorTools.LikelihoodEnums import LikeEnum
35 from AthenaConfiguration.Enums import LHCPeriod
36 kwargs.setdefault("ElectronSelectionTool", result.popToolsAndMerge(AsgElectronLikelihoodToolCfg(flags,
37 name= "ElectronSelTool",
38 quality = LikeEnum.VeryLoose,
39 menu=electronLHmenu.offlineMC21 if flags.GeoModel.Run >= LHCPeriod.Run3 else electronLHmenu.offlineMC20)))
40
41 from MuonSelectorTools.MuonSelectorToolsConfig import MuonLoosenedNonCalibratedSelectionToolCfg
42 kwargs.setdefault("MuonSelectionTool", result.popToolsAndMerge(MuonLoosenedNonCalibratedSelectionToolCfg(flags,
43 MaxEta=2.7,
44 MuQuality=2,
45 )))
46 kwargs.setdefault("IsoCloseByCorrectionTool", result.popToolsAndMerge(IsoCloseByCorrectionToolCfg(flags)))
47
48
50 kwargs.setdefault("PhotContainer", "")
51 the_alg = CompFactory.CP.IsoCloseByCorrectionTrkSelAlg(name+ttva_wp+suff, **kwargs)
52 result.addEventAlgo(the_alg, primary = True)
53 return result
54
55def IsoCloseByCorrAlgCfg(flags, name="IsoCloseByCorrAlg", suff = "", isPhysLite = False, containerNames = [ "Muons", "Electrons", "Photons"], depContainerNames = None, useSelTools = False, isoDecSuffix = "CloseByCorr", caloDecSuffix = "", hasLRT = False, **kwargs):
56
57 result = ComponentAccumulator()
58
59 # When the client passes *view* container names (e.g. StdWithLRTMuons in DAOD_LLP1),
60 # the dependencies get declared on the view name, which has no
61 # producer visible to the scheduler and leads to crashes in MT when run on a view container
62 # we can declare the dependencies on the underlying container names instead then if needed
63 depNames = depContainerNames if depContainerNames is not None else containerNames
64
65 # Configure the CloseBy isolation correction alg - only need two WPs each for all iso variables
66 elIsoWPs = [ "Loose_VarRad", "TightTrackOnly_FixedRad" ]
67 muIsoWPs = [ "PflowLoose_VarRad", "Loose_VarRad" ]
68 phIsoWPs = [ "FixedCutLoose", "TightCaloOnly" ]
69
70 isoTool = result.popToolsAndMerge( IsolationSelectionToolCfg( flags,
71 ElectronWPVec = elIsoWPs,
72 MuonWPVec = muIsoWPs,
73 PhotonWPVec = phIsoWPs))
74 # Set suffix for writing corrected isolation values
75 selectionDecorator = "isoSelIsOK" + suff
76 kwargs.setdefault("IsoCloseByCorrectionTool",
77 result.popToolsAndMerge(IsoCloseByCorrectionToolCfg(flags,
78 IsolationSelectionTool = isoTool,
79 SelectionDecorator = selectionDecorator,
80 IsoDecSuffix = isoDecSuffix,
81 CaloDecSuffix = caloDecSuffix,
82 EleContainers = [ x for x in depNames if x.find("Ele") != -1],
83 MuoContainers = [ x for x in depNames if x.find("Muo") != -1],
84 PhoContainers = [ x for x in depNames if x.find("Pho") != -1])))
85
86 # Need muon selection tool to apply Loose - no pt cuts
87 from MuonSelectorTools.MuonSelectorToolsConfig import MuonLoosenedNonCalibratedSelectionToolCfg
88 kwargs.setdefault("MuonSelectionTool", result.popToolsAndMerge(MuonLoosenedNonCalibratedSelectionToolCfg(flags,
89 MaxEta = 2.7,
90 MuQuality = 2,
91 UseLRT = hasLRT,
92 )))
93
94 # Define selectors for electron and photon - different for LLP1 as compared to PHYS and PHYSLITE
95 kwargs.setdefault("PhotSelectionKey", "Photons.DFCommonPhotonsIsEMLoose")
96 if hasLRT:
97 kwargs.setdefault("ElecSelectionKey", "Electrons.DFCommonElectronsLHVeryLooseNoPix")
98 else:
99 kwargs.setdefault("ElecSelectionKey", "Electrons.DFCommonElectronsLHVeryLoose")
100
101 # Set selection for muons, electrons and photons to contribute to overlap
102 kwargs.setdefault("ParticleContainerKeys", containerNames)
103
104 # No default pt cuts for the moment
105 kwargs.setdefault("MinElecPt", 0.)
106 kwargs.setdefault("MinMuonPt", 0.)
107 kwargs.setdefault("MinPhotPt", 0.)
108
109
110 the_alg = CompFactory.CP.IsoCloseByCorrectionAlg(name + suff,
111 SelectionDecorator = selectionDecorator,
112 **kwargs)
113 result.addEventAlgo(the_alg)
114 return result
115
116def IsoCloseByCaloDecorCfg(flags, name="IsoCloseByCaloDecor", suff = "", containers =[], **kwargs):
117 result = ComponentAccumulator()
118
120 kwargs.setdefault("IsoCloseByCorrectionTool", result.popToolsAndMerge(
122 CaloCorrectionModel = -1
123 )))
124 for cont in containers:
125 result.addEventAlgo(CompFactory.CP.IsoCloseByCaloDecorAlg(name = name + cont + suff,
126 PrimaryContainer = cont,
127 **kwargs))
128 return result
129
130def TestIsoCloseByCorrectionCfg(flags, name="TestIsoCloseByAlg", suff = "", **kwargs):
131 result = ComponentAccumulator()
132 from ElectronPhotonSelectorTools.AsgElectronLikelihoodToolsConfig import AsgElectronLikelihoodToolCfg
133 from ElectronPhotonSelectorTools.ElectronLikelihoodToolMapping import electronLHmenu
134 from ElectronPhotonSelectorTools.LikelihoodEnums import LikeEnum
135 from AthenaConfiguration.Enums import LHCPeriod
136 kwargs.setdefault("ElectronSelectionTool", result.popToolsAndMerge(AsgElectronLikelihoodToolCfg(flags,
137 name= "ElectronSelTool",
138 quality = LikeEnum.VeryLoose,
139 menu=electronLHmenu.offlineMC21 if flags.GeoModel.Run >= LHCPeriod.Run3 else electronLHmenu.offlineMC20)))
140
141 from MuonSelectorTools.MuonSelectorToolsConfig import MuonLoosenedNonCalibratedSelectionToolCfg
142 kwargs.setdefault("MuonSelectionTool", result.popToolsAndMerge(MuonLoosenedNonCalibratedSelectionToolCfg(flags,
143 MaxEta=2.7,
144 MuQuality=2,
145 )))
146 the_alg = CompFactory.CP.TestIsolationCloseByCorrAlg(name + suff, **kwargs)
147 result.addEventAlgo(the_alg, primary = True)
148 return result
149
150def IsoCloseByAlgsCfg(flags, suff = "", isPhysLite = False, containerNames = [ "Muons", "Electrons", "Photons"], depContainerNames = None, stream_name="", ttva_wp = "Nonprompt_All_MaxWeight", useSelTools = False, isoDecSuffix = "CloseByCorr", caloDecSuffix = "", hasLRT = False):
151
152 # Add in two ways to do IsoCloseBy correction:
153 # - use IsoCloseByCorrAlg to modify the <iso_value>s for close by lepton/photon.
154 # These can be used directly reading a derivation.
155 # - Also add in extra information to run IsolationCloseByTool on the derivation
156 # For closeByIso correction, only one way is needed. The other way can be a cross check.
157 # The second way will be eventually deprecated and is not used for PhysLite to minimize the
158 # information on PhysLite.
159 acc = ComponentAccumulator()
160
161 # REMOVING THE FOLLOWING UNTIL THE CLASH BETWEEN THESE ALGS AND THE CLOSEBY CORRECTION IS FIXED
162 # ## Temporarily comment out for parent/child augmentation tests
163 # # Add additional information to derivation output to be able to run IsoCloseByCorrectionTool on it
164 # if not isPhysLite:
165 # from IsolationSelection.IsolationSelectionConfig import IsoCloseByCorrSkimmingAlgCfg, IsoCloseByCaloDecorCfg
166 # ### Add the tracks that potentially pollute the isolation cones of others to the collection.
167 # ### Question: Is the list of recommended TTVA working points used for isolation available somewhere?
168 # acc.merge(IsoCloseByCorrSkimmingAlgCfg(flags, suff = suff, ttva_wp = "Nonprompt_All_MaxWeight",
169 # OutputStream = stream_name))
170
171 # ### Associate the close-by pflow objects and the calorimeter clusters
172 # acc.merge(IsoCloseByCaloDecorCfg(flags, suff = suff,
173 # containers = containerNames ))
174
175 # Setup the isolation close-by correction algorithm sequence to correct the isolation of near-by el, mu, ph
176 from IsolationSelection.IsolationSelectionConfig import IsoCloseByCorrAlgCfg
177 acc.merge(IsoCloseByCorrAlgCfg(flags, suff = suff, isPhysLite = isPhysLite, containerNames = containerNames, depContainerNames = depContainerNames, useSelTools = useSelTools, isoDecSuffix = isoDecSuffix, caloDecSuffix = caloDecSuffix, hasLRT = hasLRT))
178 return acc
179
180def setupIsoCloseBySlimmingVariables(slimmingHelper, isLLP1 = False):
181
182
184 iso_corr_vars = [ "IsoCloseByCorr_assocClustEta", "IsoCloseByCorr_assocClustPhi", "IsoCloseByCorr_assocClustEnergy",
185 "IsoCloseByCorr_assocClustDecor", "IsoCloseByCorr_assocPflowEta", "IsoCloseByCorr_assocPflowPhi", "IsoCloseByCorr_assocPflowEnergy",
186 "IsoCloseByCorr_assocPflowDecor"]
187
188 if isLLP1:
189 slimmingHelper.ExtraVariables += ["Electrons."+(".".join(iso_corr_vars)),
190 "LRTElectrons."+(".".join(iso_corr_vars)),
191 "Muons."+(".".join(iso_corr_vars)),
192 "MuonsLRT."+(".".join(iso_corr_vars)) ]
193 else:
194 slimmingHelper.ExtraVariables += ["Electrons."+(".".join(iso_corr_vars)),
195 "Muons."+(".".join(iso_corr_vars)) ]
setupIsoCloseBySlimmingVariables(slimmingHelper, isLLP1=False)
IsoCloseByCorrectionToolCfg(flags, name="IsoCloseByCorrectionTool", ttva_wp="", **kwargs)
TestIsoCloseByCorrectionCfg(flags, name="TestIsoCloseByAlg", suff="", **kwargs)
IsoCloseByAlgsCfg(flags, suff="", isPhysLite=False, containerNames=["Muons", "Electrons", "Photons"], depContainerNames=None, stream_name="", ttva_wp="Nonprompt_All_MaxWeight", useSelTools=False, isoDecSuffix="CloseByCorr", caloDecSuffix="", hasLRT=False)
IsoCloseByCorrSkimmingAlgCfg(flags, suff="", name="IsoCloseByCorrSkimmingAlg", ttva_wp='Nonprompt_All_MaxWeight', **kwargs)
IsoCloseByCorrAlgCfg(flags, name="IsoCloseByCorrAlg", suff="", isPhysLite=False, containerNames=["Muons", "Electrons", "Photons"], depContainerNames=None, useSelTools=False, isoDecSuffix="CloseByCorr", caloDecSuffix="", hasLRT=False, **kwargs)
IsoCloseByCaloDecorCfg(flags, name="IsoCloseByCaloDecor", suff="", containers=[], **kwargs)
MuonPhysValIsolationSelCfg(flags, **kwargs)
IsolationSelectionToolCfg(flags, name="IsolationSelectionTool", **kwargs)