Skip to content
Snippets Groups Projects
Commit bb718e76 authored by Nils Erik Krumnack's avatar Nils Erik Krumnack Committed by Adam Edward Barton
Browse files

allow splitting calibration and smearing for e-gamma objects ATLASG-2358

allow splitting calibration and smearing for e-gamma objects

This is purely experimental and I haven't validated it beyond making
sure it doesn't crash. The main purpose of putting it in is to make it
easier for others to test and validate this.

Note that for the moment this has to recalibrate the objects from
PHYSLITE. This can only be avoided by adding an unsmeared energy to
PHYSLITE (to avoid double-smearing). Still, one step at a time.
parent 4a51c451
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,35 @@ class ElectronCalibrationConfig (ConfigBlock) :
"full simulation samples. Only for testing purposes. The default "
"is False.")
self.addOption ('splitCalibrationAndSmearing', False, type=bool,
info="EXPERIMENTAL: This splits the EgammaCalibrationAndSmearingTool "
" into two steps. The first step applies a baseline calibration that "
"is not affected by systematics. The second step then applies the "
"systematics dependent corrections. The net effect is that the "
"slower first step only has to be run once, while the second is run "
"once per systematic. ATLASG-2358")
def makeCalibrationAndSmearingAlg (self, config, name) :
"""Create the calibration and smearing algorithm
Factoring this out into its own function, as we want to
instantiate it in multiple places"""
# Set up the calibration and smearing algorithm:
alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg', name + self.postfix )
config.addPrivateTool( 'calibrationAndSmearingTool',
'CP::EgammaCalibrationAndSmearingTool' )
alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
alg.calibrationAndSmearingTool.decorrelationModel = '1NP_v1'
alg.calibrationAndSmearingTool.useFastSim = (
0 if self.forceFullSimConfig
else int( config.dataType() is DataType.FastSim ))
alg.egammas = config.readName (self.containerName)
alg.egammasOut = config.copyName (self.containerName)
alg.preselection = config.getPreselection (self.containerName, '')
return alg
def makeAlgs (self, config) :
if self.forceFullSimConfig:
......@@ -84,21 +113,40 @@ class ElectronCalibrationConfig (ConfigBlock) :
alg.preselection = config.getPreselection (self.containerName, '')
config.addSelection (self.containerName, '', alg.selectionDecoration)
# Set up the calibration and smearing algorithm:
alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg',
'ElectronCalibrationAndSmearingAlg' + self.postfix )
config.addPrivateTool( 'calibrationAndSmearingTool',
'CP::EgammaCalibrationAndSmearingTool' )
alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
alg.calibrationAndSmearingTool.decorrelationModel = '1NP_v1'
alg.calibrationAndSmearingTool.useFastSim = (
0 if self.forceFullSimConfig
else int( config.dataType() is DataType.FastSim ))
alg.egammas = config.readName (self.containerName)
alg.egammasOut = config.copyName (self.containerName)
alg.preselection = config.getPreselection (self.containerName, '')
if config.isPhyslite() and not self.recalibratePhyslite :
alg.skipNominal = True
if not self.splitCalibrationAndSmearing :
# Set up the calibration and smearing algorithm:
alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationAndSmearingAlg')
if config.isPhyslite() and not self.recalibratePhyslite :
alg.skipNominal = True
else:
# This splits the EgammaCalibrationAndSmearingTool into two
# steps. The first step applies a baseline calibration that
# is not affected by systematics. The second step then
# applies the systematics dependent corrections. The net
# effect is that the slower first step only has to be run
# once, while the second is run once per systematic.
#
# For now (22 May 24) this has to happen in the same job, as
# the output of the first step is not part of PHYSLITE, and
# even for the nominal the output of the first and second
# step are different. In the future the plan is to put both
# the output of the first and second step into PHYSLITE,
# allowing to skip the first step when running on PHYSLITE.
#
# WARNING: All of this is experimental, see: ATLASG-2358
# Set up the calibration algorithm:
alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronBaseCalibrationAlg')
# turn off systematics for the calibration step
alg.noToolSystematics = True
# turn off smearing for the calibration step
alg.calibrationAndSmearingTool.doSmearing = False
# Set up the smearing algorithm:
alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationSystematicsAlg')
# turn off scale corrections for the smearing step
alg.calibrationAndSmearingTool.doScaleCorrection = False
alg.calibrationAndSmearingTool.useMVACalibration = False
if self.minPt > 0 :
# Set up the the pt selection
......
......@@ -51,6 +51,33 @@ class PhotonCalibrationConfig (ConfigBlock) :
info="whether to force the tool to use the configuration meant for "
"full simulation samples. Only for testing purposes. "
"The default is False.")
self.addOption ('splitCalibrationAndSmearing', False, type=bool,
info="EXPERIMENTAL: This splits the EgammaCalibrationAndSmearingTool "
" into two steps. The first step applies a baseline calibration that "
"is not affected by systematics. The second step then applies the "
"systematics dependent corrections. The net effect is that the "
"slower first step only has to be run once, while the second is run "
"once per systematic. ATLASG-2358")
def makeCalibrationAndSmearingAlg (self, config, name) :
"""Create the calibration and smearing algorithm
Factoring this out into its own function, as we want to
instantiate it in multiple places"""
# Set up the calibration and smearing algorithm:
alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg', name + self.postfix )
config.addPrivateTool( 'calibrationAndSmearingTool',
'CP::EgammaCalibrationAndSmearingTool' )
alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
alg.calibrationAndSmearingTool.decorrelationModel = '1NP_v1'
alg.calibrationAndSmearingTool.useFastSim = (
0 if self.forceFullSimConfig
else int( config.dataType() is DataType.FastSim ))
alg.egammas = config.readName (self.containerName)
alg.egammasOut = config.copyName (self.containerName)
alg.preselection = config.getPreselection (self.containerName, '')
return alg
def makeAlgs (self, config) :
......@@ -129,21 +156,40 @@ class PhotonCalibrationConfig (ConfigBlock) :
alg.photonsOut = config.copyName (self.containerName)
alg.preselection = config.getPreselection (self.containerName, '')
# Do calibration
alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg',
'PhotonCalibrationAndSmearingAlg' + postfix )
config.addPrivateTool( 'calibrationAndSmearingTool',
'CP::EgammaCalibrationAndSmearingTool' )
alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
alg.calibrationAndSmearingTool.decorrelationModel = '1NP_v1'
alg.calibrationAndSmearingTool.useFastSim = (
0 if self.forceFullSimConfig
else int( config.dataType() is DataType.FastSim ))
alg.egammas = config.readName (self.containerName)
alg.egammasOut = config.copyName (self.containerName)
alg.preselection = config.getPreselection (self.containerName, '')
if config.isPhyslite() and not self.recalibratePhyslite :
alg.skipNominal = True
if not self.splitCalibrationAndSmearing :
# Set up the calibration and smearing algorithm:
alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonCalibrationAndSmearingAlg')
if config.isPhyslite() and not self.recalibratePhyslite :
alg.skipNominal = True
else:
# This splits the EgammaCalibrationAndSmearingTool into two
# steps. The first step applies a baseline calibration that
# is not affected by systematics. The second step then
# applies the systematics dependent corrections. The net
# effect is that the slower first step only has to be run
# once, while the second is run once per systematic.
#
# For now (22 May 24) this has to happen in the same job, as
# the output of the first step is not part of PHYSLITE, and
# even for the nominal the output of the first and second
# step are different. In the future the plan is to put both
# the output of the first and second step into PHYSLITE,
# allowing to skip the first step when running on PHYSLITE.
#
# WARNING: All of this is experimental, see: ATLASG-2358
# Set up the calibration algorithm:
alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonBaseCalibrationAlg')
# turn off systematics for the calibration step
alg.noToolSystematics = True
# turn off smearing for the calibration step
alg.calibrationAndSmearingTool.doSmearing = False
# Set up the smearing algorithm:
alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonCalibrationSystematicsAlg')
# turn off scale corrections for the smearing step
alg.calibrationAndSmearingTool.doScaleCorrection = False
alg.calibrationAndSmearingTool.useMVACalibration = False
if self.minPt > 0:
# Set up the the pt selection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment