From 0279bad8959a2a944551d76f4c0665a70bb00275 Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Sat, 28 Jul 2018 15:27:37 +0200
Subject: [PATCH] * Adding Default calibration to MUST2 Time         - Si T is
 now in ADC channel out of the simulation         - Default calibration are
 applied

---
 Examples/Example1/ShowResults.C            |   2 +-
 Examples/Example1/configs/ConfigMust2.dat  |   4 +-
 Examples/Example1/cuts/ETOF.root           | Bin 4279 -> 5393 bytes
 NPLib/Core/NPCore.cxx                      |  22 +++++++++
 NPLib/Core/NPCore.h                        |   2 +
 NPLib/Detectors/MUST2/TMust2Physics.cxx    |  24 ++++++---
 NPSimulation/Detectors/MUST2/MUST2Array.cc |  54 +++++++++++++--------
 NPSimulation/Detectors/MUST2/MUST2Array.hh |   2 +-
 8 files changed, 76 insertions(+), 34 deletions(-)

diff --git a/Examples/Example1/ShowResults.C b/Examples/Example1/ShowResults.C
index 3a2792926..eabef9bf3 100644
--- a/Examples/Example1/ShowResults.C
+++ b/Examples/Example1/ShowResults.C
@@ -36,7 +36,7 @@ void ShowResults(){
     
     // E-TOF
     c1->cd(2);
-    chain->Draw("-MUST2.Si_T:SSSD.Energy+MUST2.Si_E>>hIDT(1000,0,35,1000,-30,0)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5","colz");
+    chain->Draw("MUST2.Si_T:SSSD.Energy+MUST2.Si_E>>hIDT(1000,0,35,500,450,500)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5","colz");
 
 
     ETOF->Draw("same");
diff --git a/Examples/Example1/configs/ConfigMust2.dat b/Examples/Example1/configs/ConfigMust2.dat
index bcbc385cb..bebb0bf9e 100755
--- a/Examples/Example1/configs/ConfigMust2.dat
+++ b/Examples/Example1/configs/ConfigMust2.dat
@@ -1,5 +1,5 @@
 ConfigMust2
-	MAX_STRIP_MULTIPLICITY 1
+	MAX_STRIP_MULTIPLICITY 100
 	STRIP_ENERGY_MATCHING_NUMBER_OF_SIGMA 5
   STRIP_ENERGY_MATCHING_SIGMA 0.02
 	DISABLE_CHANNEL MM1STRY12
@@ -14,6 +14,4 @@ ConfigMust2
 	DISABLE_ALL MM6
 	DISABLE_ALL MM7
 	DISABLE_ALL MM8
-	SI_X_E_RAW_THRESHOLD 0
- 	CSI_E_RAW_THRESHOLD 0
   CSI_SIZE 256
diff --git a/Examples/Example1/cuts/ETOF.root b/Examples/Example1/cuts/ETOF.root
index 067d548e7c6f2d4adc224047d2a23700cc380032..a57897ebf177e383f164c5d592085d98cb81da22 100644
GIT binary patch
literal 5393
zcma)A3v?6bmHz&DNu!5Hqmi)uLStiI#=(z3NO;P|I1n&)Z6%nuWou*)$QoNCVH<)l
z3&Awx0ra)aquVwOX~J%orcDA(XcC&F?WSqyh9)FS+qBRo?dD+;pzS7Idgbh%?dj<`
zTb*-fe$9XH{U7(ckN;0wRt9+gEPyx=RDr;2)Sgeoh$6x#4Sql18wdN9BnJ+gb#FiZ
z!uUr&>-_Eu)cbe+Zbe?vs*QiR@=erEXr|EsG1_b<je?$R#;#cwZEc>N&QIsB|3l2n
zO~?Y9Ni0G%Ay2a%{{JS$eLX+67@d%xH8J*^d3iCqG@H3m$PX*tn2rtft(wC!9HJt|
z?)>ia-#Pz_1LJxGVjDPm&VdjC3Q0P@E8rnG|3Z?woZ$GLFe22HJb07;Ej3*9Z8`!=
zM(5&kC44LrXgW4fa{r-7@gt9XrR3hvMJm_6;{V1gKab4bFw}d`tbdHm9r?Gfe6Xk@
za$Wt2?0Y4@bmCHNeRX&97kcf;>_aW@ww}EdnSM_F@abFLj#Si0pMP@R*CHi>HUGTt
z%F0Oa@w-CWdT+!(r*$58mXBzThg)91(;CL*Ei95N_HN0xJQB&(ty!~r&f-XJ@von#
zTvHaw-Sot)J$g+fxAx)f|9P<`l3V|D_l;MMMsf?cy>k9YZ6vqojqh!XT9MqG@OAdV
z??iGlT22MN|Mf_&WN@A1qqieD*QxOI(;r82h~BgQ@fndEw`KPePwtE4LT$M}eRysd
zmuT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std::string NPL::itoa(const int& i){
   return NPL::itoa_array[i];
 }
+////////////////////////////////////////////////////////////////////////////////
+unsigned int NPL::EnergyToADC(const double& E, const double& Emin, const double& Emax, const int& Pedestal, const int& ADCMax){
+  double Crange = ADCMax - Pedestal;
+  double Erange = Emax - Emin;
+  
+  // Standard case where larger ADC channel means larger Energy
+  if(Crange > 0){
+    double answer = Crange*E/Erange  + Pedestal;
+    if(answer > ADCMax)
+       answer = ADCMax;
+    return answer;
+  }
+  // Reverse coding case where larger ADC channel means smaller Energy
+  else{
+    double answer = Crange*E/Erange  + Pedestal;
+    if(answer < ADCMax)
+       answer = ADCMax;
+    return answer;
+  }
+    
+  return -1000;
+}
diff --git a/NPLib/Core/NPCore.h b/NPLib/Core/NPCore.h
index 9f14ffadd..0cf9ac195 100644
--- a/NPLib/Core/NPCore.h
+++ b/NPLib/Core/NPCore.h
@@ -28,5 +28,7 @@ namespace NPL{
   void SendWarning(std::string Class, std::string Warning);
   void SendInformation(std::string Class, std::string Information);
   void SendErrorAndExit(std::string Class,std::string Error);
+  // For use to simulate electronic
+  unsigned int EnergyToADC(const double& E, const double& Emin, const double& Emax, const int& Pedestal, const int& ADCMax);
 }
 #endif
diff --git a/NPLib/Detectors/MUST2/TMust2Physics.cxx b/NPLib/Detectors/MUST2/TMust2Physics.cxx
index 7c5f7d735..41a672f0f 100644
--- a/NPLib/Detectors/MUST2/TMust2Physics.cxx
+++ b/NPLib/Detectors/MUST2/TMust2Physics.cxx
@@ -896,24 +896,32 @@ map< string , TH1*> TMust2Physics::GetSpectra() {
 void TMust2Physics::AddParameterToCalibrationManager()
 {
   CalibrationManager* Cal = CalibrationManager::getInstance();
+  // Good for simulation, close to typical values
+  vector<double> standardX = {-63, 63./8192.};
+  vector<double> standardY = {63, -63./8192.};
+  vector<double> standardCsI = {-250, 250./8192.};
+  vector<double> standardSiLi = {-250, 250./8192.};
+  vector<double> standardT = {-1000, 1000./8192.};
+
+
 
   for(int i = 0 ; i < m_NumberOfTelescope ; ++i){
 
     for( int j = 0 ; j < 128 ; ++j){
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_E")   ;
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_E")   ;
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_T")   ;
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_T")   ;
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_E",standardX)   ;
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_E",standardY)   ;
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_Si_X"+NPL::itoa(j+1)+"_T",standardT )   ;
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_Si_Y"+NPL::itoa(j+1)+"_T",standardT )   ;
     }
 
     for( int j = 0 ; j < 16 ; ++j){
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_E")   ;
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_T")   ;
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_E",standardSiLi)   ;
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_SiLi"+NPL::itoa(j+1)+"_T",standardT )   ;
     }
 
     for( int j = 0 ; j < 16 ; ++j){
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_E")      ;
-      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_T")      ;
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_E","MUST2_T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_E",standardCsI);
+      Cal->AddParameter("MUST2", "T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_T","MUST2_T"+NPL::itoa(i+1)+"_CsI"+NPL::itoa(j+1)+"_T",standardT )      ;
     }
   }
 
diff --git a/NPSimulation/Detectors/MUST2/MUST2Array.cc b/NPSimulation/Detectors/MUST2/MUST2Array.cc
index 6796a6dfa..950046182 100644
--- a/NPSimulation/Detectors/MUST2/MUST2Array.cc
+++ b/NPSimulation/Detectors/MUST2/MUST2Array.cc
@@ -44,7 +44,8 @@
 #include "SiliconScorers.hh"
 #include "CalorimeterScorers.hh"
 #include "NPOptionManager.h"
-
+// NPL
+#include "NPCore.h"
 //ROOT
 #include "RootOutput.h"
 
@@ -758,9 +759,10 @@ void MUST2Array::ReadSensitive(const G4Event* event){
       if(r==0){
         trig.insert(detectorNbr);
         // Energy 
-        m_Event->SetStripXE(detectorNbr,b+1,energyX);
+        m_Event->SetStripXE(detectorNbr,b+1,NPL::EnergyToADC(energyX,0,63,8192,16384));
         // Time 
-        m_Event->SetStripXT(detectorNbr,b+1,RandGauss::shoot(time, ResoTimeMust));
+        double timeX = TimeOffset - RandGauss::shoot(time, ResoTimeMust);
+        m_Event->SetStripXT(detectorNbr,b+1,NPL::EnergyToADC(timeX,0,1000,8192,16384));
       }
       else{ // Interstrip X, keep maximum shared energy
         double rand = G4UniformRand();
@@ -769,9 +771,10 @@ void MUST2Array::ReadSensitive(const G4Event* event){
           if(energyX>0.1*keV){
             trig.insert(detectorNbr);
             // Energy 
-            m_Event->SetStripXE(detectorNbr,b+1,energyX) ; 
+            m_Event->SetStripXE(detectorNbr,b+1,NPL::EnergyToADC(energyX,0,63,8192,16384)) ; 
             // Time 
-            m_Event->SetStripXT(detectorNbr,b+1,RandGauss::shoot(time, ResoTimeMust));
+            double timeX = TimeOffset - RandGauss::shoot(time, ResoTimeMust);
+            m_Event->SetStripXT(detectorNbr,b+1,NPL::EnergyToADC(timeX,0,1000,8192,16384));
           } 
         }
         else{
@@ -780,10 +783,11 @@ void MUST2Array::ReadSensitive(const G4Event* event){
             trig.insert(detectorNbr);
 
             // Energy 
-            m_Event->SetStripXE(detectorNbr,g+1,energyX) ;  
+            m_Event->SetStripXE(detectorNbr,g+1,NPL::EnergyToADC(energyX,0,63,8192,16384)) ;  
             // Time 
-            m_Event->SetStripXT(detectorNbr,g+1,RandGauss::shoot(time, ResoTimeMust));
-          }
+            double timeX = TimeOffset - RandGauss::shoot(time, ResoTimeMust);
+            m_Event->SetStripXT(detectorNbr,b+1,NPL::EnergyToADC(timeX,0,1000,8192,16384));
+           }
         }
       }
     }
@@ -799,10 +803,11 @@ void MUST2Array::ReadSensitive(const G4Event* event){
       if(r==0){
         trig.insert(detectorNbr);
         // Energy 
-        m_Event->SetStripYE(detectorNbr,b+1,energyY);
+        m_Event->SetStripYE(detectorNbr,b+1,NPL::EnergyToADC(energyY,0,63,8192,0));
         // Time 
-        m_Event->SetStripYT(detectorNbr,b+1,RandGauss::shoot(time, ResoTimeMust)); 
-      }
+        double timeY = TimeOffset - RandGauss::shoot(time, ResoTimeMust);
+        m_Event->SetStripYT(detectorNbr,b+1,NPL::EnergyToADC(timeY,0,1000,8192,16384));
+       }      
       else{ // Interstrip Y, keep both strip with shared energy
         double rand = G4UniformRand();
         double energyY1 = rand*energyY;
@@ -810,19 +815,22 @@ void MUST2Array::ReadSensitive(const G4Event* event){
           trig.insert(detectorNbr);
 
           // Energy 
-          m_Event->SetStripYE(detectorNbr,b+1,energyY1); 
+          m_Event->SetStripYE(detectorNbr,b+1,NPL::EnergyToADC(energyY1,0,63,8192,0)); 
+
           // Time 
-          m_Event->SetStripYT(detectorNbr,b+1,RandGauss::shoot(time, ResoTimeMust));
-        }
+          double timeY = TimeOffset - RandGauss::shoot(time, ResoTimeMust);
+          m_Event->SetStripYT(detectorNbr,b+1,NPL::EnergyToADC(timeY,0,1000,8192,16384));
+        } 
 
         if(energyY1>0.1*keV){
           trig.insert(detectorNbr);
           double energyY2 = (1-rand)*energyY;
           // Energy 
-          m_Event->SetStripYE(detectorNbr,g+1,energyY2);  
+          m_Event->SetStripYE(detectorNbr,g+1,NPL::EnergyToADC(energyY2,0,63,8192,0));  
           // Time 
-          m_Event->SetStripYT(detectorNbr,g+1,RandGauss::shoot(time, ResoTimeMust));
-        }
+          double timeY = TimeOffset - RandGauss::shoot(time, ResoTimeMust);
+          m_Event->SetStripYT(detectorNbr,b+1,NPL::EnergyToADC(timeY,0,1000,8192,16384));
+        } 
       }
     }
  
@@ -859,8 +867,10 @@ void MUST2Array::ReadSensitive(const G4Event* event){
     for(SiLi_itr = SiLiHitMap->GetMap()->begin(); SiLi_itr!=SiLiHitMap->GetMap()->end() ; SiLi_itr++){
       G4double* Info = *(SiLi_itr->second);
       if(Info[7]==*itr){//matching telescope number
-        m_Event->SetSiLiE(Info[7],Info[8],RandGauss::shoot(Info[0],ResoSiLi));
-        m_Event->SetSiLiT(Info[7],Info[8],RandGauss::shoot(Info[1],ResoTimeMust));
+        double ESiLi = RandGauss::shoot(Info[0],ResoSiLi);
+        m_Event->SetSiLiE(Info[7],Info[8],NPL::EnergyToADC(ESiLi,0,250,8192,16384));
+        double timeSiLi = RandGauss::shoot(Info[1],ResoTimeMust);
+        m_Event->SetSiLiT(Info[7],Info[8],NPL::EnergyToADC(timeSiLi,0,1000,16384,8192));
       }
     }
   }
@@ -871,8 +881,10 @@ void MUST2Array::ReadSensitive(const G4Event* event){
       G4double* Info = *(CsI_itr->second);
       
       if(Info[7]==*itr){//matching telescope number
-        m_Event->SetCsIE(Info[7],Info[8],RandGauss::shoot(Info[0],ResoCsI));
-        m_Event->SetCsIT(Info[7],Info[8],RandGauss::shoot(Info[1],ResoTimeMust));
+        double ECsI = RandGauss::shoot(Info[0],ResoCsI);
+        m_Event->SetCsIE(Info[7],Info[8],NPL::EnergyToADC(ECsI,0,250,8192,16384));
+        double timeCsI = RandGauss::shoot(Info[1],ResoTimeMust);
+        m_Event->SetCsIT(Info[7],Info[8],NPL::EnergyToADC(timeCsI,0,1000,16384,8192));
       }
     }
   }
diff --git a/NPSimulation/Detectors/MUST2/MUST2Array.hh b/NPSimulation/Detectors/MUST2/MUST2Array.hh
index ad42412f7..883b62a01 100644
--- a/NPSimulation/Detectors/MUST2/MUST2Array.hh
+++ b/NPSimulation/Detectors/MUST2/MUST2Array.hh
@@ -39,7 +39,7 @@ namespace MUST2
    const G4double ResoSiLi     = 0.028          ;// = 130 keV of resolution //   Unit is MeV/2.35
    const G4double ResoCsI      = 0.08           ;// = 188 kev of resolution //   Unit is MeV/2.35
    const G4double ResoStrip    = 0.0149         ;// 0.0223 = 52keV of Resolution   //   Unit is MeV/2.35  14.861996
-
+   const G4double TimeOffset   = 500            ;// 500 ns stop
    // Geometry
    const G4double FaceFront = 11.*cm ;
    const G4double FaceBack = 16.5*cm ;
-- 
GitLab