From 6ae26d35545147fab5c855a49e36c9789bda28c9 Mon Sep 17 00:00:00 2001
From: christos <christos@cern.ch>
Date: Thu, 22 Sep 2022 22:43:11 +0200
Subject: [PATCH 1/4] Asg Electron Eff interface, add override final

---
 .../AsgElectronEfficiencyCorrectionTool.h     | 101 +++++++++---------
 .../ElectronChargeEfficiencyCorrectionTool.h  |  39 ++++---
 ...ElectronChargeEfficiencyCorrectionTool.cxx |   8 --
 .../share/ut_TestFunctionality.ref            |   2 +-
 .../util/SFHelpers.cxx                        |  34 +++---
 .../util/SFHelpers.h                          |   3 +-
 .../util/testEgChargeCorr.cxx                 |   2 -
 .../util/testEgEfficiencyCorr.cxx             |  36 +++----
 .../util/testEgEfficiencyCorrFwd.cxx          |  34 +++---
 .../util/testEgEfficiencyCorrWithoutFile.cxx  |   8 +-
 .../IAsgElectronEfficiencyCorrectionTool.h    |  34 +++---
 11 files changed, 158 insertions(+), 143 deletions(-)

diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
index b3a01971092b..7cd35465293e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
@@ -32,7 +32,7 @@ class TElectronEfficiencyCorrectionTool;
 #include "PATInterfaces/CorrectionCode.h"
 #include "PATInterfaces/SystematicRegistry.h"
 
-class AsgElectronEfficiencyCorrectionTool
+class AsgElectronEfficiencyCorrectionTool final
   : virtual public IAsgElectronEfficiencyCorrectionTool
   , public asg::AsgMetadataTool
 {
@@ -42,27 +42,47 @@ class AsgElectronEfficiencyCorrectionTool
 public:
   /// Standard constructor
   AsgElectronEfficiencyCorrectionTool(const std::string& myname);
-
   /// Standard destructor
-  virtual ~AsgElectronEfficiencyCorrectionTool();
-
+  virtual ~AsgElectronEfficiencyCorrectionTool() override final;
   /// Gaudi Service Interface method implementations
-  virtual StatusCode initialize();
+  virtual StatusCode initialize() override final;
 
-  /// Metadata methods
-  virtual StatusCode beginInputFile();
-  virtual StatusCode beginEvent();
+  /*
+   * Metadata tool methods
+   */
+  virtual StatusCode beginInputFile() override final;
+  virtual StatusCode beginEvent() override final;
 
-  int getNumberOfToys() { return m_number_of_toys; };
+  /*
+   * ISystematic tool methods
+   */
+  /// returns: the list of all systematics this tool can be affected by
+  virtual CP::SystematicSet affectingSystematics() const override final;
+  /// returns: the list of all systematics this tool recommends to use
+  virtual CP::SystematicSet recommendedSystematics() const override final;
+  /// returns: whether this tool is affected by the given systematis
+  virtual bool isAffectedBySystematic(
+    const CP::SystematicVariation& systematic) const override final;
+  /// Configure this tool for the given systematics
+  virtual StatusCode applySystematicVariation(
+    const CP::SystematicSet& systConfig) override final;
 
-  CP::CorrectionCode getEfficiencyScaleFactor(
+  /*
+   * IAsgElectronEfficiencyCorrectionTool methods
+   */
+  virtual CP::CorrectionCode getEfficiencyScaleFactor(
     const xAOD::Electron& inputObject,
-    double& efficiencyScaleFactor) const;
-  CP::CorrectionCode applyEfficiencyScaleFactor(
-    const xAOD::Electron& inputObject) const;
-
+    double& efficiencyScaleFactor) const override final;
+  //
+  virtual CP::CorrectionCode applyEfficiencyScaleFactor(
+    const xAOD::Electron& inputObject) const override final;
+  //
+  virtual int getNumberOfToys() const override final
+  {
+    return m_number_of_toys;
+  };
   /// print available/implemented correlation models
-  void printCorrelationModels()
+  virtual void printCorrelationModels() const override final
   {
     ATH_MSG_INFO(
       " Available Correlation Models for the ElectronEfficiencyCorrectionTool");
@@ -74,47 +94,34 @@ public:
     ATH_MSG_INFO("TOTAL");
   };
 
-  /// returns: whether this tool is affected by the given systematis
-  virtual bool isAffectedBySystematic(
-    const CP::SystematicVariation& systematic) const;
-
-  /// returns: the list of all systematics this tool can be affected by
-  virtual CP::SystematicSet affectingSystematics() const;
-
-  /// returns: the list of all systematics this tool recommends to use
-  virtual CP::SystematicSet recommendedSystematics() const;
-
   /// returns: the currently applied systematics
-  const CP::SystematicSet& appliedSystematics() const
+  virtual const CP::SystematicSet& appliedSystematics() const override final
   {
     return *m_appliedSystematics;
   }
 
-  /// Configure this tool for the given systematics
-  virtual StatusCode applySystematicVariation(
-    const CP::SystematicSet& systConfig);
-
-  StatusCode registerSystematics();
-
-  int systUncorrVariationIndex(const xAOD::Electron& inputObject) const;
+  virtual int systUncorrVariationIndex(
+    const xAOD::Electron& inputObject) const override final;
 
-  // Private member variables
 private:
-  // To check if the metadat can be retrieved
-  bool m_metadata_retrieved = false;
-
-  // Get the simulation type from metadata
-  StatusCode get_simType_from_metadata(
-    PATCore::ParticleDataType::DataType& result) const;
+  StatusCode registerSystematics();
 
   int currentSimplifiedUncorrSystRegion(const double cluster_eta,
                                         const double et) const;
   int currentUncorrSystRegion(const double cluster_eta, const double et) const;
 
-  /// The main calculate method: the actual correction factors are determined
-  /// here
+  /// initialize the systematics
   StatusCode InitSystematics();
 
+  // Gets the correction filename from map
+  virtual StatusCode getFile(const std::string& recokey,
+                             const std::string& idkey,
+                             const std::string& isokey,
+                             const std::string& trigkey);
+  // Get the simulation type from metadata
+  StatusCode get_simType_from_metadata(
+    PATCore::ParticleDataType::DataType& result) const;
+
   // struct for toys
   struct SystConf
   {
@@ -123,11 +130,8 @@ private:
     float m_toy_scale;
   };
 
-  // Gets the correction filename from map
-  virtual StatusCode getFile(const std::string& recokey,
-                             const std::string& idkey,
-                             const std::string& isokey,
-                             const std::string& trigkey);
+  // To check if the metadat can be retrieved
+  bool m_metadata_retrieved = false;
 
   /// Pointer to the underlying ROOT based tool
   Root::TElectronEfficiencyCorrectionTool* m_rootTool;
@@ -201,13 +205,12 @@ private:
   TH2F* m_UncorrRegions;
   int m_nSimpleUncorrSyst;
 
-  //Caching of variations we know after initialize
+  // Caching of variations we know after initialize
   std::string m_prefixUncorr;
   std::string m_toysBasename;
   std::vector<CP::SystematicVariation> m_corrVarUp;
   std::vector<CP::SystematicVariation> m_corrVarDown;
 
-
 }; // End: class definition
 
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h
index 94c96d465831..ca2bbb36a294 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h
@@ -23,7 +23,7 @@ class IParticle;
 
 namespace CP {
 
-class ElectronChargeEfficiencyCorrectionTool
+class ElectronChargeEfficiencyCorrectionTool final
   : virtual public IAsgElectronEfficiencyCorrectionTool
   , public asg::AsgTool
 {
@@ -39,41 +39,38 @@ public:
 
 public:
   /// Gaudi Service Interface method implementations
-  virtual StatusCode initialize();
+  virtual StatusCode initialize() override final;
 
-  /// Gaudi Service Interface method implementations
-  virtual StatusCode finalize();
 
   /// Retrieve the Scale factor
   virtual CP::CorrectionCode getEfficiencyScaleFactor(
     const xAOD::Electron& inputObject,
-    double& sf) const;
+    double& sf) const override final;
 
   /// Decorate the electron
   virtual CP::CorrectionCode applyEfficiencyScaleFactor(
-    const xAOD::Electron& inputObject) const;
+    const xAOD::Electron& inputObject) const override final;
 
   /// Returns whether this tool is affected by the given systematics
   virtual bool isAffectedBySystematic(
-    const SystematicVariation& systematic) const;
+    const SystematicVariation& systematic) const override final;
 
   /// Returns the list of all systematics this tool can be affected by
-  virtual SystematicSet affectingSystematics() const;
+  virtual SystematicSet affectingSystematics() const override final;
 
   /// Returns the list of all systematics this tool recommends to use
-  virtual CP::SystematicSet recommendedSystematics() const;
+  virtual CP::SystematicSet recommendedSystematics() const override final;
 
-  virtual StatusCode applySystematicVariation(const SystematicSet& systConfig);
+  virtual StatusCode applySystematicVariation(const SystematicSet& systConfig) override final;
 
-  StatusCode registerSystematics();
 
   /// returns: the currently applied systematics
-  const CP::SystematicSet& appliedSystematics() const
+  virtual const CP::SystematicSet& appliedSystematics() const override  final
   {
     return *m_appliedSystematics;
   }
 
-  int systUncorrVariationIndex(const xAOD::Electron&) const
+  virtual int systUncorrVariationIndex(const xAOD::Electron&) const override final
   {
     ATH_MSG_WARNING("systUncorrVariationIndex is not implemented in "
                     "ElectronChargeEfficiencyCorrectionTool");
@@ -81,8 +78,24 @@ public:
   }
 
   //
+  //
+  virtual int getNumberOfToys() const override final
+  {
+    ATH_MSG_WARNING("No toysimplemented in "
+                    "ElectronChargeEfficiencyCorrectionTool");
+ 
+    return -1;
+  };
+  /// print available/implemented correlation models
+  virtual void printCorrelationModels() const override final
+  {
+    ATH_MSG_INFO(
+      "ONLY A DEFAULT Correlation model available for now");
+  };
 
+ 
 private:
+  StatusCode registerSystematics();
   /// Get the charge flip rate rate given pt, eta, histogram
   float getChargeFlipRate(double eta,
                           double pt,
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/ElectronChargeEfficiencyCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/ElectronChargeEfficiencyCorrectionTool.cxx
index cabedf4a44dc..aa376a01495b 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/ElectronChargeEfficiencyCorrectionTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/ElectronChargeEfficiencyCorrectionTool.cxx
@@ -331,14 +331,6 @@ CP::ElectronChargeEfficiencyCorrectionTool::initialize()
   return StatusCode::SUCCESS;
 }
 
-// =============================================================================
-// Athena finalize method
-// =============================================================================
-StatusCode
-CP::ElectronChargeEfficiencyCorrectionTool::finalize()
-{
-  return StatusCode::SUCCESS;
-}
 
 //---------------------------------------------------------------------------------------
 // Get the scale factor for the electron
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/share/ut_TestFunctionality.ref b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/share/ut_TestFunctionality.ref
index 3e04fab0c1f8..c72d81e39d28 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/share/ut_TestFunctionality.ref
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/share/ut_TestFunctionality.ref
@@ -6,7 +6,7 @@ EgEfficiencyCorr_testE...INFO    ===> Model : SIMPLIFIED| electron : Pt = 41212.
 EgEfficiencyCorr_testEgEfficiencyCorrWithoutFile  -t FullSim -r 425504 -c FULL -e -0.94 -p 41212.10 -d Medium | grep SF  2>&1
 EgEfficiencyCorr_testE...INFO    ===> Model : FULL| electron : Pt = 41212.1 : eta = -0.94 : Bin index = 124 : SF = 0.994283 + 0.00814953 - 0.00814953 <===
 EgEfficiencyCorr_testEgEfficiencyCorrWithoutFile  -t FullSim -r 425504 -c TOTAL -e -0.94 -p 41212.10 -d Medium -l 0 | grep map  2>&1
-ElEffCorrectionTool.MapFilePath = 'ElectronEfficiencyCorrection/2015_2025/rel22.2/2022_Summer_Prerecom_v1/map1.txt'
+ToolSvc.ElEffCorrectionTool.MapFilePath = 'ElectronEfficiencyCorrection/2015_2025/rel22.2/2022_Summer_Prerecom_v1/map1.txt'
  ==== CHECK II:  DEFAULT MAP ==== 
     ---> map looks good! 
  ==== CHECK III:  ID LVL ==== 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.cxx
index ce4f5af8632a..85285b846fb9 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.cxx
@@ -11,25 +11,25 @@
 
 #include "AsgMessaging/MessageCheck.h"
 #include "AsgMessaging/MsgStream.h"
-
 namespace asg {
 ANA_MSG_HEADER(SFHelper)
 ANA_MSG_SOURCE(SFHelper, "")
 }
 
 int
-SFHelpers::result(AsgElectronEfficiencyCorrectionTool& tool,
-                  const xAOD::Electron& el,
-                  double& nominalSF,
-                  double& totalPos,
-                  double& totalNeg,
-                  const bool isToys)
+SFHelpers::result(
+  asg::StandaloneToolHandle<IAsgElectronEfficiencyCorrectionTool>& tool,
+  const xAOD::Electron& el,
+  double& nominalSF,
+  double& totalPos,
+  double& totalNeg,
+  const bool isToys)
 {
   using namespace asg::SFHelper;
   ANA_CHECK_SET_TYPE(int);
   setMsgLevel(MSG::INFO);
 
-  CP::SystematicSet systs = tool.recommendedSystematics();
+  CP::SystematicSet systs = tool->recommendedSystematics();
   if (!isToys) {
     /*
      * Split the variation in up and down
@@ -56,28 +56,28 @@ SFHelpers::result(AsgElectronEfficiencyCorrectionTool& tool,
         double total2{};
         double systematic{};
         for (const auto& sys : variations) {
-          if (tool.applySystematicVariation({ sys }) != StatusCode::SUCCESS ||
-              tool.getEfficiencyScaleFactor(el, systematic) !=
+          if (tool->applySystematicVariation({ sys }) != StatusCode::SUCCESS ||
+              tool->getEfficiencyScaleFactor(el, systematic) !=
                 CP::CorrectionCode::Ok) {
             ANA_MSG_ERROR("Error in setting/getting " << sys.name());
             return -999.0;
           }
           total2 += (nominal - systematic) * (nominal - systematic);
         }
-        return  std::sqrt(total2);
+        return std::sqrt(total2);
       };
 
     // Do the work
     // Empty variation is the nominal
-    ANA_CHECK(tool.applySystematicVariation({}));
-    ANA_CHECK(tool.getEfficiencyScaleFactor(el, nominalSF) ==
+    ANA_CHECK(tool->applySystematicVariation({}));
+    ANA_CHECK(tool->getEfficiencyScaleFactor(el, nominalSF) ==
               CP::CorrectionCode::Ok);
     totalNeg = totalSyst(el, negativeVar, nominalSF);
     totalPos = totalSyst(el, positiveVar, nominalSF);
   } else {
     CP::MakeSystematicsVector sysVec;
     sysVec.addGroup("toys");
-    sysVec.setToys(tool.getNumberOfToys());
+    sysVec.setToys(tool->getNumberOfToys());
     sysVec.calc(systs);
     std::vector<CP::SystematicSet> toys = sysVec.result("toys");
     std::vector<double> toysVal{};
@@ -86,10 +86,10 @@ SFHelpers::result(AsgElectronEfficiencyCorrectionTool& tool,
     // Do the work
     for (const auto& sys : toys) {
       double systematic{};
-      ANA_CHECK(tool.applySystematicVariation(sys) == StatusCode::SUCCESS &&
-                tool.getEfficiencyScaleFactor(el, systematic) ==
+      ANA_CHECK(tool->applySystematicVariation(sys) == StatusCode::SUCCESS &&
+                tool->getEfficiencyScaleFactor(el, systematic) ==
                   CP::CorrectionCode::Ok);
-      ANA_MSG_DEBUG(tool.appliedSystematics().name()
+      ANA_MSG_DEBUG(tool->appliedSystematics().name()
                     << " toy Result : " << systematic);
       toysVal.push_back(systematic);
     }
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h
index 43a82ca07385..273165f52583 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h
@@ -8,9 +8,10 @@
 #include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
 #include <xAODEgamma/Electron.h>
 
+#include "AsgTools/StandaloneToolHandle.h"
 namespace SFHelpers {
 int
-result(AsgElectronEfficiencyCorrectionTool& tool,
+result(asg::StandaloneToolHandle<IAsgElectronEfficiencyCorrectionTool>& tool,
        const xAOD::Electron& el,
        double& nominalSF,
        double& totalPos,
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgChargeCorr.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgChargeCorr.cxx
index d074423f08d3..818246311972 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgChargeCorr.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgChargeCorr.cxx
@@ -231,8 +231,6 @@ main(int argc, char* argv[])
   Info(APP_NAME, "===>>>  compared to #%f (from Charge MisId SF)", SF_chargeID);
   Info(APP_NAME, "===>>>  compared to #%f and #%f ", n_chargeID, n_chargeMisID);
 
-  ANA_CHECK(myEgCorrections.finalize());
-
   // Return gracefully:
   return 0;
 }
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx
index b697c1008031..3fed8cac448e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx
@@ -2,7 +2,7 @@
    Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
  */
 
-//Local includes
+// Local includes
 #include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
 #include "SFHelpers.h"
 // System include(s):
@@ -18,19 +18,17 @@
 #include "xAODEgamma/Electron.h"
 #include "xAODEgamma/ElectronContainer.h"
 
-// To disable sending data
-#include "xAODRootAccess/tools/TFileAccessTracer.h"
-
 #include "AsgMessaging/MessageCheck.h"
 #include "AsgMessaging/MsgStream.h"
+#include "AsgTools/StandaloneToolHandle.h"
+// To disable sending data
+#include "xAODRootAccess/tools/TFileAccessTracer.h"
 
-
-namespace asg{
-  ANA_MSG_HEADER (testEgEfficiencyCorr)
-  ANA_MSG_SOURCE (testEgEfficiencyCorr, "") 
+namespace asg {
+ANA_MSG_HEADER(testEgEfficiencyCorr)
+ANA_MSG_SOURCE(testEgEfficiencyCorr, "")
 }
 
-
 int
 main(int argc, char* argv[])
 {
@@ -40,8 +38,8 @@ main(int argc, char* argv[])
   const char* APP_NAME = argv[0];
 
   using namespace asg::testEgEfficiencyCorr;
-  ANA_CHECK_SET_TYPE (int);
-  MSG::Level mylevel=MSG::INFO;
+  ANA_CHECK_SET_TYPE(int);
+  MSG::Level mylevel = MSG::INFO;
   setMsgLevel(mylevel);
   msg().setName(APP_NAME);
 
@@ -64,12 +62,12 @@ main(int argc, char* argv[])
   ANA_CHECK(ifile.get());
 
   // Create a TEvent object:
-  // xAOD::TEvent event( xAOD::TEvent::kBranchAccess );
   xAOD::TEvent event;
 
   // Then the tools
-  AsgElectronEfficiencyCorrectionTool ElEffCorrectionTool(
-    "ElEffCorrectionTool");
+  asg::StandaloneToolHandle<IAsgElectronEfficiencyCorrectionTool>
+    ElEffCorrectionTool(
+      "AsgElectronEfficiencyCorrectionTool/ElEffCorrectionTool");
   ANA_CHECK(ElEffCorrectionTool.setProperty("IdKey", "Medium"));
   ANA_CHECK(ElEffCorrectionTool.setProperty("ForceDataType", 1));
   ANA_CHECK(ElEffCorrectionTool.setProperty("OutputLevel", mylevel));
@@ -80,7 +78,7 @@ main(int argc, char* argv[])
   // Then open the file(s)
   ANA_CHECK(event.readFrom(ifile.get()));
   ANA_MSG_INFO("Number of available events to read in:  "
-           << static_cast<long long int>(event.getEntries()));
+               << static_cast<long long int>(event.getEntries()));
 
   // Decide how many events to run over:
   long long int entries = event.getEntries();
@@ -112,7 +110,7 @@ main(int argc, char* argv[])
         continue;
       }
 
-      int index = ElEffCorrectionTool.systUncorrVariationIndex(*el);
+      int index = ElEffCorrectionTool->systUncorrVariationIndex(*el);
       /*
        * Set up the systematic variations
        */
@@ -126,9 +124,9 @@ main(int argc, char* argv[])
         0);
 
       ANA_MSG_INFO("===> electron : Pt = "
-               << el->pt() << " : eta = " << el->eta()
-               << " : Bin index = " << index << " : SF = " << nominalSF << " + "
-               << totalPos << " - " << totalNeg << " <===");
+                   << el->pt() << " : eta = " << el->eta()
+                   << " : Bin index = " << index << " : SF = " << nominalSF
+                   << " + " << totalPos << " - " << totalNeg << " <===");
     }
   }
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrFwd.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrFwd.cxx
index 3448e96c598e..120ac6062037 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrFwd.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrFwd.cxx
@@ -2,7 +2,7 @@
   Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
-//package includes
+// package includes
 #include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
 #include "SFHelpers.h"
 // System include(s):
@@ -18,19 +18,17 @@
 #include "xAODEgamma/Electron.h"
 #include "xAODEgamma/ElectronContainer.h"
 
-// To disable sending data
-#include "xAODRootAccess/tools/TFileAccessTracer.h"
-
 #include "AsgMessaging/MessageCheck.h"
 #include "AsgMessaging/MsgStream.h"
+#include "AsgTools/StandaloneToolHandle.h"
+// To disable sending data
+#include "xAODRootAccess/tools/TFileAccessTracer.h"
 
-
-namespace asg{
-  ANA_MSG_HEADER (testEgEfficiencyCorrFwd)
-  ANA_MSG_SOURCE (testEgEfficiencyCorrFwd, "") 
+namespace asg {
+ANA_MSG_HEADER(testEgEfficiencyCorrFwd)
+ANA_MSG_SOURCE(testEgEfficiencyCorrFwd, "")
 }
 
-
 int
 main(int argc, char* argv[])
 {
@@ -39,8 +37,8 @@ main(int argc, char* argv[])
   // The application's name:
   const char* APP_NAME = argv[0];
   using namespace asg::testEgEfficiencyCorrFwd;
-  ANA_CHECK_SET_TYPE (int);
-  MSG::Level mylevel=MSG::INFO;
+  ANA_CHECK_SET_TYPE(int);
+  MSG::Level mylevel = MSG::INFO;
   setMsgLevel(mylevel);
   msg().setName(APP_NAME);
 
@@ -71,8 +69,8 @@ main(int argc, char* argv[])
     "efficiencySF.offline.FwdTight.2012.8TeV.rel17p2.GEO21.v02.root"
   }; // we don't support keys for fwd electrons, yet. Our latest file is 2012,
      // still
-  AsgElectronEfficiencyCorrectionTool ElEffCorrectionTool(
-    "ElEffCorrectionTool");
+  asg::StandaloneToolHandle<IAsgElectronEfficiencyCorrectionTool> ElEffCorrectionTool(
+    "AsgElectronEfficiencyCorrectionTool/ElEffCorrectionTool");
   ANA_CHECK(
     ElEffCorrectionTool.setProperty("CorrectionFileNameList", id_configFiles));
   ANA_CHECK(ElEffCorrectionTool.setProperty("ForceDataType", 1));
@@ -84,7 +82,7 @@ main(int argc, char* argv[])
   // Then open the file(s)
   ANA_CHECK(event.readFrom(ifile.get()));
   ANA_MSG_INFO("Number of available events to read in:  "
-           << static_cast<long long int>(event.getEntries()));
+               << static_cast<long long int>(event.getEntries()));
 
   // Decide how many events to run over:
   long long int entries = event.getEntries();
@@ -109,7 +107,7 @@ main(int argc, char* argv[])
         continue; // skip electrons outside of recommendations
       if (fabs(el->caloCluster()->eta()) < 2.5)
         continue; // skip electrons outside of recommendations
-      int index = ElEffCorrectionTool.systUncorrVariationIndex(*el);
+      int index = ElEffCorrectionTool->systUncorrVariationIndex(*el);
       /*
        * Set up the systematic variations
        */
@@ -123,9 +121,9 @@ main(int argc, char* argv[])
         0);
 
       ANA_MSG_INFO("===> electron : Pt = "
-               << el->pt() << " : eta = " << el->eta()
-               << " : Bin index = " << index << " : SF = " << nominalSF << " + "
-               << totalPos << " - " << totalNeg << " <===");
+                   << el->pt() << " : eta = " << el->eta()
+                   << " : Bin index = " << index << " : SF = " << nominalSF
+                   << " + " << totalPos << " - " << totalNeg << " <===");
     }
   }
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx
index b7432ef91054..3ebcf8ef7c48 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx
@@ -24,6 +24,7 @@
 
 #include "AsgMessaging/MessageCheck.h"
 #include "AsgMessaging/MsgStream.h"
+#include "AsgTools/StandaloneToolHandle.h"
 
 namespace asg {
 ANA_MSG_HEADER(msgSelectorCheck)
@@ -126,8 +127,9 @@ main(int argc, char* argv[])
   xAOD::TStore store;
 
   // Configure the tool based on the inputs
-  AsgElectronEfficiencyCorrectionTool ElEffCorrectionTool(
-    "ElEffCorrectionTool");
+  asg::StandaloneToolHandle<IAsgElectronEfficiencyCorrectionTool>
+    ElEffCorrectionTool(
+      "AsgElectronEfficiencyCorrectionTool/ElEffCorrectionTool");
   if (!fileName.empty()) {
     std::vector<std::string> inputFiles{ fileName };
     ANA_CHECK(
@@ -170,7 +172,7 @@ main(int argc, char* argv[])
    * Potentiallly we can make this part more clever, for now since it is an
    * util I did not try to optimise too much.
    */
-  int index = ElEffCorrectionTool.systUncorrVariationIndex(el);
+  int index = ElEffCorrectionTool->systUncorrVariationIndex(el);
   /*
    * Set up the systematic variations
    * 2 cases one for "continuous" one for "toys"
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
index 4a76f71b96ec..9b7c48f3c5d8 100644
--- a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
@@ -2,31 +2,41 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-//IAsgElectronEfficiencyCorrection.h to be used in the tool.
+// IAsgElectronEfficiencyCorrection.h to be used in the tool.
 #ifndef EGAMMAANALYSISINTERFACES__IASGELECTRONEFFICIENCYCORRECTION__
 #define EGAMMAANALYSISINTERFACES__IASGELECTRONEFFICIENCYCORRECTION__
 
 #include "AsgTools/IAsgTool.h"
-#include "xAODEgamma/ElectronFwd.h"
 #include "PATInterfaces/CorrectionCode.h"
 #include "PATInterfaces/ISystematicsTool.h"
-namespace xAOD{
-  class IParticle;
+#include "xAODEgamma/ElectronFwd.h"
+namespace xAOD {
+class IParticle;
 }
 
-
 class IAsgElectronEfficiencyCorrectionTool : virtual public CP::ISystematicsTool
 {
   ASG_TOOL_INTERFACE(IAsgElectronEfficiencyCorrectionTool)
 
-  public:
-  ///The interface for Scale Factors
-  virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Electron& inputObject, double& efficiencyScaleFactor) const = 0;
-  virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::Electron& inputObject) const = 0;
-  virtual int systUncorrVariationIndex( const xAOD::Electron &inputObject) const =0;
-  virtual ~IAsgElectronEfficiencyCorrectionTool() {}
+public:
+  virtual CP::CorrectionCode getEfficiencyScaleFactor(
+    const xAOD::Electron& inputObject,
+    double& efficiencyScaleFactor) const = 0;
 
-};
+  virtual CP::CorrectionCode applyEfficiencyScaleFactor(
+    const xAOD::Electron& inputObject) const = 0;
+
+  virtual int systUncorrVariationIndex(
+    const xAOD::Electron& inputObject) const = 0;
 
+  virtual int getNumberOfToys() const = 0;
+
+  virtual const CP::SystematicSet& appliedSystematics() const = 0;
+
+  /// print available/implemented correlation models
+  virtual void printCorrelationModels() const = 0;
+
+  virtual ~IAsgElectronEfficiencyCorrectionTool() = default;
+};
 
 #endif
-- 
GitLab


From f82ea63a4f1b76dde38434ae23f11ad716da99a6 Mon Sep 17 00:00:00 2001
From: christos <christos@cern.ch>
Date: Thu, 22 Sep 2022 23:49:23 +0200
Subject: [PATCH 2/4] update copyrights

---
 .../ElectronEfficiencyCorrection/util/SFHelpers.h               | 2 +-
 .../IAsgElectronEfficiencyCorrectionTool.h                      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h
index 273165f52583..db3707dcb935 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/SFHelpers.h
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+   Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
  */
 
 #ifndef __ELECTRONEFFICIENCYCORRECTION_SFHELPER__
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
index 9b7c48f3c5d8..c717f6f56e4e 100644
--- a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 // IAsgElectronEfficiencyCorrection.h to be used in the tool.
-- 
GitLab


From 543d44eb9b9a5de7fae318436c8e89d2b603d766 Mon Sep 17 00:00:00 2001
From: christos <christos@cern.ch>
Date: Fri, 23 Sep 2022 01:26:19 +0200
Subject: [PATCH 3/4] cache more of the systematics we already know

---
 .../AsgElectronEfficiencyCorrectionTool.h     |  3 +-
 .../AsgElectronEfficiencyCorrectionTool.cxx   | 91 +++++++++----------
 2 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
index 7cd35465293e..f8054ffecc2b 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
@@ -206,10 +206,11 @@ private:
   int m_nSimpleUncorrSyst;
 
   // Caching of variations we know after initialize
-  std::string m_prefixUncorr;
   std::string m_toysBasename;
   std::vector<CP::SystematicVariation> m_corrVarUp;
   std::vector<CP::SystematicVariation> m_corrVarDown;
+  std::vector<CP::SystematicVariation> m_uncorrVarUp;
+  std::vector<CP::SystematicVariation> m_uncorrVarDown;
 
 }; // End: class definition
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx
index 696a1d8c87b4..46b5e6995870 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx
@@ -67,10 +67,11 @@ AsgElectronEfficiencyCorrectionTool::AsgElectronEfficiencyCorrectionTool(
   , m_nUncorrSyst(0)
   , m_UncorrRegions(nullptr)
   , m_nSimpleUncorrSyst(0)
-  , m_prefixUncorr{}
   , m_toysBasename{}
   , m_corrVarUp{}
   , m_corrVarDown{}
+  , m_uncorrVarUp{}
+  , m_uncorrVarDown{}
 {
   // Create an instance of the underlying ROOT tool
   m_rootTool =
@@ -369,13 +370,8 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
   // use et from cluster because it is immutable under syst variations of ele
   // energy scale
   const double energy = cluster->e();
-  if (inputObject.trackParticle()) {
-    et = (std::cosh(inputObject.trackParticle()->eta()) != 0.)
-           ? energy / std::cosh(inputObject.trackParticle()->eta())
-           : 0.;
-  } else {
-    et = (std::cosh(cluster_eta) != 0.) ? energy / std::cosh(cluster_eta) : 0.;
-  }
+  const double parEta = inputObject.eta();
+  et = (std::cosh(parEta) != 0.) ? energy / std::cosh(parEta) : 0.;
 
   // allow for a 5% margin at the lowest pT bin boundary (i.e. increase et by 5%
   // for sub-threshold electrons). This assures that electrons that pass the
@@ -421,15 +417,9 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
   // First the logic if the user requested toys
   if (m_correlation_model == correlationModel::MCTOYS ||
       m_correlation_model == correlationModel::COMBMCTOYS) {
-    if (m_correlation_model == correlationModel::MCTOYS) {
-      auto toy = appliedSystematics().getToyVariationByBaseName(m_toysBasename);
-      toy.second = m_scale_toys;
-      sys = result[MCToysIndex + toy.first - 1] * m_scale_toys;
-    } else if (m_correlation_model == correlationModel::COMBMCTOYS) {
-      auto toy = appliedSystematics().getToyVariationByBaseName(m_toysBasename);
-      toy.second = m_scale_toys;
-      sys = result[MCToysIndex + toy.first - 1] * m_scale_toys;
-    }
+    auto toy = appliedSystematics().getToyVariationByBaseName(m_toysBasename);
+    toy.second = m_scale_toys;
+    sys = result[MCToysIndex + toy.first - 1] * m_scale_toys;
     // return here for Toy variations
     efficiencyScaleFactor = sys;
     return CP::CorrectionCode::Ok;
@@ -438,26 +428,25 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
   else if (m_correlation_model == correlationModel::TOTAL) {
     sys = result[static_cast<size_t>(
       Root::TElectronEfficiencyCorrectionTool::Position::Total)];
-    if (appliedSystematics().matchSystematic(
-          CP::SystematicVariation(m_prefixUncorr + "1NPCOR_PLUS_UNCOR", 1))) {
+    if (appliedSystematics().matchSystematic(m_uncorrVarUp[0])) {
       return HelperFunc(efficiencyScaleFactor, sys);
     }
-    if (appliedSystematics().matchSystematic(
-          CP::SystematicVariation(m_prefixUncorr + "1NPCOR_PLUS_UNCOR", -1))) {
+    if (appliedSystematics().matchSystematic(m_uncorrVarDown[0])) {
       return HelperFunc(efficiencyScaleFactor, -1 * sys);
     }
   }
   // Then the uncorrelated part for the FULL model
   else if (m_correlation_model == correlationModel::FULL) {
     int currentReg = currentUncorrSystRegion(cluster_eta, et);
-    if (appliedSystematics().matchSystematic(CP::SystematicVariation(
-          m_prefixUncorr + Form("UncorrUncertaintyNP%d", currentReg), 1))) {
+    if (currentReg < 0) {
+      return CP::CorrectionCode::OutOfValidityRange;
+    }
+    if (appliedSystematics().matchSystematic(m_uncorrVarUp[currentReg])) {
       sys = result[static_cast<size_t>(
         Root::TElectronEfficiencyCorrectionTool::Position::UnCorr)];
       return HelperFunc(efficiencyScaleFactor, sys);
     }
-    if (appliedSystematics().matchSystematic(CP::SystematicVariation(
-          m_prefixUncorr + Form("UncorrUncertaintyNP%d", currentReg), -1))) {
+    if (appliedSystematics().matchSystematic(m_uncorrVarDown[currentReg])) {
       sys = -1 * result[static_cast<size_t>(
                    Root::TElectronEfficiencyCorrectionTool::Position::UnCorr)];
       return HelperFunc(efficiencyScaleFactor, sys);
@@ -469,15 +458,13 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
       return CP::CorrectionCode::OutOfValidityRange;
     }
 
-    if (appliedSystematics().matchSystematic(CP::SystematicVariation(
-          m_prefixUncorr + Form("UncorrUncertaintyNP%d", currentReg), 1))) {
+    if (appliedSystematics().matchSystematic(m_uncorrVarUp[currentReg])) {
       sys = result[static_cast<size_t>(
         Root::TElectronEfficiencyCorrectionTool::Position::UnCorr)];
       return HelperFunc(efficiencyScaleFactor, sys);
     }
 
-    if (appliedSystematics().matchSystematic(CP::SystematicVariation(
-          m_prefixUncorr + Form("UncorrUncertaintyNP%d", currentReg), -1))) {
+    if (appliedSystematics().matchSystematic(m_uncorrVarDown[currentReg])) {
       sys = -1 * result[static_cast<size_t>(
                    Root::TElectronEfficiencyCorrectionTool::Position::UnCorr)];
       return HelperFunc(efficiencyScaleFactor, sys);
@@ -496,7 +483,8 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
         result[static_cast<size_t>(
           Root::TElectronEfficiencyCorrectionTool::Position::UnCorr)] *
           result[static_cast<size_t>(Root::TElectronEfficiencyCorrectionTool::
-                                       Position::UnCorr)]); // total -stat
+                                       Position::UnCorr)]); // total
+                                                            // -stat
       return HelperFunc(efficiencyScaleFactor, sys);
     }
     if (appliedSystematics().matchSystematic(m_corrVarDown[0])) {
@@ -640,8 +628,8 @@ AsgElectronEfficiencyCorrectionTool::applySystematicVariation(
 StatusCode
 AsgElectronEfficiencyCorrectionTool::InitSystematics()
 {
-  std::string prefix = "EL_EFF_" + m_sysSubstring;
-  m_prefixUncorr = prefix + m_correlation_model_name + "_";
+  const std::string prefix = "EL_EFF_" + m_sysSubstring;
+  const std::string prefixUncorr = prefix + m_correlation_model_name + "_";
   // Toys
   if (m_correlation_model == correlationModel::COMBMCTOYS) {
     m_toysBasename = prefix + "COMBMCTOY";
@@ -664,8 +652,8 @@ AsgElectronEfficiencyCorrectionTool::InitSystematics()
       for (int i = 0; i < m_nCorrSyst; ++i) {
         auto varUp =
           CP::SystematicVariation(prefix + Form("CorrUncertaintyNP%d", i), 1);
-        auto varDown = CP::SystematicVariation(
-          prefix + Form("CorrUncertaintyNP%d", i), -1);
+        auto varDown =
+          CP::SystematicVariation(prefix + Form("CorrUncertaintyNP%d", i), -1);
         m_corrVarUp.push_back(varUp);
         m_corrVarDown.push_back(varDown);
         m_affectedSys.insert(varUp);
@@ -674,23 +662,34 @@ AsgElectronEfficiencyCorrectionTool::InitSystematics()
   }
   // Different tratement for the uncorrelated per model
   if (m_correlation_model == correlationModel::TOTAL) {
-    m_affectedSys.insert(
-      CP::SystematicVariation(m_prefixUncorr + "1NPCOR_PLUS_UNCOR", 1));
-    m_affectedSys.insert(
-      CP::SystematicVariation(m_prefixUncorr + "1NPCOR_PLUS_UNCOR", -1));
+    auto varUp = CP::SystematicVariation(prefixUncorr + "1NPCOR_PLUS_UNCOR", 1);
+    auto varDown =
+      CP::SystematicVariation(prefixUncorr + "1NPCOR_PLUS_UNCOR", -1);
+    m_uncorrVarUp.push_back(varUp);
+    m_uncorrVarDown.push_back(varDown);
+    m_affectedSys.insert(varUp);
+    m_affectedSys.insert(varDown);
   } else if (m_correlation_model == correlationModel::FULL) {
     for (int i = 0; i < m_nUncorrSyst; ++i) {
-      m_affectedSys.insert(CP::SystematicVariation(
-        m_prefixUncorr + Form("UncorrUncertaintyNP%d", i), 1));
-      m_affectedSys.insert(CP::SystematicVariation(
-        m_prefixUncorr + Form("UncorrUncertaintyNP%d", i), -1));
+      auto varUp = CP::SystematicVariation(
+        prefixUncorr + Form("UncorrUncertaintyNP%d", i), 1);
+      auto varDown = CP::SystematicVariation(
+        prefixUncorr + Form("UncorrUncertaintyNP%d", i), -1);
+      m_uncorrVarUp.push_back(varUp);
+      m_uncorrVarDown.push_back(varDown);
+      m_affectedSys.insert(varUp);
+      m_affectedSys.insert(varDown);
     }
   } else if (m_correlation_model == correlationModel::SIMPLIFIED) {
     for (int i = 0; i < m_nSimpleUncorrSyst; ++i) {
-      m_affectedSys.insert(CP::SystematicVariation(
-        m_prefixUncorr + Form("UncorrUncertaintyNP%d", i), 1));
-      m_affectedSys.insert(CP::SystematicVariation(
-        m_prefixUncorr + Form("UncorrUncertaintyNP%d", i), -1));
+      auto varUp = CP::SystematicVariation(
+        prefixUncorr + Form("UncorrUncertaintyNP%d", i), 1);
+      auto varDown = CP::SystematicVariation(
+        prefixUncorr + Form("UncorrUncertaintyNP%d", i), -1);
+      m_uncorrVarUp.push_back(varUp);
+      m_uncorrVarDown.push_back(varDown);
+      m_affectedSys.insert(varUp);
+      m_affectedSys.insert(varDown);
     }
   }
   return StatusCode::SUCCESS;
-- 
GitLab


From 1d54902d9ebc7f7d73745797cba6b85e441dbcb8 Mon Sep 17 00:00:00 2001
From: christos <christos@cern.ch>
Date: Fri, 23 Sep 2022 05:55:30 +0200
Subject: [PATCH 4/4] fix dummy in the TrigGlobalEffTool

---
 .../util/TrigGlobEffCorrValidation.cxx                         | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.cxx b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.cxx
index 77ebb4455d54..4be5776af49f 100644
--- a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.cxx
+++ b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.cxx
@@ -51,6 +51,9 @@ public:
 	virtual CP::SystematicSet recommendedSystematics() const override { return CP::SystematicSet(); }
 	virtual StatusCode applySystematicVariation(const CP::SystematicSet&) override { return StatusCode::SUCCESS; }
 	virtual int systUncorrVariationIndex( const xAOD::Electron &) const override { return 0; }
+  virtual int getNumberOfToys() const override {return 0;}
+  virtual const CP::SystematicSet& appliedSystematics() const { static const CP::SystematicSet dummy ; return dummy;};
+  virtual void printCorrelationModels() const {}
 };
 
 class SimplePhotonEfficiencyCorrectionTool : virtual public IAsgPhotonEfficiencyCorrectionTool, public asg::AsgTool
-- 
GitLab