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