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