diff --git a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/FullCPAlgorithmsTest.py index 8acec3d0ead5623a81b7b9d1d2c22b0304298fca..f9fae6787a8938955e36d8cbd7f2623518460552 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 @@ -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', 'LooseBLayerLH') 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 30688d6a12a42dd84367a947a1db8c9815a2506d..0de2ca377edbc874105c856cb71255e507058042 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,12 +156,17 @@ 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 config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' ) dfFlag = "DFCommonElectronsLH" + self.likelihoodWP.split('LH')[0] + dfFlag = dfFlag.replace("BLayer","BL") alg.selectionTool.selectionFlags = [dfFlag] algDecorCount = 1 else: @@ -170,7 +176,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 +226,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 +241,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 +337,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 +349,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 +362,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) diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py index a25a71051bcaf2ec4c6f9feae0ed83f8ab6b03d6..6e789d97a1b65abed8afa122ba88ac4f0b07222f 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: