From f490d8e9409b0c50f65ef81dfcbb25155dd17190 Mon Sep 17 00:00:00 2001
From: Jovan Mitrevski <Jovan.Mitrevski@cern.ch>
Date: Thu, 14 Mar 2019 12:57:58 +0100
Subject: [PATCH] improve unique_ptr usage

---
 .../egamma/egammaAlgs/src/electronSuperClusterBuilder.cxx   | 6 +++---
 .../egamma/egammaAlgs/src/photonSuperClusterBuilder.cxx     | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Reconstruction/egamma/egammaAlgs/src/electronSuperClusterBuilder.cxx b/Reconstruction/egamma/egammaAlgs/src/electronSuperClusterBuilder.cxx
index 927f46c806f..9f2356a698a 100644
--- a/Reconstruction/egamma/egammaAlgs/src/electronSuperClusterBuilder.cxx
+++ b/Reconstruction/egamma/egammaAlgs/src/electronSuperClusterBuilder.cxx
@@ -187,16 +187,16 @@ StatusCode electronSuperClusterBuilder::execute(){
     //
     //////////////////////////////////////////////////////////////////
     //Push back the new cluster into the output container.
-    outputClusterContainer->push_back(newClus.release());
+    outputClusterContainer->push_back(std::move(newClus));
     ElementLink< xAOD::CaloClusterContainer > clusterLink(*outputClusterContainer, outputClusterContainer->size() - 1);
     std::vector< ElementLink<xAOD::CaloClusterContainer> > elClusters {clusterLink};
     //
     ////////////////////////////////////////////////////////////////////
     //Make egammaRec object, and push it back into output container.
-    egammaRec *newEgRec = new egammaRec(*egRec);
+    auto newEgRec = std::make_unique<egammaRec>(*egRec);
     if (newEgRec) {
       newEgRec->setCaloClusters  (elClusters);
-      newEgammaRecs->push_back(newEgRec);
+      newEgammaRecs->push_back(std::move(newEgRec));
       ATH_MSG_DEBUG("Made new egammaRec object");
     } else {
       ATH_MSG_FATAL("Couldn't make an egammaRec object");
diff --git a/Reconstruction/egamma/egammaAlgs/src/photonSuperClusterBuilder.cxx b/Reconstruction/egamma/egammaAlgs/src/photonSuperClusterBuilder.cxx
index ac8c98da333..59b01bce62d 100644
--- a/Reconstruction/egamma/egammaAlgs/src/photonSuperClusterBuilder.cxx
+++ b/Reconstruction/egamma/egammaAlgs/src/photonSuperClusterBuilder.cxx
@@ -151,7 +151,7 @@ StatusCode photonSuperClusterBuilder::execute(){
     ATH_MSG_DEBUG("extra clusters: " << nExtraClusters);
      
     //push back the new photon super cluster 
-    outputClusterContainer->push_back(newCluster.release());
+    outputClusterContainer->push_back(std::move(newCluster));
 
     //Add the cluster link to the super cluster
     ElementLink< xAOD::CaloClusterContainer > clusterLink(*outputClusterContainer, outputClusterContainer->size() - 1);
@@ -159,11 +159,11 @@ StatusCode photonSuperClusterBuilder::execute(){
 
     ///////////////////////////////////////////////////////
     //Now create the new eg Rec 
-    egammaRec *newEgRec = new egammaRec(*egRec);
+    auto newEgRec = std::make_unique<egammaRec>(*egRec);
     if (newEgRec) {
       newEgRec->setCaloClusters(phCluster);
       //push it back
-      newEgammaRecs->push_back(newEgRec);
+      newEgammaRecs->push_back(std::move(newEgRec));
       ATH_MSG_DEBUG("Finished making photon egammaRec object");
     } else {
       ATH_MSG_FATAL("Couldn't make an egammaRec object");
-- 
GitLab