From 66766b7e9cbf02f80fe4ca8c9ff435f1d90c0870 Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Thu, 9 Apr 2015 12:16:58 +0100
Subject: [PATCH] * Tweaking a few detail on RootInput and RootOuput

---
 NPLib/Core/NPDetectorManager.cxx |  2 +-
 NPLib/Core/RootInput.cxx         | 12 +++++++++---
 NPLib/Core/RootOutput.cxx        |  2 +-
 NPLib/Utility/npanalysis.cxx     |  6 ++++--
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/NPLib/Core/NPDetectorManager.cxx b/NPLib/Core/NPDetectorManager.cxx
index 722894c8a..05bb7754b 100644
--- a/NPLib/Core/NPDetectorManager.cxx
+++ b/NPLib/Core/NPDetectorManager.cxx
@@ -289,7 +289,7 @@ void NPA::DetectorManager::InitThreadPool(){
 
   cout << "\033[1;33m**** Detector Manager : Started " << i << " Threads ****\033[0m" << endl ;
   // Sleep to let the time to the thread to start
-  this_thread::sleep_for (std::chrono::milliseconds(1));
+  this_thread::sleep_for (std::chrono::milliseconds(100));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/NPLib/Core/RootInput.cxx b/NPLib/Core/RootInput.cxx
index 495d55226..94706bc3b 100644
--- a/NPLib/Core/RootInput.cxx
+++ b/NPLib/Core/RootInput.cxx
@@ -131,15 +131,18 @@ RootInput::RootInput(string configFileName){
       exit(1);
     }
     else{
-    cout << "\033[1;32mROOTInput:  " << pRootChain->GetEntries() << " entries loaded in the input chain\033[0m" << endl ;
+      cout << "\033[1;32mROOTInput:  " << pRootChain->GetEntries() << " entries loaded in the input chain\033[0m" << endl ;
     }
-      
-   }
+
+  }
 
   if (!CheckRootFileName || !CheckTreeName) 
     cout << "\033[1;33mWARNING: Token not found for InputTree Declaration : Input Tree may not be instantiate properly\033[0m" << endl;
 
+  int  cachesize = 10000000;   //100 MBytes
+  pRootChain->SetCacheSize(cachesize);
   pRootChain->SetCacheLearnEntries(100);
+
   gEnv->SetValue("TFile.AsyncPrefetching", 1);
 }
 
@@ -285,6 +288,9 @@ RootInput::~RootInput(){
   if (res == 0) {   // if does exist, delete it
     if (system("rm -rf ./.tmp") != 0) cout << "RootInput::~RootInput() problem deleting ./.tmp directory" << endl; 
   }
+  cout << endl << "Root Input summary" << endl;
+  cout << "  - Number of bites read: " << pRootFile->GetBytesRead() << endl;
+  cout << "  - Number of transactions: " << pRootFile->GetReadCalls() << endl;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/NPLib/Core/RootOutput.cxx b/NPLib/Core/RootOutput.cxx
index f8191733f..408d90ecc 100644
--- a/NPLib/Core/RootOutput.cxx
+++ b/NPLib/Core/RootOutput.cxx
@@ -132,7 +132,7 @@ RootOutput::~RootOutput()
       TDirectory* currentPath= gDirectory;
       gDirectory->cd(pRootFile->GetPath());
       cout << endl;
-      cout << "Got histograms and Tree !" << endl;
+      cout << endl << "Root Output summary" << endl;
       cout << "  - Number of entries in the Tree: " << pRootTree->GetEntries() << endl;
       cout << "  - Number of bites written to file: " << pRootTree->Write("", TObject::kOverwrite) << endl;
 
diff --git a/NPLib/Utility/npanalysis.cxx b/NPLib/Utility/npanalysis.cxx
index 328dd5cf2..b82318d23 100644
--- a/NPLib/Utility/npanalysis.cxx
+++ b/NPLib/Utility/npanalysis.cxx
@@ -114,6 +114,7 @@ int main(int argc , char** argv){
   #endif
   ProgressDisplay(begin,end,treated,inter,nentries);
   RootOutput::getInstance()->Destroy();
+  RootInput::getInstance()->Destroy();
   return 0;
 }
 
@@ -135,9 +136,10 @@ void ProgressDisplay(clock_t& begin, clock_t& end, unsigned int& treated,unsigne
     if(treated!=total)
       printf("\r \033[1;31m ******* Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s *******\033[0m", percent,event_rate/1000.,timer);
     
-    else
+    else{
+      printf("\r                                                                                                                    ");  
       printf("\r \033[1;32m ******* Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s *******\033[0m", percent,event_rate/1000.,timer);
-   
+    }
     fflush(stdout);
     inter=0;
     begin = clock() ;
-- 
GitLab