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