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