From 22d6e07549c6dc6f689f52a12dbcb6e3c1384a56 Mon Sep 17 00:00:00 2001 From: Baptiste Ravina <baptiste.ravina@sheffield.ac.uk> Date: Thu, 29 Jun 2023 12:14:45 +0200 Subject: [PATCH 1/5] updates to electron algorithms --- .../python/FullCPAlgorithmsTest.py | 4 +- .../python/ElectronAnalysisConfig.py | 82 +++++++++++++++++-- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py index 8acec3d0ead5..8d7df9447a8a 100644 --- a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py +++ b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py @@ -579,9 +579,9 @@ def makeSequenceBlocks (dataType, algSeq, forCompare, isPhyslite, noPhysliteBrok configSeq += makeConfig ('Electrons', 'AnaElectrons') configSeq += makeConfig ('Electrons.Selection', 'AnaElectrons.loose') if likelihood: - configSeq.setOptionValue ('.likelihoodWP', 'LooseLHElectron') + configSeq.setOptionValue ('.likelihoodWP', 'LooseLH') else: - configSeq.setOptionValue ('.likelihoodWP', 'LooseDNNElectron') + configSeq.setOptionValue ('.likelihoodWP', 'LooseDNN') # FIXME: fails for PHYSLITE with missing data item # ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000 if not noPhysliteBroken : diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py index 30688d6a12a4..ea261526fbe6 100644 --- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py +++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py @@ -133,6 +133,7 @@ class ElectronWorkingPointConfig (ConfigBlock) : self.addOption ('isolationWP', None, type=str) self.addOption ('recomputeLikelihood', False, type=bool) self.addOption ('chargeIDSelection', False, type=bool) + self.addOption ('isRun3Geo', False, type=bool) def makeAlgs (self, config) : @@ -155,7 +156,11 @@ class ElectronWorkingPointConfig (ConfigBlock) : # Rerun the likelihood ID config.addPrivateTool( 'selectionTool', 'AsgElectronLikelihoodTool' ) alg.selectionTool.primaryVertexContainer = 'PrimaryVertices' - alg.selectionTool.WorkingPoint = self.likelihoodWP + # Here we have to match the naming convention of EGSelectorConfigurationMapping.h + if self.isRun3Geo: + alg.selectionTool.WorkingPoint = self.likelihoodWP + 'Electron' + else: + alg.selectionTool.WorkingPoint = self.likelihoodWP + 'Electron_Run2' algDecorCount = 7 else: # Select from Derivation Framework flags @@ -170,7 +175,11 @@ class ElectronWorkingPointConfig (ConfigBlock) : if self.recomputeLikelihood: # Rerun the DNN ID config.addPrivateTool( 'selectionTool', 'AsgElectronSelectorTool' ) - alg.selectionTool.WorkingPoint = self.likelihoodWP + # Here we have to match the naming convention of EGSelectorConfigurationMapping.h + if self.isRun3Geo: + raise ValueError ( "DNN working points are not available for Run 3 yet.") + else: + alg.selectionTool.WorkingPoint = self.likelihoodWP + 'Electron' algDecorCount = 6 else: # Select from Derivation Framework flags @@ -216,13 +225,13 @@ class ElectronWorkingPointConfig (ConfigBlock) : alg.preselection = config.getFullSelection (self.containerName, self.selectionName) config.addOutputVar (self.containerName, 'baselineSelection' + postfix, 'select' + postfix) - # Set up the electron efficiency correction algorithm: + # Set up the RECO electron efficiency correction algorithm: if config.dataType() != 'data': alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg', - 'ElectronEfficiencyCorrectionAlg' + postfix ) + 'ElectronEfficiencyCorrectionAlgReco' + postfix ) config.addPrivateTool( 'efficiencyCorrectionTool', 'AsgElectronEfficiencyCorrectionTool' ) - alg.scaleFactorDecoration = 'effSF' + selectionPostfix + '_%SYS%' + alg.scaleFactorDecoration = 'el_reco_effSF' + selectionPostfix + '_%SYS%' alg.efficiencyCorrectionTool.RecoKey = "Reconstruction" alg.efficiencyCorrectionTool.CorrelationModel = "TOTAL" if config.dataType() == 'afii': @@ -231,13 +240,67 @@ class ElectronWorkingPointConfig (ConfigBlock) : elif config.dataType() == 'mc': alg.efficiencyCorrectionTool.ForceDataType = \ PATCore.ParticleDataType.Full + if not self.isRun3Geo: + alg.efficiencyCorrectionTool.MapFilePath = "ElectronEfficiencyCorrection/2015_2018/rel21.2/Precision_Summer2020_v1/map4.txt" alg.outOfValidity = 2 #silent - alg.outOfValidityDeco = 'bad_eff' + selectionPostfix + alg.outOfValidityDeco = 'el_reco_bad_eff' + selectionPostfix alg.electrons = config.readName (self.containerName) alg.preselection = config.getPreselection (self.containerName, self.selectionName) - config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'effSF' + postfix) + config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'reco_effSF' + postfix) + # Set up the ID electron efficiency correction algorithm: + if config.dataType() != 'data': + alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg', + 'ElectronEfficiencyCorrectionAlgID' + postfix ) + config.addPrivateTool( 'efficiencyCorrectionTool', + 'AsgElectronEfficiencyCorrectionTool' ) + alg.scaleFactorDecoration = 'el_id_effSF' + selectionPostfix + '_%SYS%' + alg.efficiencyCorrectionTool.IdKey = self.likelihoodWP.replace("LH","") + alg.efficiencyCorrectionTool.CorrelationModel = "TOTAL" + if config.dataType() == 'afii': + alg.efficiencyCorrectionTool.ForceDataType = \ + PATCore.ParticleDataType.Fast + elif config.dataType() == 'mc': + alg.efficiencyCorrectionTool.ForceDataType = \ + PATCore.ParticleDataType.Full + if not self.isRun3Geo: + alg.efficiencyCorrectionTool.MapFilePath = "ElectronEfficiencyCorrection/2015_2018/rel21.2/Precision_Summer2020_v1/map4.txt" + alg.outOfValidity = 2 #silent + alg.outOfValidityDeco = 'el_id_bad_eff' + selectionPostfix + alg.electrons = config.readName (self.containerName) + alg.preselection = config.getPreselection (self.containerName, self.selectionName) + config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'id_effSF' + postfix) + + # Set up the ISO electron efficiency correction algorithm: + if config.dataType() != 'data' and self.isolationWP != 'NonIso': + alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg', + 'ElectronEfficiencyCorrectionAlgIsol' + postfix ) + config.addPrivateTool( 'efficiencyCorrectionTool', + 'AsgElectronEfficiencyCorrectionTool' ) + alg.scaleFactorDecoration = 'el_isol_effSF' + selectionPostfix + '_%SYS%' + alg.efficiencyCorrectionTool.IdKey = self.likelihoodWP.replace("LH","") + alg.efficiencyCorrectionTool.IsoKey = self.isolationWP + alg.efficiencyCorrectionTool.CorrelationModel = "TOTAL" + if config.dataType() == 'afii': + alg.efficiencyCorrectionTool.ForceDataType = \ + PATCore.ParticleDataType.Fast + elif config.dataType() == 'mc': + alg.efficiencyCorrectionTool.ForceDataType = \ + PATCore.ParticleDataType.Full + if not self.isRun3Geo: + alg.efficiencyCorrectionTool.MapFilePath = "ElectronEfficiencyCorrection/2015_2018/rel21.2/Precision_Summer2020_v1/map4.txt" + alg.outOfValidity = 2 #silent + alg.outOfValidityDeco = 'el_isol_bad_eff' + selectionPostfix + alg.electrons = config.readName (self.containerName) + alg.preselection = config.getPreselection (self.containerName, self.selectionName) + config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'isol_effSF' + postfix) + + # TO-DO: add trigger SFs, for which we need ID key + ISO key + Trigger key ! + if self.chargeIDSelection: + # ECIDS is currently not supported in R22. + # SFs might become available or it will be part of the DNN ID. + pass def makeElectronCalibrationConfig( seq, containerName, postfix = None, @@ -273,7 +336,8 @@ def makeElectronCalibrationConfig( seq, containerName, postfix = None, def makeElectronWorkingPointConfig( seq, containerName, workingPoint, postfix, recomputeLikelihood = None, - chargeIDSelection = None ): + chargeIDSelection = None, + isRun3Geo = None ): """Create electron analysis configuration blocks Keyword arguments: @@ -284,6 +348,7 @@ def makeElectronWorkingPointConfig( seq, containerName, workingPoint, names are unique. recomputeLikelihood -- Whether to rerun the LH. If not, use derivation flags chargeIDSelection -- Whether or not to perform charge ID/flip selection + isRun3Geo -- Whether to retrieve Run 3 efficiency SFs """ @@ -296,4 +361,5 @@ def makeElectronWorkingPointConfig( seq, containerName, workingPoint, config.setOptionValue ('isolationWP', splitWP[1]) config.setOptionValue ('recomputeLikelihood', recomputeLikelihood, noneAction='ignore') config.setOptionValue ('chargeIDSelection', chargeIDSelection, noneAction='ignore') + config.setOptionValue ('isRun3Geo', isRun3Geo, noneAction='ignore') seq.append (config) -- GitLab From 90f099154becd077d54b6bfdc06d88970b70894b Mon Sep 17 00:00:00 2001 From: Baptiste Ravina <baptiste.ravina@sheffield.ac.uk> Date: Fri, 30 Jun 2023 15:11:15 +0200 Subject: [PATCH 2/5] handle LooseBLayer properly --- .../EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py index ea261526fbe6..0de2ca377edb 100644 --- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py +++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py @@ -166,6 +166,7 @@ class ElectronWorkingPointConfig (ConfigBlock) : # Select from Derivation Framework flags config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' ) dfFlag = "DFCommonElectronsLH" + self.likelihoodWP.split('LH')[0] + dfFlag = dfFlag.replace("BLayer","BL") alg.selectionTool.selectionFlags = [dfFlag] algDecorCount = 1 else: -- GitLab From 9f666395a10ab01d534576f93781d9a5e326bf97 Mon Sep 17 00:00:00 2001 From: Baptiste Ravina <baptiste.ravina@sheffield.ac.uk> Date: Fri, 30 Jun 2023 15:11:51 +0200 Subject: [PATCH 3/5] fix AnalysisAlgorithmsConfig_TestJobFullSimConfig_ctest --- .../AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py index 8d7df9447a8a..510ee6738632 100644 --- a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py +++ b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py @@ -579,7 +579,7 @@ def makeSequenceBlocks (dataType, algSeq, forCompare, isPhyslite, noPhysliteBrok configSeq += makeConfig ('Electrons', 'AnaElectrons') configSeq += makeConfig ('Electrons.Selection', 'AnaElectrons.loose') if likelihood: - configSeq.setOptionValue ('.likelihoodWP', 'LooseLH') + configSeq.setOptionValue ('.likelihoodWP', 'LooseBLayerLH') else: configSeq.setOptionValue ('.likelihoodWP', 'LooseDNN') # FIXME: fails for PHYSLITE with missing data item -- GitLab From df6ec0728f3dbfccc9d17ef7a9fb51e2af7b6319 Mon Sep 17 00:00:00 2001 From: Baptiste Ravina <baptiste.ravina@sheffield.ac.uk> Date: Fri, 30 Jun 2023 19:48:23 +0200 Subject: [PATCH 4/5] trying to match the sequence test --- .../AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py index 510ee6738632..f9fae6787a89 100644 --- a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py +++ b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py @@ -208,7 +208,7 @@ def makeSequenceOld (dataType, algSeq, forCompare, isPhyslite, noPhysliteBroken, likelihood = True recomputeLikelihood=False if likelihood: - workingpoint = 'LooseLHElectron.Loose_VarRad' + workingpoint = 'LooseBLayerLHElectron.Loose_VarRad' else: workingpoint = 'LooseDNNElectron.Loose_VarRad' # FIXME: fails for PHYSLITE with missing data item -- GitLab From 99e21cbd42761fa7d92a1b2576fd7c2580842a8a Mon Sep 17 00:00:00 2001 From: Baptiste Ravina <baptiste.ravina@sheffield.ac.uk> Date: Fri, 30 Jun 2023 21:37:42 +0200 Subject: [PATCH 5/5] fix CI --- .../EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py index a25a71051bca..6e789d97a1b6 100644 --- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py +++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py @@ -248,6 +248,7 @@ def makeElectronWorkingPointSequence( seq, dataType, workingPoint, # Select from Derivation Framework flags addPrivateTool( alg, 'selectionTool', 'CP::AsgFlagSelectionTool' ) dfFlag = "DFCommonElectronsLH" + likelihoodWP.split('LH')[0] + dfFlag = dfFlag.replace("BLayer","BL") alg.selectionTool.selectionFlags = [dfFlag] algDecorCount = 1 else: -- GitLab