From 403cad6eaca1766a1b843d0673bdeeff1132bf10 Mon Sep 17 00:00:00 2001
From: Morfouace <pierre.morfouace@gmail.com>
Date: Wed, 15 Jun 2022 10:15:03 +0200
Subject: [PATCH] Updating Vendeta Project

---
 Inputs/EventGenerator/neutron.source          |  2 +-
 .../FissionChamber/TFissionChamberData.cxx    | 26 +++-------
 .../FissionChamber/TFissionChamberData.h      | 45 +++++-----------
 .../FissionChamber/TFissionChamberPhysics.cxx | 29 ++++-------
 .../FissionChamber/TFissionChamberPhysics.h   |  2 +-
 .../FissionChamber/TFissionChamberSpectra.cxx | 29 ++++-------
 NPLib/Detectors/Vendeta/TVendetaData.cxx      | 25 +++------
 NPLib/Detectors/Vendeta/TVendetaData.h        | 48 ++++++-----------
 NPLib/Detectors/Vendeta/TVendetaPhysics.cxx   | 50 ++++++++++--------
 NPLib/Detectors/Vendeta/TVendetaPhysics.h     | 11 +++-
 NPLib/Detectors/Vendeta/TVendetaSpectra.cxx   | 40 ++++++---------
 .../FissionChamber/FissionChamber.cc          |  5 +-
 NPSimulation/Detectors/Vendeta/Vendeta.cc     |  7 ++-
 Projects/Vendeta/Analysis.cxx                 | 51 +++++++++++++++----
 Projects/Vendeta/Analysis.h                   | 15 ++++++
 Projects/Vendeta/PhysicsListOption.txt        | 15 ++++++
 Projects/Vendeta/Vendeta.detector             |  7 +++
 Projects/Vendeta/Vendeta_full.detector        | 18 +++++++
 18 files changed, 223 insertions(+), 202 deletions(-)
 create mode 100644 Projects/Vendeta/PhysicsListOption.txt
 create mode 100644 Projects/Vendeta/Vendeta_full.detector

diff --git a/Inputs/EventGenerator/neutron.source b/Inputs/EventGenerator/neutron.source
index 8b5c55629..4ed71397d 100644
--- a/Inputs/EventGenerator/neutron.source
+++ b/Inputs/EventGenerator/neutron.source
@@ -13,7 +13,7 @@ Isotropic
  %EnergyDistribution= 0.619676*TMath::SinH(sqrt(1.07777*x))*exp(-0.847212*x)
  %EnergyDistribution= 1.5*TMath::SinH(sqrt(1.3*x))*exp(-0.89*x)
  HalfOpenAngleMin= 0
- HalfOpenAngleMax= 0
+ HalfOpenAngleMax= 180
  x0= 0 
  y0= 0 
  z0= 0 mm 
diff --git a/NPLib/Detectors/FissionChamber/TFissionChamberData.cxx b/NPLib/Detectors/FissionChamber/TFissionChamberData.cxx
index 13453c44c..8ce206a75 100644
--- a/NPLib/Detectors/FissionChamber/TFissionChamberData.cxx
+++ b/NPLib/Detectors/FissionChamber/TFissionChamberData.cxx
@@ -44,12 +44,9 @@ TFissionChamberData::~TFissionChamberData() {
 
 //////////////////////////////////////////////////////////////////////
 void TFissionChamberData::Clear() {
-  // Energy
-  fFissionChamber_E_DetectorNbr.clear();
-  fFissionChamber_Energy.clear();
-  // Time
-  fFissionChamber_T_DetectorNbr.clear();
-  fFissionChamber_Time.clear();
+  fFC_AnodeNbr.clear();
+  fFC_Energy.clear();
+  fFC_Time.clear();
 }
 
 
@@ -59,21 +56,12 @@ void TFissionChamberData::Dump() const {
   // This method is very useful for debuging and worth the dev.
   cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TFissionChamberData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
 
-  // Energy
-  size_t mysize = fFissionChamber_E_DetectorNbr.size();
+  size_t mysize = fFC_Energy.size();
   cout << "FissionChamber_E_Mult: " << mysize << endl;
  
   for (size_t i = 0 ; i < mysize ; i++){
-    cout << "DetNbr: " << fFissionChamber_E_DetectorNbr[i]
-         << " Energy: " << fFissionChamber_Energy[i];
-  }
-  
-  // Time
-  mysize = fFissionChamber_T_DetectorNbr.size();
-  cout << "FissionChamber_T_Mult: " << mysize << endl;
- 
-  for (size_t i = 0 ; i < mysize ; i++){
-    cout << "DetNbr: " << fFissionChamber_T_DetectorNbr[i]
-         << " Time: " << fFissionChamber_Time[i];
+    cout << "AnodeNbr: " << fFC_AnodeNbr[i]
+         << " Energy: " << fFC_Energy[i]
+         << " Time: " << fFC_Time[i];
   }
 }
diff --git a/NPLib/Detectors/FissionChamber/TFissionChamberData.h b/NPLib/Detectors/FissionChamber/TFissionChamberData.h
index 637a869ea..133fb2cf4 100644
--- a/NPLib/Detectors/FissionChamber/TFissionChamberData.h
+++ b/NPLib/Detectors/FissionChamber/TFissionChamberData.h
@@ -34,13 +34,9 @@ class TFissionChamberData : public TObject {
   // data members are hold into vectors in order 
   // to allow multiplicity treatment
   private: 
-    // Energy
-    vector<UShort_t>   fFissionChamber_E_DetectorNbr;
-    vector<Double_t>   fFissionChamber_Energy;
-
-    // Time
-    vector<UShort_t>   fFissionChamber_T_DetectorNbr;
-    vector<Double_t>   fFissionChamber_Time;
+    vector<UShort_t>   fFC_AnodeNbr;
+    vector<Double_t>   fFC_Energy;
+    vector<Double_t>   fFC_Time;
 
 
   //////////////////////////////////////////////////////////////
@@ -65,35 +61,20 @@ class TFissionChamberData : public TObject {
   // add //! to avoid ROOT creating dictionnary for the methods
   public:
     //////////////////////    SETTERS    ////////////////////////
-    // Energy
-    inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){
-      fFissionChamber_E_DetectorNbr.push_back(DetNbr);
-      fFissionChamber_Energy.push_back(Energy);
-    };//!
-
-    // Time
-    inline void SetTime(const UShort_t& DetNbr,const Double_t& Time)	{
-      fFissionChamber_T_DetectorNbr.push_back(DetNbr);     
-      fFissionChamber_Time.push_back(Time);
-    };//!
-
+    inline void SetAnodeNbr(const UShort_t& AnodeNbr){fFC_AnodeNbr.push_back(AnodeNbr);}//!
+    inline void SetEnergy(const Double_t& Energy){fFC_Energy.push_back(Energy);}//!
+    inline void SetTime(const Double_t& Time){fFC_Time.push_back(Time);}//!
 
     //////////////////////    GETTERS    ////////////////////////
     // Energy
     inline UShort_t GetMultEnergy() const
-      {return fFissionChamber_E_DetectorNbr.size();}
-    inline UShort_t GetE_DetectorNbr(const unsigned int &i) const 
-      {return fFissionChamber_E_DetectorNbr[i];}//!
-    inline Double_t Get_Energy(const unsigned int &i) const 
-      {return fFissionChamber_Energy[i];}//!
-
-    // Time
-    inline UShort_t GetMultTime() const
-      {return fFissionChamber_T_DetectorNbr.size();}
-    inline UShort_t GetT_DetectorNbr(const unsigned int &i) const 
-      {return fFissionChamber_T_DetectorNbr[i];}//!
-    inline Double_t Get_Time(const unsigned int &i) const 
-      {return fFissionChamber_Time[i];}//!
+      {return fFC_Energy.size();}
+    inline UShort_t GetAnodeNbr(const unsigned int &i) const 
+      {return fFC_AnodeNbr[i];}//!
+    inline Double_t GetEnergy(const unsigned int &i) const 
+      {return fFC_Energy[i];}//!
+    inline Double_t GetTime(const unsigned int &i) const 
+      {return fFC_Time[i];}//!
 
 
   //////////////////////////////////////////////////////////////
diff --git a/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.cxx b/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.cxx
index cf42247c4..bb52375c0 100644
--- a/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.cxx
+++ b/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.cxx
@@ -84,15 +84,10 @@ void TFissionChamberPhysics::BuildPhysicalEvent() {
 
   // match energy and time together
   unsigned int mysizeE = m_PreTreatedData->GetMultEnergy();
-  unsigned int mysizeT = m_PreTreatedData->GetMultTime();
   for (UShort_t e = 0; e < mysizeE ; e++) {
-    for (UShort_t t = 0; t < mysizeT ; t++) {
-      if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) {
-        DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e));
-        Energy.push_back(m_PreTreatedData->Get_Energy(e));
-        Time.push_back(m_PreTreatedData->Get_Time(t));
-      }
-    }
+    AnodeNumber.push_back(m_PreTreatedData->GetAnodeNbr(e));
+    Energy.push_back(m_PreTreatedData->GetEnergy(e));
+    Time.push_back(m_PreTreatedData->GetTime(e));
   }
 }
 
@@ -107,23 +102,17 @@ void TFissionChamberPhysics::PreTreat() {
   // instantiate CalibrationManager
   static CalibrationManager* Cal = CalibrationManager::getInstance();
 
-  // Energy
   unsigned int mysize = m_EventData->GetMultEnergy();
   for (UShort_t i = 0; i < mysize ; ++i) {
-    if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) {
-      Double_t Energy = Cal->ApplyCalibration("FissionChamber/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i));
+    if (m_EventData->GetEnergy(i) > m_E_RAW_Threshold) {
+      Double_t Energy = Cal->ApplyCalibration("FissionChamber/ENERGY"+NPL::itoa(m_EventData->GetAnodeNbr(i)),m_EventData->GetEnergy(i));
       if (Energy > m_E_Threshold) {
-        m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy);
+        m_PreTreatedData->SetAnodeNbr(m_EventData->GetAnodeNbr(i));
+        m_PreTreatedData->SetEnergy(Energy);
+        m_PreTreatedData->SetTime(m_EventData->GetTime(i));
       }
     }
   }
-
-  // Time 
-  mysize = m_EventData->GetMultTime();
-  for (UShort_t i = 0; i < mysize; ++i) {
-    Double_t Time= Cal->ApplyCalibration("FissionChamber/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i));
-    m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time);
-  }
 }
 
 
@@ -194,7 +183,7 @@ void TFissionChamberPhysics::ReadAnalysisConfig() {
 
 ///////////////////////////////////////////////////////////////////////////
 void TFissionChamberPhysics::Clear() {
-  DetectorNumber.clear();
+  AnodeNumber.clear();
   Energy.clear();
   Time.clear();
 }
diff --git a/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.h b/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.h
index 847f7d731..035a16b37 100644
--- a/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.h
+++ b/NPLib/Detectors/FissionChamber/TFissionChamberPhysics.h
@@ -62,7 +62,7 @@ class TFissionChamberPhysics : public TObject, public NPL::VDetector {
   // data obtained after BuildPhysicalEvent() and stored in
   // output ROOT file
   public:
-    vector<int>      DetectorNumber;
+    vector<int>      AnodeNumber;
     vector<double>   Energy;
     vector<double>   Time;
 
diff --git a/NPLib/Detectors/FissionChamber/TFissionChamberSpectra.cxx b/NPLib/Detectors/FissionChamber/TFissionChamberSpectra.cxx
index 9f6f07f65..4c2ba9ae1 100644
--- a/NPLib/Detectors/FissionChamber/TFissionChamberSpectra.cxx
+++ b/NPLib/Detectors/FissionChamber/TFissionChamberSpectra.cxx
@@ -114,19 +114,14 @@ void TFissionChamberSpectra::FillRawSpectra(TFissionChamberData* RawData) {
   // Energy 
   unsigned int sizeE = RawData->GetMultEnergy();
   for (unsigned int i = 0; i < sizeE; i++) {
-    name = "FissionChamber"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW";
+    name = "FissionChamber"+NPL::itoa(RawData->GetAnodeNbr(i))+"_ENERGY_RAW";
     family = "FissionChamber/RAW";
+    FillSpectra(family,name,RawData->GetEnergy(i));
 
-    FillSpectra(family,name,RawData->Get_Energy(i));
-  }
-
-  // Time
-  unsigned int sizeT = RawData->GetMultTime();
-  for (unsigned int i = 0; i < sizeT; i++) {
-    name = "FissionChamber"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW";
+    name = "FissionChamber"+NPL::itoa(RawData->GetAnodeNbr(i))+"_TIME_RAW";
     family = "FissionChamber/RAW";
+    FillSpectra(family,name,RawData->GetTime(i));
 
-    FillSpectra(family,name,RawData->Get_Time(i));
   }
 }
 
@@ -140,19 +135,13 @@ void TFissionChamberSpectra::FillPreTreatedSpectra(TFissionChamberData* PreTreat
   // Energy 
   unsigned int sizeE = PreTreatedData->GetMultEnergy();
   for (unsigned int i = 0; i < sizeE; i++) {
-    name = "FissionChamber"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL";
+    name = "FissionChamber"+NPL::itoa(PreTreatedData->GetAnodeNbr(i))+"_ENERGY_CAL";
     family = "FissionChamber/CAL";
-
-    FillSpectra(family,name,PreTreatedData->Get_Energy(i));
-  }
-
-  // Time
-  unsigned int sizeT = PreTreatedData->GetMultTime();
-  for (unsigned int i = 0; i < sizeT; i++) {
-    name = "FissionChamber"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL";
+    FillSpectra(family,name,PreTreatedData->GetEnergy(i));
+  
+    name = "FissionChamber"+NPL::itoa(PreTreatedData->GetAnodeNbr(i))+"_TIME_CAL";
     family = "FissionChamber/CAL";
-
-    FillSpectra(family,name,PreTreatedData->Get_Time(i));
+    FillSpectra(family,name,PreTreatedData->GetTime(i));
   }
 }
 
diff --git a/NPLib/Detectors/Vendeta/TVendetaData.cxx b/NPLib/Detectors/Vendeta/TVendetaData.cxx
index 0b7bc019c..28597a37f 100644
--- a/NPLib/Detectors/Vendeta/TVendetaData.cxx
+++ b/NPLib/Detectors/Vendeta/TVendetaData.cxx
@@ -44,12 +44,11 @@ TVendetaData::~TVendetaData() {
 
 //////////////////////////////////////////////////////////////////////
 void TVendetaData::Clear() {
-  // Energy
-  fVendeta_E_DetectorNbr.clear();
-  fVendeta_Energy.clear();
-  // Time
-  fVendeta_T_DetectorNbr.clear();
+  fVendeta_DetectorNbr.clear();
+  fVendeta_Q1.clear();
+  fVendeta_Q2.clear();
   fVendeta_Time.clear();
+  fVendeta_isHG.clear();
 }
 
 
@@ -59,21 +58,13 @@ void TVendetaData::Dump() const {
   // This method is very useful for debuging and worth the dev.
   cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TVendetaData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
 
-  // Energy
-  size_t mysize = fVendeta_E_DetectorNbr.size();
+  size_t mysize = fVendeta_DetectorNbr.size();
   cout << "Vendeta_E_Mult: " << mysize << endl;
  
   for (size_t i = 0 ; i < mysize ; i++){
-    cout << "DetNbr: " << fVendeta_E_DetectorNbr[i]
-         << " Energy: " << fVendeta_Energy[i];
-  }
-  
-  // Time
-  mysize = fVendeta_T_DetectorNbr.size();
-  cout << "Vendeta_T_Mult: " << mysize << endl;
- 
-  for (size_t i = 0 ; i < mysize ; i++){
-    cout << "DetNbr: " << fVendeta_T_DetectorNbr[i]
+    cout << "DetNbr: " << fVendeta_DetectorNbr[i]
+         << " Q1: " << fVendeta_Q1[i]
+         << " Q2: " << fVendeta_Q2[i]
          << " Time: " << fVendeta_Time[i];
   }
 }
diff --git a/NPLib/Detectors/Vendeta/TVendetaData.h b/NPLib/Detectors/Vendeta/TVendetaData.h
index d9b2671ee..58951831e 100644
--- a/NPLib/Detectors/Vendeta/TVendetaData.h
+++ b/NPLib/Detectors/Vendeta/TVendetaData.h
@@ -34,13 +34,11 @@ class TVendetaData : public TObject {
   // data members are hold into vectors in order 
   // to allow multiplicity treatment
   private: 
-    // Energy
-    vector<UShort_t>   fVendeta_E_DetectorNbr;
-    vector<Double_t>   fVendeta_Energy;
-
-    // Time
-    vector<UShort_t>   fVendeta_T_DetectorNbr;
+    vector<UShort_t>   fVendeta_DetectorNbr;
+    vector<Double_t>   fVendeta_Q1;
+    vector<Double_t>   fVendeta_Q2;
     vector<Double_t>   fVendeta_Time;
+    vector<Bool_t>     fVendeta_isHG; 
 
 
   //////////////////////////////////////////////////////////////
@@ -66,35 +64,19 @@ class TVendetaData : public TObject {
   public:
     //////////////////////    SETTERS    ////////////////////////
     // Energy
-    inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){
-      fVendeta_E_DetectorNbr.push_back(DetNbr);
-      fVendeta_Energy.push_back(Energy);
-    };//!
-
-    // Time
-    inline void SetTime(const UShort_t& DetNbr,const Double_t& Time)	{
-      fVendeta_T_DetectorNbr.push_back(DetNbr);     
-      fVendeta_Time.push_back(Time);
-    };//!
-
+    inline void SetDetectorNbr(const UShort_t& DetNbr) {fVendeta_DetectorNbr.push_back(DetNbr);};//!
+    inline void SetQ1(const Double_t& Q1) {fVendeta_Q1.push_back(Q1);};//!
+    inline void SetQ2(const Double_t& Q2) {fVendeta_Q2.push_back(Q2);};//!
+    inline void SetTime(const Double_t& Time) {fVendeta_Time.push_back(Time);};//!
+    inline void SetHighGainStatus(const Bool_t& isHG) {fVendeta_isHG.push_back(isHG);};//
 
     //////////////////////    GETTERS    ////////////////////////
-    // Energy
-    inline UShort_t GetMultEnergy() const
-      {return fVendeta_E_DetectorNbr.size();}
-    inline UShort_t GetE_DetectorNbr(const unsigned int &i) const 
-      {return fVendeta_E_DetectorNbr[i];}//!
-    inline Double_t Get_Energy(const unsigned int &i) const 
-      {return fVendeta_Energy[i];}//!
-
-    // Time
-    inline UShort_t GetMultTime() const
-      {return fVendeta_T_DetectorNbr.size();}
-    inline UShort_t GetT_DetectorNbr(const unsigned int &i) const 
-      {return fVendeta_T_DetectorNbr[i];}//!
-    inline Double_t Get_Time(const unsigned int &i) const 
-      {return fVendeta_Time[i];}//!
-
+    inline UShort_t GetMultEnergy() const {return fVendeta_DetectorNbr.size();}
+    inline UShort_t GetDetectorNbr(const unsigned int &i) const {return fVendeta_DetectorNbr[i];}//!
+    inline Double_t GetQ1(const unsigned int &i) const {return fVendeta_Q1[i];}//!
+    inline Double_t GetQ2(const unsigned int &i) const {return fVendeta_Q2[i];}//!
+    inline Double_t GetTime(const unsigned int &i) const {return fVendeta_Time[i];}//!
+    inline Bool_t GetHighGainStatus(const unsigned int &i) const {return fVendeta_isHG[i];}//!
 
   //////////////////////////////////////////////////////////////
   // Required for ROOT dictionnary
diff --git a/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx b/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx
index 686d55be2..d28864b54 100644
--- a/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx
+++ b/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx
@@ -50,6 +50,7 @@ TVendetaPhysics::TVendetaPhysics()
      m_Spectra(0),
      m_E_RAW_Threshold(0), // adc channels
      m_E_Threshold(0),     // MeV
+     m_AnodeNumber(-1),
      m_NumberOfDetectors(0) {
 }
 
@@ -79,21 +80,23 @@ void TVendetaPhysics::BuildSimplePhysicalEvent() {
 
 ///////////////////////////////////////////////////////////////////////////
 void TVendetaPhysics::BuildPhysicalEvent() {
+  // Treat Event, only if Fission Chamber has triggered
+  if(m_AnodeNumber==-1)
+    return;
+
   // apply thresholds and calibration
   PreTreat();
 
   // match energy and time together
   unsigned int mysizeE = m_PreTreatedData->GetMultEnergy();
-  unsigned int mysizeT = m_PreTreatedData->GetMultTime();
   for (UShort_t e = 0; e < mysizeE ; e++) {
-    for (UShort_t t = 0; t < mysizeT ; t++) {
-      if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) {
-        DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e));
-        Energy.push_back(m_PreTreatedData->Get_Energy(e));
-        Time.push_back(m_PreTreatedData->Get_Time(t));
-      }
-    }
+    DetectorNumber.push_back(m_PreTreatedData->GetDetectorNbr(e));
+    Q1.push_back(m_PreTreatedData->GetQ1(e));
+    Q2.push_back(m_PreTreatedData->GetQ2(e));
+    Time.push_back(m_PreTreatedData->GetTime(e));
   }
+
+  m_AnodeNumber=-1;
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -110,19 +113,24 @@ void TVendetaPhysics::PreTreat() {
   // Energy
   unsigned int mysize = m_EventData->GetMultEnergy();
   for (UShort_t i = 0; i < mysize ; ++i) {
-    if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) {
-      Double_t Energy = Cal->ApplyCalibration("Vendeta/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i));
-      if (Energy > m_E_Threshold) {
-        m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy);
+    if (m_EventData->GetQ1(i) > m_E_RAW_Threshold && m_EventData->GetQ2(i) > m_E_RAW_Threshold) {
+      int det = m_EventData->GetDetectorNbr(i);
+      bool isHG = m_PreTreatedData->GetHighGainStatus(i);
+      double TimeOffset=0;
+      if(isHG==0){
+        TimeOffset = Cal->GetValue("Vendeta/DET"+NPL::itoa(det)+"_LG_ANODE"+NPL::itoa(m_AnodeNumber)+"_TIMEOFFSET",0);
+      }
+      else if(isHG==1){ 
+        TimeOffset = Cal->GetValue("Vendeta/DET"+NPL::itoa(det)+"_LG_ANODE"+NPL::itoa(m_AnodeNumber)+"_TIMEOFFSET",0);
       }
-    }
-  }
 
-  // Time 
-  mysize = m_EventData->GetMultTime();
-  for (UShort_t i = 0; i < mysize; ++i) {
-    Double_t Time= Cal->ApplyCalibration("Vendeta/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i));
-    m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time);
+      double Time = m_EventData->GetTime(i - TimeOffset);
+      m_PreTreatedData->SetDetectorNbr(det);
+      m_PreTreatedData->SetQ1(m_EventData->GetQ1(i));
+      m_PreTreatedData->SetQ2(m_EventData->GetQ2(i));
+      m_PreTreatedData->SetTime(Time);
+      m_PreTreatedData->SetHighGainStatus(isHG);
+    }
   }
 }
 
@@ -195,8 +203,10 @@ void TVendetaPhysics::ReadAnalysisConfig() {
 ///////////////////////////////////////////////////////////////////////////
 void TVendetaPhysics::Clear() {
   DetectorNumber.clear();
-  Energy.clear();
+  Q1.clear();
+  Q2.clear();
   Time.clear();
+  isHG.clear();
 }
 
 
diff --git a/NPLib/Detectors/Vendeta/TVendetaPhysics.h b/NPLib/Detectors/Vendeta/TVendetaPhysics.h
index 9678edd34..27adaca36 100644
--- a/NPLib/Detectors/Vendeta/TVendetaPhysics.h
+++ b/NPLib/Detectors/Vendeta/TVendetaPhysics.h
@@ -63,8 +63,10 @@ class TVendetaPhysics : public TObject, public NPL::VDetector {
   // output ROOT file
   public:
     vector<int>      DetectorNumber;
-    vector<double>   Energy;
+    vector<double>   Q1;
+    vector<double>   Q2;
     vector<double>   Time;
+    vector<bool>     isHG;
 
   /// A usefull method to bundle all operation to add a detector
   void AddDetector(TVector3 POS, string shape); 
@@ -141,7 +143,9 @@ class TVendetaPhysics : public TObject, public NPL::VDetector {
     // give and external TVendetaData object to TVendetaPhysics. 
     // needed for online analysis for example
     void SetRawDataPointer(TVendetaData* rawDataPointer) {m_EventData = rawDataPointer;}
-    
+   
+    void SetAnodeNumber(int AnodeNbr) {m_AnodeNumber = AnodeNbr;}; //!
+
   // objects are not written in the TTree
   private:
     TVendetaData*         m_EventData;        //!
@@ -159,6 +163,9 @@ class TVendetaPhysics : public TObject, public NPL::VDetector {
     double m_E_RAW_Threshold; //!
     double m_E_Threshold;     //!
 
+  private:
+    // Anode number from fission chamber for time offset calibration
+    int m_AnodeNumber; //!
   // number of detectors
   private:
     int m_NumberOfDetectors;  //!
diff --git a/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx b/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx
index f57efca4f..286cb7f8f 100644
--- a/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx
+++ b/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx
@@ -111,22 +111,16 @@ void TVendetaSpectra::FillRawSpectra(TVendetaData* RawData) {
   static string name;
   static string family;
 
-  // Energy 
   unsigned int sizeE = RawData->GetMultEnergy();
   for (unsigned int i = 0; i < sizeE; i++) {
-    name = "Vendeta"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW";
+    name = "Vendeta"+NPL::itoa(RawData->GetDetectorNbr(i))+"_ENERGY_RAW";
     family = "Vendeta/RAW";
+    FillSpectra(family,name,RawData->GetQ1(i));
 
-    FillSpectra(family,name,RawData->Get_Energy(i));
-  }
-
-  // Time
-  unsigned int sizeT = RawData->GetMultTime();
-  for (unsigned int i = 0; i < sizeT; i++) {
-    name = "Vendeta"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW";
+    name = "Vendeta"+NPL::itoa(RawData->GetDetectorNbr(i))+"_TIME_RAW";
     family = "Vendeta/RAW";
-
-    FillSpectra(family,name,RawData->Get_Time(i));
+    FillSpectra(family,name,RawData->GetTime(i));
+ 
   }
 }
 
@@ -140,19 +134,14 @@ void TVendetaSpectra::FillPreTreatedSpectra(TVendetaData* PreTreatedData) {
   // Energy 
   unsigned int sizeE = PreTreatedData->GetMultEnergy();
   for (unsigned int i = 0; i < sizeE; i++) {
-    name = "Vendeta"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL";
+    name = "Vendeta"+NPL::itoa(PreTreatedData->GetDetectorNbr(i))+"_ENERGY_CAL";
     family = "Vendeta/CAL";
+    FillSpectra(family,name,PreTreatedData->GetQ1(i));
 
-    FillSpectra(family,name,PreTreatedData->Get_Energy(i));
-  }
-
-  // Time
-  unsigned int sizeT = PreTreatedData->GetMultTime();
-  for (unsigned int i = 0; i < sizeT; i++) {
-    name = "Vendeta"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL";
+    name = "Vendeta"+NPL::itoa(PreTreatedData->GetDetectorNbr(i))+"_TIME_CAL";
     family = "Vendeta/CAL";
-
-    FillSpectra(family,name,PreTreatedData->Get_Time(i));
+    FillSpectra(family,name,PreTreatedData->GetTime(i));
+ 
   }
 }
 
@@ -165,10 +154,13 @@ void TVendetaSpectra::FillPhysicsSpectra(TVendetaPhysics* Physics) {
   family= "Vendeta/PHY";
 
   // Energy vs time
-  unsigned int sizeE = Physics->Energy.size();
+  unsigned int sizeE = Physics->DetectorNumber.size();
   for(unsigned int i = 0 ; i < sizeE ; i++){
-    name = "Vendeta_ENERGY_TIME";
-    FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]);
+    name = "Vendeta_Q1_Q2";
+    FillSpectra(family,name,Physics->Q1[i],Physics->Q2[i]);
+
+    name = "Vendeta_Q2_Time";
+    FillSpectra(family,name,Physics->Time[i],Physics->Q2[i]);
   }
 }
 
diff --git a/NPSimulation/Detectors/FissionChamber/FissionChamber.cc b/NPSimulation/Detectors/FissionChamber/FissionChamber.cc
index 1f2b491c7..215d1a015 100644
--- a/NPSimulation/Detectors/FissionChamber/FissionChamber.cc
+++ b/NPSimulation/Detectors/FissionChamber/FissionChamber.cc
@@ -404,8 +404,9 @@ void FissionChamber::ReadSensitive(const G4Event* ){
     if(Energy>FissionChamber_NS::EnergyThreshold){
       double Time = RandGauss::shoot(Scorer->GetTime(i),FissionChamber_NS::ResoTime);
       int DetectorNbr = level[0];
-      m_Event->SetEnergy(DetectorNbr,Energy);
-      m_Event->SetTime(DetectorNbr,Time); 
+      m_Event->SetAnodeNbr(DetectorNbr);
+      m_Event->SetEnergy(Energy);
+      m_Event->SetTime(Time); 
     }
   }
 }
diff --git a/NPSimulation/Detectors/Vendeta/Vendeta.cc b/NPSimulation/Detectors/Vendeta/Vendeta.cc
index c9fa54a0f..54c489ec7 100644
--- a/NPSimulation/Detectors/Vendeta/Vendeta.cc
+++ b/NPSimulation/Detectors/Vendeta/Vendeta.cc
@@ -297,8 +297,11 @@ void Vendeta::ReadSensitive(const G4Event* ){
     if(Energy>Vendeta_NS::EnergyThreshold){
       double Time = RandGauss::shoot(Scorer->GetTime(i),Vendeta_NS::ResoTime);
       int DetectorNbr = level[0]-1;
-      m_Event->SetEnergy(DetectorNbr,Energy);
-      m_Event->SetTime(DetectorNbr,Time); 
+      m_Event->SetDetectorNbr(DetectorNbr);
+      m_Event->SetQ1(0.2*Energy);
+      m_Event->SetQ2(Energy);
+      m_Event->SetTime(Time); 
+      m_Event->SetHighGain(0); 
     }
   }
 }
diff --git a/Projects/Vendeta/Analysis.cxx b/Projects/Vendeta/Analysis.cxx
index f0fe7e1f7..24c68aacb 100644
--- a/Projects/Vendeta/Analysis.cxx
+++ b/Projects/Vendeta/Analysis.cxx
@@ -24,6 +24,8 @@ using namespace std;
 #include"Analysis.h"
 #include"NPAnalysisFactory.h"
 #include"NPDetectorManager.h"
+#include"NPOptionManager.h"
+
 ////////////////////////////////////////////////////////////////////////////////
 Analysis::Analysis(){
 }
@@ -33,11 +35,42 @@ Analysis::~Analysis(){
 
 ////////////////////////////////////////////////////////////////////////////////
 void Analysis::Init(){
-   Vendeta= (TVendetaPhysicsPhysics*) m_DetectorManager->GetDetector("Vendeta");
+  Vendeta= (TVendetaPhysics*) m_DetectorManager->GetDetector("Vendeta");
+  FC= (TFissionChamberPhysics*) m_DetectorManager->GetDetector("FissionChamber");
+
+  InitOutputBranch();
+
+  neutron = new NPL::Particle("1n");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Analysis::TreatEvent(){
+  ReInitValue();
+
+  unsigned int FC_mult = FC->Energy.size();
+  if(FC_mult==1){
+    int anode = FC->AnodeNumber[0];
+
+    Vendeta->SetAnodeNumber(anode);
+    Vendeta->BuildPhysicalEvent();
+  }
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Analysis::InitOutputBranch(){
+  RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab);
+  RootOutput::getInstance()->GetTree()->Branch("ELab",&ELab);
+  RootOutput::getInstance()->GetTree()->Branch("Tof",&Tof);
+  RootOutput::getInstance()->GetTree()->Branch("Charge",&Charge);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Analysis::ReInitValue(){
+  ThetaLab.clear();
+  ELab.clear();
+  Tof.clear();
+  Charge.clear();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -56,13 +89,13 @@ NPL::VAnalysis* Analysis::Construct(){
 //            Registering the construct method to the factory                 //
 ////////////////////////////////////////////////////////////////////////////////
 extern "C"{
-class proxy{
-  public:
-    proxy(){
-      NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct);
-    }
-};
-
-proxy p;
+  class proxy{
+    public:
+      proxy(){
+        NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct);
+      }
+  };
+
+  proxy p;
 }
 
diff --git a/Projects/Vendeta/Analysis.h b/Projects/Vendeta/Analysis.h
index 36098a760..33d58de8c 100644
--- a/Projects/Vendeta/Analysis.h
+++ b/Projects/Vendeta/Analysis.h
@@ -23,6 +23,10 @@
 
 #include"NPVAnalysis.h"
 #include"TVendetaPhysics.h"
+#include"TFissionChamberPhysics.h"
+#include "NPParticle.h"
+#include "TRandom3.h"
+
 class Analysis: public NPL::VAnalysis{
   public:
     Analysis();
@@ -32,11 +36,22 @@ class Analysis: public NPL::VAnalysis{
     void Init();
     void TreatEvent();
     void End();
+    void InitOutputBranch();
+    void ReInitValue();
 
    static NPL::VAnalysis* Construct();
 
+  private:
+   vector<double> ThetaLab;
+   vector<double> ELab;
+   vector<double> Tof;
+   vector<double> Charge;
+
   private:
    TVendetaPhysics* Vendeta;
+   TFissionChamberPhysics* FC;
 
+   NPL::Particle* neutron;
+   TRandom3 ra;
 };
 #endif
diff --git a/Projects/Vendeta/PhysicsListOption.txt b/Projects/Vendeta/PhysicsListOption.txt
new file mode 100644
index 000000000..ec1a9581f
--- /dev/null
+++ b/Projects/Vendeta/PhysicsListOption.txt
@@ -0,0 +1,15 @@
+EmPhysicsList Option4
+DefaultCutOff 1
+DriftElectronPhysics 0
+IonBinaryCascadePhysics 0
+NPIonInelasticPhysics 0
+EmExtraPhysics 0
+HadronElasticPhysics 0
+StoppingPhysics 0
+OpticalPhysics 0
+HadronPhysicsINCLXX 0
+HadronPhysicsQGSP_BIC_HP 0
+HadronPhysicsQGSP_BERT_HP 0
+Decay 0
+Menate_R 0
+NeutronHP 1
diff --git a/Projects/Vendeta/Vendeta.detector b/Projects/Vendeta/Vendeta.detector
index 389959f68..fc25c975e 100644
--- a/Projects/Vendeta/Vendeta.detector
+++ b/Projects/Vendeta/Vendeta.detector
@@ -12,5 +12,12 @@ Vendeta
  R= 1000 mm
  THETA= 0 deg
  PHI= 0 deg
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Vendeta
+ R= 1000 mm
+ THETA= 20 deg
+ PHI= 0 deg
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+
diff --git a/Projects/Vendeta/Vendeta_full.detector b/Projects/Vendeta/Vendeta_full.detector
new file mode 100644
index 000000000..83be2514e
--- /dev/null
+++ b/Projects/Vendeta/Vendeta_full.detector
@@ -0,0 +1,18 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Alias Theta
+ Action= Copy
+ Value= 20 33 46 59 72 85 98 111 124 137 150 163 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Alias Phi
+ Action= Copy
+ Value= -20 15 50 130 165 200
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Vendeta
+ R= 1000 mm
+ THETA= @Theta deg
+ PHI= @Phi deg
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FissionChamber
+  POS= 0 0 0 mm
+  GasMaterial= CF4
+  Pressure= 1 bar
-- 
GitLab