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

Constructor & Destructor Documentation

◆ __init__()

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.__init__ ( self)

Definition at line 308 of file PhotonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 364 of file PhotonAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 370 of file PhotonAnalysisConfig.py.

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

◆ containerName

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.containerName

Definition at line 429 of file PhotonAnalysisConfig.py.

◆ doFSRSelection

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.doFSRSelection

Definition at line 433 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForID

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.forceFullSimConfigForID

Definition at line 378 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForIso

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.forceFullSimConfigForIso

Definition at line 382 of file PhotonAnalysisConfig.py.

◆ noEffSFForID

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.noEffSFForID

Definition at line 457 of file PhotonAnalysisConfig.py.

◆ qualityWP

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

Definition at line 392 of file PhotonAnalysisConfig.py.

◆ recomputeIsEM

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.recomputeIsEM

Definition at line 404 of file PhotonAnalysisConfig.py.

◆ saveCombinedSF

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.saveCombinedSF

Definition at line 508 of file PhotonAnalysisConfig.py.

◆ saveDetailedSF

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.saveDetailedSF

Definition at line 476 of file PhotonAnalysisConfig.py.

◆ selectionName

python.PhotonAnalysisConfig.PhotonWorkingPointConfig.selectionName

Definition at line 429 of file PhotonAnalysisConfig.py.


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