From 0b8398ef839df61a44fd127722c72b4f8f6e9f54 Mon Sep 17 00:00:00 2001
From: Filip Nechansky <filip.nechansky@cern.ch>
Date: Sat, 18 May 2024 01:38:24 +0200
Subject: [PATCH] Implement both DNN ID and ID+CF and add to PHYSLITE

Implement both DNN ID and ID+CF and add to PHYSLITE
---
 .../python/EGammaCommonConfig.py              | 78 +++++++++++++++++++
 .../python/ElectronsCPContent.py              |  2 +-
 .../python/PHYSLITE.py                        |  2 +-
 .../AsgElectronSelectorTool.h                 |  4 +-
 .../Root/AsgElectronSelectorTool.cxx          | 10 ++-
 .../Root/EGSelectorConfigurationMapping.h     | 14 +++-
 .../Root/ElectronDNNCalculator.cxx            | 13 ++--
 .../Root/ElectronDNNCalculator.h              |  5 +-
 Tools/WorkflowTestRunner/python/References.py | 20 ++---
 9 files changed, 125 insertions(+), 23 deletions(-)

diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommonConfig.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommonConfig.py
index 8e393ab9e0f9..a6c9820f260b 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommonConfig.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommonConfig.py
@@ -179,6 +179,39 @@ def EGammaCommonCfg(ConfigFlags):
     )
     acc.addPublicTool(ElectronDNNSelectorTight)
 
+    # ====================================================================
+    # ELECTRON DNN SELECTORS WITHOUT CF REJECTION
+    # ====================================================================
+    # Loose
+    ElectronDNNSelectorLooseNoCF = acc.popToolsAndMerge(
+        AsgElectronSelectorToolCfg(
+            ConfigFlags,
+            name="ElectronDNNSelectorLooseNoCF",
+            WorkingPoint="LooseDNNnoCFElectron",
+        )
+    )
+    acc.addPublicTool(ElectronDNNSelectorLooseNoCF)
+
+    # Medium
+    ElectronDNNSelectorMediumNoCF = acc.popToolsAndMerge(
+        AsgElectronSelectorToolCfg(
+            ConfigFlags,
+            name="ElectronDNNSelectorMediumNoCF",
+            WorkingPoint="MediumDNNnoCFElectron",
+        )
+    )
+    acc.addPublicTool(ElectronDNNSelectorMediumNoCF)
+
+    # Tight
+    ElectronDNNSelectorTightNoCF = acc.popToolsAndMerge(
+        AsgElectronSelectorToolCfg(
+            ConfigFlags,
+            name="ElectronDNNSelectorTightNoCF",
+            WorkingPoint="TightDNNnoCFElectron",
+        )
+    )
+    acc.addPublicTool(ElectronDNNSelectorTightNoCF)
+
     # ====================================================================
     # ELECTRON CHARGE SELECTION
     # ====================================================================
@@ -462,6 +495,48 @@ def EGammaCommonCfg(ConfigFlags):
         )
     )
 
+    # decorate electrons with the output of DNN Loose without CF
+    ElectronPassDNNLooseNoCF = acc.getPrimaryAndMerge(
+        EGElectronLikelihoodToolWrapperCfg(
+            ConfigFlags,
+            name="ElectronPassDNNLooseNoCF",
+            EGammaElectronLikelihoodTool=ElectronDNNSelectorLooseNoCF,
+            EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
+            CutType="",
+            StoreGateEntryName="DFCommonElectronsDNNLooseNoCF",
+            ContainerName="Electrons",
+            StoreTResult=False,
+        )
+    )
+
+    # decorate electrons with the output of DNN Medium without CF
+    ElectronPassDNNMediumNoCF = acc.getPrimaryAndMerge(
+        EGElectronLikelihoodToolWrapperCfg(
+            ConfigFlags,
+            name="ElectronPassDNNMediumNoCF",
+            EGammaElectronLikelihoodTool=ElectronDNNSelectorMediumNoCF,
+            EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
+            CutType="",
+            StoreGateEntryName="DFCommonElectronsDNNMediumNoCF",
+            ContainerName="Electrons",
+            StoreTResult=False,
+        )
+    )
+
+    # decorate electrons with the output of DNN Tight without CF
+    ElectronPassDNNTightNoCF = acc.getPrimaryAndMerge(
+        EGElectronLikelihoodToolWrapperCfg(
+            ConfigFlags,
+            name="ElectronPassDNNTightNoCF",
+            EGammaElectronLikelihoodTool=ElectronDNNSelectorTightNoCF,
+            EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
+            CutType="",
+            StoreGateEntryName="DFCommonElectronsDNNTightNoCF",
+            ContainerName="Electrons",
+            StoreTResult=False,
+        )
+    )
+
     # decorate electrons with the output of ECIDS
     if ConfigFlags.Derivation.Egamma.addECIDS:
         ElectronPassECIDS = acc.getPrimaryAndMerge(
@@ -636,6 +711,9 @@ def EGammaCommonCfg(ConfigFlags):
         ElectronPassDNNLoose,
         ElectronPassDNNMedium,
         ElectronPassDNNTight,
+        ElectronPassDNNLooseNoCF,
+        ElectronPassDNNMediumNoCF,
+        ElectronPassDNNTightNoCF,
         PhotonPassIsEMLoose,
         PhotonPassIsEMMedium,
         PhotonPassIsEMTight,
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py
index 6cf2875c37bc..470e358346a6 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py
@@ -2,7 +2,7 @@
 
 ElectronsCPContent = [
 "Electrons",
-"ElectronsAux.trackParticleLinks.pt.eta.phi.m.charge.author.OQ.DFCommonElectronsLHVeryLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHLooseBL.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsLHVeryLooseIsEMValue.DFCommonElectronsLHLooseIsEMValue.DFCommonElectronsLHLooseBLIsEMValue.DFCommonElectronsLHMediumIsEMValue.DFCommonElectronsLHTightIsEMValue.DFCommonElectronsDNNLoose.DFCommonElectronsDNNLooseIsEMValue.DFCommonElectronsDNNMedium.DFCommonElectronsDNNMediumIsEMValue.DFCommonElectronsDNNTight.DFCommonElectronsDNNTightIsEMValue.DFCommonElectronsDNN_pel.DFCommonElectronsDNN_pcf.DFCommonElectronsDNN_ppc.DFCommonElectronsDNN_phf.DFCommonElectronsDNN_ple.DFCommonElectronsDNN_plh.ptvarcone20.topoetcone20.topoetcone20ptCorrection.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.neflowisol20.core57cellsEnergyCorrection.topoetconecoreConeEnergyCorrection.DFCommonCrackVetoCleaning.caloClusterLinks.ambiguityLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.ambiguityType.DFCommonAddAmbiguity.topoetcone20_CloseByCorr.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.Eadded_Lr2.Eadded_Lr3",
+"ElectronsAux.trackParticleLinks.pt.eta.phi.m.charge.author.OQ.DFCommonElectronsLHVeryLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHLooseBL.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsLHVeryLooseIsEMValue.DFCommonElectronsLHLooseIsEMValue.DFCommonElectronsLHLooseBLIsEMValue.DFCommonElectronsLHMediumIsEMValue.DFCommonElectronsLHTightIsEMValue.DFCommonElectronsDNNLoose.DFCommonElectronsDNNLooseIsEMValue.DFCommonElectronsDNNMedium.DFCommonElectronsDNNMediumIsEMValue.DFCommonElectronsDNNTight.DFCommonElectronsDNNTightIsEMValue.DFCommonElectronsDNN_pel.DFCommonElectronsDNN_pcf.DFCommonElectronsDNN_ppc.DFCommonElectronsDNN_phf.DFCommonElectronsDNN_ple.DFCommonElectronsDNN_plh.DFCommonElectronsDNNLooseNoCF.DFCommonElectronsDNNMediumNoCF.DFCommonElectronsDNNTightNoCF.ptvarcone20.topoetcone20.topoetcone20ptCorrection.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.neflowisol20.core57cellsEnergyCorrection.topoetconecoreConeEnergyCorrection.DFCommonCrackVetoCleaning.caloClusterLinks.ambiguityLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.ambiguityType.DFCommonAddAmbiguity.topoetcone20_CloseByCorr.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.Eadded_Lr2.Eadded_Lr3",
 "GSFTrackParticles",
 "GSFTrackParticlesAux.chiSquared.phi.d0.theta.qOverP.definingParametersCovMatrixDiag.definingParametersCovMatrixOffDiag.numberOfPixelHits.numberOfPixelOutliers.numberOfPixelDeadSensors.numberOfSCTHits.numberOfSCTOutliers.numberOfSCTDeadSensors.z0.vz.charge.vertexLink.numberOfInnermostPixelLayerHits.numberOfInnermostPixelLayerOutliers.numberOfNextToInnermostPixelLayerOutliers.expectInnermostPixelLayerHit.truthParticleLink.originalTrackParticle.numberOfNextToInnermostPixelLayerHits.expectNextToInnermostPixelLayerHit",
 "GSFConversionVertices",
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py
index d0103fe8f6c8..c306db64364d 100755
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py
@@ -412,7 +412,7 @@ def PHYSLITECfg(flags):
     btag_variables = [f'GN2v01_p{x}' for x in ['b', 'c', 'u', 'tau']]
     btag_variables += [f'DL1dv01_p{x}' for x in ['b', 'c', 'u']]
     PHYSLITESlimmingHelper.ExtraVariables += [ 
-        'AnalysisElectrons.trackParticleLinks.f1.pt.eta.phi.m.charge.author.DFCommonElectronsLHVeryLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHLooseBL.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsLHVeryLooseIsEMValue.DFCommonElectronsLHLooseIsEMValue.DFCommonElectronsLHLooseBLIsEMValue.DFCommonElectronsLHMediumIsEMValue.DFCommonElectronsLHTightIsEMValue.DFCommonElectronsECIDS.DFCommonElectronsECIDSResult.topoetcone20.topoetcone20ptCorrection.neflowisol20.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.topoetcone20_CloseByCorr.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.caloClusterLinks.ambiguityLink.TruthLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.ambiguityType.OQ',
+        'AnalysisElectrons.trackParticleLinks.f1.pt.eta.phi.m.charge.author.DFCommonElectronsLHVeryLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHLooseBL.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsLHVeryLooseIsEMValue.DFCommonElectronsLHLooseIsEMValue.DFCommonElectronsLHLooseBLIsEMValue.DFCommonElectronsLHMediumIsEMValue.DFCommonElectronsLHTightIsEMValue.DFCommonElectronsDNNLoose.DFCommonElectronsDNNMedium.DFCommonElectronsDNNTight.DFCommonElectronsDNNLooseNoCF.DFCommonElectronsDNNMediumNoCF.DFCommonElectronsDNNTightNoCF.DFCommonElectronsECIDS.DFCommonElectronsECIDSResult.topoetcone20.topoetcone20ptCorrection.neflowisol20.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt500.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.topoetcone20_CloseByCorr.ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.caloClusterLinks.ambiguityLink.TruthLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.ambiguityType.OQ',
         'AnalysisSiHitElectrons.pt.eta.phi.m.charge.author.topoetcone20_CloseByCorr.DFCommonElectronsLHVeryLoose.ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr.OQ.truthOrigin.truthType.firstEgMotherTruthType.firstEgMotherTruthOrigin.z0stheta.d0Normalized.nInnerExpPix.clEta.clPhi',
         'AnalysisPhotons.f1.pt.eta.phi.m.author.OQ.DFCommonPhotonsIsEMLoose.DFCommonPhotonsIsEMMedium.DFCommonPhotonsIsEMTight.DFCommonPhotonsIsEMTightIsEMValue.DFCommonPhotonsCleaning.DFCommonPhotonsCleaningNoTime.ptcone20.topoetcone20.topoetcone40.topoetcone20ptCorrection.topoetcone40ptCorrection.topoetcone20_CloseByCorr.topoetcone40_CloseByCorr.ptcone20_CloseByCorr.caloClusterLinks.vertexLinks.ambiguityLink.TruthLink.truthParticleLink.truthOrigin.truthType',
         'GSFTrackParticles.chiSquared.phi.d0.theta.qOverP.definingParametersCovMatrixDiag.definingParametersCovMatrixOffDiag.z0.vz.charge.vertexLink.numberOfPixelHits.numberOfSCTHits.expectInnermostPixelLayerHit.expectNextToInnermostPixelLayerHit.numberOfInnermostPixelLayerHits.numberOfNextToInnermostPixelLayerHits.originalTrackParticle',
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronSelectorTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronSelectorTool.h
index a09ad5f6623f..19e79f275465 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronSelectorTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronSelectorTool.h
@@ -152,8 +152,10 @@ private:
 
   /// Multiclass model or not
   bool m_multiClass{};
-  /// Multiclass model or not
+  /// Run CF rejection or not
   bool m_CFReject{};
+  /// New or old set of variables 
+  bool m_newVars{};
   /// Use the CF output node in the numerator or the denominator
   bool m_cfSignal{};
   /// Fractions to combine the output nodes of a multiclass model into one discriminant.
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronSelectorTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronSelectorTool.cxx
index 91da564b6e71..847eda31f792 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronSelectorTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronSelectorTool.cxx
@@ -199,9 +199,15 @@ StatusCode AsgElectronSelectorTool::initialize()
     else {
       m_CFReject = false;
     }
+    // This is temporary solution to figure out if the dnn uses old or new set of variables
+    // (qd0+SCT vs d0). Longterm solution will be to define variables used in the dnn
+    // directly  based on `m_variables` so the config can contain any combination of
+    // supported variables
+    auto it = std::find(m_variables.begin(), m_variables.end(), "SCTWeightedCharge");
+    m_newVars = (it != m_variables.end());
 
     // Create an instance of the class calculating the DNN score
-    m_mvaTool = std::make_unique<ElectronDNNCalculator>(this, filename.c_str(), qfilename.c_str(), m_variables, m_multiClass, m_CFReject);
+    m_mvaTool = std::make_unique<ElectronDNNCalculator>(this, filename.c_str(), qfilename.c_str(), m_variables, m_multiClass, m_newVars);
 
     if (m_multiClass){
       // Fractions are only needed if multiclass model is used
@@ -779,7 +785,7 @@ std::vector<float> AsgElectronSelectorTool::calculateMultipleOutputs(const Event
   vars.f1 = f1;
   vars.Eratio = Eratio;
   vars.deltaEta1 = deltaEta1;
-  if (m_CFReject){
+  if (m_newVars){
     vars.qd0 = qd0;
     vars.SCTWeightedCharge = SCTWeightedCharge;
   }
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h
index f5560d130d3a..a9f3d64b079f 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h
@@ -136,7 +136,19 @@ const std::map<std::string, std::string> ElectronDNNPointToConfFile = {
     "ElectronDNNMulticlassMedium.conf"},
   { "TightDNNElectron",
     "ElectronPhotonSelectorTools/offline/mc20_20240509/"
-    "ElectronDNNMulticlassTight.conf"}
+    "ElectronDNNMulticlassTight.conf"},
+   { "VeryLooseDNNnoCFElectron",
+    "ElectronPhotonSelectorTools/offline/mc20_20240515/"
+    "ElectronDNNMulticlassVeryLoose.conf"},
+  { "LooseDNNnoCFElectron",
+    "ElectronPhotonSelectorTools/offline/mc20_20240515/"
+    "ElectronDNNMulticlassLoose.conf"},
+  { "MediumDNNnoCFElectron",
+    "ElectronPhotonSelectorTools/offline/mc20_20240515/"
+    "ElectronDNNMulticlassMedium.conf"},
+  { "TightDNNnoCFElectron",
+    "ElectronPhotonSelectorTools/offline/mc20_20240515/"
+    "ElectronDNNMulticlassTight.conf"}   
 };
 }
 ////////////////////////////////////////////
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.cxx
index 42e2b32704c8..2553b49f75a2 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.cxx
@@ -28,10 +28,10 @@ ElectronDNNCalculator::ElectronDNNCalculator(AsgElectronSelectorTool* owner,
                                              const std::string& quantileFileName,
                                              const std::vector<std::string>& variables,
                                              const bool multiClass,
-                                             const bool CFReject) :
+                                             const bool newVars) :
                                             asg::AsgMessagingForward(owner),
                                             m_multiClass(multiClass),
-                                            m_CFReject(CFReject)
+                                            m_newVars(newVars)
 {
   ATH_MSG_INFO("Initializing ElectronDNNCalculator...");
 
@@ -47,8 +47,11 @@ ElectronDNNCalculator::ElectronDNNCalculator(AsgElectronSelectorTool* owner,
 
   // Create input order for the NN, the data needs to be passed in this exact order
   lwt::InputOrder order;
+  // TODO: for latest DNN `inputVariables` has the same content
+  // as `variables` (including order), check if valid for 
+  // old dnn and if yes use `variables` directly.
   std::vector<std::string> inputVariables;
-  if(m_CFReject){
+  if(m_newVars){
     inputVariables = {"d0significance", "dPOverP",
                                             "deltaEta1", "deltaPhiRescaled2", "trans_TRTPID",
                                             "nPixHitsPlusDeadSensors", "nSCTHitsPlusDeadSensors",
@@ -103,7 +106,7 @@ Eigen::Matrix<float, -1, 1> ElectronDNNCalculator::calculate( const MVAEnum::MVA
 
   // This has to be in the same order as the InputOrder was defined
   
-  if(m_CFReject){
+  if(m_newVars){
     inputVector(0) = transformInput( m_quantiles.d0significance, varsStruct.d0significance);
     inputVector(1) = transformInput( m_quantiles.dPOverP, varsStruct.dPOverP);
     inputVector(2) = transformInput( m_quantiles.deltaEta1, varsStruct.deltaEta1);
@@ -225,7 +228,7 @@ int ElectronDNNCalculator::readQuantileTransformer( TTree* tree, const std::vect
     m_quantiles.Reta.push_back(readVars["Reta"]);
     m_quantiles.Eratio.push_back(readVars["Eratio"]);
     m_quantiles.wtots1.push_back(readVars["wtots1"]);
-    if(m_CFReject){
+    if(m_newVars){
       m_quantiles.SCTWeightedCharge.push_back(readVars["SCTWeightedCharge"]);
       m_quantiles.qd0.push_back(readVars["qd0"]);
     }
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.h
index 9f4cfdd4dcce..09d484f3e93b 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronDNNCalculator.h
@@ -83,7 +83,7 @@ public:
                          const std::string& quantileFileName,
                          const std::vector<std::string>& variablesName,
                          const bool multiClass,
-                         const bool CFReject);
+                         const bool newVars);
 
   /** Standard destructor*/
   ~ElectronDNNCalculator() {};
@@ -106,7 +106,8 @@ private:
   std::vector<double> m_references;
   /// Whether the used model is a multiclass model or not.
   bool m_multiClass;
-  bool m_CFReject; 
+  /// Whether the model uses old or new set of variables.
+  bool m_newVars; 
 
 };
 
diff --git a/Tools/WorkflowTestRunner/python/References.py b/Tools/WorkflowTestRunner/python/References.py
index 19093469171e..41e8df2b84f5 100644
--- a/Tools/WorkflowTestRunner/python/References.py
+++ b/Tools/WorkflowTestRunner/python/References.py
@@ -29,14 +29,14 @@ references_map = {
     "q452": "v10",
     "q454": "v16",
     # Derivations
-    "data_PHYS_Run2": "v22",
-    "data_PHYSLITE_Run2": "v3",
-    "data_PHYS_Run3": "v21",
-    "data_PHYSLITE_Run3": "v3",
-    "mc_PHYS_Run2": "v26",
-    "mc_PHYSLITE_Run2": "v4",
-    "mc_PHYS_Run3": "v27",
-    "mc_PHYSLITE_Run3": "v4",
-    "af3_PHYS_Run3": "v8",
-    "af3_PHYSLITE_Run3": "v4",
+    "data_PHYS_Run2": "v23",
+    "data_PHYSLITE_Run2": "v4",
+    "data_PHYS_Run3": "v22",
+    "data_PHYSLITE_Run3": "v4",
+    "mc_PHYS_Run2": "v27",
+    "mc_PHYSLITE_Run2": "v5",
+    "mc_PHYS_Run3": "v28",
+    "mc_PHYSLITE_Run3": "v5",
+    "af3_PHYS_Run3": "v9",
+    "af3_PHYSLITE_Run3": "v5",
 }
-- 
GitLab