From e2dc034e30397391fab1406a39cc87718db95bfe Mon Sep 17 00:00:00 2001
From: Tadej Novak <tadej.novak@cern.ch>
Date: Wed, 13 Oct 2021 08:35:31 +0200
Subject: [PATCH] CP algs: move more algorithms to use SysReadHandle

---
 .../AsgClassificationDecorationAlg.h                |  6 +++---
 .../AsgLeptonTrackSelectionAlg.h                    |  5 +++--
 .../Root/AsgClassificationDecorationAlg.cxx         | 11 ++++++-----
 .../Root/AsgLeptonTrackSelectionAlg.cxx             | 10 +++++-----
 .../EgammaIsolationSelectionAlg.h                   |  4 ++--
 .../Root/EgammaIsolationSelectionAlg.cxx            |  6 +++---
 .../python/PhotonAnalysisSequence.py                |  3 +--
 .../python/FTagAnalysisSequence.py                  |  8 +++-----
 .../JetAnalysisAlgorithms/JetSelectionAlg.h         |  4 ++--
 .../JetAnalysisAlgorithms/Root/JetSelectionAlg.cxx  |  6 +++---
 .../MuonAnalysisAlgorithms/MuonIsolationAlg.h       |  4 ++--
 .../MuonAnalysisAlgorithms/MuonSelectionAlg.h       |  4 ++--
 .../Root/MuonIsolationAlg.cxx                       |  6 +++---
 .../Root/MuonSelectionAlg.cxx                       |  6 +++---
 .../python/MuonAnalysisSequence.py                  |  2 +-
 .../Root/DiTauEfficiencyCorrectionsAlg.cxx          | 13 +++++++------
 .../Root/DiTauTruthMatchingAlg.cxx                  |  6 +++---
 .../Root/TauTruthMatchingAlg.cxx                    |  6 +++---
 .../DiTauEfficiencyCorrectionsAlg.h                 | 13 +++++--------
 .../TauAnalysisAlgorithms/DiTauTruthMatchingAlg.h   |  4 ++--
 .../TauAnalysisAlgorithms/TauTruthMatchingAlg.h     |  4 ++--
 .../python/DiTauAnalysisSequence.py                 |  4 ++--
 .../python/TauAnalysisSequence.py                   |  2 +-
 23 files changed, 67 insertions(+), 70 deletions(-)

diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgClassificationDecorationAlg.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgClassificationDecorationAlg.h
index 069d942c101a..4320217c88b8 100644
--- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgClassificationDecorationAlg.h
+++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgClassificationDecorationAlg.h
@@ -8,8 +8,8 @@
 #define ASG_ANALYSIS_ALGORITHMS__ASG_CLASSIFICATION_DECORATION_ALG_H
 
 #include <AnaAlgorithm/AnaAlgorithm.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
 #include <xAODBase/IParticle.h>
 #include <xAODBase/IParticleContainer.h>
 
@@ -46,7 +46,7 @@ private:
 
   /// \brief particles container handle
 private:
-  CP::SysCopyHandle<xAOD::IParticleContainer> m_particlesHandle {
+  CP::SysReadHandle<xAOD::IParticleContainer> m_particlesHandle {
     this, "particles", "", "the container to use"};
 
   /// \brief the decoration for the truth classification
@@ -55,7 +55,7 @@ private:
 
   /// \brief the accessor for \ref m_truthClassificationDecoration
 private:
-  std::unique_ptr<const SG::AuxElement::Accessor<unsigned int> > m_classificationAccessor {};
+  std::unique_ptr<const SG::AuxElement::Decorator<unsigned int> > m_classificationDecorator {};
 };
 
 } // namespace CP
diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgLeptonTrackSelectionAlg.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgLeptonTrackSelectionAlg.h
index d512edb99297..ef989f61cdab 100644
--- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgLeptonTrackSelectionAlg.h
+++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgLeptonTrackSelectionAlg.h
@@ -13,8 +13,9 @@
 #include <PATCore/IAsgSelectionTool.h>
 #include <SelectionHelpers/ISelectionAccessor.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
+#include <xAODBase/IParticleContainer.h>
 
 namespace CP
 {
@@ -69,7 +70,7 @@ namespace CP
 
     /// \brief the particle continer we run on
   private:
-    SysCopyHandle<xAOD::IParticleContainer> m_particlesHandle {
+    SysReadHandle<xAOD::IParticleContainer> m_particlesHandle {
       this, "particles", "", "the asg collection to run on"};
 
     /// \brief the preselection we apply to our input
diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgClassificationDecorationAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgClassificationDecorationAlg.cxx
index 0497fa752895..8a04f6bc53c8 100644
--- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgClassificationDecorationAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgClassificationDecorationAlg.cxx
@@ -29,7 +29,7 @@ StatusCode AsgClassificationDecorationAlg::initialize()
     return StatusCode::FAILURE;
   }
 
-  m_classificationAccessor = std::make_unique<SG::AuxElement::Accessor<unsigned int> > (m_classificationDecoration);
+  m_classificationDecorator = std::make_unique<SG::AuxElement::Decorator<unsigned int> > (m_classificationDecoration);
 
   ANA_CHECK (m_particlesHandle.initialize (m_systematicsList));
   ANA_CHECK(m_systematicsList.initialize());
@@ -45,13 +45,14 @@ StatusCode AsgClassificationDecorationAlg::execute()
 {
   for (const auto& sys : m_systematicsList.systematicsVector())
   {
-    xAOD::IParticleContainer *particles{};
-    ANA_CHECK(m_particlesHandle.getCopy(particles, sys));
+    const xAOD::IParticleContainer *particles{};
+    ANA_CHECK(m_particlesHandle.retrieve(particles, sys));
 
-    for (xAOD::IParticle *particle : *particles) {
+    for (const xAOD::IParticle *particle : *particles)
+    {
       unsigned int classification{};
       ANA_CHECK(m_tool->classify(*particle, classification));
-      (*m_classificationAccessor)(*particle) = classification;
+      (*m_classificationDecorator)(*particle) = classification;
     }
   }
   return StatusCode::SUCCESS;
diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgLeptonTrackSelectionAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgLeptonTrackSelectionAlg.cxx
index 9a2cd74fe089..320dcd78a180 100644
--- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgLeptonTrackSelectionAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgLeptonTrackSelectionAlg.cxx
@@ -116,9 +116,9 @@ namespace CP
 
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
-      xAOD::IParticleContainer *particles = nullptr;
-      ANA_CHECK (m_particlesHandle.getCopy (particles, sys));
-      for (xAOD::IParticle *particle : *particles)
+      const xAOD::IParticleContainer *particles = nullptr;
+      ANA_CHECK (m_particlesHandle.retrieve (particles, sys));
+      for (const xAOD::IParticle *particle : *particles)
       {
         asg::AcceptData acceptData (&m_accept);
 
@@ -127,9 +127,9 @@ namespace CP
           std::size_t cutIndex {0};
 
           const xAOD::TrackParticle *track {nullptr};
-          if (const xAOD::Muon *muon = dynamic_cast<xAOD::Muon*>(particle))
+          if (const xAOD::Muon *muon = dynamic_cast<const xAOD::Muon *>(particle))
             track = muon->primaryTrackParticle();
-          else if (const xAOD::Electron *electron = dynamic_cast<xAOD::Electron*>(particle))
+          else if (const xAOD::Electron *electron = dynamic_cast<const xAOD::Electron *>(particle))
             track = electron->trackParticle();
           else
           {
diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/EgammaAnalysisAlgorithms/EgammaIsolationSelectionAlg.h b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/EgammaAnalysisAlgorithms/EgammaIsolationSelectionAlg.h
index 8b4503a8387e..709a2ed769f1 100644
--- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/EgammaAnalysisAlgorithms/EgammaIsolationSelectionAlg.h
+++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/EgammaAnalysisAlgorithms/EgammaIsolationSelectionAlg.h
@@ -15,8 +15,8 @@
 #include <SelectionHelpers/ISelectionAccessor.h>
 #include <SelectionHelpers/OutOfValidityHelper.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
 
 namespace CP
 {
@@ -53,7 +53,7 @@ namespace CP
 
     /// \brief the particle continer we run on
   private:
-    SysCopyHandle<xAOD::EgammaContainer> m_egammasHandle {
+    SysReadHandle<xAOD::EgammaContainer> m_egammasHandle {
       this, "egammas", "Electrons", "the egamma collection to run on"};
 
     /// \brief the decoration for the asg selection
diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/Root/EgammaIsolationSelectionAlg.cxx b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/Root/EgammaIsolationSelectionAlg.cxx
index ce802747d9fd..bb419d639c2a 100644
--- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/Root/EgammaIsolationSelectionAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/Root/EgammaIsolationSelectionAlg.cxx
@@ -58,9 +58,9 @@ namespace CP
   {
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
-      xAOD::EgammaContainer *egammas = nullptr;
-      ANA_CHECK (m_egammasHandle.getCopy (egammas, sys));
-      for (xAOD::Egamma *egamma : *egammas)
+      const xAOD::EgammaContainer *egammas = nullptr;
+      ANA_CHECK (m_egammasHandle.retrieve (egammas, sys));
+      for (const xAOD::Egamma *egamma : *egammas)
       {
         if (m_preselection.getBool (*egamma))
         {
diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/PhotonAnalysisSequence.py b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/PhotonAnalysisSequence.py
index 7ba200c2d023..83b0828b4b73 100644
--- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/PhotonAnalysisSequence.py
+++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/PhotonAnalysisSequence.py
@@ -94,7 +94,6 @@ def makePhotonAnalysisSequence( dataType, workingPoint,
     addPrivateTool( alg, 'selectionTool', 'CP::EgammaIsGoodOQSelectionTool' )
     alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
     seq.append( alg, inputPropName = 'particles',
-                outputPropName = 'particlesOut',
                 stageName = 'calibration',
                 metaConfig = {'selectionDecorNames' : [alg.selectionDecoration],
                               'selectionDecorCount' : [1]},
@@ -154,7 +153,7 @@ def makePhotonAnalysisSequence( dataType, workingPoint,
     alg.selectionDecoration = 'isolated' + postfix
     addPrivateTool( alg, 'selectionTool', 'CP::IsolationSelectionTool' )
     alg.selectionTool.PhotonWP = isolationWP
-    seq.append( alg, inputPropName = 'egammas', outputPropName = 'egammasOut',
+    seq.append( alg, inputPropName = 'egammas',
                 stageName = 'selection',
                 metaConfig = {'selectionDecorNames' : [alg.selectionDecoration],
                               'selectionDecorCount' : [1]} )
diff --git a/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisSequence.py b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisSequence.py
index dd6006e3ab2f..53b2e65a23bd 100644
--- a/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisSequence.py
+++ b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisSequence.py
@@ -84,15 +84,14 @@ def makeFTagAnalysisSequence( seq, dataType, jetCollection,
         addPrivateTool( alg, 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
         alg.selectionTool.minPt = minPt
         alg.selectionTool.maxEta = 2.5
-        alg.selectionDecoration = 'ftag_kin_select'
-        seq.append( alg, inputPropName = 'particles',
-                    outputPropName = 'particlesOut' )
+        alg.selectionDecoration = 'ftag_kin_select_' + btagger + '_' + btagWP
+        seq.append( alg, inputPropName = 'particles' )
 
         # Set up an algorithm that makes a view container using the selections
         # performed previously:
         alg = createAlgorithm( 'CP::AsgViewFromSelectionAlg',
                                'FTagKinViewFromSelectionAlg'+postfix )
-        alg.selection = [ 'ftag_kin_select' ]
+        alg.selection = [ 'ftag_kin_select_' + btagger + '_' + btagWP ]
         seq.append( alg, inputPropName = 'input', outputPropName = 'output',
                     stageName = 'selection' )
 
@@ -108,7 +107,6 @@ def makeFTagAnalysisSequence( seq, dataType, jetCollection,
         alg.preselection = preselection
     alg.selectionDecoration = 'ftag_select_' + btagger + '_' + btagWP + ',as_char'
     seq.append( alg, inputPropName = 'particles',
-                outputPropName = 'particlesOut',
                 stageName = 'selection' )
 
     if not noEfficiency and dataType != 'data':
diff --git a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetSelectionAlg.h b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetSelectionAlg.h
index 14e727242a5c..26477a246855 100644
--- a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetSelectionAlg.h
+++ b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetSelectionAlg.h
@@ -12,8 +12,8 @@
 #include <JetInterface/IJetSelector.h>
 #include <SelectionHelpers/ISelectionAccessor.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
 #include <xAODJet/JetContainer.h>
 
 namespace CP
@@ -46,7 +46,7 @@ namespace CP
 
     /// \brief the jet collection we run on
   private:
-    SysCopyHandle<xAOD::JetContainer> m_jetHandle {
+    SysReadHandle<xAOD::JetContainer> m_jetHandle {
       this, "jets", "AntiKt4EMTopoJets", "the jet collection to run on"};
 
     /// \brief the preselection we apply to our input
diff --git a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/Root/JetSelectionAlg.cxx b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/Root/JetSelectionAlg.cxx
index e99e0179bd8a..24bfe88b4ec1 100644
--- a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/Root/JetSelectionAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/Root/JetSelectionAlg.cxx
@@ -56,9 +56,9 @@ namespace CP
   {
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
-      xAOD::JetContainer *jets = nullptr;
-      ANA_CHECK (m_jetHandle.getCopy (jets, sys));
-      for (xAOD::Jet *jet : *jets)
+      const xAOD::JetContainer *jets = nullptr;
+      ANA_CHECK (m_jetHandle.retrieve (jets, sys));
+      for (const xAOD::Jet *jet : *jets)
       {
         if (m_preselection.getBool (*jet))
         {
diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonIsolationAlg.h b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonIsolationAlg.h
index 3f8b83f301f2..43f950ae3c79 100644
--- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonIsolationAlg.h
+++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonIsolationAlg.h
@@ -13,8 +13,8 @@
 #include <IsolationSelection/IIsolationSelectionTool.h>
 #include <SelectionHelpers/ISelectionAccessor.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
 #include <xAODMuon/MuonContainer.h>
 
 namespace CP
@@ -47,7 +47,7 @@ namespace CP
 
     /// \brief the muon collection we run on
   private:
-    SysCopyHandle<xAOD::MuonContainer> m_muonHandle {
+    SysReadHandle<xAOD::MuonContainer> m_muonHandle {
       this, "muons", "Muons", "the muon collection to run on"};
 
     /// \brief the preselection we apply to our input
diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonSelectionAlg.h b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonSelectionAlg.h
index 7537d0ce572a..7a7268c68e21 100644
--- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonSelectionAlg.h
+++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/MuonAnalysisAlgorithms/MuonSelectionAlg.h
@@ -11,8 +11,8 @@
 #include <MuonAnalysisInterfaces/IMuonSelectionTool.h>
 #include <SelectionHelpers/ISelectionAccessor.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
 #include <xAODMuon/MuonContainer.h>
 
 namespace CP
@@ -50,7 +50,7 @@ namespace CP
 
     /// \brief the particle continer we run on
   private:
-    SysCopyHandle<xAOD::MuonContainer> m_muonsHandle {
+    SysReadHandle<xAOD::MuonContainer> m_muonsHandle {
       this, "muons", "Muons", "the muons collection to run on"};
 
     /// \brief the decoration for the quality selection
diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonIsolationAlg.cxx b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonIsolationAlg.cxx
index e1b8b7825ddf..48a6dadc5df2 100644
--- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonIsolationAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonIsolationAlg.cxx
@@ -60,9 +60,9 @@ namespace CP
   {
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
-      xAOD::MuonContainer *muons = nullptr;
-      ANA_CHECK (m_muonHandle.getCopy (muons, sys));
-      for (xAOD::Muon *muon : *muons)
+      const xAOD::MuonContainer *muons = nullptr;
+      ANA_CHECK (m_muonHandle.retrieve (muons, sys));
+      for (const xAOD::Muon *muon : *muons)
       {
         if (m_preselection.getBool (*muon))
         {
diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonSelectionAlg.cxx b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonSelectionAlg.cxx
index 4c37cbcd823b..91eefd86098a 100644
--- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonSelectionAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/Root/MuonSelectionAlg.cxx
@@ -65,9 +65,9 @@ namespace CP
   {
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
-      xAOD::MuonContainer *muons = nullptr;
-      ANA_CHECK (m_muonsHandle.getCopy (muons, sys));
-      for (xAOD::Muon *muon : *muons)
+      const xAOD::MuonContainer *muons = nullptr;
+      ANA_CHECK (m_muonsHandle.retrieve (muons, sys));
+      for (const xAOD::Muon *muon : *muons)
       {
         if (m_preselection.getBool (*muon))
         {
diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py
index 2b79d744c5e5..2f110c62dc6b 100644
--- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py
+++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py
@@ -152,7 +152,7 @@ def makeMuonAnalysisSequence( dataType, workingPoint,
                                'MuonIsolationAlg' + postfix )
         addPrivateTool( alg, 'isolationTool', 'CP::IsolationSelectionTool' )
         alg.isolationDecoration = 'isolated_muon' + postfix + ',as_bits'
-        seq.append( alg, inputPropName = 'muons', outputPropName = 'muonsOut',
+        seq.append( alg, inputPropName = 'muons',
                     stageName = 'selection',
                     metaConfig = {'selectionDecorNames' : [alg.isolationDecoration],
                                   'selectionDecorNamesOutput' : [alg.isolationDecoration],
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauEfficiencyCorrectionsAlg.cxx b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauEfficiencyCorrectionsAlg.cxx
index 50fd77d3d6b3..2e926a5ec87e 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauEfficiencyCorrectionsAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauEfficiencyCorrectionsAlg.cxx
@@ -25,7 +25,6 @@ namespace CP
     , m_efficiencyCorrectionsTool ("TauAnalysisTools::DiTauEfficiencyCorrectionsTool", this)
   {
     declareProperty ("efficiencyCorrectionsTool", m_efficiencyCorrectionsTool, "the calibration and smearing tool we apply");
-    declareProperty ("scaleFactorDecoration", m_scaleFactorDecoration, "the decoration for the tau scale factor");
   }
 
 
@@ -38,10 +37,10 @@ namespace CP
       ANA_MSG_ERROR ("no scale factor decoration name set");
       return StatusCode::FAILURE;
     }
-    m_scaleFactorAccessor = std::make_unique<SG::AuxElement::Accessor<float> > (m_scaleFactorDecoration);
 
     ANA_CHECK (m_efficiencyCorrectionsTool.retrieve());
     ANA_CHECK (m_tauHandle.initialize (m_systematicsList));
+    ANA_CHECK (m_scaleFactorDecoration.initialize (m_systematicsList, m_tauHandle));
     ANA_CHECK (m_systematicsList.addSystematics (*m_efficiencyCorrectionsTool));
     ANA_CHECK (m_systematicsList.initialize());
     ANA_CHECK (m_preselection.initialize());
@@ -57,15 +56,17 @@ namespace CP
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
       ANA_CHECK (m_efficiencyCorrectionsTool->applySystematicVariation (sys));
-      xAOD::DiTauJetContainer *taus = nullptr;
-      ANA_CHECK (m_tauHandle.getCopy (taus, sys));
-      for (xAOD::DiTauJet *tau : *taus)
+      const xAOD::DiTauJetContainer *taus = nullptr;
+      ANA_CHECK (m_tauHandle.retrieve (taus, sys));
+      for (const xAOD::DiTauJet *tau : *taus)
       {
         if (m_preselection.getBool (*tau))
         {
           double sf = 0;
           ANA_CHECK_CORRECTION (m_outOfValidity, *tau, m_efficiencyCorrectionsTool->getEfficiencyScaleFactor (*tau, sf));
-          (*m_scaleFactorAccessor) (*tau) = sf;
+          m_scaleFactorDecoration.set (*tau, sf, sys);
+        } else {
+          m_scaleFactorDecoration.set (*tau, invalidScaleFactor(), sys);
         }
       }
     }
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauTruthMatchingAlg.cxx b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauTruthMatchingAlg.cxx
index 9812aedf17d3..a68e691a5803 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauTruthMatchingAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/DiTauTruthMatchingAlg.cxx
@@ -46,9 +46,9 @@ namespace CP
   {
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
-      xAOD::DiTauJetContainer *taus = nullptr;
-      ANA_CHECK (m_tauHandle.getCopy (taus, sys));
-      for (xAOD::DiTauJet *tau : *taus)
+      const xAOD::DiTauJetContainer *taus = nullptr;
+      ANA_CHECK (m_tauHandle.retrieve (taus, sys));
+      for (const xAOD::DiTauJet *tau : *taus)
       {
         if (m_preselection.getBool (*tau))
         {
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/TauTruthMatchingAlg.cxx b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/TauTruthMatchingAlg.cxx
index 9394bc749620..3bcef2282642 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/TauTruthMatchingAlg.cxx
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/Root/TauTruthMatchingAlg.cxx
@@ -46,9 +46,9 @@ namespace CP
   {
     for (const auto& sys : m_systematicsList.systematicsVector())
     {
-      xAOD::TauJetContainer *taus = nullptr;
-      ANA_CHECK (m_tauHandle.getCopy (taus, sys));
-      for (xAOD::TauJet *tau : *taus)
+      const xAOD::TauJetContainer *taus = nullptr;
+      ANA_CHECK (m_tauHandle.retrieve (taus, sys));
+      for (const xAOD::TauJet *tau : *taus)
       {
         if (m_preselection.getBool (*tau))
         {
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauEfficiencyCorrectionsAlg.h b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauEfficiencyCorrectionsAlg.h
index 194af5403133..eb53719611c5 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauEfficiencyCorrectionsAlg.h
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauEfficiencyCorrectionsAlg.h
@@ -12,9 +12,9 @@
 #include <TauAnalysisTools/IDiTauEfficiencyCorrectionsTool.h>
 #include <SelectionHelpers/OutOfValidityHelper.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
 #include <SystematicsHandles/SysReadHandle.h>
+#include <SystematicsHandles/SysWriteDecorHandle.h>
 #include <xAODTau/DiTauJetContainer.h>
 
 namespace CP
@@ -47,7 +47,7 @@ namespace CP
 
     /// \brief the tau collection we run on
   private:
-    SysCopyHandle<xAOD::DiTauJetContainer> m_tauHandle {
+    SysReadHandle<xAOD::DiTauJetContainer> m_tauHandle {
       this, "taus", "DiTauJets", "the tau collection to run on"};
 
     /// \brief the preselection we apply to our input
@@ -59,13 +59,10 @@ namespace CP
   private:
     OutOfValidityHelper m_outOfValidity {this};
 
-    /// \brief the decoration for the tau scale factor
+    /// \brief the decoration for the muon scale factor
   private:
-    std::string m_scaleFactorDecoration;
-
-    /// \brief the accessor for \ref m_scaleFactorDecoration
-  private:
-    std::unique_ptr<const SG::AuxElement::Accessor<float> > m_scaleFactorAccessor;
+    SysWriteDecorHandle<float> m_scaleFactorDecoration {
+      this, "scaleFactorDecoration", "", "the decoration for the di-tau efficiency scale factor"};
   };
 }
 
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauTruthMatchingAlg.h b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauTruthMatchingAlg.h
index a93a3aaf6172..578ac577f66e 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauTruthMatchingAlg.h
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/DiTauTruthMatchingAlg.h
@@ -12,8 +12,8 @@
 #include <AnaAlgorithm/AnaAlgorithm.h>
 #include <TauAnalysisTools/IDiTauTruthMatchingTool.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
 #include <xAODTau/DiTauJetContainer.h>
 
 namespace CP
@@ -46,7 +46,7 @@ namespace CP
 
     /// \brief the tau collection we run on
   private:
-    SysCopyHandle<xAOD::DiTauJetContainer> m_tauHandle {
+    SysReadHandle<xAOD::DiTauJetContainer> m_tauHandle {
       this, "taus", "DiTauJets", "the tau collection to run on"};
 
     /// \brief the preselection we apply to our input
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/TauTruthMatchingAlg.h b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/TauTruthMatchingAlg.h
index 0bd2409052c3..494183e1cd19 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/TauTruthMatchingAlg.h
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/TauAnalysisAlgorithms/TauTruthMatchingAlg.h
@@ -12,8 +12,8 @@
 #include <AnaAlgorithm/AnaAlgorithm.h>
 #include <TauAnalysisTools/ITauTruthMatchingTool.h>
 #include <SelectionHelpers/SelectionReadHandle.h>
-#include <SystematicsHandles/SysCopyHandle.h>
 #include <SystematicsHandles/SysListHandle.h>
+#include <SystematicsHandles/SysReadHandle.h>
 #include <xAODTau/TauJetContainer.h>
 
 namespace CP
@@ -46,7 +46,7 @@ namespace CP
 
     /// \brief the tau collection we run on
   private:
-    SysCopyHandle<xAOD::TauJetContainer> m_tauHandle {
+    SysReadHandle<xAOD::TauJetContainer> m_tauHandle {
       this, "taus", "TauJets", "the tau collection to run on"};
 
     /// \brief the preselection we apply to our input
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/DiTauAnalysisSequence.py b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/DiTauAnalysisSequence.py
index 52239dcf4876..169c2a0fe766 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/DiTauAnalysisSequence.py
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/DiTauAnalysisSequence.py
@@ -71,7 +71,7 @@ def makeDiTauAnalysisSequence( dataType, workingPoint,
     alg.scaleFactorDecoration = 'tau_effSF' + postfix
     # alg.outOfValidity = 2 #silent
     # alg.outOfValidityDeco = "bad_eff"
-    seq.append( alg, inputPropName = 'taus', outputPropName = 'tausOut',
+    seq.append( alg, inputPropName = 'taus',
                 stageName = 'efficiency' )
 
     # Set up the tau truth matching algorithm:
@@ -81,7 +81,7 @@ def makeDiTauAnalysisSequence( dataType, workingPoint,
         addPrivateTool( alg, 'matchingTool',
                         'TauAnalysisTools::DiTauTruthMatchingTool' )
         alg.matchingTool.WriteTruthTaus = 1
-        seq.append( alg, inputPropName = 'taus', outputPropName = 'tausOut',
+        seq.append( alg, inputPropName = 'taus',
                     stageName = 'selection' )
         pass
 
diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisSequence.py b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisSequence.py
index 29817be83509..a5c1615f77e7 100644
--- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisSequence.py
+++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisSequence.py
@@ -75,7 +75,7 @@ def makeTauAnalysisSequence( dataType, workingPoint, postfix = '',
         addPrivateTool( alg, 'matchingTool',
                         'TauAnalysisTools::TauTruthMatchingTool' )
         alg.matchingTool.WriteTruthTaus = 1
-        seq.append( alg, inputPropName = 'taus', outputPropName = 'tausOut',
+        seq.append( alg, inputPropName = 'taus',
                     stageName = 'selection' )
         pass
 
-- 
GitLab