From adcdd54164c149b0e47f6dd712a85ef98c23a92c Mon Sep 17 00:00:00 2001
From: Emmanuel Le Guirriec <emmanuel.le.guirriec@cern.ch>
Date: Thu, 17 Jan 2019 15:40:16 +0100
Subject: [PATCH 1/2] Fix memory leak in m_histos from JetTagCalibCondData
 Remove unused method

---
 .../JetTagCalibration/JetTagCalibCondData.h   |  4 +--
 .../src/JetTagCalibCondData.cxx               | 32 +++++++++----------
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/PhysicsAnalysis/JetTagging/JetTagCalibration/JetTagCalibration/JetTagCalibCondData.h b/PhysicsAnalysis/JetTagging/JetTagCalibration/JetTagCalibration/JetTagCalibCondData.h
index c9fc9f3b5726..1cd99be70dbc 100644
--- a/PhysicsAnalysis/JetTagging/JetTagCalibration/JetTagCalibration/JetTagCalibCondData.h
+++ b/PhysicsAnalysis/JetTagging/JetTagCalibration/JetTagCalibration/JetTagCalibCondData.h
@@ -37,7 +37,7 @@ public:
   // Constructor
   JetTagCalibCondData();
   // Destructor
-  virtual ~JetTagCalibCondData() = default;
+  ~JetTagCalibCondData();
 
   /** Resize the data members */
   void resize(const std::vector<std::string> sizeHisto);
@@ -46,6 +46,7 @@ public:
   void printHistosStatus() const; 
   std::string getChannelAlias(const std::string& originalChannel) const;
   void addHisto(const unsigned int indexTagger, const std::string& name, TObject *);
+  void deleteHistos();
   void addDL1NN(const std::string& tagger, const std::string& channel, const lwt::JSONConfig& );
   void addChannelAlias(const std::string& channel, const std::string& alias);
   TH1* retrieveHistogram(const std::string& folder, const std::string& channel, const std::string& hname) const; 
@@ -55,7 +56,6 @@ public:
   std::string channelName(const std::string& fullHistoName) const;
   std::string histoName(const std::string& fullHistoName) const ;
   std::string fullHistoName(const std::string& channel, const std::string& histoName) const;
-  std::vector<std::string> tokenize(std::string str, std::string delim);
 
 private:
   std::vector< std::map<std::string, TObject*> > m_histos;
diff --git a/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx b/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx
index 1b98f19cd84f..7fb857cb40fb 100644
--- a/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx
+++ b/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx
@@ -26,6 +26,21 @@ JetTagCalibCondData::JetTagCalibCondData()
     m_channelAliasesMap.clear();
   }
 
+JetTagCalibCondData::~JetTagCalibCondData() {
+    this->deleteHistos();
+}
+
+void JetTagCalibCondData::deleteHistos() {
+    std::map<std::string, TObject*>::const_iterator iter_hist;
+    for(unsigned int i=0;i<m_histos.size();i++) {
+      iter_hist = m_histos[i].begin();
+      for(;iter_hist!=m_histos[i].end();++iter_hist) {
+        MsgStream log(Athena::getMessageSvc(), "JetTagCalibCondData");
+        log << MSG::DEBUG << "#BTAG# delete histo of " << iter_hist->first << endmsg;
+        delete iter_hist->second;
+      }
+    }
+}
 
 void JetTagCalibCondData::resize(const std::vector<std::string> taggers) {
     m_histos.reserve(taggers.size());
@@ -119,23 +134,6 @@ lwt::JSONConfig JetTagCalibCondData::retrieveDL1NN(std::string& tagger, const st
   return config;
 }
 
-std::vector<std::string> JetTagCalibCondData::tokenize(std::string str, std::string delim){
-  std::vector<std::string> tokens;
-  std::string::size_type sPos, sEnd, sLen;
-  // if str starts with a character in delim, do you want an empty string in tokens?
-  // sPos = 0; // if answer is yes
-  sPos = str.find_first_not_of(delim);  // if answer is no
-  while(sPos != std::string::npos){
-    sEnd = str.find_first_of(delim, sPos);
-    if(sEnd == std::string::npos) sEnd = str.length();
-    sLen = sEnd - sPos;
-    std::string token = str.substr(sPos, sLen);
-    tokens.push_back(token);
-    sPos = str.find_first_not_of(delim, sEnd);
-  }
-  return tokens;
-}
-
 std::string JetTagCalibCondData::channelName(const std::string& fname) const {
   const std::string delim("#");
   std::string::size_type sPos;
-- 
GitLab


From 6a010cef204baef3ab0361cf3e26765af2b42f6a Mon Sep 17 00:00:00 2001
From: Emmanuel Le Guirriec <emmanuel.le.guirriec@cern.ch>
Date: Fri, 18 Jan 2019 12:47:15 +0000
Subject: [PATCH 2/2] Update JetTagCalibCondData.cxx

---
 .../JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx b/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx
index 7fb857cb40fb..ac5ad67f92e2 100644
--- a/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx
+++ b/PhysicsAnalysis/JetTagging/JetTagCalibration/src/JetTagCalibCondData.cxx
@@ -31,11 +31,11 @@ JetTagCalibCondData::~JetTagCalibCondData() {
 }
 
 void JetTagCalibCondData::deleteHistos() {
+    MsgStream log(Athena::getMessageSvc(), "JetTagCalibCondData");
     std::map<std::string, TObject*>::const_iterator iter_hist;
     for(unsigned int i=0;i<m_histos.size();i++) {
       iter_hist = m_histos[i].begin();
       for(;iter_hist!=m_histos[i].end();++iter_hist) {
-        MsgStream log(Athena::getMessageSvc(), "JetTagCalibCondData");
         log << MSG::DEBUG << "#BTAG# delete histo of " << iter_hist->first << endmsg;
         delete iter_hist->second;
       }
-- 
GitLab