ATLAS Offline Software
IsolationSelectionConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 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, **kwargs):
56 
57  result = ComponentAccumulator()
58  # Check for LLP1 to use different selection decorators
59  isLLP1 = suff == "_LLP1"
60 
61  # Configure the CloseBy isolation correction alg - only need two WPs each for all iso variables
62  elIsoWPs = [ "Loose_VarRad", "TightTrackOnly_FixedRad" ]
63  muIsoWPs = [ "PflowLoose_VarRad", "Loose_VarRad" ]
64  phIsoWPs = [ "FixedCutLoose", "TightCaloOnly" ]
65 
66  isoTool = result.popToolsAndMerge( IsolationSelectionToolCfg( flags,
67  ElectronWPVec = elIsoWPs,
68  MuonWPVec = muIsoWPs,
69  PhotonWPVec = phIsoWPs))
70  # Set suffix for writing corrected isolation values
71  isoDecSuffix = "CloseByCorr"
72  selectionDecorator = "isoSelIsOK"
73  kwargs.setdefault("IsoCloseByCorrectionTool",
74  result.popToolsAndMerge(IsoCloseByCorrectionToolCfg(flags,
75  IsolationSelectionTool = isoTool,
76  SelectionDecorator = selectionDecorator,
77  IsoDecSuffix = isoDecSuffix,
78  EleContainers = [ x for x in containerNames if x.find("Ele") != -1],
79  MuoContainers = [ x for x in containerNames if x.find("Muo") != -1],
80  PhoContainers = [ x for x in containerNames if x.find("Pho") != -1])))
81 
82  # Need muon selection tool to apply Loose - no pt cuts
83  from MuonSelectorTools.MuonSelectorToolsConfig import MuonSelectionToolCfg
84  kwargs.setdefault("MuonSelectionTool", result.popToolsAndMerge(MuonSelectionToolCfg(flags,
85  MaxEta = 2.7,
86  DisablePtCuts = True,
87  MuQuality = 2,
88  )))
89 
90  # Define selectors for electron and photon - different for LLP1 as compared to PHYS and PHYSLITE
91  if isLLP1:
92  kwargs.setdefault("ElecSelectionKey", "Electrons.DFCommonElectronsLHVeryLooseNoPix")
93  kwargs.setdefault("PhotSelectionKey", "Photons.DFCommonPhotonsIsEMMedium")
94  else:
95  kwargs.setdefault("ElecSelectionKey", "Electrons.DFCommonElectronsLHVeryLoose")
96  kwargs.setdefault("PhotSelectionKey", "Photons.DFCommonPhotonsIsEMLoose")
97 
98  # Set selection for muons, electrons and photons to contribute to overlap
99  kwargs.setdefault("ParticleContainerKeys", containerNames)
100 
101  # No default pt cuts for the moment
102  kwargs.setdefault("MinElecPt", 0.)
103  kwargs.setdefault("MinMuonPt", 0.)
104  kwargs.setdefault("MinPhotPt", 0.)
105 
106 
107  the_alg = CompFactory.CP.IsoCloseByCorrectionAlg(name + suff, **kwargs)
108  result.addEventAlgo(the_alg)
109  return result
110 
111 def IsoCloseByCaloDecorCfg(flags, name="IsoCloseByCaloDecor", suff = "", containers =[], **kwargs):
112  result = ComponentAccumulator()
113 
115  kwargs.setdefault("IsoCloseByCorrectionTool", result.popToolsAndMerge(
117  CaloCorrectionModel = -1
118  )))
119  for cont in containers:
120  result.addEventAlgo(CompFactory.CP.IsoCloseByCaloDecorAlg(name = name + cont + suff,
121  PrimaryContainer = cont,
122  **kwargs))
123  return result
124 
125 def TestIsoCloseByCorrectionCfg(flags, name="TestIsoCloseByAlg", suff = "", **kwargs):
126  result = ComponentAccumulator()
127  from ElectronPhotonSelectorTools.AsgElectronLikelihoodToolsConfig import AsgElectronLikelihoodToolCfg
128  from ElectronPhotonSelectorTools.ElectronLikelihoodToolMapping import electronLHmenu
129  from ElectronPhotonSelectorTools.LikelihoodEnums import LikeEnum
130  from AthenaConfiguration.Enums import LHCPeriod
131  kwargs.setdefault("ElectronSelectionTool", result.popToolsAndMerge(AsgElectronLikelihoodToolCfg(flags,
132  name= "ElectronSelTool",
133  quality = LikeEnum.VeryLoose,
134  menu=electronLHmenu.offlineMC21 if flags.GeoModel.Run >= LHCPeriod.Run3 else electronLHmenu.offlineMC20)))
135 
136  from MuonSelectorTools.MuonSelectorToolsConfig import MuonSelectionToolCfg
137  kwargs.setdefault("MuonSelectionTool", result.popToolsAndMerge(MuonSelectionToolCfg(flags,
138  MaxEta=2.7,
139  DisablePtCuts=True,
140  MuQuality=2,
141  )))
142  the_alg = CompFactory.CP.TestIsolationCloseByCorrAlg(name + suff, **kwargs)
143  result.addEventAlgo(the_alg, primary = True)
144  return result
145 
146 def IsoCloseByAlgsCfg(flags, suff = "", isPhysLite = False, containerNames = [ "Muons", "Electrons", "Photons"], stream_name="", ttva_wp = "Nonprompt_All_MaxWeight", useSelTools = False):
147 
148  # Add in two ways to do IsoCloseBy correction:
149  # - use IsoCloseByCorrAlg to modify the <iso_value>s for close by lepton/photon.
150  # These can be used directly reading a derivation.
151  # - Also add in extra information to run IsolationCloseByTool on the derivation
152  # For closeByIso correction, only one way is needed. The other way can be a cross check.
153  # The second way will be eventually depricated and is not used for PhysLite to minimize the
154  # information on PhysLite.
155  acc = ComponentAccumulator()
156 
157  # REMOVING THE FOLLOWING UNTIL THE CLASH BETWEEN THESE ALGS AND THE CLOSEBY CORRECTION IS FIXED
158  # ## Temporarily comment out for parent/child augmentation tests
159  # # Add additional information to derivation output to be able to run IsoCloseByCorrectionTool on it
160  # if not isPhysLite:
161  # from IsolationSelection.IsolationSelectionConfig import IsoCloseByCorrSkimmingAlgCfg, IsoCloseByCaloDecorCfg
162  # ### Add the tracks that potentially polute the isolation cones of others to the collection.
163  # ### Question: Is the list of recommended TTVA working points used for isolation available somewhere?
164  # acc.merge(IsoCloseByCorrSkimmingAlgCfg(flags, suff = suff, ttva_wp = "Nonprompt_All_MaxWeight",
165  # OutputStream = stream_name))
166 
167  # ### Associate the close-by pflow objects and the calorimeter clusters
168  # acc.merge(IsoCloseByCaloDecorCfg(flags, suff = suff,
169  # containers = containerNames ))
170 
171  # Setup the isolation close-by correction algorithm sequence to correct the isolation of near-by el, mu, ph
172  from IsolationSelection.IsolationSelectionConfig import IsoCloseByCorrAlgCfg
173  acc.merge(IsoCloseByCorrAlgCfg(flags, suff = suff, isPhysLite = isPhysLite, containerNames = containerNames, useSelTools = useSelTools))
174 
175 
176  return acc
177 
178 def setupIsoCloseBySlimmingVariables(slimmingHelper, isLLP1 = False):
179 
180 
182  iso_corr_vars = [ "IsoCloseByCorr_assocClustEta", "IsoCloseByCorr_assocClustPhi", "IsoCloseByCorr_assocClustEnergy",
183  "IsoCloseByCorr_assocClustDecor", "IsoCloseByCorr_assocPflowEta", "IsoCloseByCorr_assocPflowPhi", "IsoCloseByCorr_assocPflowEnergy",
184  "IsoCloseByCorr_assocPflowDecor"]
185 
186  if isLLP1:
187  slimmingHelper.ExtraVariables += ["Electrons."+(".".join(iso_corr_vars)),
188  "LRTElectrons."+(".".join(iso_corr_vars)),
189  "Muons."+(".".join(iso_corr_vars)),
190  "MuonsLRT."+(".".join(iso_corr_vars)) ]
191  else:
192  slimmingHelper.ExtraVariables += ["Electrons."+(".".join(iso_corr_vars)),
193  "Muons."+(".".join(iso_corr_vars)) ]
IsolationSelectionConfig.IsoCloseByCorrAlgCfg
def IsoCloseByCorrAlgCfg(flags, name="IsoCloseByCorrAlg", suff="", isPhysLite=False, containerNames=["Muons", "Electrons", "Photons"], useSelTools=False, **kwargs)
Definition: IsolationSelectionConfig.py:55
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
IsolationSelectionConfig.TestIsoCloseByCorrectionCfg
def TestIsoCloseByCorrectionCfg(flags, name="TestIsoCloseByAlg", suff="", **kwargs)
Definition: IsolationSelectionConfig.py:125
IsolationSelectionConfig.setupIsoCloseBySlimmingVariables
def setupIsoCloseBySlimmingVariables(slimmingHelper, isLLP1=False)
Definition: IsolationSelectionConfig.py:178
IsolationSelectionConfig.IsoCloseByAlgsCfg
def IsoCloseByAlgsCfg(flags, suff="", isPhysLite=False, containerNames=["Muons", "Electrons", "Photons"], stream_name="", ttva_wp="Nonprompt_All_MaxWeight", useSelTools=False)
Definition: IsolationSelectionConfig.py:146
python.AsgElectronLikelihoodToolsConfig.AsgElectronLikelihoodToolCfg
def AsgElectronLikelihoodToolCfg(flag, name, quality, menu=electronLHmenu.offlineMC21)
Definition: AsgElectronLikelihoodToolsConfig.py:13
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:111
TrackToCaloConfig.ParticleCaloExtensionToolCfg
def ParticleCaloExtensionToolCfg(flags, name='ParticleCaloExtensionTool', **kwargs)
Definition: TrackToCaloConfig.py:10
TrackVertexAssociationToolConfig.isoTTVAToolCfg
def isoTTVAToolCfg(flags, name="ttvaToolForIso", **kwargs)
Definition: TrackVertexAssociationToolConfig.py:36