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