ATLAS Offline Software
Loading...
Searching...
No Matches
TrackingAnalysisConfig.InDetTrackWorkingPointConfig Class Reference
Inheritance diagram for TrackingAnalysisConfig.InDetTrackWorkingPointConfig:
Collaboration diagram for TrackingAnalysisConfig.InDetTrackWorkingPointConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 makeAlgs (self, config)

Public Attributes

 additionalCuts
 runTruthFilter
str cutLevel = "Loose":
 fFakeTight
 calibFile
 fFakeLoose
 filterToolSeed
 trkEffSystScale
 containerName
 selectionName

Detailed Description

the ConfigBlock for the track working point

Definition at line 235 of file TrackingAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.__init__ ( self)

Definition at line 238 of file TrackingAnalysisConfig.py.

238 def __init__ (self) :
239 super (InDetTrackWorkingPointConfig, self).__init__ ()
240 self.addOption ('containerName', '', type=str,
241 noneAction='error',
242 info="the name of the input container.")
243 self.addOption ('selectionName', '', type=str,
244 noneAction='error',
245 info="the name of the track selection to define (e.g. `tightPrimary` "
246 "or `loose`).")
247 self.addOption ('postfix', None, type=str,
248 info="a postfix to apply to decorations and algorithm names. "
249 "Typically not needed here as `selectionName` is used internally.")
250 self.addOption ('cutLevel', None, type=str,
251 noneAction='error',
252 info="the selection WP to use. Supported WPs for general "
253 "use: `Loose` and `TightPrimary`. For expert studies, further "
254 "WPs are available: `NoCut`, `LoosePrimary`, `LooseElectron`, "
255 "`LooseMuon`, `LooseTau`, `MinBias`, `HILoose`, `HITight`, "
256 "`HILooseOptimized`, `HITightOptimized`.",
257 expertMode=["NoCut", "LoosePrimary", "LooseElectron",
258 "LooseMuon", "LooseTau", "MinBias", "HILoose", "HITight",
259 "HILooseOptimized", "HITightOptimized"])
260 self.addOption ('additionalCuts', None, type=dict,
261 info="additional cuts to modify the selection WP. Only meant for "
262 "expert studies of track selection. Passed as pairs of `cutName: value`. "
263 "For an overview of available cuts, see twiki.cern.ch/twiki/bin/viewauth/"
264 "AtlasProtected/InDetTrackSelectionTool#List_of_possible_cuts.",
265 expertMode=True)
266 self.addOption ('vertexContainer', None, type=str,
267 info="A vertex collection to be used by the additionalCuts. The leading "
268 "primary vertex is passed to the selectionTool to calculate the distance "
269 "in the maxZ0 cuts.",
270 expertMode=True)
271 self.addOption ('runTruthFilter', True, type=bool,
272 info="whether to run the `TruthFilterTool`. This tool is only compatible "
273 "with the cut levels `Loose` and `TightPrimary`.")
274 self.addOption ('calibFile', None, type=str,
275 info="name of the calibration file to use for efficiencies "
276 "in the `TruthFilter` tool. Expert option to override the "
277 "recommendations based on the campaign.",
278 expertMode=True)
279 self.addOption ('filterToolSeed', None, type=int,
280 info="random seed to be used by the `InDetTrackTruthFilterTool`.",
281 expertMode=True)
282 self.addOption ('fFakeLoose', None, type=float,
283 info="the fraction of fake tracks in the `Loose` working point. "
284 "Will be used by the `InDetTrackTruthFilterTool`. Expert option to "
285 "override the recommendations.",
286 expertMode=True)
287 self.addOption ('fFakeTight', None, type=float,
288 info="the fraction of fake tracks in the `TightPrimary` working "
289 "point. Will be used by the `InDetTrackTruthFilterTool`. Expert option "
290 "to override the recommendations.",
291 expertMode=True)
292 self.addOption ('trkEffSystScale', None, type=float,
293 info="the track efficiency systematic scale. Will be used "
294 "by the `InDetTrackTruthFilterTool`. Expert option to override the "
295 "recommendations.",
296 expertMode=True)
297 self.addOption ('addSelectionToPreselection', True, type=bool,
298 info="whether to retain only tracks satisfying the `cutLevel` "
299 "requirements.")
300

Member Function Documentation

◆ instanceName()

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.instanceName ( self)
Return the instance name for this block

Definition at line 301 of file TrackingAnalysisConfig.py.

301 def instanceName (self) :
302 """Return the instance name for this block"""
303 if self.postfix is not None:
304 return self.containerName + self.selectionName + self.postfix
305 else:
306 return self.containerName + self.selectionName
307

◆ makeAlgs()

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.makeAlgs ( self,
config )

Definition at line 308 of file TrackingAnalysisConfig.py.

308 def makeAlgs (self, config) :
309 log = logging.getLogger('InDetTrackWorkingPointConfig')
310
311 selectionPostfix = self.selectionName
312 if selectionPostfix != '' and selectionPostfix[0] != '_' :
313 selectionPostfix = '_' + selectionPostfix
314
315 postfix = self.postfix
316 if postfix is None :
317 postfix = self.selectionName
318 if postfix != '' and postfix[0] != '_' :
319 postfix = '_' + postfix
320
321 cutLevels = ["NoCut", "Loose", "LoosePrimary", "TightPrimary", "LooseMuon",
322 "LooseElectron", "LooseTau", "MinBias", "HILoose", "HITight",
323 "HILooseOptimized", "HITightOptimized"]
324 alg = config.createAlgorithm( 'CP::InDetTrackSelectionAlg', 'InDetTrackSelectionAlg' )
325 alg.selectionDecoration = 'selectTrack' + postfix + '_%SYS%,as_bits'
326 config.addPrivateTool( 'selectionTool', 'InDet::InDetTrackSelectionTool')
327 if self.cutLevel is None:
328 log.warning("No selection WP chosen, not setting up InDetTrackSelectionTool.")
329 elif self.cutLevel not in cutLevels:
330 raise ValueError ('Invalid cut level: \"' + self.cutLevel + '\", has '
331 'to be one of: ' + ', '.join(cutLevels))
332 elif self.cutLevel in ["Loose", "TightPrimary"]:
333 alg.selectionTool.CutLevel = self.cutLevel
334 else:
335 log.warning('Using cut level: \"' + self.cutLevel + '\" that is not '
336 'meant for general use, but only expert studies.')
337 alg.selectionTool.CutLevel = self.cutLevel
338
339 if self.additionalCuts:
340 for cutName, value in self.additionalCuts.items():
341 setattr(alg.selectionTool, cutName, value)
342 if self.vertexContainer is not None:
343 alg.vertices = self.vertexContainer
344
345 # Set up the truth filtering algorithm:
346 if config.dataType() is not DataType.Data:
347 if self.runTruthFilter:
348 if config.isPhyslite():
349 log.warning ('The TruthFilterTool is not compatible with Physlite mode. '
350 'This tool is skipped for now. Please set \"runTruthFilter: '
351 'False\" to get rid of this warning.')
352 else:
353 config.addPrivateTool( 'filterTool', 'InDet::InDetTrackTruthFilterTool' )
354 config.addPrivateTool( 'filterTool.trackOriginTool', 'InDet::InDetTrackTruthOriginTool' )
355 # Set working point based on cut level
356 if self.cutLevel == "Loose":
357 alg.filterWP = "LOOSE"
358 elif self.cutLevel == "TightPrimary":
359 alg.filterWP = "TIGHT"
360 else:
361 raise ValueError ('Attempting to set TruthFilter WP based on cut level: \"'
362 + self.efficiencyWP + '\" that is not supported.')
363 # Set calibFile and fake rates based on campaign
364 if config.geometry() is LHCPeriod.Run2:
365 # Run 2 recommendations (MC20)
366 alg.filterTool.calibFileNomEff = "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root"
367 alg.filterTool.fFakeLoose = 0.10
368 alg.filterTool.fFakeTight = 1.00
369 elif config.geometry() is LHCPeriod.Run3:
370 if config.campaign() in [Campaign.MC23a, Campaign.MC23d, Campaign.MC23e]:
371 # 2022/23/24 recommendations (MC23a/d/e)
372 alg.filterTool.calibFileNomEff = "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root"
373 alg.filterTool.fFakeLoose = 0.40
374 alg.filterTool.fFakeTight = 1.00
375 elif not (self.calibFile and self.fFakeLoose and self.fFakeTight):
376 raise ValueError ('No efficiency recommendations found for campaign \"'
377 + config.campaign().value + '\" in Run 3. '
378 'Please check that the recommendations exist.')
379 elif not (self.calibFile and self.fFakeLoose and self.fFakeTight):
380 raise ValueError ('No efficiency recommendations found for geometry \"'
381 + config.geometry().value + '\". Please check '
382 'the configuration.')
383 # Set custom calibFile, fake rates, or random seed
384 if self.calibFile:
385 alg.filterTool.calibFileNomEff = self.calibFile
386 if self.fFakeLoose:
387 alg.filterTool.fFakeLoose = self.fFakeLoose
388 if self.fFakeTight:
389 alg.filterTool.fFakeTight = self.fFakeTight
390 if self.filterToolSeed:
391 alg.filterTool.Seed = self.filterToolSeed
392 if self.trkEffSystScale:
393 alg.filterTool.trkEffSystScale = self.trkEffSystScale
394 alg.inDetTracks = config.readName (self.containerName)
395 alg.preselection = config.getPreselection (self.containerName, '')
396 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
397 preselection=self.addSelectionToPreselection)

Member Data Documentation

◆ additionalCuts

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.additionalCuts

Definition at line 339 of file TrackingAnalysisConfig.py.

◆ calibFile

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.calibFile

Definition at line 384 of file TrackingAnalysisConfig.py.

◆ containerName

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.containerName

Definition at line 396 of file TrackingAnalysisConfig.py.

◆ cutLevel

str TrackingAnalysisConfig.InDetTrackWorkingPointConfig.cutLevel = "Loose":

Definition at line 356 of file TrackingAnalysisConfig.py.

◆ fFakeLoose

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.fFakeLoose

Definition at line 386 of file TrackingAnalysisConfig.py.

◆ fFakeTight

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.fFakeTight

Definition at line 375 of file TrackingAnalysisConfig.py.

◆ filterToolSeed

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.filterToolSeed

Definition at line 390 of file TrackingAnalysisConfig.py.

◆ runTruthFilter

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.runTruthFilter

Definition at line 347 of file TrackingAnalysisConfig.py.

◆ selectionName

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.selectionName

Definition at line 396 of file TrackingAnalysisConfig.py.

◆ trkEffSystScale

TrackingAnalysisConfig.InDetTrackWorkingPointConfig.trkEffSystScale

Definition at line 392 of file TrackingAnalysisConfig.py.


The documentation for this class was generated from the following file: