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