Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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, containerName='', selectionName='')
 
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 297 of file PhotonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.PhotonAnalysisConfig.PhotonWorkingPointConfig.__init__ (   self,
  containerName = '',
  selectionName = '' 
)

Definition at line 302 of file PhotonAnalysisConfig.py.

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

Member Function Documentation

◆ makeAlgs()

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

Definition at line 355 of file PhotonAnalysisConfig.py.

355  def makeAlgs (self, config) :
356 
357  log = logging.getLogger('PhotonWorkingPointConfig')
358 
359  # The setup below is inappropriate for Run 1
360  if config.geometry() is LHCPeriod.Run1:
361  raise ValueError ("Can't set up the PhotonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
362 
363  if self.forceFullSimConfigForID:
364  log.warning("You are running PhotonWorkingPointConfig forcing full sim config for ID")
365  log.warning("This is only intended to be used for testing purposes")
366 
367  if self.forceFullSimConfigForIso:
368  log.warning("You are running PhotonWorkingPointConfig forcing full sim config for Iso")
369  log.warning("This is only intended to be used for testing purposes")
370 
371  postfix = self.postfix
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  # Set up the photon selection algorithm:
385  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonIsEMSelectorAlg' + postfix )
386  alg.selectionDecoration = 'selectEM' + postfix + ',as_char'
387  if self.recomputeIsEM:
388  # Rerun the cut-based ID
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  # Select from Derivation Framework flags
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  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
413  preselection=self.addSelectionToPreselection)
414 
415  # Set up the FSR selection
416  if self.doFSRSelection :
417  # save the flag set for the WP
418  wpFlag = alg.selectionDecoration.split(",")[0]
419  alg = config.createAlgorithm( 'CP::EgammaFSRForMuonsCollectorAlg', 'EgammaFSRForMuonsCollectorAlg' + postfix + '_ph') # added extra postfix to avoid name clash with electrons
420  alg.selectionDecoration = wpFlag
421  alg.ElectronOrPhotonContKey = config.readName (self.containerName)
422 
423  # Set up the isolation selection algorithm:
424  if self.isolationWP != 'NonIso' :
425  alg = config.createAlgorithm( 'CP::EgammaIsolationSelectionAlg',
426  'PhotonIsolationSelectionAlg' + postfix )
427  alg.selectionDecoration = 'isolated' + postfix + ',as_char'
428  config.addPrivateTool( 'selectionTool', 'CP::IsolationSelectionTool' )
429  alg.selectionTool.PhotonWP = self.isolationWP
430  if self.closeByCorrection:
431  alg.selectionTool.IsoDecSuffix = "CloseByCorr"
432  alg.isPhoton = True
433  alg.egammas = config.readName (self.containerName)
434  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
435  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
436  preselection=self.addSelectionToPreselection)
437 
438  sfList = []
439  # Set up the ID/reco photon efficiency correction algorithm:
440  if config.dataType() is not DataType.Data and not self.noEffSFForID:
441  alg = config.createAlgorithm( 'CP::PhotonEfficiencyCorrectionAlg',
442  'PhotonEfficiencyCorrectionAlgID' + postfix )
443  config.addPrivateTool( 'efficiencyCorrectionTool',
444  'AsgPhotonEfficiencyCorrectionTool' )
445  alg.scaleFactorDecoration = 'ph_id_effSF' + postfix + '_%SYS%'
446  if config.dataType() is DataType.FastSim:
447  alg.efficiencyCorrectionTool.ForceDataType = (
448  PATCore.ParticleDataType.Full if self.forceFullSimConfigForID else
449  PATCore.ParticleDataType.Fast)
450  elif config.dataType() is DataType.FullSim:
451  alg.efficiencyCorrectionTool.ForceDataType = \
452  PATCore.ParticleDataType.Full
453  if config.geometry() >= LHCPeriod.Run2:
454  alg.efficiencyCorrectionTool.MapFilePath = 'PhotonEfficiencyCorrection/2015_2025/rel22.2/2024_FinalRun2_Recommendation_v1/map1.txt'
455  alg.outOfValidity = 2 #silent
456  alg.outOfValidityDeco = 'ph_id_bad_eff' + postfix
457  alg.photons = config.readName (self.containerName)
458  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
459  if self.saveDetailedSF:
460  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
461  'id_effSF' + postfix)
462  sfList += [alg.scaleFactorDecoration]
463 
464  # Set up the ISO photon efficiency correction algorithm:
465  if config.dataType() is not DataType.Data and self.isolationWP != 'NonIso' and not self.noEffSFForIso:
466  alg = config.createAlgorithm( 'CP::PhotonEfficiencyCorrectionAlg',
467  'PhotonEfficiencyCorrectionAlgIsol' + postfix )
468  config.addPrivateTool( 'efficiencyCorrectionTool',
469  'AsgPhotonEfficiencyCorrectionTool' )
470  alg.scaleFactorDecoration = 'ph_isol_effSF' + postfix + '_%SYS%'
471  if config.dataType() is DataType.FastSim:
472  alg.efficiencyCorrectionTool.ForceDataType = (
473  PATCore.ParticleDataType.Full if self.forceFullSimConfigForIso else
474  PATCore.ParticleDataType.Fast)
475  elif config.dataType() is DataType.FullSim:
476  alg.efficiencyCorrectionTool.ForceDataType = \
477  PATCore.ParticleDataType.Full
478  alg.efficiencyCorrectionTool.IsoKey = self.isolationWP.replace("FixedCut","")
479  if config.geometry() >= LHCPeriod.Run2:
480  alg.efficiencyCorrectionTool.MapFilePath = 'PhotonEfficiencyCorrection/2015_2025/rel22.2/2022_Summer_Prerecom_v1/map1.txt'
481  alg.outOfValidity = 2 #silent
482  alg.outOfValidityDeco = 'ph_isol_bad_eff' + postfix
483  alg.photons = config.readName (self.containerName)
484  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
485  if self.saveDetailedSF:
486  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
487  'isol_effSF' + postfix)
488  sfList += [alg.scaleFactorDecoration]
489 
490  doCombEffSF = not self.noEffSFForID or not self.noEffSFForIso
491  if config.dataType() is not DataType.Data and doCombEffSF and self.saveCombinedSF:
492  alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
493  'PhotonCombinedEfficiencyScaleFactorAlg' + postfix )
494  alg.particles = config.readName (self.containerName)
495  alg.inScaleFactors = sfList
496  alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
497  config.addOutputVar (self.containerName, alg.outScaleFactor, 'effSF' + postfix)
498 

Member Data Documentation

◆ qualityWP

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.qualityWP

Definition at line 375 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