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
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
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
364 if config.geometry() is LHCPeriod.Run2:
365
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
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
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)