384 def makeAlgs (self, config) :
385
386
387 if config.geometry() is LHCPeriod.Run1:
388 raise ValueError ("Can't set up the PhotonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
389
390 postfix = self.postfix
391 if postfix is None :
392 postfix = self.selectionName
393 if postfix != '' and postfix[0] != '_' :
394 postfix = '_' + postfix
395
396 if self.qualityWP == 'Tight' :
397 quality = ROOT.egammaPID.PhotonTight
398 elif self.qualityWP == 'Medium' :
399 quality = ROOT.egammaPID.PhotonMedium
400 elif self.qualityWP == 'Loose' :
401 quality = ROOT.egammaPID.PhotonLoose
402 else :
403 raise Exception (f'unknown photon quality working point "{self.qualityWP}" should be Tight, Medium or Loose')
404
405
406 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonIsEMSelectorAlg' )
407 alg.selectionDecoration = 'selectEM' + postfix + ',as_char'
408 if self.recomputeIsEM:
409
410 config.addPrivateTool( 'selectionTool', 'AsgPhotonIsEMSelector' )
411 alg.selectionTool.isEMMask = quality
412 if config.geometry() is LHCPeriod.Run2:
413 if self.qualityWP == 'Tight':
414 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMTightSelectorCutDefs_pTdep_mc20_smooth.conf'
415 elif self.qualityWP == 'Loose':
416 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
417 elif self.qualityWP == 'Medium':
418 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMMediumSelectorCutDefs_pTdep_smooth.conf'
419 if config.geometry() is LHCPeriod.Run3:
420 if self.qualityWP == 'Tight':
421 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc23_20260924/PhotonIsEMTightSelectorCutDefs.conf'
422 elif self.qualityWP == 'Loose':
423 alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
424 elif self.qualityWP == 'Medium':
425 raise ValueError('No Medium menu available for Run-3. Please get in contact with egamma')
426 else:
427
428 config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
429 dfFlag = 'DFCommonPhotonsIsEM' + self.qualityWP
430 alg.selectionTool.selectionFlags = [ dfFlag ]
431 alg.particles = config.readName (self.containerName)
432 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
433
434
435 if self.doFSRSelection :
436
437 wpDecoration = alg.selectionDecoration
438 wpDecorationName = wpDecoration.split(',')[0]
439
440 underscorePos = wpDecorationName.find('_')
441 if underscorePos < 0:
442 underscorePos = len(wpDecorationName)
443 outputDecorationName = wpDecorationName[:underscorePos] + 'FSR' + wpDecorationName[underscorePos:]
444
445 alg = config.createAlgorithm( 'CP::EgammaFSRForMuonsCollectorAlg', 'EgammaFSRForMuonsCollectorAlg')
446 alg.wpSelection = wpDecoration
447 alg.selectionDecoration = outputDecorationName
448 alg.ElectronOrPhotonContKey = config.readName (self.containerName)
449 if self.muonsForFSRSelection is not None:
450 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
451
452
453 config.addSelection (self.containerName, self.selectionName,
454 alg.selectionDecoration + ',as_char',
455 preselection=self.addSelectionToPreselection)
456 else:
457
458 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
459 preselection=self.addSelectionToPreselection)
460
461
462 if self.isolationWP != 'NonIso' :
463 alg = config.createAlgorithm( 'CP::EgammaIsolationSelectionAlg',
464 'PhotonIsolationSelectionAlg' )
465 alg.selectionDecoration = 'isolated' + postfix + ',as_char'
466 config.addPrivateTool( 'selectionTool', 'CP::IsolationSelectionTool' )
467 alg.selectionTool.PhotonWP = self.isolationWP
468 if self.closeByCorrection:
469 alg.selectionTool.IsoDecSuffix = "CloseByCorr"
470 alg.isPhoton = True
471 alg.egammas = config.readName (self.containerName)
472 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
473 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
474 preselection=self.addSelectionToPreselection)
475
476