From 03d89a53d77a3c61c8762a6c05f4992c8855a53e Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Mon, 19 May 2014 14:37:54 +0100
Subject: [PATCH] * fixing issue with older compilator not knowing std::map::at
 * introductiong VSpectra a template virtual class from which derived the *
 TSpectra classes

---
 NPLib/CATS/TCATSSpectra.cxx         |  69 ------------------
 NPLib/CATS/TCATSSpectra.h           |  23 ++----
 NPLib/Charissa/TCharissaSpectra.cxx |  94 -------------------------
 NPLib/Charissa/TCharissaSpectra.h   |  18 ++---
 NPLib/Exogam/TExogamSpectra.cxx     |  85 ----------------------
 NPLib/Exogam/TExogamSpectra.h       |  17 +----
 NPLib/LaBr3/TLaBr3Spectra.cxx       |  94 -------------------------
 NPLib/LaBr3/TLaBr3Spectra.h         |  18 ++---
 NPLib/MUST2/TMust2Spectra.cxx       |  83 ----------------------
 NPLib/MUST2/TMust2Spectra.h         |  18 +----
 NPLib/SiLi/TSiLiSpectra.cxx         |  94 -------------------------
 NPLib/SiLi/TSiLiSpectra.h           |  20 ++----
 NPLib/SiRes/TSiResSpectra.cxx       |  94 -------------------------
 NPLib/SiRes/TSiResSpectra.h         |  22 ++----
 NPLib/Tiara/TTiaraBarrelSpectra.cxx |  84 ----------------------
 NPLib/Tiara/TTiaraBarrelSpectra.h   |  17 +----
 NPLib/Tiara/TTiaraHyballSpectra.cxx |  73 -------------------
 NPLib/Tiara/TTiaraHyballSpectra.h   |  14 +---
 NPLib/VDetector/Makefile            |   5 +-
 NPLib/VDetector/VSpectra.cxx        | 105 ++++++++++++++++++++++++++++
 NPLib/VDetector/VSpectra.h          |  69 ++++++++++++++++++
 21 files changed, 213 insertions(+), 903 deletions(-)
 create mode 100644 NPLib/VDetector/VSpectra.cxx
 create mode 100644 NPLib/VDetector/VSpectra.h

diff --git a/NPLib/CATS/TCATSSpectra.cxx b/NPLib/CATS/TCATSSpectra.cxx
index c84da91d7..6674bd199 100644
--- a/NPLib/CATS/TCATSSpectra.cxx
+++ b/NPLib/CATS/TCATSSpectra.cxx
@@ -326,72 +326,3 @@ void TCATSSpectra::FillPhysicsSpectra(TCATSPhysics* Physics){
   }
 }
 
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TCATSSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index] = hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TCATSSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index] = hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TCATSSpectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.reserve(2);
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-    cout << "ERROR : the folowing Histo has been requested by TCATSSpectra and does not exist: family:" << family << " name: "  << name << endl ;
-    exit(1);
-  }
-
-  return histo;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void TCATSSpectra::WriteHisto(string filename){
-  TFile* f = NULL; 
-
-  if (filename != "VOID") {
-    f = new TFile(filename.c_str(),"RECREATE");
-  }
-
-  map< vector<string>, TH1* >::iterator it;
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
-    it->second->Write();
-  }
-
-  if (filename != "VOID") {
-    f->Close();
-    delete f;
-  }
-}
diff --git a/NPLib/CATS/TCATSSpectra.h b/NPLib/CATS/TCATSSpectra.h
index 3a70e23eb..c5c754fa6 100644
--- a/NPLib/CATS/TCATSSpectra.h
+++ b/NPLib/CATS/TCATSSpectra.h
@@ -1,5 +1,5 @@
-#ifndef TTIARAHYBALLSPECTRA_H
-#define TTIARAHYBALLSPECTRA_H
+#ifndef TCATSSPECTRA_H
+#define TCATSSPECTRA_H
 /*****************************************************************************
  * Copyright (C) 2009-2014    this file is part of the NPTool Project        *
  *                                                                           *
@@ -8,17 +8,16 @@
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+ * Original Author: A. Matta         contact address: a.matta@surrey.ac.uk   *
  *                                                                           *
  * Creation Date  : dec 2013                                                 *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class holds all the online spectra needed for Tiara/Hyball          *
+ *  This class holds all the online spectra needed for CATS                  *
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
- *    + first version (not complete yet)                                     *
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
@@ -29,6 +28,7 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TCATSData.h"
 #include "TCATSPhysics.h"
 
@@ -41,7 +41,7 @@ using namespace std;
 class TCATSPhysics;
 
 
-class TCATSSpectra {
+class TCATSSpectra:public VSpectra {
   public:
     // constructor and destructor
     TCATSSpectra();
@@ -52,7 +52,7 @@ class TCATSSpectra {
     // Instantiate and register histo to maps
     TH1* AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family);
     TH1* AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, 
-                                                 Int_t nbinsy, Double_t ylow, Double_t yup, string family);
+        Int_t nbinsy, Double_t ylow, Double_t yup, string family);
 
     // Initialization methods
     void InitRawSpectra();
@@ -65,12 +65,6 @@ class TCATSSpectra {
     void FillPreTreatedSpectra(TCATSData*);
     void FillPhysicsSpectra(TCATSPhysics*);
 
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family, string& name);    
-    void WriteHisto(string filename = "VOID");      
-
   private: // Information on MUST2
     unsigned int fNumberOfCats;
     unsigned int fStripsNumber;
@@ -79,9 +73,6 @@ class TCATSSpectra {
     int fEventLoopIndex;
     vector<double> fEventLoopQSum;
 
-  private:
-// map holding histo pointers and their family names
-map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/Charissa/TCharissaSpectra.cxx b/NPLib/Charissa/TCharissaSpectra.cxx
index a21158af2..c3ca27e2f 100644
--- a/NPLib/Charissa/TCharissaSpectra.cxx
+++ b/NPLib/Charissa/TCharissaSpectra.cxx
@@ -519,97 +519,3 @@ void TCharissaSpectra::FillPhysicsSpectra(TCharissaPhysics* Physics)
  
 }
 
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TCharissaSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TCharissaSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TCharissaSpectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-  
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-  cout << "ERROR : the folowing Histo has been requested by TCharissaSpectra and does not exist: family:" << family << " name: "  << name << endl ;
-  exit(1);
-  }
-
-  return histo;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-void TCharissaSpectra::WriteHisto(string filename)
-{
-   TFile *f = NULL; 
-
-   if (filename != "VOID") {
-      f = new TFile(filename.c_str(), "RECREATE");
-   }
-
-   map< vector<string>, TH1* >::iterator it;
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
-      it->second->Write();
-   }
-
-   if (filename != "VOID") {
-      f->Close();
-      delete f;
-   }
-}
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-void TCharissaSpectra::CheckSpectra()
-{
-   map< vector<string>, TH1* >::iterator it;
-   Color_t ok_color      = kTeal+9;
-   Color_t warning_color = kOrange+8;  warning_color *= 1;
-   Color_t bad_color     = kRed;       bad_color     *= 1;
-
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it)
-   {
-      it->second->SetLineColor(ok_color);
-      it->second->SetFillStyle(1001);
-      it->second->SetFillColor(ok_color);
-   }
-}
diff --git a/NPLib/Charissa/TCharissaSpectra.h b/NPLib/Charissa/TCharissaSpectra.h
index a4f0f8d3d..062f4c76b 100644
--- a/NPLib/Charissa/TCharissaSpectra.h
+++ b/NPLib/Charissa/TCharissaSpectra.h
@@ -8,7 +8,7 @@
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+ * Original Author: A. Matta         contact address: a.matta@surrey.ac.uk   *
  *                                                                           *
  * Creation Date  : dec 2013                                                 *
  * Last update    :                                                          *
@@ -18,13 +18,13 @@
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
- *    + first version (not complete yet)                                     *
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
 
 // C++ STL headers
 #include <map>
+using namespace std;
 
 // ROOT headers
 #include "TObject.h"
@@ -32,14 +32,15 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TCharissaData.h"
 #include "TCharissaPhysics.h"
-using namespace std;
+
 
 // ForwardDeclaration
 class TCharissaPhysics;
 
-class TCharissaSpectra {
+class TCharissaSpectra: public VSpectra {
   public:
     // constructor and destructor
     TCharissaSpectra();
@@ -65,21 +66,12 @@ class TCharissaSpectra {
     // Check the Spectra
     void CheckSpectra();
 
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family,string& name);    
-    void WriteHisto(string filename="VOID");      
 
   private: // Information on CHARISSA
     unsigned int fNumberOfTelescope;
     unsigned int fStripX;
     unsigned int fStripY;
     unsigned int fCrystalCsI;
-
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/Exogam/TExogamSpectra.cxx b/NPLib/Exogam/TExogamSpectra.cxx
index 55743bee9..acf1b16b8 100644
--- a/NPLib/Exogam/TExogamSpectra.cxx
+++ b/NPLib/Exogam/TExogamSpectra.cxx
@@ -205,88 +205,3 @@ void TExogamSpectra::FillPhysicsSpectra(TExogamPhysics* Physics){
   }
 
 }
-////////////////////////////////////////////////////////////////////////////////
-TH1* TExogamSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TExogamSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TExogamSpectra::GetHisto(string family, string name){
-vector<string> index;
-  index.reserve(2);
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-    cout << "ERROR : the folowing Histo has been requested by TCATSSpectra and does not exist: family:" << family << " name: "  << name << endl ;
-    exit(1);
-  }
-
-  return histo;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-void TExogamSpectra::WriteHisto(string filename){
-  TFile* f=NULL; 
-
-  if(filename!="VOID"){
-    f = new TFile(filename.c_str(),"RECREATE");
-  }
-
-  map< vector<string>, TH1* >::iterator it;
-
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){
-    it->second->Write();
-  }
-
-  if(filename!="VOID"){
-    f->Close();
-    delete f;
-  }
-
-}
-///////////////////////////////////////////////////////////////////////////////
-void TExogamSpectra::CheckSpectra(){
-map< vector<string>, TH1* >::iterator it;
-  Color_t ok_color = kTeal+9;
-  Color_t warning_color = kOrange+8;   warning_color *= 1;
-  Color_t bad_color = kRed;            bad_color *= 1;
-
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){
-    it->second->SetLineColor(ok_color);
-    it->second->SetFillStyle(1001);
-    it->second->SetFillColor(ok_color);
-  }
-
-}
diff --git a/NPLib/Exogam/TExogamSpectra.h b/NPLib/Exogam/TExogamSpectra.h
index 04e6aebf9..46d98b4ec 100644
--- a/NPLib/Exogam/TExogamSpectra.h
+++ b/NPLib/Exogam/TExogamSpectra.h
@@ -25,6 +25,7 @@
 
 // C++ STL headers
 #include <map>
+using namespace std;
 
 // ROOT headers
 #include "TObject.h"
@@ -32,14 +33,14 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TExogamData.h"
 #include "TExogamPhysics.h"
-using namespace std;
 
 // ForwardDeclaration
 class TExogamPhysics ;
 
-class TExogamSpectra {
+class TExogamSpectra:public VSpectra {
   public:
     // constructor and destructor
     TExogamSpectra();
@@ -62,14 +63,6 @@ class TExogamSpectra {
     void FillRawSpectra(TExogamData*);
     void FillPreTreatedSpectra(TExogamData*);
     void FillPhysicsSpectra(TExogamPhysics*);
-    // Check the Spectra
-    void CheckSpectra();
-
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string family,string name);    
-    void WriteHisto(string filename="VOID");      
 
   private: // Information on Exogam
     unsigned int fNumberOfClover ;
@@ -81,10 +74,6 @@ class TExogamSpectra {
     unsigned int fbinCalMax;
     unsigned int fNumberOfSegments;
     unsigned int fNumberOfCores;
-
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/LaBr3/TLaBr3Spectra.cxx b/NPLib/LaBr3/TLaBr3Spectra.cxx
index 760d88816..b8c3ce5b5 100644
--- a/NPLib/LaBr3/TLaBr3Spectra.cxx
+++ b/NPLib/LaBr3/TLaBr3Spectra.cxx
@@ -337,97 +337,3 @@ void TLaBr3Spectra::FillPhysicsSpectra(TLaBr3Physics* Physics)
    }
 }
 
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TLaBr3Spectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TLaBr3Spectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TLaBr3Spectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-  
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-  cout << "ERROR : the folowing Histo has been requested by TLaBr3Spectra and does not exist: family:" << family << " name: "  << name << endl ;
-  exit(1);
-  }
-
-  return histo;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-void TLaBr3Spectra::WriteHisto(string filename)
-{
-   TFile *f = NULL; 
-
-   if (filename != "VOID") {
-      f = new TFile(filename.c_str(), "RECREATE");
-   }
-
-   map< vector<string>, TH1* >::iterator it;
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
-      it->second->Write();
-   }
-
-   if (filename != "VOID") {
-      f->Close();
-      delete f;
-   }
-}
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-void TLaBr3Spectra::CheckSpectra()
-{
-   map< vector<string>, TH1* >::iterator it;
-   Color_t ok_color      = kTeal+9;
-   Color_t warning_color = kOrange+8;  warning_color *= 1;
-   Color_t bad_color     = kRed;       bad_color     *= 1;
-
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it)
-   {
-      it->second->SetLineColor(ok_color);
-      it->second->SetFillStyle(1001);
-      it->second->SetFillColor(ok_color);
-   }
-}
diff --git a/NPLib/LaBr3/TLaBr3Spectra.h b/NPLib/LaBr3/TLaBr3Spectra.h
index 3eb8dff43..ff8cb6af3 100644
--- a/NPLib/LaBr3/TLaBr3Spectra.h
+++ b/NPLib/LaBr3/TLaBr3Spectra.h
@@ -25,6 +25,7 @@
 
 // C++ STL headers
 #include <map>
+using namespace std;
 
 // ROOT headers
 #include "TObject.h"
@@ -32,14 +33,14 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TLaBr3Data.h"
 #include "TLaBr3Physics.h"
-using namespace std;
 
 // ForwardDeclaration
 class TLaBr3Physics;
 
-class TLaBr3Spectra {
+class TLaBr3Spectra: public VSpectra {
   public:
     // constructor and destructor
     TLaBr3Spectra();
@@ -62,21 +63,10 @@ class TLaBr3Spectra {
     void FillRawSpectra(TLaBr3Data*);
     void FillPreTreatedSpectra(TLaBr3Data*);
     void FillPhysicsSpectra(TLaBr3Physics*);
-    // Check the Spectra
-    void CheckSpectra();
 
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family,string& name);    
-    void WriteHisto(string filename="VOID");      
-
-  private: // Information on CHARISSA
+  private: // Information on LaBr3
     unsigned int fNumberDetector;
 
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/MUST2/TMust2Spectra.cxx b/NPLib/MUST2/TMust2Spectra.cxx
index 7ac54d00e..4fc34e0c5 100644
--- a/NPLib/MUST2/TMust2Spectra.cxx
+++ b/NPLib/MUST2/TMust2Spectra.cxx
@@ -611,87 +611,4 @@ void TMust2Spectra::FillPhysicsSpectra(TMust2Physics* Physics){
   }
 
 }
-////////////////////////////////////////////////////////////////////////////////
-TH1* TMust2Spectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TMust2Spectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TMust2Spectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.reserve(2);
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-  
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-  cout << "ERROR : the folowing Histo has been requested by TMust2Spectra and does not exist: family:" << family << " name: "  << name << endl ;
-  exit(1);
-  }
 
-  return histo;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void TMust2Spectra::WriteHisto(string filename){
-  TFile* f=NULL; 
-
-  if(filename!="VOID"){
-    f = new TFile(filename.c_str(),"RECREATE");
-  }
-
-  map< vector<string>, TH1* >::iterator it;
-
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){
-    it->second->Write();
-  }
-
-  if(filename!="VOID"){
-    f->Close();
-    delete f;
-  }
-
-}
-///////////////////////////////////////////////////////////////////////////////
-void TMust2Spectra::CheckSpectra(){
-  map< vector<string>, TH1* >::iterator it;
-  Color_t ok_color = kTeal+9;
-  Color_t warning_color = kOrange+8;   warning_color *= 1;
-  Color_t bad_color = kRed;            bad_color *= 1;
-
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){
-    it->second->SetLineColor(ok_color);
-    it->second->SetFillStyle(1001);
-    it->second->SetFillColor(ok_color);
-  }
-
-}
diff --git a/NPLib/MUST2/TMust2Spectra.h b/NPLib/MUST2/TMust2Spectra.h
index b56bd6dd6..518485826 100644
--- a/NPLib/MUST2/TMust2Spectra.h
+++ b/NPLib/MUST2/TMust2Spectra.h
@@ -18,13 +18,13 @@
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
- *    + first version (not complete yet)                                     *
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
 
 // C++ STL headers
 #include <map>
+using namespace std;
 
 // ROOT headers
 #include "TObject.h"
@@ -32,14 +32,14 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TMust2Data.h"
 #include "TMust2Physics.h"
-using namespace std;
 
 // ForwardDeclaration
 class TMust2Physics ;
 
-class TMust2Spectra {
+class TMust2Spectra:public VSpectra {
   public:
     // constructor and destructor
     TMust2Spectra();
@@ -62,14 +62,6 @@ class TMust2Spectra {
     void FillRawSpectra(TMust2Data*);
     void FillPreTreatedSpectra(TMust2Data*);
     void FillPhysicsSpectra(TMust2Physics*);
-    // Check the Spectra
-    void CheckSpectra();
-
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family,string& name);    
-    void WriteHisto(string filename="VOID");      
 
   private: // Information on MUST2
     unsigned int fNumberOfTelescope;
@@ -77,10 +69,6 @@ class TMust2Spectra {
     unsigned int fStripY;
     unsigned int fPadSili;
     unsigned int fCrystalCsI;
-
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/SiLi/TSiLiSpectra.cxx b/NPLib/SiLi/TSiLiSpectra.cxx
index d526bc569..32c50af0b 100644
--- a/NPLib/SiLi/TSiLiSpectra.cxx
+++ b/NPLib/SiLi/TSiLiSpectra.cxx
@@ -338,97 +338,3 @@ void TSiLiSpectra::FillPhysicsSpectra(TSiLiPhysics* Physics)
    }
 }
 
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TSiLiSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TSiLiSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TSiLiSpectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-  
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-  cout << "ERROR : the folowing Histo has been requested by TSiLiSpectra and does not exist: family:" << family << " name: "  << name << endl ;
-  exit(1);
-  }
-
-  return histo;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-void TSiLiSpectra::WriteHisto(string filename)
-{
-   TFile *f = NULL; 
-
-   if (filename != "VOID") {
-      f = new TFile(filename.c_str(), "RECREATE");
-   }
-
-   map< vector<string>, TH1* >::iterator it;
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
-      it->second->Write();
-   }
-
-   if (filename != "VOID") {
-      f->Close();
-      delete f;
-   }
-}
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-void TSiLiSpectra::CheckSpectra()
-{
-   map< vector<string>, TH1* >::iterator it;
-   Color_t ok_color      = kTeal+9;
-   Color_t warning_color = kOrange+8;  warning_color *= 1;
-   Color_t bad_color     = kRed;       bad_color     *= 1;
-
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it)
-   {
-      it->second->SetLineColor(ok_color);
-      it->second->SetFillStyle(1001);
-      it->second->SetFillColor(ok_color);
-   }
-}
diff --git a/NPLib/SiLi/TSiLiSpectra.h b/NPLib/SiLi/TSiLiSpectra.h
index eecae3ed4..7a3bdacf6 100644
--- a/NPLib/SiLi/TSiLiSpectra.h
+++ b/NPLib/SiLi/TSiLiSpectra.h
@@ -14,17 +14,17 @@
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class holds all the online spectra needed for SiLi              *
+ *  This class holds all the online spectra needed for SiLi                  *
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
- *    + first version (not complete yet)                                     *
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
 
 // C++ STL headers
 #include <map>
+using namespace std;
 
 // ROOT headers
 #include "TObject.h"
@@ -32,14 +32,14 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TSiLiData.h"
 #include "TSiLiPhysics.h"
-using namespace std;
 
 // ForwardDeclaration
 class TSiLiPhysics;
 
-class TSiLiSpectra {
+class TSiLiSpectra:public VSpectra {
   public:
     // constructor and destructor
     TSiLiSpectra();
@@ -62,21 +62,9 @@ class TSiLiSpectra {
     void FillRawSpectra(TSiLiData*);
     void FillPreTreatedSpectra(TSiLiData*);
     void FillPhysicsSpectra(TSiLiPhysics*);
-    // Check the Spectra
-    void CheckSpectra();
-
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family,string& name);    
-    void WriteHisto(string filename="VOID");      
 
   private: // Information on CHARISSA
     unsigned int fNumberDetector;
-
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/SiRes/TSiResSpectra.cxx b/NPLib/SiRes/TSiResSpectra.cxx
index b5797d6c0..73041afd5 100644
--- a/NPLib/SiRes/TSiResSpectra.cxx
+++ b/NPLib/SiRes/TSiResSpectra.cxx
@@ -268,97 +268,3 @@ void TSiResSpectra::FillPhysicsSpectra(TSiResPhysics* Physics)
 
 }
 
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TSiResSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TSiResSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TSiResSpectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-  
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-  cout << "ERROR : the folowing Histo has been requested by TSiResSpectra and does not exist: family:" << family << " name: "  << name << endl ;
-  exit(1);
-  }
-
-  return histo;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-void TSiResSpectra::WriteHisto(string filename)
-{
-   TFile *f = NULL; 
-
-   if (filename != "VOID") {
-      f = new TFile(filename.c_str(), "RECREATE");
-   }
-
-   map< vector<string>, TH1* >::iterator it;
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
-      it->second->Write();
-   }
-
-   if (filename != "VOID") {
-      f->Close();
-      delete f;
-   }
-}
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-void TSiResSpectra::CheckSpectra()
-{
-   map< vector<string>, TH1* >::iterator it;
-   Color_t ok_color      = kTeal+9;
-   Color_t warning_color = kOrange+8;  warning_color *= 1;
-   Color_t bad_color     = kRed;       bad_color     *= 1;
-
-   for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it)
-   {
-      it->second->SetLineColor(ok_color);
-      it->second->SetFillStyle(1001);
-      it->second->SetFillColor(ok_color);
-   }
-}
diff --git a/NPLib/SiRes/TSiResSpectra.h b/NPLib/SiRes/TSiResSpectra.h
index e18cdda21..25cc06948 100644
--- a/NPLib/SiRes/TSiResSpectra.h
+++ b/NPLib/SiRes/TSiResSpectra.h
@@ -14,17 +14,17 @@
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class holds all the online spectra needed for SiRes              *
+ *  This class holds all the online spectra needed for SiRes                 *
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
- *    + first version (not complete yet)                                     *
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
 
 // C++ STL headers
 #include <map>
+using namespace std;
 
 // ROOT headers
 #include "TObject.h"
@@ -32,14 +32,14 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TSiResData.h"
 #include "TSiResPhysics.h"
-using namespace std;
 
 // ForwardDeclaration
 class TSiResPhysics;
 
-class TSiResSpectra {
+class TSiResSpectra: public VSpectra {
   public:
     // constructor and destructor
     TSiResSpectra();
@@ -62,21 +62,9 @@ class TSiResSpectra {
     void FillRawSpectra(TSiResData*);
     void FillPreTreatedSpectra(TSiResData*);
     void FillPhysicsSpectra(TSiResPhysics*);
-    // Check the Spectra
-    void CheckSpectra();
-
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family,string& name);    
-    void WriteHisto(string filename="VOID");      
 
-  private: // Information on CHARISSA
+  private: 
     unsigned int fNumberDetector;
-
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/Tiara/TTiaraBarrelSpectra.cxx b/NPLib/Tiara/TTiaraBarrelSpectra.cxx
index 330857283..d31d8be35 100644
--- a/NPLib/Tiara/TTiaraBarrelSpectra.cxx
+++ b/NPLib/Tiara/TTiaraBarrelSpectra.cxx
@@ -308,87 +308,3 @@ void TTiaraBarrelSpectra::FillPhysicsSpectra(TTiaraBarrelPhysics* Physics){
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////
-TH1* TTiaraBarrelSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TTiaraBarrelSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index ;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index]=hist;
-
-  return hist;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TTiaraBarrelSpectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.reserve(2);
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-    cout << "ERROR : the folowing Histo has been requested by TTiaraBarrelSpectra and does not exist: family:" << family << " name: "  << name << endl ;
-    exit(1);
-  }
-
-  return histo;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void TTiaraBarrelSpectra::WriteHisto(string filename){
-  TFile* f=NULL; 
-
-  if(filename!="VOID"){
-    f = new TFile(filename.c_str(),"RECREATE");
-  }
-
-  map< vector<string>, TH1* >::iterator it;
-
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){
-    it->second->Write();
-  }
-
-  if(filename!="VOID"){
-    f->Close();
-    delete f;
-  }
-
-}
-///////////////////////////////////////////////////////////////////////////////
-void TTiaraBarrelSpectra::CheckSpectra(){
-  map< vector<string>, TH1* >::iterator it;
-  Color_t ok_color = kTeal+9;
-  Color_t warning_color = kOrange+8;   warning_color *= 1;
-  Color_t bad_color = kRed;            bad_color *= 1;
-
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){
-    it->second->SetLineColor(ok_color);
-    it->second->SetFillStyle(1001);
-    it->second->SetFillColor(ok_color);
-  }
-
-}
diff --git a/NPLib/Tiara/TTiaraBarrelSpectra.h b/NPLib/Tiara/TTiaraBarrelSpectra.h
index 3892b99eb..a170a3449 100644
--- a/NPLib/Tiara/TTiaraBarrelSpectra.h
+++ b/NPLib/Tiara/TTiaraBarrelSpectra.h
@@ -25,6 +25,7 @@
 
 // C++ STL headers
 #include <map>
+using namespace std;
 
 // ROOT headers
 #include "TObject.h"
@@ -32,14 +33,14 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TTiaraBarrelData.h"
 #include "TTiaraBarrelPhysics.h"
-using namespace std;
 
 // ForwardDeclaration
 class TTiaraBarrelPhysics ;
 
-class TTiaraBarrelSpectra {
+class TTiaraBarrelSpectra: public VSpectra {
   public:
     // constructor and destructor
     TTiaraBarrelSpectra();
@@ -62,23 +63,11 @@ class TTiaraBarrelSpectra {
     void FillRawSpectra(TTiaraBarrelData*);
     void FillPreTreatedSpectra(TTiaraBarrelData*);
     void FillPhysicsSpectra(TTiaraBarrelPhysics*);
-    // Check the Spectra
-    void CheckSpectra();
-
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family,string& name);    
-    void WriteHisto(string filename="VOID");      
 
   private: // Information on TIARA/BARREL
     unsigned int fNumberOfDetector;
     unsigned int fInnerBarrelStrip;
     unsigned int fOuterBarrelStrip;
-
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/Tiara/TTiaraHyballSpectra.cxx b/NPLib/Tiara/TTiaraHyballSpectra.cxx
index 6ec5a7853..88bee0446 100644
--- a/NPLib/Tiara/TTiaraHyballSpectra.cxx
+++ b/NPLib/Tiara/TTiaraHyballSpectra.cxx
@@ -294,76 +294,3 @@ void TTiaraHyballSpectra::FillPhysicsSpectra(TTiaraHyballPhysics* Physics){
 
 }
 
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TTiaraHyballSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
-  // create histo
-  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
-
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index] = hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TTiaraHyballSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
-  // create histo
-  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
-
-  vector<string> index;
-  index.push_back(family);
-  index.push_back(name);
-
-  // fill map
-  fMapHisto[index] = hist;
-
-  return hist;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-TH1* TTiaraHyballSpectra::GetHisto(string& family, string& name){
-  vector<string> index;
-  index.reserve(2);
-  index.push_back(family);
-  index.push_back(name);
-  TH1* histo ; 
-  
-  try{
-    histo = fMapHisto.at(index); 
-  }
-
-  catch(const std::out_of_range& oor){
-  cout << "ERROR : the folowing Histo has been requested by THyballSpectra and does not exist: family:" << family << " name: "  << name << endl ;
-  exit(1);
-  }
-
-  return histo;
-}
-////////////////////////////////////////////////////////////////////////////////
-void TTiaraHyballSpectra::WriteHisto(string filename){
-  TFile* f = NULL; 
-
-  if (filename != "VOID") {
-    f = new TFile(filename.c_str(),"RECREATE");
-  }
-
-  map< vector<string>, TH1* >::iterator it;
-  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
-    it->second->Write();
-  }
-
-  if (filename != "VOID") {
-    f->Close();
-    delete f;
-  }
-}
diff --git a/NPLib/Tiara/TTiaraHyballSpectra.h b/NPLib/Tiara/TTiaraHyballSpectra.h
index 380a8f3a7..734ef0ebc 100644
--- a/NPLib/Tiara/TTiaraHyballSpectra.h
+++ b/NPLib/Tiara/TTiaraHyballSpectra.h
@@ -18,7 +18,6 @@
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
- *    + first version (not complete yet)                                     *
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
@@ -29,6 +28,7 @@
 #include <TH2.h>
 
 // NPLib headers
+#include "../include/VSpectra.h"
 #include "TTiaraHyballData.h"
 #include "TTiaraHyballPhysics.h"
 
@@ -41,7 +41,7 @@ using namespace std;
 class TTiaraHyballPhysics;
 
 
-class TTiaraHyballSpectra {
+class TTiaraHyballSpectra:public VSpectra {
   public:
     // constructor and destructor
     TTiaraHyballSpectra();
@@ -64,20 +64,10 @@ class TTiaraHyballSpectra {
     void FillPreTreatedSpectra(TTiaraHyballData*);
     void FillPhysicsSpectra(TTiaraHyballPhysics*);
 
-  public:
-    // get map histo which will be used for GSpectra in GUser
-    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
-    TH1* GetHisto(string& family, string& name);    
-    void WriteHisto(string filename = "VOID");      
-
   private: // Information on MUST2
     unsigned int fRingsNumber;
     unsigned int fSectorsNumber;
     unsigned int fWedgesNumber;
-
-  private:
-    // map holding histo pointers and their family names
-    map< vector<string>, TH1* > fMapHisto;
 };
 
 #endif
diff --git a/NPLib/VDetector/Makefile b/NPLib/VDetector/Makefile
index 1384fe386..0bd21743d 100644
--- a/NPLib/VDetector/Makefile
+++ b/NPLib/VDetector/Makefile
@@ -8,11 +8,12 @@ all:            $(SHARELIB)
 ############### Detector ##############
 
 ## VDetector ##
-libVDetector.so: VDetector.o DetectorManager.o
+libVDetector.so: VDetector.o DetectorManager.o VSpectra.o
 		$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@	
 			
 # dependances
-VDetector.o:		VDetector.cxx	VDetector.h
+VDetector.o: VDetector.cxx	VDetector.h
+VSpectra.o: VSpectra.cxx VSpectra.h
 DetectorManager.o: DetectorManager.cxx DetectorManager.h	../DetectorList.inc
 #######################################
 
diff --git a/NPLib/VDetector/VSpectra.cxx b/NPLib/VDetector/VSpectra.cxx
new file mode 100644
index 000000000..eefbe271d
--- /dev/null
+++ b/NPLib/VDetector/VSpectra.cxx
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * Copyright (C) 2009-2014   this file is part of the NPTool Project         *
+ *                                                                           *
+ * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
+ * For the list of contributors see $NPTOOL/Licence/Contributors             *
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Original Author: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+ *                                                                           *
+ * Creation Date  : dec 2013                                                 *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  This class holds all the online spectra needed for Tiara/Hyball          *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *    + first version (not complete yet)                                     *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+
+//STL
+#include <iostream>
+#include <cstdlib>
+// NPL
+#include "VSpectra.h"
+#include "NPOptionManager.h"
+
+
+// ROOT
+#include "TDirectory.h"
+#include "TFile.h"
+
+////////////////////////////////////////////////////////////////////////////////
+TH1* VSpectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
+  // create histo
+  TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
+
+  vector<string> index;
+  index.push_back(family);
+  index.push_back(name);
+
+  // fill map
+  fMapHisto[index] = hist;
+
+  return hist;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+TH1* VSpectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
+  // create histo
+  TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
+
+  vector<string> index;
+  index.push_back(family);
+  index.push_back(name);
+
+  // fill map
+  fMapHisto[index] = hist;
+
+  return hist;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+TH1* VSpectra::GetHisto(string& family, string& name){
+  vector<string> index;
+  index.reserve(2);
+  index.push_back(family);
+  index.push_back(name);
+  TH1* histo ; 
+
+  map< vector<string> , TH1*>::iterator it;
+  it = fMapHisto.find(index);
+
+  if(it == fMapHisto.end()){
+    cout << "ERROR : the folowing Histo has been requested and does not exist: family:" << family << " name: "  << name << endl ;
+    exit(1);
+  }
+
+  else
+    histo = it->second; 
+
+  return histo;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void VSpectra::WriteHisto(string filename){
+  TFile* f = NULL; 
+
+  if (filename != "VOID") {
+    f = new TFile(filename.c_str(),"RECREATE");
+  }
+
+  map< vector<string>, TH1* >::iterator it;
+  for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
+    it->second->Write();
+  }
+
+  if (filename != "VOID") {
+    f->Close();
+    delete f;
+  }
+}
diff --git a/NPLib/VDetector/VSpectra.h b/NPLib/VDetector/VSpectra.h
new file mode 100644
index 000000000..a541ca8f6
--- /dev/null
+++ b/NPLib/VDetector/VSpectra.h
@@ -0,0 +1,69 @@
+#ifndef VSPECTRA_H
+#define VSPECTRA_H
+/*****************************************************************************
+ * Copyright (C) 2009-2014    this file is part of the NPTool Project        *
+ *                                                                           *
+ * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
+ * For the list of contributors see $NPTOOL/Licence/Contributors             *
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Original Author: A. Matta         contact address: a.matta@surrey.ac.uk   *
+ *                                                                           *
+ * Creation Date  : may 2014                                                 *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  Virtual class for the TDetectorSpectra classes                           *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+
+// ROOT headers
+#include "TObject.h"
+#include <TH1.h>
+#include <TH2.h>
+
+// C++ STL headers
+#include <map>
+#include <string>
+using namespace std;
+
+class VSpectra {
+  public:
+    // constructor and destructor
+    VSpectra();
+    ~VSpectra();
+
+  private:
+    // Instantiate and register histo to maps
+    TH1* AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family);
+    TH1* AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, 
+        Int_t nbinsy, Double_t ylow, Double_t yup, string family);
+
+    // Initialization methods
+    virtual void InitRawSpectra(){};
+    virtual void InitPreTreatedSpectra(){};
+    virtual void InitPhysicsSpectra(){};
+
+  public:
+    // Filling methods
+    virtual void FillRawSpectra(void*){};
+    virtual void FillPreTreatedSpectra(void*){};
+    virtual void FillPhysicsSpectra(void*){};
+    virtual void CheckSpectra(){};
+
+  public:
+    // get map histo which will be used for GSpectra in GUser
+    map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
+    TH1* GetHisto(string& family, string& name);    
+    void WriteHisto(string filename = "VOID");      
+      private:
+    // map holding histo pointers and their family names
+    map< vector<string>, TH1* > fMapHisto;
+};
+
+#endif
-- 
GitLab