From 859f086e8e1d65eb3ce340c93fd42bbef4bdb01c Mon Sep 17 00:00:00 2001
From: lenain <lenain@lpccaen.in2p3.fr>
Date: Wed, 3 Aug 2022 17:03:25 +0200
Subject: [PATCH] Upadting Vendeta to manage double gain: one variable's vector
 per gain

---
 NPLib/Detectors/Vendeta/TVendetaData.cxx    |  28 +++--
 NPLib/Detectors/Vendeta/TVendetaData.h      |  78 ++++++++-----
 NPLib/Detectors/Vendeta/TVendetaPhysics.cxx | 122 +++++++++++++-------
 NPLib/Detectors/Vendeta/TVendetaPhysics.h   |  17 ++-
 NPLib/Detectors/Vendeta/TVendetaSpectra.cxx |  26 ++---
 NPSimulation/Detectors/Vendeta/Vendeta.cc   |  21 +++-
 6 files changed, 187 insertions(+), 105 deletions(-)

diff --git a/NPLib/Detectors/Vendeta/TVendetaData.cxx b/NPLib/Detectors/Vendeta/TVendetaData.cxx
index 28597a37f..a9dbd4ecb 100644
--- a/NPLib/Detectors/Vendeta/TVendetaData.cxx
+++ b/NPLib/Detectors/Vendeta/TVendetaData.cxx
@@ -44,11 +44,19 @@ TVendetaData::~TVendetaData() {
 
 //////////////////////////////////////////////////////////////////////
 void TVendetaData::Clear() {
-  fVendeta_DetectorNbr.clear();
-  fVendeta_Q1.clear();
-  fVendeta_Q2.clear();
-  fVendeta_Time.clear();
-  fVendeta_isHG.clear();
+  
+  fVendeta_LG_DetectorNbr.clear();
+  fVendeta_LG_Q1.clear();
+  fVendeta_LG_Q2.clear();
+  fVendeta_LG_Time.clear();
+  fVendeta_LG_Qmax.clear();
+ 
+  fVendeta_HG_DetectorNbr.clear();
+  fVendeta_HG_Q1.clear();
+  fVendeta_HG_Q2.clear();
+  fVendeta_HG_Time.clear();
+  fVendeta_HG_Qmax.clear();
+
 }
 
 
@@ -58,13 +66,13 @@ void TVendetaData::Dump() const {
   // This method is very useful for debuging and worth the dev.
   cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TVendetaData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
 
-  size_t mysize = fVendeta_DetectorNbr.size();
+  size_t mysize = fVendeta_HG_DetectorNbr.size();
   cout << "Vendeta_E_Mult: " << mysize << endl;
  
   for (size_t i = 0 ; i < mysize ; i++){
-    cout << "DetNbr: " << fVendeta_DetectorNbr[i]
-         << " Q1: " << fVendeta_Q1[i]
-         << " Q2: " << fVendeta_Q2[i]
-         << " Time: " << fVendeta_Time[i];
+    cout << "DetNbr: " << fVendeta_HG_DetectorNbr[i]
+         << " Q1: "    << fVendeta_HG_Q1[i]
+         << " Q2: "    << fVendeta_HG_Q2[i]
+         << " Time: "  << fVendeta_HG_Time[i];
   }
 }
diff --git a/NPLib/Detectors/Vendeta/TVendetaData.h b/NPLib/Detectors/Vendeta/TVendetaData.h
index 58951831e..3045a350b 100644
--- a/NPLib/Detectors/Vendeta/TVendetaData.h
+++ b/NPLib/Detectors/Vendeta/TVendetaData.h
@@ -34,53 +34,71 @@ class TVendetaData : public TObject {
   // data members are hold into vectors in order 
   // to allow multiplicity treatment
   private: 
-    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; 
+    
+    vector<UShort_t>   fVendeta_LG_DetectorNbr;
+    vector<Double_t>   fVendeta_LG_Q1;
+    vector<Double_t>   fVendeta_LG_Q2;
+    vector<Double_t>   fVendeta_LG_Time;
+    vector<Double_t>   fVendeta_LG_Qmax; 
 
+    vector<UShort_t>   fVendeta_HG_DetectorNbr;
+    vector<Double_t>   fVendeta_HG_Q1;
+    vector<Double_t>   fVendeta_HG_Q2;
+    vector<Double_t>   fVendeta_HG_Time;
+    vector<Double_t>   fVendeta_HG_Qmax; 
 
-  //////////////////////////////////////////////////////////////
-  // Constructor and destructor
+    //////////////////////////////////////////////////////////////
+    // Constructor and destructor
   public: 
     TVendetaData();
     ~TVendetaData();
-    
 
-  //////////////////////////////////////////////////////////////
-  // Inherited from TObject and overriden to avoid warnings
+    //////////////////////////////////////////////////////////////
+    // Inherited from TObject and overriden to avoid warnings
   public:
     void Clear();
     void Clear(const Option_t*) {};
     void Dump() const;
 
-
-  //////////////////////////////////////////////////////////////
-  // Getters and Setters
-  // Prefer inline declaration to avoid unnecessary called of 
-  // frequently used methods
-  // add //! to avoid ROOT creating dictionnary for the methods
+    //////////////////////////////////////////////////////////////
+    // Getters and Setters
+    // Prefer inline declaration to avoid unnecessary called of 
+    // frequently used methods
+    // add //! to avoid ROOT creating dictionnary for the methods
   public:
     //////////////////////    SETTERS    ////////////////////////
     // Energy
-    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);};//
+    
+    inline void SetLGDetectorNbr(const UShort_t& DetNbr) {fVendeta_LG_DetectorNbr.push_back(DetNbr);};//!
+    inline void SetLGQ1(const Double_t& Q1) {fVendeta_LG_Q1.push_back(Q1);};//!
+    inline void SetLGQ2(const Double_t& Q2) {fVendeta_LG_Q2.push_back(Q2);};//!
+    inline void SetLGTime(const Double_t& Time) {fVendeta_LG_Time.push_back(Time);};//!
+    inline void SetLGQmax(const Double_t& Qmax) {fVendeta_LG_Qmax.push_back(Qmax);};//
+
+    inline void SetHGDetectorNbr(const UShort_t& DetNbr) {fVendeta_HG_DetectorNbr.push_back(DetNbr);};//!
+    inline void SetHGQ1(const Double_t& Q1) {fVendeta_HG_Q1.push_back(Q1);};//!
+    inline void SetHGQ2(const Double_t& Q2) {fVendeta_HG_Q2.push_back(Q2);};//!
+    inline void SetHGTime(const Double_t& Time) {fVendeta_HG_Time.push_back(Time);};//!
+    inline void SetHGQmax(const Double_t& Qmax) {fVendeta_HG_Qmax.push_back(Qmax);};//
 
     //////////////////////    GETTERS    ////////////////////////
-    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];}//!
+    inline UShort_t GetLGMultEnergy() const {return fVendeta_LG_DetectorNbr.size();}
+    inline UShort_t GetLGDetectorNbr(const unsigned int &i) const {return fVendeta_LG_DetectorNbr[i];}//!
+    inline Double_t GetLGQ1(const unsigned int &i) const {return fVendeta_LG_Q1[i];}//!
+    inline Double_t GetLGQ2(const unsigned int &i) const {return fVendeta_LG_Q2[i];}//!
+    inline Double_t GetLGTime(const unsigned int &i) const {return fVendeta_LG_Time[i];}//!
+    inline Double_t GetLGQmax(const unsigned int &i) const {return fVendeta_LG_Qmax[i];}//!
 
-  //////////////////////////////////////////////////////////////
-  // Required for ROOT dictionnary
-  ClassDef(TVendetaData,1)  // VendetaData structure
+    inline UShort_t GetHGMultEnergy() const {return fVendeta_HG_DetectorNbr.size();}
+    inline UShort_t GetHGDetectorNbr(const unsigned int &i) const {return fVendeta_HG_DetectorNbr[i];}//!
+    inline Double_t GetHGQ1(const unsigned int &i) const {return fVendeta_HG_Q1[i];}//!
+    inline Double_t GetHGQ2(const unsigned int &i) const {return fVendeta_HG_Q2[i];}//!
+    inline Double_t GetHGTime(const unsigned int &i) const {return fVendeta_HG_Time[i];}//!
+    inline Double_t GetHGQmax(const unsigned int &i) const {return fVendeta_HG_Qmax[i];}//!
+
+    //////////////////////////////////////////////////////////////
+    // Required for ROOT dictionnary
+    ClassDef(TVendetaData,1)  // VendetaData structure
 };
 
 #endif
diff --git a/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx b/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx
index 3ff0e3d4f..3c2564bb4 100644
--- a/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx
+++ b/NPLib/Detectors/Vendeta/TVendetaPhysics.cxx
@@ -50,7 +50,7 @@ TVendetaPhysics::TVendetaPhysics()
      m_Spectra(0),
      m_E_RAW_Threshold(0), // adc channels
      m_E_Threshold(0),     // MeV
-     m_AnodeNumber(-1),
+     m_AnodeNumber(1),
      m_NumberOfDetectors(0) {
      }
 
@@ -81,24 +81,35 @@ 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();
-  for (UShort_t e = 0; e < mysizeE ; e++) {
-    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));
-    isHG.push_back(m_PreTreatedData->GetHighGainStatus(e));
+  unsigned int mysizeLGE = m_PreTreatedData->GetLGMultEnergy();
+  unsigned int mysizeHGE = m_PreTreatedData->GetHGMultEnergy();
+
+  for (UShort_t e = 0; e < mysizeLGE ; e++) {
+    LG_DetectorNumber.push_back(m_PreTreatedData->GetLGDetectorNbr(e));
+    LG_Q1.push_back(m_PreTreatedData->GetLGQ1(e));
+    LG_Q2.push_back(m_PreTreatedData->GetLGQ2(e));
+    LG_Time.push_back(m_PreTreatedData->GetLGTime(e));
+    LG_Qmax.push_back(m_PreTreatedData->GetLGQmax(e));
+  }
+  
+  for (UShort_t e = 0; e < mysizeHGE ; e++) {
+    HG_DetectorNumber.push_back(m_PreTreatedData->GetHGDetectorNbr(e));
+    HG_Q1.push_back(m_PreTreatedData->GetHGQ1(e));
+    HG_Q2.push_back(m_PreTreatedData->GetHGQ2(e));
+    HG_Time.push_back(m_PreTreatedData->GetHGTime(e));
+    HG_Qmax.push_back(m_PreTreatedData->GetHGQmax(e));
   }
 
-  m_AnodeNumber=-1;
+  /* m_AnodeNumber=-1; */
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -111,26 +122,46 @@ void TVendetaPhysics::PreTreat() {
 
   // instantiate CalibrationManager
   static CalibrationManager* Cal = CalibrationManager::getInstance();
+  unsigned int mysizeLG = m_EventData->GetLGMultEnergy();
+  unsigned int mysizeHG = m_EventData->GetHGMultEnergy();
 
-  unsigned int mysize = m_EventData->GetMultEnergy();
-  for (UShort_t i = 0; i < mysize ; ++i){
-    int det = m_EventData->GetDetectorNbr(i);
-    bool isHG = m_EventData->GetHighGainStatus(i);
+  // LG pretreat 
+  for (UShort_t i = 0; i < mysizeLG ; ++i){
+    int det = m_EventData->GetLGDetectorNbr(i);
+    double Qmax = m_EventData->GetLGQmax(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)+"_HG_ANODE"+NPL::itoa(m_AnodeNumber)+"_TIMEOFFSET",0);
-      }
+    
+    TimeOffset = Cal->GetValue("Vendeta/DET"+NPL::itoa(det)+"_LG_ANODE"+NPL::itoa(m_AnodeNumber)+"_TIMEOFFSET",0);
 
-    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);
+    double Time = m_EventData->GetLGTime(i) + TimeOffset;
+    
+    m_PreTreatedData->SetLGDetectorNbr(det);
+    m_PreTreatedData->SetLGQ1(m_EventData->GetLGQ1(i));
+    m_PreTreatedData->SetLGQ2(m_EventData->GetLGQ2(i));
+    m_PreTreatedData->SetLGTime(Time);
+    m_PreTreatedData->SetLGQmax(Qmax);
+    
   }
+   
+  // HG pretreat
+  for (UShort_t i = 0; i < mysizeHG ; ++i){
+    
+    int det = m_EventData->GetHGDetectorNbr(i);
+    double Qmax = m_EventData->GetHGQmax(i);
+    double TimeOffset=0;
+    TimeOffset = Cal->GetValue("Vendeta/DET"+NPL::itoa(det)+"_HG_ANODE"+NPL::itoa(m_AnodeNumber)+"_TIMEOFFSET",0);
+
+    double Time = m_EventData->GetHGTime(i) + TimeOffset;
+    m_PreTreatedData->SetHGDetectorNbr(det);
+    m_PreTreatedData->SetHGQ1(m_EventData->GetHGQ1(i));
+    m_PreTreatedData->SetHGQ2(m_EventData->GetHGQ2(i));
+    m_PreTreatedData->SetHGTime(Time);
+    m_PreTreatedData->SetHGQmax(Qmax);
+
+  }
+
+
+
 }
 
 
@@ -201,11 +232,18 @@ void TVendetaPhysics::ReadAnalysisConfig() {
 
 ///////////////////////////////////////////////////////////////////////////
 void TVendetaPhysics::Clear() {
-  DetectorNumber.clear();
-  Q1.clear();
-  Q2.clear();
-  Time.clear();
-  isHG.clear();
+  LG_DetectorNumber.clear();
+  LG_Q1.clear();
+  LG_Q2.clear();
+  LG_Time.clear();
+  LG_Qmax.clear();
+
+  HG_DetectorNumber.clear();
+  HG_Q1.clear();
+  HG_Q2.clear();
+  HG_Time.clear();
+  HG_Qmax.clear();
+
 }
 
 
@@ -223,7 +261,7 @@ void TVendetaPhysics::ReadConfiguration(NPL::InputParser parser) {
     if(blocks[i]->HasTokenList(cart)){
       if(NPOptionManager::getInstance()->GetVerboseLevel())
         cout << endl << "////  Vendeta " << i+1 <<  endl;
-    
+
       TVector3 Pos = blocks[i]->GetTVector3("POS","mm");
       AddDetector(Pos);
     }
@@ -294,8 +332,8 @@ void TVendetaPhysics::AddParameterToCalibrationManager() {
   CalibrationManager* Cal = CalibrationManager::getInstance();
   for (int i = 0; i < m_NumberOfDetectors; ++i) {
     for(int j = 0; j < 11; j++){
-    Cal->AddParameter("Vendeta","DET"+NPL::itoa(i+1)+"_LG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET","Vendeta_DET"+ NPL::itoa(i+1)+"_LG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET");
-    Cal->AddParameter("Vendeta","DET"+NPL::itoa(i+1)+"_HG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET","Vendeta_DET"+ NPL::itoa(i+1)+"_HG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET");
+      Cal->AddParameter("Vendeta","DET"+NPL::itoa(i+1)+"_LG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET","Vendeta_DET"+ NPL::itoa(i+1)+"_LG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET");
+      Cal->AddParameter("Vendeta","DET"+NPL::itoa(i+1)+"_HG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET","Vendeta_DET"+ NPL::itoa(i+1)+"_HG_ANODE"+NPL::itoa(j+1)+"_TIMEOFFSET");
     }
   }
 }
@@ -340,14 +378,14 @@ NPL::VDetector* TVendetaPhysics::Construct() {
 //            Registering the construct method to the factory                 //
 ////////////////////////////////////////////////////////////////////////////////
 extern "C"{
-class proxy_Vendeta{
-  public:
-    proxy_Vendeta(){
-      NPL::DetectorFactory::getInstance()->AddToken("Vendeta","Vendeta");
-      NPL::DetectorFactory::getInstance()->AddDetector("Vendeta",TVendetaPhysics::Construct);
-    }
-};
+  class proxy_Vendeta{
+    public:
+      proxy_Vendeta(){
+        NPL::DetectorFactory::getInstance()->AddToken("Vendeta","Vendeta");
+        NPL::DetectorFactory::getInstance()->AddDetector("Vendeta",TVendetaPhysics::Construct);
+      }
+  };
 
-proxy_Vendeta p_Vendeta;
+  proxy_Vendeta p_Vendeta;
 }
 
diff --git a/NPLib/Detectors/Vendeta/TVendetaPhysics.h b/NPLib/Detectors/Vendeta/TVendetaPhysics.h
index d78d4207b..f7b2d0b64 100644
--- a/NPLib/Detectors/Vendeta/TVendetaPhysics.h
+++ b/NPLib/Detectors/Vendeta/TVendetaPhysics.h
@@ -62,11 +62,18 @@ class TVendetaPhysics : public TObject, public NPL::VDetector {
   // data obtained after BuildPhysicalEvent() and stored in
   // output ROOT file
   public:
-    vector<int>      DetectorNumber;
-    vector<double>   Q1;
-    vector<double>   Q2;
-    vector<double>   Time;
-    vector<bool>     isHG;
+    vector<int>      LG_DetectorNumber;
+    vector<double>   LG_Q1;
+    vector<double>   LG_Q2;
+    vector<double>   LG_Time;
+    vector<double>   LG_Qmax;
+   
+    vector<int>      HG_DetectorNumber;
+    vector<double>   HG_Q1;
+    vector<double>   HG_Q2;
+    vector<double>   HG_Time;
+    vector<double>   HG_Qmax;
+
 
   /// A usefull method to bundle all operation to add a detector
   void AddDetector(TVector3 POS); 
diff --git a/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx b/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx
index 286cb7f8f..0f041acf0 100644
--- a/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx
+++ b/NPLib/Detectors/Vendeta/TVendetaSpectra.cxx
@@ -111,15 +111,15 @@ void TVendetaSpectra::FillRawSpectra(TVendetaData* RawData) {
   static string name;
   static string family;
 
-  unsigned int sizeE = RawData->GetMultEnergy();
+  unsigned int sizeE = RawData->GetLGMultEnergy();
   for (unsigned int i = 0; i < sizeE; i++) {
-    name = "Vendeta"+NPL::itoa(RawData->GetDetectorNbr(i))+"_ENERGY_RAW";
+    name = "Vendeta"+NPL::itoa(RawData->GetLGDetectorNbr(i))+"_ENERGY_RAW";
     family = "Vendeta/RAW";
-    FillSpectra(family,name,RawData->GetQ1(i));
+    FillSpectra(family,name,RawData->GetLGQ1(i));
 
-    name = "Vendeta"+NPL::itoa(RawData->GetDetectorNbr(i))+"_TIME_RAW";
+    name = "Vendeta"+NPL::itoa(RawData->GetLGDetectorNbr(i))+"_TIME_RAW";
     family = "Vendeta/RAW";
-    FillSpectra(family,name,RawData->GetTime(i));
+    FillSpectra(family,name,RawData->GetLGTime(i));
  
   }
 }
@@ -132,15 +132,15 @@ void TVendetaSpectra::FillPreTreatedSpectra(TVendetaData* PreTreatedData) {
   static string family;
   
   // Energy 
-  unsigned int sizeE = PreTreatedData->GetMultEnergy();
+  unsigned int sizeE = PreTreatedData->GetLGMultEnergy();
   for (unsigned int i = 0; i < sizeE; i++) {
-    name = "Vendeta"+NPL::itoa(PreTreatedData->GetDetectorNbr(i))+"_ENERGY_CAL";
+    name = "Vendeta"+NPL::itoa(PreTreatedData->GetLGDetectorNbr(i))+"_ENERGY_CAL";
     family = "Vendeta/CAL";
-    FillSpectra(family,name,PreTreatedData->GetQ1(i));
+    FillSpectra(family,name,PreTreatedData->GetLGQ1(i));
 
-    name = "Vendeta"+NPL::itoa(PreTreatedData->GetDetectorNbr(i))+"_TIME_CAL";
+    name = "Vendeta"+NPL::itoa(PreTreatedData->GetLGDetectorNbr(i))+"_TIME_CAL";
     family = "Vendeta/CAL";
-    FillSpectra(family,name,PreTreatedData->GetTime(i));
+    FillSpectra(family,name,PreTreatedData->GetLGTime(i));
  
   }
 }
@@ -154,13 +154,13 @@ void TVendetaSpectra::FillPhysicsSpectra(TVendetaPhysics* Physics) {
   family= "Vendeta/PHY";
 
   // Energy vs time
-  unsigned int sizeE = Physics->DetectorNumber.size();
+  unsigned int sizeE = Physics->LG_DetectorNumber.size();
   for(unsigned int i = 0 ; i < sizeE ; i++){
     name = "Vendeta_Q1_Q2";
-    FillSpectra(family,name,Physics->Q1[i],Physics->Q2[i]);
+    FillSpectra(family,name,Physics->LG_Q1[i],Physics->LG_Q2[i]);
 
     name = "Vendeta_Q2_Time";
-    FillSpectra(family,name,Physics->Time[i],Physics->Q2[i]);
+    FillSpectra(family,name,Physics->LG_Time[i],Physics->LG_Q2[i]);
   }
 }
 
diff --git a/NPSimulation/Detectors/Vendeta/Vendeta.cc b/NPSimulation/Detectors/Vendeta/Vendeta.cc
index cf3e89670..786abe378 100644
--- a/NPSimulation/Detectors/Vendeta/Vendeta.cc
+++ b/NPSimulation/Detectors/Vendeta/Vendeta.cc
@@ -344,11 +344,22 @@ 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->SetDetectorNbr(DetectorNbr);
-      m_Event->SetQ1(0.2*Energy);
-      m_Event->SetQ2(Energy);
-      m_Event->SetTime(Time); 
-      m_Event->SetHighGainStatus(0); 
+
+      if(Energy < 1) {  
+        m_Event->SetHGDetectorNbr(DetectorNbr);
+        m_Event->SetHGQ1(0.2*Energy);
+        m_Event->SetHGQ2(Energy);
+        m_Event->SetHGTime(Time); 
+        m_Event->SetHGQmax(0); 
+      }
+      else if(Energy > 1){
+        m_Event->SetLGDetectorNbr(DetectorNbr);
+        m_Event->SetLGQ1(0.2*Energy);
+        m_Event->SetLGQ2(Energy);
+        m_Event->SetLGTime(Time); 
+        m_Event->SetLGQmax(0); 
+      }
+
     }
   }
 }
-- 
GitLab