diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7c3d69c3422c8c41a5eac3e51e165e3f0219f19f..a2b623f7cc473eb26264e066ba0e0187206d379b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,5 @@
-add_library(NPZdd SHARED ZddDetector.cxx ZddData.cxx ZddPhysics.cxx)
-target_link_libraries(NPZdd PUBLIC PUBLIC ROOT::RIO ROOT::Tree ROOT::Physics ROOT::Imt NPRoot nptool )
+add_library(NPZdd SHARED ZddDetector.cxx ZddData.cxx ZddPhysics.cxx ZddSpectra.cxx)
+target_link_libraries(NPZdd PUBLIC PUBLIC ROOT::RIO ROOT::Tree ROOT::Physics ROOT::Gpad ROOT::Imt ROOT::Hist NPRoot nptool )
 
 if(MFM_FOUND)
   target_compile_definitions(NPZdd PUBLIC MFM_FOUND)
@@ -7,4 +7,4 @@ if(MFM_FOUND)
 endif()
 
 install(DIRECTORY ./ DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY} FILES_MATCHING PATTERN "*.h" )
-ROOT_GENERATE_DICTIONARY(ZddDict ZddData.h ZddPhysics.h LINKDEF Zddlinkdef.hh MODULE NPZdd)
+ROOT_GENERATE_DICTIONARY(ZddDict ZddData.h ZddPhysics.h ZddSpectra.h LINKDEF Zddlinkdef.hh MODULE NPZdd)
diff --git a/src/ZddDetector.cxx b/src/ZddDetector.cxx
index 00dbbad4eb332ca2dbe18cd61550063a61f71e7f..f1b5e257cb6fb4d786c628fb6e7e0686ba00bad7 100644
--- a/src/ZddDetector.cxx
+++ b/src/ZddDetector.cxx
@@ -2,6 +2,8 @@
 #include "NPFunction.h"
 #include "NPRootPlugin.h"
 #include <iostream>
+#include "ZddSpectra.h"
+
 using namespace zdd;
 using namespace std;
 using namespace ROOT::Math;
@@ -116,19 +118,33 @@ void ZddDetector::BuildPhysicalEvent() {
   Match_IC1();
   if (m_PhysicsData->IC_Nbr.size() > 0)
     Match_PL();
+
+  Treat_Exo();
   // Treat_DC();
   SortIC.clear();
   SortPL.clear();
 }
 
+///////////////////////////////////////////////////////////////////////////
+void ZddDetector::Treat_Exo() {
+
+  unsigned int size = m_CalData->GetZDD_EXOMult();
+  for(unsigned int i = 0 ; i < size ; i++){
+    std::cout << "test treat" << std::endl;
+    m_PhysicsData->Exo_Nbr.push_back(m_CalData->GetZDD_EXON(i));
+    m_PhysicsData->Exo_E.push_back(m_CalData->GetZDD_EXOE(i));
+    m_PhysicsData->Exo_TS.push_back(m_CalData->GetZDD_EXOTS(i));
+  }
+}
+
 ///////////////////////////////////////////////////////////////////////////
 void ZddDetector::Treat_DC() {
   /* // Dont have anything to modify for the moment
-   unsigned int mysizeDC = m_CalData->GetMultDrift();
-   for(int i = 0; i < mysizeDC; i++){
+     unsigned int mysizeDC = m_CalData->GetMultDrift();
+     for(int i = 0; i < mysizeDC; i++){
      DC_DetectorNumber.push_back(m_CalData->GetDrift_DetectorNbr(i));
      DC_DriftTime.push_back(m_CalData->Get_DriftTime(i));
-   }*/
+     }*/
 }
 ///////////////////////////////////////////////////////////////////////////
 void ZddDetector::Match_IC() {
@@ -144,13 +160,12 @@ void ZddDetector::Match_IC() {
         break;
       }
       SortIC[m_CalData->GetZDD_ICN(i)]
-          = std::make_pair(m_CalData->GetZDD_ICE(i), m_CalData->GetZDD_ICTS(i));
+        = std::make_pair(m_CalData->GetZDD_ICE(i), m_CalData->GetZDD_ICTS(i));
     }
     // Adding the IC info to the std::vectors
     m_PhysicsData->ICSum = 0;
     for (auto it = SortIC.begin(); it != SortIC.end(); ++it) {
       m_PhysicsData->ICSum += (it->second).first;
-      // std::cout << "Test " << it->first << " " << it->second.first << std::endl;
       m_PhysicsData->IC_Nbr.push_back(it->first);
       m_PhysicsData->IC_E.push_back((it->second).first);
       m_PhysicsData->IC_TS.push_back((it->second).second);
@@ -166,7 +181,7 @@ void ZddDetector::Match_IC1() {
   for (unsigned int i = 0; i < m_CalData->GetZDD_ICMult(); i++) {
     if (SortIC.find(m_CalData->GetZDD_ICN(i)) == SortIC.end()) {
       SortIC[m_CalData->GetZDD_ICN(i)]
-          = std::make_pair(m_CalData->GetZDD_ICE(i), m_CalData->GetZDD_ICTS(i));
+        = std::make_pair(m_CalData->GetZDD_ICE(i), m_CalData->GetZDD_ICTS(i));
     }
   }
   // Adding the IC info to the std::vectors
@@ -182,13 +197,14 @@ void ZddDetector::Match_IC1() {
 
 void ZddDetector::Match_PL() {
   for (unsigned int i = 0; i < m_CalData->GetZDD_PLMult(); i++) {
-    SortPL[m_CalData->GetZDD_PLN(i)]
-        = std::make_pair(m_CalData->GetZDD_PLE(i), m_CalData->GetZDD_PLTS(i));
+    SortPL[m_CalData->GetZDD_PLN(i)%5].push_back(std::make_pair(m_CalData->GetZDD_PLE(i), m_CalData->GetZDD_PLTS(i)));
   }
   for (auto it = SortPL.begin(); it != SortPL.end(); ++it) {
+    if(it->second.size()==2){
     m_PhysicsData->PL_Nbr.push_back(it->first);
-    m_PhysicsData->PL_E.push_back((it->second).first);
-    m_PhysicsData->PL_TS.push_back((it->second).second);
+    m_PhysicsData->PL_E.push_back(sqrt((it->second)[0].first*(it->second)[1].first));
+    m_PhysicsData->PL_TS.push_back(((it->second)[0].second +(it->second)[1].second)/2);
+    }
   }
 }
 
@@ -205,67 +221,68 @@ void ZddDetector::PreTreat() {
       //           << " " << Map_IC[m_RawData->GetZDD_ICN(i)] << std::endl;
       // std::cout << m_IC_E_RAW_Threshold << std::endl;
       m_CalData->SetZDDIC(Map_IC[m_RawData->GetZDD_ICN(i)],
-                          m_RawData->GetZDD_ICE(i), m_RawData->GetZDD_ICTS(i));
+          m_RawData->GetZDD_ICE(i), m_RawData->GetZDD_ICTS(i));
     }
   }
 
   for (unsigned int i = 0; i < m_PL_Mult; ++i) {
     if (m_RawData->GetZDD_PLE(i) > m_PL_E_RAW_Threshold) {
       m_CalData->SetZDDPL(m_RawData->GetZDD_PLN(i), m_RawData->GetZDD_PLE(i),
-                          m_RawData->GetZDD_PLTS(i));
+          m_RawData->GetZDD_PLTS(i));
     }
   }
 
   for (unsigned int i = 0; i < m_DC_Mult; ++i) {
     if (m_RawData->GetZDD_DCE(i) > m_DC_E_RAW_Threshold) {
       m_CalData->SetZDDDC(m_RawData->GetZDD_DCN(i), m_RawData->GetZDD_DCE(i),
-                          m_RawData->GetZDD_DCTS(i));
+          m_RawData->GetZDD_DCTS(i));
     }
   }
 
   for (unsigned int i = 0; i < m_EXO_Mult; ++i) {
-    if (m_RawData->GetZDD_EXOE(i) > m_EXO_E_RAW_Threshold) {
-      m_CalData->SetZDDEXO(m_RawData->GetZDD_EXON(i), m_RawData->GetZDD_EXOE(i),
-                           m_RawData->GetZDD_EXOTS(i));
-    }
+    // if (m_RawData->GetZDD_EXOE(i) > m_EXO_E_RAW_Threshold) {
+    // std::cout << fZDDEXO_E(i) << std::endl;
+    m_CalData->SetZDDEXO(m_RawData->GetZDD_EXON(i), fZDDEXO_E(i),
+        m_RawData->GetZDD_EXOTS(i));
+    // }
   }
 }
 
 ///////////////////////////////////////////////////////////////////////////
 void ZddDetector::PreTreatEnergy(std::string Detector) {
   /*unsigned int mysize = m_RawData->GetMultEnergy(Detector);
-  for (UShort_t i = 0; i < mysize ; ++i) {
+    for (UShort_t i = 0; i < mysize ; ++i) {
     if (m_RawData->Get_Energy(Detector, i) > m_E_RAW_Threshold) {
-      Double_t Energy =
-  Cal->ApplyCalibration("ZDD/ENERGY"+nptool::itoa(m_RawData->GetE_DetectorNbr(Detector,
-  i)),m_RawData->Get_Energy(Detector, i)); if (Energy > m_E_Threshold) {
-        if(Detector == "IC")
-          m_CalData->Set_IC_Energy(m_RawData->GetE_DetectorNbr(Detector, i),
-  Energy);
-
-        else if(Detector == "Plastic")
-          m_CalData->Set_Plastic_Energy(m_RawData->GetE_DetectorNbr(Detector,
-  i), Energy);
-      }
+    Double_t Energy =
+    Cal->ApplyCalibration("ZDD/ENERGY"+nptool::itoa(m_RawData->GetE_DetectorNbr(Detector,
+    i)),m_RawData->Get_Energy(Detector, i)); if (Energy > m_E_Threshold) {
+    if(Detector == "IC")
+    m_CalData->Set_IC_Energy(m_RawData->GetE_DetectorNbr(Detector, i),
+    Energy);
+
+    else if(Detector == "Plastic")
+    m_CalData->Set_Plastic_Energy(m_RawData->GetE_DetectorNbr(Detector,
+    i), Energy);
     }
-  }
-*/
+    }
+    }
+    */
 }
 
 ///////////////////////////////////////////////////////////////////////////
 void ZddDetector::PreTreatTime(std::string Detector) {
   /*  unsigned int mysize = m_RawData->GetMultTime(Detector);
-    for (UShort_t i = 0; i < mysize; ++i) {
+      for (UShort_t i = 0; i < mysize; ++i) {
       Double_t Time=
-    Cal->ApplyCalibration("ZDD/TIME"+nptool::itoa(m_RawData->GetT_DetectorNbr(Detector,
-    i)),m_RawData->Get_Time(Detector,i)); if(Detector == "IC")
-        m_CalData->Set_IC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
+      Cal->ApplyCalibration("ZDD/TIME"+nptool::itoa(m_RawData->GetT_DetectorNbr(Detector,
+      i)),m_RawData->Get_Time(Detector,i)); if(Detector == "IC")
+      m_CalData->Set_IC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
       else if(Detector == "Plastic")
-        m_CalData->Set_Plastic_Time(m_RawData->GetT_DetectorNbr(Detector, i),
-    Time); else if(Detector == "DC")
-        m_CalData->Set_DC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
-    }
-  */
+      m_CalData->Set_Plastic_Time(m_RawData->GetT_DetectorNbr(Detector, i),
+      Time); else if(Detector == "DC")
+      m_CalData->Set_DC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
+      }
+      */
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -281,7 +298,7 @@ void ZddDetector::ReadAnalysisConfig() {
 
   if (!AnalysisConfigFile.is_open()) {
     cout << " No ConfigZDD.dat found: Default parameter loaded for Analayis "
-         << FileName << endl;
+      << FileName << endl;
     return;
   }
   cout << " Loading user parameter for Analysis from ConfigZDD.dat " << endl;
@@ -332,21 +349,28 @@ void ZddDetector::ReadAnalysisConfig() {
       } else if (whatToDo == "MAP_IC") {
         AnalysisConfigFile >> DataBuffer;
         Map_IC[atoi(DataBuffer.substr(0, 1).c_str())]
-            = atoi(DataBuffer.substr(1, 1).c_str());
+          = atoi(DataBuffer.substr(1, 1).c_str());
         cout << whatToDo << " " << atoi(DataBuffer.substr(0, 1).c_str()) << " "
-             << atoi(DataBuffer.substr(1, 1).c_str()) << endl;
+          << atoi(DataBuffer.substr(1, 1).c_str()) << endl;
       } else if (whatToDo == "E_THRESHOLD") {
         AnalysisConfigFile >> DataBuffer;
         m_E_Threshold = atof(DataBuffer.c_str());
         cout << whatToDo << " " << m_E_Threshold << endl;
       }
-
       else {
         ReadingStatus = false;
       }
     }
   }
 }
+////////////////////////////////////////////////////////////////////////////////
+//	tranform an integer to a string
+double ZddDetector::fZDDEXO_E(const unsigned int& i) {
+  static string name;
+  name = "ZDDEXO_E";
+  name += nptool::itoa(m_RawData->GetZDD_EXON(i));
+  return m_Cal.ApplyCalibration(name, m_RawData->GetZDD_EXOE(i), 1);
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 void ZddDetector::InitializeDataInputRaw(
@@ -368,9 +392,27 @@ void ZddDetector::InitializeDataOutputPhysics(
     std::shared_ptr<nptool::VDataOutput> output) {
   output->Attach("zdd", "zdd::ZddPhysics", &m_PhysicsData);
 }
+
 ////////////////////////////////////////////////////////////////////////////////
-extern "C" {
-shared_ptr<nptool::VDetector> ConstructDetector() {
-  return make_shared<zdd::ZddDetector>();
+void ZddDetector::InitSpectra() {
+  m_Spectra = std::make_shared<zdd::ZddSpectra>();
+};
+////////////////////////////////////////////////////////////////////////////////
+void ZddDetector::FillSpectra() {
+  m_Spectra->FillRaw();
+  m_Spectra->FillPhy();
 };
+////////////////////////////////////////////////////////////////////////////////
+void ZddDetector::WriteSpectra() {};
+////////////////////////////////////////////////////////////////////////////////
+void ZddDetector::CheckSpectra() {};
+////////////////////////////////////////////////////////////////////////////////
+void ZddDetector::ClearSpectra() { m_Spectra->Clear(); };
+
+
+////////////////////////////////////////////////////////////////////////////////
+extern "C" {
+  shared_ptr<nptool::VDetector> ConstructDetector() {
+    return make_shared<zdd::ZddDetector>();
+  };
 }
diff --git a/src/ZddDetector.h b/src/ZddDetector.h
index adc3ed291afb4968d4797bb88f938f25924870e8..555174e9233112d929d87efefef3e9e1b73a8cb8 100644
--- a/src/ZddDetector.h
+++ b/src/ZddDetector.h
@@ -25,6 +25,7 @@
 
 namespace zdd {
 
+class ZddSpectra;
 class ZddDetector : public nptool::VDetector {
 public: // Constructor and Destructor
   ZddDetector();
@@ -35,6 +36,8 @@ public: // Data member
   zdd::ZddData*              m_CalData;
   zdd::ZddPhysics*           m_PhysicsData;
   nptool::CalibrationManager m_Cal;
+  std::shared_ptr<zdd::ZddSpectra> m_Spectra;
+
 
 public: // inherrited from nptool::VPlugin
   std::vector<std::string> GetDependencies() { return {"root"}; };
@@ -68,10 +71,10 @@ public: // inherrited from nptool::VDetector
   //  This method is called at each event of a conversion to fill in the data
   //  class
   void BuildRawEvent(const std::string& daq_name, const std::string& label,
-                     void* commonframe);
+      void* commonframe);
 
   void SetNumexoMap(std::string Type, unsigned int Board,
-                    unsigned int NUMEXOChannel);
+      unsigned int NUMEXOChannel);
 
   std::string GetTypeFromNumexoMap(unsigned int Board, unsigned int Channel);
   void TreatFrame(void* commonframe);
@@ -94,6 +97,7 @@ public: // inherrited from nptool::VDetector
   void ClearEventData() { m_RawData->Clear(); };
 
   void Treat_DC();
+  void Treat_Exo();
   // Matching IC
   void Match_IC();
   void Match_IC1();
@@ -139,28 +143,30 @@ private:
   unsigned int                         m_EXO_Mult; //!
   std::map<unsigned int, unsigned int> Map_IC; //!
   std::map<unsigned int, std::pair<unsigned int, unsigned long long>>
-      SortIC; //!
-  std::map<unsigned int, std::pair<unsigned int, unsigned long long>>
-      SortPL; //!
+    SortIC; //!
+  std::map<unsigned int,std::vector<std::pair<unsigned int, unsigned long long>>>
+    SortPL; //!
   int m_NumberOfDetectors; //!
 
   // Method related to the TSpectra classes, aimed at providing a framework for
   // online applications Instantiate the Spectra class and the histogramm
   // throught it
-  void InitSpectra() {};
+  void InitSpectra();
   // Fill the spectra hold by the spectra class
-  void FillSpectra() {};
+  void FillSpectra();
   // Write the spectra to a file
-  void WriteSpectra() {};
+  void WriteSpectra();
   // Used for Online mainly, perform check on the histo and for example change
   // their color if issues are found
-  void CheckSpectra() {};
+  void CheckSpectra();
   // Used for Online only, clear all the spectra hold by the Spectra class
-  void ClearSpectra() {};
+  void ClearSpectra();
   // Used for interoperability with other framework
   void SetRawDataPointer(void*) {};
 
-private:
+  // ApplyCalibration
+  double fZDDEXO_E(const unsigned int& i);
+
 private: //   Parameter used in the analysis
 };
 
diff --git a/src/ZddPhysics.cxx b/src/ZddPhysics.cxx
index 360cc7b67e1c9617ab85fa6d5c18b82cefb886a8..3180084ed5bab34bd9a1cc81f3e860c68b16a05a 100644
--- a/src/ZddPhysics.cxx
+++ b/src/ZddPhysics.cxx
@@ -11,6 +11,11 @@ void zdd::ZddPhysics::Clear() {
   ICSum = 0;
   // SortIC.clear();
   // SortPL.clear();
-  DC_DetectorNumber.clear();
+  DC_Nbr.clear();
   DC_DriftTime.clear();
+
+  Exo_Nbr.clear();
+  Exo_E.clear();
+  Exo_TS.clear();
+
 }
diff --git a/src/ZddPhysics.h b/src/ZddPhysics.h
index cd0bb9d625c762bc4e1c3a9bf34bf24fc022abc3..95c614ae20249b0ec39d6a2c7a4df32d3ad43211 100644
--- a/src/ZddPhysics.h
+++ b/src/ZddPhysics.h
@@ -25,9 +25,13 @@ public:
     std::vector<double>   PL_E;
     std::vector<unsigned long long>   PL_TS;
 
-    std::vector<int>      DC_DetectorNumber;
+    std::vector<int>      DC_Nbr;
     std::vector<double>   DC_DriftTime;
 
+    std::vector<int>      Exo_Nbr;
+    std::vector<double>   Exo_E;
+    std::vector<double>   Exo_TS;
+
 };
 } // namespace zdd
 #endif
diff --git a/src/ZddSpectra.cxx b/src/ZddSpectra.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..ff66d458db6338cfd9f8208c70cb97ff6e4abfc1
--- /dev/null
+++ b/src/ZddSpectra.cxx
@@ -0,0 +1,200 @@
+#include "ZddSpectra.h"
+#include "NPApplication.h"
+
+using namespace zdd;
+
+////////////////////////////////////////////////////////////////////////////////
+ZddSpectra::ZddSpectra() {
+  // Set Pointers:
+  m_detector = std::dynamic_pointer_cast<ZddDetector>(
+      nptool::Application::GetApplication()->GetDetector("zdd"));
+
+  m_RawData     = m_detector->m_RawData;
+  m_RawData->Clear();
+
+  m_PhysicsData = m_detector->m_PhysicsData;
+  m_PhysicsData->Clear();
+
+  // Declare Raw Spectra
+  for (auto map: m_detector->m_NumexoMap) {
+    std::string hist_name = "ZDD_" + map.second + "_Board_" + nptool::itoa(map.first/1000) + "_Channel_" + nptool::itoa(map.first%1000);
+    std::cout << "Hist name " << hist_name << std::endl;
+
+    m_raw_hist[map.second][map.first%1000] = new TH1F(hist_name.c_str(), hist_name.c_str(),
+        65536/4, 0, 65536);
+  }
+
+  // Build Raw Canvases
+  std::vector<TCanvas*> canvases;
+
+  auto cIC_raw = new TCanvas("ZDD raw IC");
+  cIC_raw->Divide(3,2);
+  auto cPL_raw = new TCanvas("ZDD raw PL");
+  cPL_raw->Divide(5,2);
+  auto cDC_raw = new TCanvas("ZDD raw DC");
+  cDC_raw->Divide(2,2);
+  auto cEXO_raw = new TCanvas("ZDD raw EXO");
+  cEXO_raw->Divide(2,2);
+  unsigned int c_IC = 1;
+  unsigned int c_DC = 1;
+  unsigned int c_PL = 1;
+  unsigned int c_EXO = 1;
+  // Loop through cristals
+  for (auto det: m_raw_hist) {
+    if(det.first.find("IC") != std::string::npos){
+      for (auto hist: det.second) {
+      cIC_raw->cd(c_IC);
+      c_IC++;
+      hist.second->Draw();
+      }
+    }
+    else if(det.first.find("DC") != std::string::npos){
+      for (auto hist: det.second) {
+      cDC_raw->cd(c_DC);
+      c_DC++;
+      hist.second->Draw();
+      }
+    }
+    else if(det.first.find("PL") != std::string::npos){
+      for (auto hist: det.second) {
+      cPL_raw->cd(c_PL);
+      c_PL++;
+      hist.second->Draw();
+      }
+    }
+    else if(det.first.find("EXO") != std::string::npos){
+      for (auto hist: det.second) {
+      cEXO_raw->cd(c_EXO);
+      c_EXO++;
+      hist.second->Draw();
+      }
+    }
+    else{
+      std::cout << "Initialized something that is not a ZDD : " << det.first << std::endl;
+    }
+  }
+
+
+  ////////////////////////////////////////////////////////////////////////////////
+  // phy histo
+
+  unsigned int ExoSize = 4;
+  for(unsigned int i = 0 ; i < ExoSize ; i++){
+    std::string hist_name = "ZDD_EXO_phy" +  nptool::itoa(i); 
+    m_phy_hist[hist_name] = new TH1F(hist_name.c_str(), hist_name.c_str(),
+        5000, 0, 10000);
+  }
+  
+  // for(auto hist: m_raw_hist["EXO"]){
+  //   std::string hist_name = "ZDD_EXO_phy_Channel_" + nptool::itoa(hist.first);
+  //   std::cout << "Hist name " << hist_name << std::endl;
+  //   m_phy_hist[hist_name] = new TH1F(hist_name.c_str(), hist_name.c_str(),
+  //       5000, 0, 10000);
+  // }
+    
+
+  std::string hist_name = "ZDD_EXO_All_phy";
+  m_phy_hist[hist_name] = new TH1F(hist_name.c_str(), hist_name.c_str(),
+        5000, 0, 10000);
+  
+  // std::string hist_name = "ZDD__phy";
+  // m_phy_hist[hist_name] = new TH1F(hist_name.c_str(), hist_name.c_str(),
+  //       5000, 0, 10000);
+  
+  unsigned int PlSize = 5;
+  for(unsigned int i = 0 ; i < PlSize ; i++){
+    std::string hist_name = "ZDD_PL_phy_" +  nptool::itoa(i); 
+    m_phy_hist[hist_name] = new TH1F(hist_name.c_str(), hist_name.c_str(),
+        5000, 0, 20000);
+  }
+  hist_name = "IC_phy_Sum";
+  m_phy_hist[hist_name] = new TH1F(hist_name.c_str(), hist_name.c_str(),
+        3000, 0, 30000);
+
+  c_EXO = 1;
+  auto cEXO_phy = new TCanvas("ZDD phy EXO");
+  cEXO_phy->Divide(2,2);
+  
+  c_PL = 1;
+  auto cPL_phy = new TCanvas("ZDD phy PL");
+  cPL_phy->Divide(3,2);
+
+  for (auto hist: m_phy_hist){
+    if(hist.first.find("ZDD_EXO_phy") != std::string::npos){
+      cEXO_phy->cd(c_EXO);
+      c_EXO++;
+      hist.second->Draw();
+  }
+    if(hist.first.find("ZDD_PL_phy_") != std::string::npos){
+      cPL_phy->cd(c_PL);
+      c_PL++;
+      hist.second->Draw();
+  }
+    if(hist.first.find("IC_phy_sum") != std::string::npos){
+      cPL_phy->cd(c_PL);
+      c_PL++;
+      hist.second->Draw();
+  }
+  }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ZddSpectra::FillPhy() {
+  auto size_EXO = m_PhysicsData->Exo_E.size();
+    // std::cout << "test size " << size_EXO << std::endl;
+  for(unsigned int i = 0 ; i < size_EXO ; i++){
+    if(m_PhysicsData->Exo_E[i]>0){
+    // std::cout << "test " << std::endl;
+    std::string hist_name = "ZDD_EXO_phy_" +  nptool::itoa(m_PhysicsData->Exo_Nbr[i]); 
+    m_phy_hist[hist_name]->Fill(m_PhysicsData->Exo_E[i]);
+    hist_name = "ZDD_EXO_All_phy";
+    m_phy_hist[hist_name]->Fill(m_PhysicsData->Exo_E[i]);
+    }
+  }
+  unsigned int size_PL = m_PhysicsData->PL_E.size();
+  for(unsigned int i = 0 ;i< size_PL ; i++){
+    if(m_PhysicsData->PL_E[i]>0){
+    std::string hist_name = "ZDD_PL_phy_" +  nptool::itoa(m_PhysicsData->PL_Nbr[i]); 
+    m_phy_hist[hist_name]->Fill(m_PhysicsData->PL_E[i]);
+    }
+  }
+  if(m_PhysicsData->ICSum>0){
+    std::string hist_name = "IC_phy_Sum"; 
+    m_phy_hist[hist_name]->Fill(m_PhysicsData->ICSum);
+  }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ZddSpectra::FillRaw() {
+  auto size_IC =  m_RawData->GetZDD_ICMult();
+  for (unsigned int i = 0; i < size_IC; i++) {
+    if(m_RawData->GetZDD_ICE(i)>0)
+      m_raw_hist["IC"][m_RawData->GetZDD_ICN(i)]->Fill(m_RawData->GetZDD_ICE(i));
+  }
+  auto size_PL =  m_RawData->GetZDD_PLMult();
+  for (unsigned int i = 0; i < size_PL; i++) {
+    if(m_RawData->GetZDD_PLE(i)>0)
+      m_raw_hist["PL"][m_RawData->GetZDD_PLN(i)]->Fill(m_RawData->GetZDD_PLE(i));
+  }
+  auto size_DC =  m_RawData->GetZDD_DCMult();
+  for (unsigned int i = 0; i < size_DC; i++) {
+    if(m_RawData->GetZDD_DCE(i)>0)
+      m_raw_hist["DC"][m_RawData->GetZDD_DCN(i)]->Fill(m_RawData->GetZDD_DCE(i));
+  }
+  auto size_EXO =  m_RawData->GetZDD_EXOMult();
+  for (unsigned int i = 0; i < size_EXO; i++) {
+    if(m_RawData->GetZDD_EXOE(i)>0)
+      m_raw_hist["EXO"][m_RawData->GetZDD_EXON(i)]->Fill(m_RawData->GetZDD_EXOE(i));
+  }
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ZddSpectra::Clear() {
+  for (auto det : m_raw_hist)
+    for (auto hist : det.second)
+      hist.second->Reset();
+  for (auto hist : m_phy_hist)
+    hist.second->Reset();
+}
+
diff --git a/src/ZddSpectra.h b/src/ZddSpectra.h
new file mode 100644
index 0000000000000000000000000000000000000000..cde97063ecc9e34c18679374b83674f84f85f66e
--- /dev/null
+++ b/src/ZddSpectra.h
@@ -0,0 +1,35 @@
+#ifndef ZddSpectra_h
+#define ZddSpectra_h
+#include "ZddDetector.h"
+// root
+#include "TCanvas.h"
+#include "TH1.h"
+#include "TH2.h"
+// std
+#include <map>
+#include <memory>
+namespace zdd {
+
+  // forward declaration is necessary
+  // class ZddDetector;
+  class ZddSpectra {
+   public:
+    ZddSpectra();
+    ~ZddSpectra(){};
+
+   private:
+    std::shared_ptr<zdd::ZddDetector> m_detector;
+    zdd::ZddData* m_RawData;
+    zdd::ZddPhysics* m_PhysicsData;
+    std::map<std::string,std::map<unsigned int, TH1*>> m_raw_hist;
+    // std::map<std::string,std::map<unsigned int, TH1*>> m_phy_hist;
+    std::map<std::string, TH1*> m_phy_hist;
+
+   public:
+    void FillRaw();
+    void FillPhy();
+    void Clear();
+  };
+
+} // namespace zdd
+#endif