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 302 of file PhotonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.PhotonAnalysisConfig.PhotonWorkingPointConfig.__init__ (   self)

Definition at line 307 of file PhotonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 363 of file PhotonAnalysisConfig.py.

363  def instanceName (self) :
364  """Return the instance name for this block"""
365  if self.postfix is not None :
366  return self.containerName + '_' + self.selectionName + self.postfix
367  return self.containerName + '_' + self.selectionName
368 

◆ makeAlgs()

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

Definition at line 369 of file PhotonAnalysisConfig.py.

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

Member Data Documentation

◆ qualityWP

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.qualityWP

Definition at line 391 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.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18