ATLAS Offline Software
InDetSelectionConfig.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 '''@file InDetSelectionConfig.py
6 @author M. Aparo
7 @date 02-10-2023
8 @brief CA-based python configurations for selection tools in this package
9 '''
10 
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 
14 
15 def RoiSelectionToolCfg( flags, name="RoiSelectionTool", **kwargs ) :
16  '''
17  CA-based configuration for the Tool to retrieve and select RoIs
18  '''
19  acc = ComponentAccumulator()
20 
21  kwargs.setdefault( "RoiKey", flags.PhysVal.IDTPM.currentTrkAna.RoiKey )
22  kwargs.setdefault( "ChainLeg", flags.PhysVal.IDTPM.currentTrkAna.ChainLeg )
23  kwargs.setdefault( "doTagNProbe", flags.PhysVal.IDTPM.currentTrkAna.doTagNProbe )
24  kwargs.setdefault( "RoiKeyTag", flags.PhysVal.IDTPM.currentTrkAna.RoiKeyTag )
25  kwargs.setdefault( "ChainLegTag", flags.PhysVal.IDTPM.currentTrkAna.ChainLegTag )
26  kwargs.setdefault( "RoiKeyProbe", flags.PhysVal.IDTPM.currentTrkAna.RoiKeyProbe )
27  kwargs.setdefault( "ChainLegProbe", flags.PhysVal.IDTPM.currentTrkAna.ChainLegProbe )
28 
29  acc.setPrivateTools( CompFactory.IDTPM.RoiSelectionTool( name, **kwargs ) )
30  return acc
31 
32 
33 def TrackRoiSelectionToolCfg( flags, name="TrackRoiSelectionTool", **kwargs ):
34  acc = ComponentAccumulator()
35 
36  kwargs.setdefault( "TriggerTrkParticleContainerName",
37  flags.PhysVal.IDTPM.currentTrkAna.TrigTrkKey )
38 
39  acc.setPrivateTools( CompFactory.IDTPM.TrackRoiSelectionTool( name, **kwargs ) )
40  return acc
41 
42 
43 def VertexRoiSelectionToolCfg( flags, name="VertexRoiSelectionTool", **kwargs ):
44  acc = ComponentAccumulator()
45 
46  kwargs.setdefault( "TriggerVertexContainerName",
47  flags.PhysVal.IDTPM.currentTrkAna.TrigVtxKey )
48 
49  acc.setPrivateTools( CompFactory.IDTPM.VertexRoiSelectionTool( name, **kwargs ) )
50  return acc
51 
52 
53 def TrackObjectSelectionToolCfg( flags, name="TrackObjectSelectionTool", **kwargs ):
54  acc = ComponentAccumulator()
55 
56  objStr = flags.PhysVal.IDTPM.currentTrkAna.SelectOfflineObject
57  kwargs.setdefault( "ObjectType", objStr )
58  kwargs.setdefault( "ObjectQuality", flags.PhysVal.IDTPM.currentTrkAna.ObjectQuality )
59 
60  if "Tau" in objStr:
61  kwargs.setdefault( "TauType", flags.PhysVal.IDTPM.currentTrkAna.TauType )
62  kwargs.setdefault( "TauNprongs", flags.PhysVal.IDTPM.currentTrkAna.TauNprongs )
63 
64  if "Truth" in objStr:
65  kwargs.setdefault( "MatchingTruthProb", flags.PhysVal.IDTPM.currentTrkAna.TruthProbMin )
66 
67  acc.setPrivateTools( CompFactory.IDTPM.TrackObjectSelectionTool( name, **kwargs ) )
68  return acc
69 
70 def OfflineQualitySelectionCfg( flags, name="OfflineSelectionTool", **kwargs ) :
71  acc = ComponentAccumulator()
72 
73  kwargs_InDetTrackSelectionTool = {}
74 
75  if flags.PhysVal.IDTPM.currentTrkAna.offlMinPt!=-9999.:
76  kwargs_InDetTrackSelectionTool.setdefault( "minPt", flags.PhysVal.IDTPM.currentTrkAna.offlMinPt )
77  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxAbsEta!=-9999.:
78  kwargs_InDetTrackSelectionTool.setdefault( "maxAbsEta", flags.PhysVal.IDTPM.currentTrkAna.offlMaxAbsEta )
79  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxZ0SinTheta!=-9999.:
80  kwargs_InDetTrackSelectionTool.setdefault( "maxZ0SinTheta", flags.PhysVal.IDTPM.currentTrkAna.offlMaxZ0SinTheta )
81  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxZ0!=-9999.:
82  kwargs_InDetTrackSelectionTool.setdefault( "maxZ0", flags.PhysVal.IDTPM.currentTrkAna.offlMaxZ0 )
83  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxD0!=-9999.:
84  kwargs_InDetTrackSelectionTool.setdefault( "maxD0", flags.PhysVal.IDTPM.currentTrkAna.offlMaxD0 )
85  if flags.PhysVal.IDTPM.currentTrkAna.offlMinNInnermostLayerHits!=-9999.:
86  kwargs_InDetTrackSelectionTool.setdefault( "minNInnermostLayerHits", flags.PhysVal.IDTPM.currentTrkAna.offlMinNInnermostLayerHits )
87  if flags.PhysVal.IDTPM.currentTrkAna.offlMinNBothInnermostLayersHits!=-9999.:
88  kwargs_InDetTrackSelectionTool.setdefault( "minNBothInnermostLayersHits", flags.PhysVal.IDTPM.currentTrkAna.offlMinNBothInnermostLayersHits )
89  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxNInnermostLayerSharedHits!=-9999.:
90  kwargs_InDetTrackSelectionTool.setdefault( "maxNInnermostLayerSharedHits", flags.PhysVal.IDTPM.currentTrkAna.offlMaxNInnermostLayerSharedHits )
91  if flags.PhysVal.IDTPM.currentTrkAna.offlMinNSiHits!=-9999.:
92  kwargs_InDetTrackSelectionTool.setdefault( "minNSiHits", flags.PhysVal.IDTPM.currentTrkAna.offlMinNSiHits )
93  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxNSiSharedHits!=-9999.:
94  kwargs_InDetTrackSelectionTool.setdefault( "maxNSiSharedHits", flags.PhysVal.IDTPM.currentTrkAna.offlMaxNSiSharedHits )
95  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxNSiHoles!=-9999.:
96  kwargs_InDetTrackSelectionTool.setdefault( "maxNSiHoles", flags.PhysVal.IDTPM.currentTrkAna.offlMaxNSiHoles )
97  if flags.PhysVal.IDTPM.currentTrkAna.offlMinNPixelHits!=-9999.:
98  kwargs_InDetTrackSelectionTool.setdefault( "minNPixelHits", flags.PhysVal.IDTPM.currentTrkAna.offlMinNPixelHits )
99  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxNPixelSharedHits!=-9999.:
100  kwargs_InDetTrackSelectionTool.setdefault( "maxNPixelSharedHits", flags.PhysVal.IDTPM.currentTrkAna.offlMaxNPixelSharedHits )
101  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxNPixelHoles!=-9999.:
102  kwargs_InDetTrackSelectionTool.setdefault( "maxNPixelHoles", flags.PhysVal.IDTPM.currentTrkAna.offlMaxNPixelHoles )
103  if flags.PhysVal.IDTPM.currentTrkAna.offlMinNSctHits!=-9999.:
104  kwargs_InDetTrackSelectionTool.setdefault( "minNSctHits", flags.PhysVal.IDTPM.currentTrkAna.offlMinNSctHits )
105  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxNSctSharedHits!=-9999.:
106  kwargs_InDetTrackSelectionTool.setdefault( "maxNSctSharedHits", flags.PhysVal.IDTPM.currentTrkAna.offlMaxNSctSharedHits )
107  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxNSctHoles!=-9999.:
108  kwargs_InDetTrackSelectionTool.setdefault( "maxNSctHoles", flags.PhysVal.IDTPM.currentTrkAna.offlMaxChiSq )
109  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxChiSq!=-9999.:
110  kwargs_InDetTrackSelectionTool.setdefault( "maxChiSq", flags.PhysVal.IDTPM.currentTrkAna.offlMaxAbsEta )
111  if flags.PhysVal.IDTPM.currentTrkAna.offlMaxChiSqperNdf!=-9999.:
112  kwargs_InDetTrackSelectionTool.setdefault( "maxChiSqperNdf", flags.PhysVal.IDTPM.currentTrkAna.offlMaxChiSqperNdf )
113  if flags.PhysVal.IDTPM.currentTrkAna.offlMinProb!=-9999.:
114  kwargs_InDetTrackSelectionTool.setdefault( "minProb", flags.PhysVal.IDTPM.currentTrkAna.offlMinProb )
115  kwargs_InDetTrackSelectionTool.setdefault( "CutLevel", flags.PhysVal.IDTPM.currentTrkAna.OfflineQualityWP )
116 
117  from InDetConfig.InDetTrackSelectionToolConfig import InDetTrackSelectionToolCfg
118  offlineSelectionTool = acc.popToolsAndMerge( InDetTrackSelectionToolCfg( flags, **kwargs_InDetTrackSelectionTool) )
119 
120  kwargs.setdefault( "offlineTool", offlineSelectionTool )
121  kwargs.setdefault( "maxPt", flags.PhysVal.IDTPM.currentTrkAna.offlMaxPt )
122  kwargs.setdefault( "minEta", flags.PhysVal.IDTPM.currentTrkAna.offlMinEta )
123  kwargs.setdefault( "minPhi", flags.PhysVal.IDTPM.currentTrkAna.offlMinPhi )
124  kwargs.setdefault( "maxPhi", flags.PhysVal.IDTPM.currentTrkAna.offlMaxPhi )
125  kwargs.setdefault( "minD0", flags.PhysVal.IDTPM.currentTrkAna.offlMinD0 )
126  kwargs.setdefault( "minZ0", flags.PhysVal.IDTPM.currentTrkAna.offlMinZ0 )
127  kwargs.setdefault( "minQoPT", flags.PhysVal.IDTPM.currentTrkAna.offlMinQoPT )
128  kwargs.setdefault( "maxQoPT", flags.PhysVal.IDTPM.currentTrkAna.offlMaxQoPT )
129  kwargs.setdefault( "minAbsEta", flags.PhysVal.IDTPM.currentTrkAna.offlMinAbsEta )
130  kwargs.setdefault( "minAbsPhi", flags.PhysVal.IDTPM.currentTrkAna.offlMinAbsPhi )
131  kwargs.setdefault( "maxAbsPhi", flags.PhysVal.IDTPM.currentTrkAna.offlMaxAbsPhi )
132  kwargs.setdefault( "minAbsD0", flags.PhysVal.IDTPM.currentTrkAna.offlMinAbsD0 )
133  kwargs.setdefault( "maxAbsD0", flags.PhysVal.IDTPM.currentTrkAna.offlMaxAbsD0 )
134  kwargs.setdefault( "minAbsZ0", flags.PhysVal.IDTPM.currentTrkAna.offlMinAbsZ0 )
135  kwargs.setdefault( "maxAbsZ0", flags.PhysVal.IDTPM.currentTrkAna.offlMaxAbsZ0 )
136  kwargs.setdefault( "minAbsQoPT", flags.PhysVal.IDTPM.currentTrkAna.offlMinAbsQoPT )
137  kwargs.setdefault( "maxAbsQoPT", flags.PhysVal.IDTPM.currentTrkAna.offlMaxAbsQoPT )
138 
139  acc.setPrivateTools( CompFactory.IDTPM.OfflineTrackQualitySelectionTool( name, **kwargs ) )
140 
141  return acc
142 
143 
144 def TruthQualitySelectionToolCfg( flags, name="TruthQualitySelectionTool", **kwargs ) :
145  acc = ComponentAccumulator()
146 
147  # Default configurations
148  # ----------------------
149  truthMinPt = flags.PhysVal.IDTPM.currentTrkAna.truthMinPt
150  truthMaxPt = flags.PhysVal.IDTPM.currentTrkAna.truthMaxPt
151  truthPdgId = flags.PhysVal.IDTPM.currentTrkAna.truthPdgId
152  truthIsHadron = flags.PhysVal.IDTPM.currentTrkAna.truthIsHadron
153  truthIsPion = flags.PhysVal.IDTPM.currentTrkAna.truthIsPion
154 
155  if "Muon" in flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject:
156  truthPdgId = 13
157  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "highPTMuon":
158  truthMinPt = 10000
159  truthMaxPt = -9999.
160  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "lowPTMuon":
161  truthMinPt = 1000
162  truthMaxPt = 10000
163 
164  elif "Hadron" in flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject:
165  truthIsHadron = True
166  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "highPTHadron":
167  truthMinPt = 10000
168  truthMaxPt = -9999.
169  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "lowPTHadron":
170  truthMinPt = 1000
171  truthMaxPt = 10000
172 
173  elif "Pion" in flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject:
174  truthIsPion = True
175  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "highPTPion":
176  truthMinPt = 10000
177  truthMaxPt = -9999.
178  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "lowPTHadron":
179  truthMinPt = 1000
180  truthMaxPt = 10000
181 
182  elif "Electron" in flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject:
183  truthPdgId = 11
184  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "highPTElectron":
185  truthMinPt = 20000
186  truthMaxPt = -9999.
187  if flags.PhysVal.IDTPM.currentTrkAna.SelectTruthObject == "lowPTElectron":
188  truthMinPt = 10000
189  truthMaxPt = 20000
190 
191 
192  # InDetRttTruthSelectionTool properties
193  # -------------------------------------
194  kwargs_InDetRttTruthSelectionTool = {}
195  if truthMinPt!=-9999.: kwargs_InDetRttTruthSelectionTool.setdefault( "minPt", truthMinPt )
196  if truthMaxPt!=-9999.: kwargs_InDetRttTruthSelectionTool.setdefault( "maxPt", truthMaxPt )
197  if flags.PhysVal.IDTPM.currentTrkAna.truthMaxAbsEta!=-9999.: kwargs_InDetRttTruthSelectionTool.setdefault( "maxEta", flags.PhysVal.IDTPM.currentTrkAna.truthMaxAbsEta )
198  if truthPdgId!=-9999.: kwargs_InDetRttTruthSelectionTool.setdefault( "pdgId", truthPdgId )
199 
200  from InDetPhysValMonitoring.InDetPhysValMonitoringConfig import InDetRttTruthSelectionToolCfg
201  truthSelectionTool = acc.popToolsAndMerge(InDetRttTruthSelectionToolCfg(flags, **kwargs_InDetRttTruthSelectionTool))
202 
203  # Additional properties
204  # ---------------------
205  kwargs.setdefault( "truthTool" , truthSelectionTool)
206  kwargs.setdefault( "maxEta", flags.PhysVal.IDTPM.currentTrkAna.truthMaxEta )
207  kwargs.setdefault( "minEta", flags.PhysVal.IDTPM.currentTrkAna.truthMinEta )
208  kwargs.setdefault( "minPhi", flags.PhysVal.IDTPM.currentTrkAna.truthMinPhi )
209  kwargs.setdefault( "maxPhi", flags.PhysVal.IDTPM.currentTrkAna.truthMaxPhi )
210  kwargs.setdefault( "minD0", flags.PhysVal.IDTPM.currentTrkAna.truthMinD0 )
211  kwargs.setdefault( "maxD0", flags.PhysVal.IDTPM.currentTrkAna.truthMaxD0 )
212  kwargs.setdefault( "minZ0", flags.PhysVal.IDTPM.currentTrkAna.truthMinZ0 )
213  kwargs.setdefault( "maxZ0", flags.PhysVal.IDTPM.currentTrkAna.truthMaxZ0 )
214  kwargs.setdefault( "minQoPT", flags.PhysVal.IDTPM.currentTrkAna.truthMinQoPT )
215  kwargs.setdefault( "maxQoPT", flags.PhysVal.IDTPM.currentTrkAna.truthMaxQoPT )
216  kwargs.setdefault( "isHadron", truthIsHadron )
217  kwargs.setdefault( "isPion", truthIsPion )
218  kwargs.setdefault( "minAbsEta", flags.PhysVal.IDTPM.currentTrkAna.truthMinAbsEta )
219  kwargs.setdefault( "minAbsPhi", flags.PhysVal.IDTPM.currentTrkAna.truthMinAbsPhi )
220  kwargs.setdefault( "maxAbsPhi", flags.PhysVal.IDTPM.currentTrkAna.truthMaxAbsPhi )
221  kwargs.setdefault( "minAbsD0", flags.PhysVal.IDTPM.currentTrkAna.truthMinAbsD0 )
222  kwargs.setdefault( "maxAbsD0", flags.PhysVal.IDTPM.currentTrkAna.truthMaxAbsD0 )
223  kwargs.setdefault( "minAbsZ0", flags.PhysVal.IDTPM.currentTrkAna.truthMinAbsZ0 )
224  kwargs.setdefault( "maxAbsZ0", flags.PhysVal.IDTPM.currentTrkAna.truthMaxAbsZ0 )
225  kwargs.setdefault( "minAbsQoPT", flags.PhysVal.IDTPM.currentTrkAna.truthMinAbsQoPT )
226  kwargs.setdefault( "maxAbsQoPT", flags.PhysVal.IDTPM.currentTrkAna.truthMaxAbsQoPT )
227 
228  acc.setPrivateTools( CompFactory.IDTPM.TruthQualitySelectionTool( name, **kwargs ) )
229 
230  return acc
231 
232 
233 def TrackQualitySelectionToolCfg( flags, name="TrackQualitySelectionTool", **kwargs ):
234  acc = ComponentAccumulator()
235 
236 
237  if flags.PhysVal.IDTPM.currentTrkAna.OfflineQualityWP != "" or flags.PhysVal.IDTPM.currentTrkAna.DoOfflineSelection:
238  kwargs.setdefault( "DoOfflineSelection", True )
239 
240  kwargs.setdefault( "OfflineSelectionTool", acc.popToolsAndMerge(
241  OfflineQualitySelectionCfg( flags, name="OfflineSelectionTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
242 
243 
244  if flags.Input.isMC:
245  kwargs.setdefault( "DoTruthSelection", True )
246 
247  kwargs.setdefault( "TruthSelectionTool", acc.popToolsAndMerge(
248  TruthQualitySelectionToolCfg( flags, name="TruthQualitySelectionTool"+flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
249 
250 
251  if flags.PhysVal.IDTPM.currentTrkAna.SelectOfflineObject != "":
252  kwargs.setdefault( "DoObjectSelection", True )
253 
254  if "TrackObjectSelectionTool" not in kwargs:
255  kwargs.setdefault( "TrackObjectSelectionTool", acc.popToolsAndMerge(
257  name="TrackObjectSelectionTool" + flags.PhysVal.IDTPM.currentTrkAna.anaTag ) ) )
258 
259  acc.setPrivateTools( CompFactory.IDTPM.TrackQualitySelectionTool( name, **kwargs ) )
260  return acc
261 
262 
263 def VertexQualitySelectionToolCfg( flags, name="VertexQualitySelectionTool", **kwargs ):
264  acc = ComponentAccumulator()
265 
266 
267 
268  acc.setPrivateTools( CompFactory.IDTPM.VertexQualitySelectionTool( name, **kwargs ) )
269  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
InDetSelectionConfig.TrackObjectSelectionToolCfg
def TrackObjectSelectionToolCfg(flags, name="TrackObjectSelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:53
InDetSelectionConfig.TruthQualitySelectionToolCfg
def TruthQualitySelectionToolCfg(flags, name="TruthQualitySelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:144
InDetSelectionConfig.VertexRoiSelectionToolCfg
def VertexRoiSelectionToolCfg(flags, name="VertexRoiSelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:43
InDetSelectionConfig.OfflineQualitySelectionCfg
def OfflineQualitySelectionCfg(flags, name="OfflineSelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:70
InDetSelectionConfig.TrackRoiSelectionToolCfg
def TrackRoiSelectionToolCfg(flags, name="TrackRoiSelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:33
python.InDetTrackSelectionToolConfig.InDetTrackSelectionToolCfg
def InDetTrackSelectionToolCfg(flags, name="InDetTrackSelectionTool", **kwargs)
Definition: InDetTrackSelectionToolConfig.py:7
InDetPhysValMonitoringConfig.InDetRttTruthSelectionToolCfg
def InDetRttTruthSelectionToolCfg(flags, name="InDetRttTruthSelectionTool", **kwargs)
Definition: InDetPhysValMonitoringConfig.py:38
InDetSelectionConfig.TrackQualitySelectionToolCfg
def TrackQualitySelectionToolCfg(flags, name="TrackQualitySelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:233
InDetSelectionConfig.RoiSelectionToolCfg
def RoiSelectionToolCfg(flags, name="RoiSelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:15
InDetSelectionConfig.VertexQualitySelectionToolCfg
def VertexQualitySelectionToolCfg(flags, name="VertexQualitySelectionTool", **kwargs)
Definition: InDetSelectionConfig.py:263