411 def makeAlgs (self, config) :
412
413
414 if config.geometry() is LHCPeriod.Run1:
415 raise ValueError ("Can't set up the PhotonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
416
417 postfix = self.postfix
418 if postfix is None :
419 postfix = self.selectionName
420 if postfix != '' and postfix[0] != '_' :
421 postfix = '_' + postfix
422
423 if self.qualityWP == 'Tight' :
424 quality = ROOT.egammaPID.PhotonTight
425 elif self.qualityWP == 'Medium' :
426 quality = ROOT.egammaPID.PhotonMedium
427 elif self.qualityWP == 'Loose' :
428 quality = ROOT.egammaPID.PhotonLoose
429 elif self.qualityWP == 'NoID':
430 quality = None
431 if self.recomputeIsEM:
432 raise ValueError('NoID WP cannot be recomputed.')
433 else :
434 raise Exception (f'unknown photon quality working point "{self.qualityWP}" should be Tight, Medium or Loose')
435
436
437 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonIsEMSelectorAlg' )
438 alg.selectionDecoration = 'selectEM' + postfix + ',as_char'
439 if self.recomputeIsEM:
440
441 config.addPrivateTool( 'selectionTool', 'AsgPhotonIsEMSelector' )
442 alg.selectionTool.isEMMask = quality
443 if config.geometry() is LHCPeriod.Run2:
444 if self.qualityWP == 'Tight':
445 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMTightSelectorCutDefs_pTdep_mc20_smooth.conf'
446 elif self.qualityWP == 'Loose':
447 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
448 elif self.qualityWP == 'Medium':
449 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMMediumSelectorCutDefs_pTdep_smooth.conf'
450 if config.geometry() is LHCPeriod.Run3:
451 if self.qualityWP == 'Tight':
452 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc23_20260924/PhotonIsEMTightSelectorCutDefs.conf'
453 elif self.qualityWP == 'Loose':
454 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
455 elif self.qualityWP == 'Medium':
456 raise ValueError('No Medium menu available for Run-3. Please get in contact with egamma')
457 else:
458
459 config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
460 if quality is not None:
461 dfFlag = 'DFCommonPhotonsIsEM' + self.qualityWP
462 alg.selectionTool.selectionFlags = [ dfFlag ]
463 alg.particles = config.readName (self.containerName)
464 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
465
466
467 if self.doFSRSelection :
468
469 wpDecoration = alg.selectionDecoration
470 wpDecorationName = wpDecoration.split(',')[0]
471
472 underscorePos = wpDecorationName.find('_')
473 if underscorePos < 0:
474 underscorePos = len(wpDecorationName)
475 outputDecorationName = wpDecorationName[:underscorePos] + 'FSR' + wpDecorationName[underscorePos:]
476
477 alg = config.createAlgorithm( 'CP::EgammaFSRForMuonsCollectorAlg', 'EgammaFSRForMuonsCollectorAlg')
478 alg.wpSelection = wpDecoration
479 alg.selectionDecoration = outputDecorationName
480 alg.ElectronOrPhotonContKey = config.readName (self.containerName)
481 if self.muonsForFSRSelection is not None:
482 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
483
484
485 config.addSelection (self.containerName, self.selectionName,
486 alg.selectionDecoration + ',as_char',
487 preselection=self.addSelectionToPreselection)
488 else:
489
490 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
491 preselection=self.addSelectionToPreselection)
492
493
494 if self.isolationWP != 'NonIso' :
495 alg = config.createAlgorithm( 'CP::EgammaIsolationSelectionAlg',
496 'PhotonIsolationSelectionAlg' )
497 alg.selectionDecoration = 'isolated' + postfix + ',as_char'
498 config.addPrivateTool( 'selectionTool', 'CP::IsolationSelectionTool' )
499 alg.selectionTool.PhotonWP = self.isolationWP
500 if self.closeByCorrection:
501 alg.selectionTool.IsoDecSuffix = "CloseByCorr"
502 alg.isPhoton = True
503 alg.egammas = config.readName (self.containerName)
504 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
505 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
506 preselection=self.addSelectionToPreselection)
507
508