From bc54c1eb83c01a526fa679828ffbc72449f9dbe4 Mon Sep 17 00:00:00 2001
From: Antonio De Maria <antonio.de.maria@cern.ch>
Date: Thu, 27 Mar 2025 18:07:57 +0100
Subject: [PATCH 1/2] update TauAnalysisTools to read new eVeto SF
 recommendations

---
 .../Root/TauEfficiencyCorrectionsTool.cxx     | 40 +++++++++++++++++--
 .../TauEfficiencyCorrectionsTool.h            |  4 +-
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauEfficiencyCorrectionsTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauEfficiencyCorrectionsTool.cxx
index b29282d2c682..b669beec7159 100644
--- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauEfficiencyCorrectionsTool.cxx
+++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauEfficiencyCorrectionsTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 // EDM include(s):
@@ -44,7 +44,7 @@ TauEfficiencyCorrectionsTool::TauEfficiencyCorrectionsTool( const std::string& s
   declareProperty( "UseTauSubstructure",           m_bUseTauSubstructure           = false );
   declareProperty( "JetIDLevel",                   m_iJetIDLevel                   = (int)JETIDNONE );
   declareProperty( "EleIDLevel",                   m_iEleIDLevel                   = (int)ELEIDNONE );
-  declareProperty( "MCCampaign",                   m_sMCCampaign                   = "" ); // MC16a, MC16d or MC16e
+  declareProperty( "Campaign",                     m_sCampaign                     = "" ); // MC20, MC23
   declareProperty( "useFastSim",                   m_useFastSim                    = false );
   declareProperty( "SkipTruthMatchCheck",          m_bSkipTruthMatchCheck          = false );
   declareProperty( "PileupReweightingTool",        m_tPRWTool );
@@ -191,7 +191,7 @@ void TauEfficiencyCorrectionsTool::printConfig() const
   ATH_MSG_DEBUG( "  UseTauSubstructure " << m_bUseTauSubstructure );
   ATH_MSG_DEBUG( "  JetIDLevel " << m_iJetIDLevel );
   ATH_MSG_DEBUG( "  EleIDLevel " << m_iEleIDLevel );
-  ATH_MSG_DEBUG( "  MCCampaign " << m_sMCCampaign );
+  ATH_MSG_DEBUG( "  Campaign " << m_sCampaign );
   ATH_MSG_DEBUG( "  useFastSim " << m_useFastSim);
 }
 
@@ -311,8 +311,40 @@ StatusCode TauEfficiencyCorrectionsTool::initializeTools_2025_prerec()
   std::string sDirectory = "TauAnalysisTools/" + std::string(sSharedFilesVersion) + "/EfficiencyCorrections/";
   for (auto iEfficiencyCorrectionType : m_vEfficiencyCorrectionTypes){
 
-    if (iEfficiencyCorrectionType == SFTriggerHadTau)
+    if (iEfficiencyCorrectionType == SFEleIDElectron)
     {
+      // the path must be updated once RNN eVeto SFs are available
+      if (m_sInputFilePathEleIDElectron.empty()) {
+        if(m_useFastSim) {
+          ATH_MSG_WARNING("No fast-sim recommendation for tau electron veto, using full sim");
+        }
+
+        if(m_sCampaign=="mc23"){
+            if( m_iJetIDLevel == (int)JETIDRNNLOOSE){
+                m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_SF_2022_looseRNNTauID_1p.root"; 
+            } else if( m_iJetIDLevel == (int)JETIDRNNMEDIUM){
+                m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_SF_2022_mediumRNNTauID_1p.root";
+            }
+        } else if(m_sCampaign=="mc20"){
+            if( m_iJetIDLevel == (int)JETIDRNNLOOSE){
+                m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_SF_Run2_looseRNNTauID_1p.root";
+            } else if( m_iJetIDLevel == (int)JETIDRNNMEDIUM){
+                m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_SF_Run2_mediumRNNTauID_1p.root";
+            }
+        }
+      }
+      if (m_sVarNameEleIDElectron.empty()) m_sVarNameEleIDElectron = "TauScaleFactorEleIDElectron";
+
+      asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>* tTool = new asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>("TauAnalysisTools::CommonEfficiencyTool/EleIDElectronTool", this);
+      m_vCommonEfficiencyTools.push_back(tTool);
+      ATH_CHECK(tTool->setProperty("InputFilePath", m_sInputFilePathEleIDElectron));
+      ATH_CHECK(tTool->setProperty("VarName", m_sVarNameEleIDElectron));
+      ATH_CHECK(tTool->setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
+      ATH_CHECK(tTool->setProperty("WP", ConvertEleIDToString(m_iEleIDLevel)));
+      ATH_CHECK(tTool->setProperty("UseTauSubstructure", false));
+
+    } else if (iEfficiencyCorrectionType == SFTriggerHadTau){
+
       if (m_sTriggerName.empty()) {
         ATH_MSG_ERROR("Property \"Trigger\" was not set, please provide a trigger name.");
         return StatusCode::FAILURE;
diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauEfficiencyCorrectionsTool.h b/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauEfficiencyCorrectionsTool.h
index 3b529aeba089..ae0972655154 100644
--- a/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauEfficiencyCorrectionsTool.h
+++ b/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauEfficiencyCorrectionsTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TAUANALYSISTOOLS_TAUEFFICIENCYCORRECTIONSTOOL_H
@@ -118,7 +118,7 @@ private:
   bool m_bReadRandomRunNumber;
   int m_iJetIDLevel;
   int m_iEleIDLevel;
-  std::string m_sMCCampaign;
+  std::string m_sCampaign;
   bool m_useFastSim;
   bool m_firstEvent = false;
   unsigned int m_iRunNumber;
-- 
GitLab


From 7d969fcf3aa4024c84953461ba6aa8b98729d039 Mon Sep 17 00:00:00 2001
From: Antonio De Maria <antonio.de.maria@cern.ch>
Date: Fri, 28 Mar 2025 08:23:25 +0100
Subject: [PATCH 2/2] update CP Alg with Campaign property

---
 .../TauAnalysisAlgorithms/python/TauAnalysisConfig.py        | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py
index db52df38c027..5385ae06f9a6 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py
@@ -193,6 +193,7 @@ class TauWorkingPointConfig (ConfigBlock) :
             config.addPrivateTool( 'efficiencyCorrectionsTool',
                             'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
             alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [0]
+            alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
             alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
             alg.scaleFactorDecoration = 'tau_Reco_effSF' + selectionPostfix + '_%SYS%'
             alg.outOfValidity = 2 #silent
@@ -223,6 +224,7 @@ class TauWorkingPointConfig (ConfigBlock) :
 
                 alg.efficiencyCorrectionsTool.JetIDLevel = JetIDLevel
                 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
+                alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
                 alg.scaleFactorDecoration = 'tau_ID_effSF' + selectionPostfix + '_%SYS%'
                 alg.outOfValidity = 2 #silent
                 alg.outOfValidityDeco = 'bad_ID_eff' + selectionPostfix
@@ -246,6 +248,7 @@ class TauWorkingPointConfig (ConfigBlock) :
                 # since all TauSelectionTool config files have loose eRNN, code only this option for now
                 alg.efficiencyCorrectionsTool.EleIDLevel = 2
                 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
+                alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
                 alg.scaleFactorDecoration = 'tau_EvetoFakeTau_effSF' + selectionPostfix + '_%SYS%'
                 alg.outOfValidity = 2 #silent
                 alg.outOfValidityDeco = 'bad_EvetoFakeTau_eff' + selectionPostfix
@@ -264,6 +267,7 @@ class TauWorkingPointConfig (ConfigBlock) :
 
                 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [8]
                 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
+                alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
                 alg.scaleFactorDecoration = 'tau_EvetoTrueTau_effSF' + selectionPostfix + '_%SYS%'
                 alg.outOfValidity = 2 #silent
                 alg.outOfValidityDeco = 'bad_EvetoTrueTau_eff' + selectionPostfix
@@ -372,6 +376,7 @@ class TauTriggerAnalysisSFBlock (ConfigBlock):
                 # SFTriggerHadTau correction type from
                 # https://gitlab.cern.ch/atlas/athena/-/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/Enums.h#L79
                 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [12]
+                alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
                 alg.efficiencyCorrectionsTool.TriggerName = chain
 
                 # JetIDLevel from
-- 
GitLab