ATLAS Offline Software
Loading...
Searching...
No Matches
python.PhotonAnalysisConfig.PhotonWorkingPointConfig Class Reference
Inheritance diagram for python.PhotonAnalysisConfig.PhotonWorkingPointConfig:
Collaboration diagram for python.PhotonAnalysisConfig.PhotonWorkingPointConfig:

Public Member Functions

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

Public Attributes

 forceFullSimConfigForID
 forceFullSimConfigForIso
str qualityWP = 'Tight' :
 recomputeIsEM
 containerName
 selectionName
 doFSRSelection
 closeByCorrection
 noEffSFForID
 saveDetailedSF
 saveCombinedSF

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

Constructor & Destructor Documentation

◆ __init__()

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.__init__ ( self)

Definition at line 301 of file PhotonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 351 of file PhotonAnalysisConfig.py.

351 def instanceName (self) :
352 """Return the instance name for this block"""
353 if self.postfix is not None :
354 return self.containerName + '_' + self.selectionName + self.postfix
355 return self.containerName + '_' + self.selectionName
356

◆ makeAlgs()

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

Definition at line 357 of file PhotonAnalysisConfig.py.

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

Member Data Documentation

◆ closeByCorrection

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.closeByCorrection

Definition at line 434 of file PhotonAnalysisConfig.py.

◆ containerName

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.containerName

Definition at line 416 of file PhotonAnalysisConfig.py.

◆ doFSRSelection

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.doFSRSelection

Definition at line 420 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForID

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.forceFullSimConfigForID

Definition at line 365 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForIso

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.forceFullSimConfigForIso

Definition at line 369 of file PhotonAnalysisConfig.py.

◆ noEffSFForID

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.noEffSFForID

Definition at line 444 of file PhotonAnalysisConfig.py.

◆ qualityWP

str python.PhotonAnalysisConfig.PhotonWorkingPointConfig.qualityWP = 'Tight' :

Definition at line 379 of file PhotonAnalysisConfig.py.

◆ recomputeIsEM

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.recomputeIsEM

Definition at line 391 of file PhotonAnalysisConfig.py.

◆ saveCombinedSF

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.saveCombinedSF

Definition at line 495 of file PhotonAnalysisConfig.py.

◆ saveDetailedSF

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.saveDetailedSF

Definition at line 463 of file PhotonAnalysisConfig.py.

◆ selectionName

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.selectionName

Definition at line 416 of file PhotonAnalysisConfig.py.


The documentation for this class was generated from the following file: