From 03f5a4ef7d9dbbe71dbfdb5866ea6afdb7918c7a Mon Sep 17 00:00:00 2001
From: moukaddam <mhd.moukaddam@gmail.com>
Date: Sun, 11 Dec 2016 01:05:30 +0000
Subject: [PATCH] Clearing Pretreated Data in function Pretreat(); fixing a
 leak

---
 NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx | 11 ++++++-----
 NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h   |  8 +++++---
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx
index cffae20d3..bb1a15ff3 100644
--- a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx
+++ b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx
@@ -52,6 +52,7 @@ ClassImp(TGeTAMUPhysics)
 /////////////////////////////////////////////////
 void TGeTAMUPhysics::BuildPhysicalEvent(){
   PreTreat();
+
   unsigned int c_size_e = m_PreTreatedData->GetMultiplicityCoreE();
   unsigned int s_size_e = m_PreTreatedData->GetMultiplicitySegmentE();
   unsigned int c_size_t = m_PreTreatedData->GetMultiplicityCoreT();
@@ -107,6 +108,9 @@ for (unsigned i = 0 ; i < m_PreTreatedData->GetMultiplicityCoreT(); i++)
 
 /////////////////////////////////////////////////
 void TGeTAMUPhysics::PreTreat(){
+
+  ClearPreTreatedData();
+
   static CalibrationManager* cal = CalibrationManager::getInstance();
   static string name;
   unsigned int mysizeE = m_EventData->GetMultiplicityCoreE();
@@ -304,6 +308,7 @@ void TGeTAMUPhysics::InitializeRootOutput()    {
   TTree* outputTree = RootOutput::getInstance()->GetTree();
   outputTree->Branch( "GeTAMU" , "TGeTAMUPhysics" , &m_EventPhysics );
 }
+
 ///////////////////////////////////////////////////////////////////////////  
 void TGeTAMUPhysics::Clear() {
   AddBack_E.clear();
@@ -318,11 +323,7 @@ void TGeTAMUPhysics::Clear() {
   AddBack_T.clear();
   GeTime.clear();
 }
-///////////////////////////////////////////////////////////////////////////  
-void TGeTAMUPhysics::ClearEventData() {
-  m_EventData->Clear();
-  m_PreTreatedData->Clear();
-}
+
 ///////////////////////////////////////////////////////////////////////////
 void TGeTAMUPhysics::AddParameterToCalibrationManager(){
   CalibrationManager* Cal = CalibrationManager::getInstance();
diff --git a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h
index c06078272..4399a14e1 100644
--- a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h
+++ b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h
@@ -72,11 +72,13 @@ class TGeTAMUPhysics :  public TObject, public NPL::VDetector{
     void BuildSimplePhysicalEvent(){BuildPhysicalEvent();} ;
 
     //   Clear the Event Physics
-    void ClearEventPhysics() {Clear();}      
-    void ClearEventData() ;
-
+    void ClearEventPhysics() {Clear();}          
+    void ClearEventData()    {m_EventData->Clear();}  
+    
   public:
     void PreTreat();
+    // clear the pre-treated object
+    void ClearPreTreatedData()   {m_PreTreatedData->Clear();}
 
   private:   //   Root Input and Output tree classes
 
-- 
GitLab