398 def makeAlgs (self, config) :
399
400
401 if config.geometry() is LHCPeriod.Run1:
402 raise ValueError ("Can't set up the MuonWorkingPointEfficiencyConfig with %s, there must be something wrong!" % config.geometry().value)
403
404 postfix = self.postfix
405 if postfix is None :
406 postfix = self.selectionName
407 if postfix != '' and postfix[0] != '_' :
408 postfix = '_' + postfix
409
410 sfList = []
411
412 if config.dataType() is not DataType.Data and not self.noEffSF:
413 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
414 'MuonEfficiencyScaleFactorAlgReco' )
415 config.addPrivateTool( 'efficiencyScaleFactorTool',
416 'CP::MuonEfficiencyScaleFactors' )
417 config.setExtraInputs ({('xAOD::EventInfo', 'EventInfo.RandomRunNumber')})
418 alg.scaleFactorDecoration = 'muon_reco_effSF' + postfix + "_%SYS%"
419 alg.outOfValidity = 2
420 alg.outOfValidityDeco = 'muon_reco_bad_eff' + postfix
421 alg.efficiencyScaleFactorTool.WorkingPoint = self.quality
422
423 if self.useLRT and self.quality != 'Medium':
424 raise ValueError ("useLRT is only supported with the Medium quality working point, not '%s'" % self.quality)
425 if config.geometry() >= LHCPeriod.Run3:
426 alg.efficiencyScaleFactorTool.CalibrationRelease = '250418_Preliminary_r24run3' if self.useLRT else '251211_Preliminary_r24run3'
427 else:
428 alg.efficiencyScaleFactorTool.CalibrationRelease = '240620_LRT_r22run2' if self.useLRT else '230213_Preliminary_r22run2_loosefix'
429 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
430 alg.muons = config.readName (self.containerName)
431 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
432 if self.saveDetailedSF:
433 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
434 'reco_effSF' + postfix)
435 sfList += [alg.scaleFactorDecoration]
436
437
438 if config.dataType() is not DataType.Data and self.quality == 'HighPt' and not self.noEffSF:
439 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
440 'MuonEfficiencyScaleFactorAlgBMVHighPt' )
441 config.addPrivateTool( 'efficiencyScaleFactorTool',
442 'CP::MuonEfficiencyScaleFactors' )
443 alg.scaleFactorDecoration = 'muon_BadMuonVeto_effSF' + postfix + "_%SYS%"
444 alg.outOfValidity = 2
445 alg.outOfValidityDeco = 'muon_BadMuonVeto_bad_eff' + postfix
446 alg.efficiencyScaleFactorTool.WorkingPoint = 'BadMuonVeto_HighPt'
447 if config.geometry() >= LHCPeriod.Run3:
448 alg.efficiencyScaleFactorTool.CalibrationRelease = '220817_Preliminary_r22run3'
449 else:
450 alg.efficiencyScaleFactorTool.CalibrationRelease = '230213_Preliminary_r22run2_loosefix'
451 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
452 alg.muons = config.readName (self.containerName)
453 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
454 if self.saveDetailedSF:
455 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
456 'BadMuonVeto_effSF' + postfix)
457 sfList += [alg.scaleFactorDecoration]
458
459
460 if config.dataType() is not DataType.Data and self.isolation != 'NonIso' and not self.noEffSF:
461 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
462 'MuonEfficiencyScaleFactorAlgIsol' )
463 config.addPrivateTool( 'efficiencyScaleFactorTool',
464 'CP::MuonEfficiencyScaleFactors' )
465 alg.scaleFactorDecoration = 'muon_isol_effSF' + postfix + "_%SYS%"
466 alg.outOfValidity = 2
467 alg.outOfValidityDeco = 'muon_isol_bad_eff' + postfix
468 alg.efficiencyScaleFactorTool.WorkingPoint = self.isolation + 'Iso'
469 if config.geometry() >= LHCPeriod.Run3:
470 alg.efficiencyScaleFactorTool.CalibrationRelease = '251211_Preliminary_r24run3'
471 else:
472 alg.efficiencyScaleFactorTool.CalibrationRelease = '230213_Preliminary_r22run2_loosefix'
473 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
474 alg.muons = config.readName (self.containerName)
475 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
476 if self.saveDetailedSF:
477 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
478 'isol_effSF' + postfix)
479 sfList += [alg.scaleFactorDecoration]
480
481
482 if config.dataType() is not DataType.Data and self.trackSelection and not self.noEffSF:
483 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
484 'MuonEfficiencyScaleFactorAlgTTVA' )
485 config.addPrivateTool( 'efficiencyScaleFactorTool',
486 'CP::MuonEfficiencyScaleFactors' )
487 alg.scaleFactorDecoration = 'muon_TTVA_effSF' + postfix + "_%SYS%"
488 alg.outOfValidity = 2
489 alg.outOfValidityDeco = 'muon_TTVA_bad_eff' + postfix
490 alg.efficiencyScaleFactorTool.WorkingPoint = 'TTVA'
491 if config.geometry() >= LHCPeriod.Run3:
492 alg.efficiencyScaleFactorTool.CalibrationRelease = '251211_Preliminary_r24run3'
493 else:
494 alg.efficiencyScaleFactorTool.CalibrationRelease = '230213_Preliminary_r22run2_loosefix'
495 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
496 alg.muons = config.readName (self.containerName)
497 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
498 if self.saveDetailedSF:
499 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
500 'TTVA_effSF' + postfix)
501 sfList += [alg.scaleFactorDecoration]
502
503 if config.dataType() is not DataType.Data and not self.noEffSF and self.saveCombinedSF:
504 alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
505 'MuonCombinedEfficiencyScaleFactorAlg' )
506 alg.particles = config.readName (self.containerName)
507 alg.inScaleFactors = sfList
508 alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
509 config.addOutputVar (self.containerName, alg.outScaleFactor, 'effSF' + postfix)
510