ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.PhotonAnalysisConfig.PhotonWorkingPointConfig Class Reference
Inheritance diagram for python.PhotonAnalysisConfig.PhotonWorkingPointConfig:
Collaboration diagram for python.PhotonAnalysisConfig.PhotonWorkingPointConfig:

Public Member Functions

def __init__ (self)
 
def instanceName (self)
 
def makeAlgs (self, config)
 

Public Attributes

 qualityWP
 

Detailed Description

the ConfigBlock for the photon working point

This may at some point be split into multiple blocks (29 Aug 22).

Definition at line 301 of file PhotonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.PhotonAnalysisConfig.PhotonWorkingPointConfig.__init__ (   self)

Definition at line 306 of file PhotonAnalysisConfig.py.

306  def __init__ (self) :
307  super (PhotonWorkingPointConfig, self).__init__ ()
308  self.addOption ('containerName', '', type=str,
309  noneAction='error',
310  info="the name of the input container.")
311  self.addOption ('selectionName', '', type=str,
312  noneAction='error',
313  info="the name of the photon selection to define (e.g. tight or "
314  "loose).")
315  self.addOption ('postfix', None, type=str,
316  info="a postfix to apply to decorations and algorithm names. "
317  "Typically not needed here as selectionName is used internally.")
318  self.addOption ('qualityWP', None, type=str,
319  info="the ID WP (string) to use. Supported ID WPs: Tight, Medium and Loose.")
320  self.addOption ('isolationWP', None, type=str,
321  info="the ID WP (string) to use. Supported isolation WPs: "
322  "FixedCutLoose, FixedCutTight, TightCaloOnly, NonIso.")
323  self.addOption ('addSelectionToPreselection', True, type=bool,
324  info="whether to retain only photons satisfying the working point "
325  "requirements. The default is True.")
326  self.addOption ('closeByCorrection', False, type=bool,
327  info="whether to use close-by-corrected isolation working points")
328  self.addOption ('recomputeIsEM', False, type=bool,
329  info="whether to rerun the cut-based selection. The default is "
330  "False, i.e. to use derivation flags.")
331  self.addOption ('doFSRSelection', False, type=bool,
332  info="whether to accept additional photons close to muons for the "
333  "purpose of FSR corrections to these muons. Expert feature "
334  "requested by the H4l analysis running on PHYSLITE. "
335  "The default is False.")
336  self.addOption ('noEffSFForID', False, type=bool,
337  info="disables the calculation of ID efficiencies and scale factors. "
338  "Experimental! only useful to test a new WP for which scale "
339  "factors are not available. The default is False.")
340  self.addOption ('noEffSFForIso', False, type=bool,
341  info="disables the calculation of Iso efficiencies and scale factors. "
342  "Experimental! only useful to test a new WP for which scale "
343  "factors are not available. The default is False.")
344  self.addOption ('saveDetailedSF', True, type=bool,
345  info="save all the independent detailed object scale factors. "
346  "The default is True.")
347  self.addOption ('saveCombinedSF', False, type=bool,
348  info="save the combined object scale factor. "
349  "The default is False.")
350  self.addOption ('forceFullSimConfigForID', False, type=bool,
351  info="whether to force the ID tool to use the configuration meant "
352  "for full simulation samples. Only for testing purposes. "
353  "The default is False.")
354  self.addOption ('forceFullSimConfigForIso', False, type=bool,
355  info="whether to force the Iso tool to use the configuration meant "
356  "for full simulation samples. Only for testing purposes. "
357  "The default is False.")
358 

Member Function Documentation

◆ instanceName()

def python.PhotonAnalysisConfig.PhotonWorkingPointConfig.instanceName (   self)
Return the instance name for this block

Definition at line 359 of file PhotonAnalysisConfig.py.

359  def instanceName (self) :
360  """Return the instance name for this block"""
361  if self.postfix is not None :
362  return self.containerName + '_' + self.selectionName + self.postfix
363  return self.containerName + '_' + self.selectionName
364 

◆ makeAlgs()

def python.PhotonAnalysisConfig.PhotonWorkingPointConfig.makeAlgs (   self,
  config 
)

Definition at line 365 of file PhotonAnalysisConfig.py.

365  def makeAlgs (self, config) :
366 
367  log = logging.getLogger('PhotonWorkingPointConfig')
368 
369  # The setup below is inappropriate for Run 1
370  if config.geometry() is LHCPeriod.Run1:
371  raise ValueError ("Can't set up the PhotonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
372 
373  if self.forceFullSimConfigForID:
374  log.warning("You are running PhotonWorkingPointConfig forcing full sim config for ID")
375  log.warning("This is only intended to be used for testing purposes")
376 
377  if self.forceFullSimConfigForIso:
378  log.warning("You are running PhotonWorkingPointConfig forcing full sim config for Iso")
379  log.warning("This is only intended to be used for testing purposes")
380 
381  postfix = self.postfix
382  if postfix is None :
383  postfix = self.selectionName
384  if postfix != '' and postfix[0] != '_' :
385  postfix = '_' + postfix
386 
387  if self.qualityWP == 'Tight' :
388  quality = ROOT.egammaPID.PhotonTight
389  elif self.qualityWP == 'Medium' :
390  quality = ROOT.egammaPID.PhotonMedium
391  elif self.qualityWP == 'Loose' :
392  quality = ROOT.egammaPID.PhotonLoose
393  else :
394  raise Exception ('unknown photon quality working point "' + self.qualityWP + '" should be Tight, Medium or Loose')
395 
396  # Set up the photon selection algorithm:
397  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonIsEMSelectorAlg' )
398  alg.selectionDecoration = 'selectEM' + postfix + ',as_char'
399  if self.recomputeIsEM:
400  # Rerun the cut-based ID
401  config.addPrivateTool( 'selectionTool', 'AsgPhotonIsEMSelector' )
402  alg.selectionTool.isEMMask = quality
403  if config.geometry() is LHCPeriod.Run2:
404  if self.qualityWP == 'Tight':
405  alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMTightSelectorCutDefs_pTdep_mc20_smooth.conf'
406  elif self.qualityWP == 'Loose':
407  alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
408  elif self.qualityWP == 'Medium':
409  alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMMediumSelectorCutDefs_pTdep_smooth.conf'
410  if config.geometry() is LHCPeriod.Run3:
411  if self.qualityWP == 'Tight':
412  alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/20180825/PhotonIsEMTightSelectorCutDefs.conf'
413  elif self.qualityWP == 'Loose':
414  alg.selectionTool.ConfigFile = 'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
415  elif self.qualityWP == 'Medium':
416  raise ValueError('No Medium menu available for Run-3. Please get in contact with egamma')
417  else:
418  # Select from Derivation Framework flags
419  config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
420  dfFlag = 'DFCommonPhotonsIsEM' + self.qualityWP
421  alg.selectionTool.selectionFlags = [ dfFlag ]
422  alg.particles = config.readName (self.containerName)
423  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
424  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
425  preselection=self.addSelectionToPreselection)
426 
427  # Set up the FSR selection
428  if self.doFSRSelection :
429  # save the flag set for the WP
430  wpFlag = alg.selectionDecoration.split(",")[0]
431  alg = config.createAlgorithm( 'CP::EgammaFSRForMuonsCollectorAlg', 'EgammaFSRForMuonsCollectorAlg')
432  alg.selectionDecoration = wpFlag
433  alg.ElectronOrPhotonContKey = config.readName (self.containerName)
434 
435  # Set up the isolation selection algorithm:
436  if self.isolationWP != 'NonIso' :
437  alg = config.createAlgorithm( 'CP::EgammaIsolationSelectionAlg',
438  'PhotonIsolationSelectionAlg' )
439  alg.selectionDecoration = 'isolated' + postfix + ',as_char'
440  config.addPrivateTool( 'selectionTool', 'CP::IsolationSelectionTool' )
441  alg.selectionTool.PhotonWP = self.isolationWP
442  if self.closeByCorrection:
443  alg.selectionTool.IsoDecSuffix = "CloseByCorr"
444  alg.isPhoton = True
445  alg.egammas = config.readName (self.containerName)
446  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
447  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
448  preselection=self.addSelectionToPreselection)
449 
450  sfList = []
451  # Set up the ID/reco photon efficiency correction algorithm:
452  if config.dataType() is not DataType.Data and not self.noEffSFForID:
453  alg = config.createAlgorithm( 'CP::PhotonEfficiencyCorrectionAlg',
454  'PhotonEfficiencyCorrectionAlgID' )
455  config.addPrivateTool( 'efficiencyCorrectionTool',
456  'AsgPhotonEfficiencyCorrectionTool' )
457  alg.scaleFactorDecoration = 'ph_id_effSF' + postfix + '_%SYS%'
458  if config.dataType() is DataType.FastSim:
459  alg.efficiencyCorrectionTool.ForceDataType = (
460  PATCore.ParticleDataType.Full if self.forceFullSimConfigForID else
461  PATCore.ParticleDataType.Fast)
462  elif config.dataType() is DataType.FullSim:
463  alg.efficiencyCorrectionTool.ForceDataType = \
464  PATCore.ParticleDataType.Full
465  if config.geometry() >= LHCPeriod.Run2:
466  alg.efficiencyCorrectionTool.MapFilePath = 'PhotonEfficiencyCorrection/2015_2025/rel22.2/2024_FinalRun2_Recommendation_v1/map1.txt'
467  alg.outOfValidity = 2 #silent
468  alg.outOfValidityDeco = 'ph_id_bad_eff' + postfix
469  alg.photons = config.readName (self.containerName)
470  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
471  if self.saveDetailedSF:
472  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
473  'id_effSF' + postfix)
474  sfList += [alg.scaleFactorDecoration]
475 
476  # Set up the ISO photon efficiency correction algorithm:
477  if config.dataType() is not DataType.Data and self.isolationWP != 'NonIso' and not self.noEffSFForIso:
478  alg = config.createAlgorithm( 'CP::PhotonEfficiencyCorrectionAlg',
479  'PhotonEfficiencyCorrectionAlgIsol' )
480  config.addPrivateTool( 'efficiencyCorrectionTool',
481  'AsgPhotonEfficiencyCorrectionTool' )
482  alg.scaleFactorDecoration = 'ph_isol_effSF' + postfix + '_%SYS%'
483  if config.dataType() is DataType.FastSim:
484  alg.efficiencyCorrectionTool.ForceDataType = (
485  PATCore.ParticleDataType.Full if self.forceFullSimConfigForIso else
486  PATCore.ParticleDataType.Fast)
487  elif config.dataType() is DataType.FullSim:
488  alg.efficiencyCorrectionTool.ForceDataType = \
489  PATCore.ParticleDataType.Full
490  alg.efficiencyCorrectionTool.IsoKey = self.isolationWP.replace("FixedCut","")
491  if config.geometry() >= LHCPeriod.Run2:
492  alg.efficiencyCorrectionTool.MapFilePath = 'PhotonEfficiencyCorrection/2015_2025/rel22.2/2022_Summer_Prerecom_v1/map1.txt'
493  alg.outOfValidity = 2 #silent
494  alg.outOfValidityDeco = 'ph_isol_bad_eff' + postfix
495  alg.photons = config.readName (self.containerName)
496  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
497  if self.saveDetailedSF:
498  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
499  'isol_effSF' + postfix)
500  sfList += [alg.scaleFactorDecoration]
501 
502  doCombEffSF = not self.noEffSFForID or not self.noEffSFForIso
503  if config.dataType() is not DataType.Data and doCombEffSF and self.saveCombinedSF:
504  alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
505  'PhotonCombinedEfficiencyScaleFactorAlg' )
506  alg.particles = config.readName (self.containerName)
507  alg.inScaleFactors = sfList
508  alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
509  config.addOutputVar (self.containerName, alg.outScaleFactor, 'effSF' + postfix)
510 

Member Data Documentation

◆ qualityWP

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.qualityWP

Definition at line 387 of file PhotonAnalysisConfig.py.


The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18