From 5dda4eef1490a79e6cdb522c88f6be3fafcd0379 Mon Sep 17 00:00:00 2001
From: "theodore.efremov" <theodore.efremov@cea.fr>
Date: Wed, 4 Dec 2024 15:53:34 +0100
Subject: [PATCH] Modified TTime and filled it in the convert to add the
 section of the MWPC and did some analysis

---
 NPLib/Detectors/PISTA/TTimeData.cxx           |  4 ++
 NPLib/Detectors/PISTA/TTimeData.h             | 15 ++++-
 Projects/AlPhaPha/2024/Analysis.cxx           |  5 +-
 Projects/AlPhaPha/2024/ReadMe.md              |  2 +-
 .../2024/macro/mwpc/Toff/ToffGenerator.cxx    | 56 ++++++++++++++++---
 Projects/AlPhaPha/conversion/2024/convert.C   |  2 +
 6 files changed, 72 insertions(+), 12 deletions(-)

diff --git a/NPLib/Detectors/PISTA/TTimeData.cxx b/NPLib/Detectors/PISTA/TTimeData.cxx
index 0ceb7608e..cb8713f66 100644
--- a/NPLib/Detectors/PISTA/TTimeData.cxx
+++ b/NPLib/Detectors/PISTA/TTimeData.cxx
@@ -53,6 +53,10 @@ void TTimeData::Clear() {
   fTime_MWPC14.clear();
   fTime_MWPC23.clear();
   fTime_MWPC24.clear();
+
+  fSection_MWPC3.clear();
+  fSection_MWPC4.clear();
+
 }
 
 
diff --git a/NPLib/Detectors/PISTA/TTimeData.h b/NPLib/Detectors/PISTA/TTimeData.h
index 2d036067c..066eb8d97 100644
--- a/NPLib/Detectors/PISTA/TTimeData.h
+++ b/NPLib/Detectors/PISTA/TTimeData.h
@@ -44,6 +44,8 @@ class TTimeData : public TObject {
         vector<float> fTime_MWPC23;
         vector<float> fTime_MWPC24;
 
+        vector<int> fSection_MWPC3;
+        vector<int> fSection_MWPC4;
 
 
 
@@ -80,6 +82,10 @@ class TTimeData : public TObject {
         inline void SetTime_MWPC23(float time ){fTime_MWPC23.push_back(time);};//!
         inline void SetTime_MWPC24(float time ){fTime_MWPC24.push_back(time);};//!
 
+        inline void SetSection_MWPC3(int section ){fSection_MWPC3.push_back(section);};//!
+        inline void SetSection_MWPC4(int section ){fSection_MWPC4.push_back(section);};//!
+
+
 
 
         //////////////////////    GETTERS    ////////////////////////
@@ -100,7 +106,12 @@ class TTimeData : public TObject {
         {return fTime_MWPC23.at(i) ;}//!
         inline float GetTime_MWPC24(const unsigned int &i) const
         {return fTime_MWPC24.at(i) ;}//!
-         
+        
+        inline int GetSection_MWPC3(const unsigned int &i) const
+        {return fSection_MWPC3.at(i) ;}//!
+        inline int GetSection_MWPC4(const unsigned int &i) const
+        {return fSection_MWPC4.at(i) ;}//!
+          
         inline Int_t GetMWPC13Mult() const
         {return static_cast<int>(fTime_MWPC13.size());}         
         inline Int_t GetMWPC14Mult() const
@@ -112,7 +123,7 @@ class TTimeData : public TObject {
 
         //////////////////////////////////////////////////////////////
         // Required for ROOT dictionnary
-        ClassDef(TTimeData,1)  // TimeData structure
+        ClassDef(TTimeData,2)  // TimeData structure
 };
 
 #endif
diff --git a/Projects/AlPhaPha/2024/Analysis.cxx b/Projects/AlPhaPha/2024/Analysis.cxx
index f9927ec6b..cc4cbc1df 100644
--- a/Projects/AlPhaPha/2024/Analysis.cxx
+++ b/Projects/AlPhaPha/2024/Analysis.cxx
@@ -505,10 +505,10 @@ void Analysis::VamosAnalysis(){
             // To know time of electron drift in a section of the chio
             for (int seg = 0 ; seg < IC->fIC_TS.size() ; seg++){
                 if (FPMW_Section != 0){
-                    FF_DriftTime.push_back(10* (IC->fIC_TS.at(seg) - Time->GetTS_MWPC13(0) - ((Time->GetTime_MWPC14(0)-Toff14.at(FPMW_Section-1)) - (Time->GetTime_MWPC13(0)- Toff13.at(FPMW_Section-1)))));
+                    FF_DriftTime.push_back(10* (IC->fIC_TS.at(seg) - Time->GetTS_MWPC13(0)) - ((Time->GetTime_MWPC13(0)+Toff13.at(FPMW_Section-1))));
                 }
                 else { 
-                    FF_DriftTime.push_back(10* (IC->fIC_TS.at(seg) - Time->GetTS_MWPC13(0) - ((Time->GetTime_MWPC14(0)) - (Time->GetTime_MWPC13(0)))));
+                    FF_DriftTime.push_back(10* (IC->fIC_TS.at(seg) - Time->GetTS_MWPC13(0)) - ((Time->GetTime_MWPC13(0))));
                 }
             }
 
@@ -516,6 +516,7 @@ void Analysis::VamosAnalysis(){
 
 
             FF_T13 = - MTOF_FP0_T0V[0] + Toff[FPMWPat];
+            //FF_T13 = -Time->GetTime_MWPC13(0) - Toff13[FPMW_Section-1] + 589;
             FF_D13 = FF_Path - path1 + path2; 
             FF_V13 = FF_D13/FF_T13;
             FF_Beta13 = FF_V13/29.9792458;
diff --git a/Projects/AlPhaPha/2024/ReadMe.md b/Projects/AlPhaPha/2024/ReadMe.md
index 9f8a29230..86105c145 100644
--- a/Projects/AlPhaPha/2024/ReadMe.md
+++ b/Projects/AlPhaPha/2024/ReadMe.md
@@ -39,7 +39,7 @@ Don't forget to modify the input file .
 Your project.config must point to the root dir of your computer
 
 # Compatibility AlmaLinux
-Never import a detector class in a macro, if you do be sure to put a 
+Never import a detector class in a macro, if you do, be sure to put a 
 ```
 #ifdef 0
 #include DETECTOR.h
diff --git a/Projects/AlPhaPha/2024/macro/mwpc/Toff/ToffGenerator.cxx b/Projects/AlPhaPha/2024/macro/mwpc/Toff/ToffGenerator.cxx
index 4d01c7cb3..d72802fa4 100644
--- a/Projects/AlPhaPha/2024/macro/mwpc/Toff/ToffGenerator.cxx
+++ b/Projects/AlPhaPha/2024/macro/mwpc/Toff/ToffGenerator.cxx
@@ -1,3 +1,4 @@
+#include "TICPhysics.h"
 #include "TTimeData.h"
 #include <TCanvas.h>
 #include <TChain.h>
@@ -27,7 +28,7 @@ void ToffGenerator(bool Create = true ){
     UShort_t S13[20] , S14[20] , S23[20] , S24[20];
 
     TTimeData *Time = new TTimeData();
-
+    TICPhysics *IC = new TICPhysics();
 
     chain->SetBranchStatus("MTOF_FP0_T0VN", true);
     chain->SetBranchAddress("MTOF_FP0_T0VN", &S13);
@@ -44,6 +45,8 @@ void ToffGenerator(bool Create = true ){
     chain->SetBranchStatus("Time", true);
     chain->SetBranchAddress("Time", &Time);
 
+    chain->SetBranchStatus("IC", true);
+    chain->SetBranchAddress("IC", &IC);
     //===========================================================================================================
     //                              Histograms
     //===========================================================================================================
@@ -53,6 +56,12 @@ void ToffGenerator(bool Create = true ){
     TH2F *hToff23;
     TH2F *hToff24;
 
+    TH2F *hToffOnline13;
+    TH2F *hToffOnline14;
+    TH2F *hToffOnline23;
+    TH2F *hToffOnline24;
+
+
     double xmin[4], xmax[4];
     double ymin[4], ymax[4];
     int binx = 20 , biny = 400;
@@ -62,6 +71,9 @@ void ToffGenerator(bool Create = true ){
     xmin[2] = 0 ; xmax[2] = 20 ; ymin[2] = -10 ; ymax[2] = 10 ;
     xmin[3] = 0 ; xmax[3] = 20 ; ymin[3] = -10 ; ymax[3] = 10 ;
 
+    // Toff from aligning AoQ
+    double Toff[20] = {0, 588.0, 588.5, 587.95, 588.04, 587.72, 587.92, 587.9, 587.9, 588.66, 588.80, 588.67, 588.64, 588.75, 588.47, 588.65, 588.65, 588.67, 589.05, 590.3};
+
     if (Create == true){
 
         hToff13 = new TH2F("Toff13","Toff13",binx ,xmin[0] , xmax[0], biny, ymin[0], ymax[0]);
@@ -69,6 +81,12 @@ void ToffGenerator(bool Create = true ){
         hToff23 = new TH2F("Toff23","Toff23",binx ,xmin[2] , xmax[2], biny, ymin[2], ymax[2]);
         hToff24 = new TH2F("Toff24","Toff24",binx ,xmin[3] , xmax[3], biny, ymin[3], ymax[3]);
 
+        hToffOnline13 = new TH2F("ToffOnline13","ToffOnline13",binx ,xmin[0] , xmax[0], biny, ymin[0], ymax[0]);
+        hToffOnline14 = new TH2F("ToffOnline14","ToffOnline14",binx ,xmin[1] , xmax[1], biny, ymin[1], ymax[1]);
+        hToffOnline23 = new TH2F("ToffOnline23","ToffOnline23",binx ,xmin[2] , xmax[2], biny, ymin[2], ymax[2]);
+        hToffOnline24 = new TH2F("ToffOnline24","ToffOnline24",binx ,xmin[3] , xmax[3], biny, ymin[3], ymax[3]);
+
+
         //===========================================================================================================
         //                            Loop on entries
         //===========================================================================================================
@@ -94,26 +112,29 @@ void ToffGenerator(bool Create = true ){
             M14 = Time->GetMWPC14Mult();
             M23 = Time->GetMWPC23Mult();
             M24 = Time->GetMWPC24Mult();
-
-
+            
 
             if (M13 == 2 && (abs(S13[0]-S13[1]) == 1)){
                 vector<int> Pos = SortSection(S13);
                 hToff13->Fill(S13[0],Time->GetTime_MWPC13(Pos[0]) - Time->GetTime_MWPC13(Pos[1])); 
+                hToffOnline13->Fill(S13[0],(Time->GetTime_MWPC13(Pos[0]) - Toff[S13[0]]) -( Time->GetTime_MWPC13(Pos[1])  -Toff[S13[1]]  )   ); 
             }
             if (M23 == 2 && (abs(S23[0]-S23[1]) == 1)){
                 vector<int> Pos = SortSection(S23);
                 hToff23->Fill(S23[0],Time->GetTime_MWPC23(Pos[0]) - Time->GetTime_MWPC23(Pos[1])); 
+                hToffOnline23->Fill(S23[0],(Time->GetTime_MWPC23(Pos[0]) - Toff[S23[0]]) -( Time->GetTime_MWPC23(Pos[1])  -Toff[S23[1]]  )   ); 
             }
 
             if (M14 == 2 && (abs(S14[0]-S14[1]) == 1)){
                 vector<int> Pos = SortSection(S14);
                 hToff14->Fill(S14[0],Time->GetTime_MWPC14(Pos[0]) - Time->GetTime_MWPC14(Pos[1])); 
+                hToffOnline14->Fill(S14[0],(Time->GetTime_MWPC14(Pos[0]) - Toff[S14[0]]) -( Time->GetTime_MWPC14(Pos[1])  -Toff[S14[1]]  )   ); 
             }
 
             if (M24 == 2 && (abs(S24[0]-S24[1]) == 1)){
                 vector<int> Pos = SortSection(S24);
                 hToff24->Fill(S24[0],Time->GetTime_MWPC24(Pos[0]) - Time->GetTime_MWPC24(Pos[1])); 
+                hToffOnline24->Fill(S24[0],(Time->GetTime_MWPC24(Pos[0]) - Toff[S24[0]]) -( Time->GetTime_MWPC24(Pos[1])  -Toff[S24[1]]  )   ); 
             }
         } // End loop event
 
@@ -122,6 +143,11 @@ void ToffGenerator(bool Create = true ){
         hToff14->Write();
         hToff23->Write();
         hToff24->Write();
+        
+        hToffOnline13->Write();
+        hToffOnline14->Write();
+        hToffOnline23->Write();
+        hToffOnline24->Write();
     }// end if create
 
     else {
@@ -131,6 +157,12 @@ void ToffGenerator(bool Create = true ){
         hToff14 = (TH2F*)in->Get("Toff14");
         hToff23 = (TH2F*)in->Get("Toff23");
         hToff24 = (TH2F*)in->Get("Toff24");
+
+        hToffOnline13 = (TH2F*)in->Get("ToffOnline13");
+        hToffOnline14 = (TH2F*)in->Get("ToffOnline14");
+        hToffOnline23 = (TH2F*)in->Get("ToffOnline23");
+        hToffOnline24 = (TH2F*)in->Get("ToffOnline24");
+
     }
 
     int MinX = 2;
@@ -419,39 +451,49 @@ void ToffGenerator(bool Create = true ){
     //===========================================================================================================
 
     TCanvas *c1 = new TCanvas("c1","c1");
-    c1->Divide(2);
+    c1->Divide(3);
 
     c1->cd(1);
     hToff13->Draw("colz");
     c1->cd(2);
     hCorrToff13->Draw("colz");
+    c1->cd(3);
+    hToffOnline13->Draw("colz");
+
 
     TCanvas *c2 = new TCanvas("c2","c2");
-    c2->Divide(2);
+    c2->Divide(3);
 
     c2->cd(1);
     hToff23->Draw("colz");
     c2->cd(2);
     hCorrToff23->Draw("colz");
+    c2->cd(3);
+    hToffOnline23->Draw("colz");
 
 
 
     TCanvas *c3 = new TCanvas("c3","c3");
-    c3->Divide(2);
+    c3->Divide(3);
 
     c3->cd(1);
     hToff14->Draw("colz");
     c3->cd(2);
     hCorrToff14->Draw("colz");
+    c3->cd(3);
+    hToffOnline14->Draw("colz");
 
 
     TCanvas *c4 = new TCanvas("c4","c4");
-    c4->Divide(2);
+    c4->Divide(3);
 
     c4->cd(1);
     hToff24->Draw("colz");
     c4->cd(2);
     hCorrToff24->Draw("colz");
+    c4->cd(3);
+    hToffOnline24->Draw("colz");
+
 }
 
 vector<int> SortSection(UShort_t STargFocal[2]){
diff --git a/Projects/AlPhaPha/conversion/2024/convert.C b/Projects/AlPhaPha/conversion/2024/convert.C
index 7346962e6..d526162f3 100644
--- a/Projects/AlPhaPha/conversion/2024/convert.C
+++ b/Projects/AlPhaPha/conversion/2024/convert.C
@@ -86,6 +86,7 @@ void convert(int run=204){
     for (int i=0; i<MTOF_FP0_T0VM;i++){
         m_time->SetTS_MWPC13(MTOF_FP0_T0VTS[i]); 
         m_time->SetTime_MWPC13(MTOF_FP0_T0V[i]); 
+        m_time->SetSection_MWPC3(MTOF_FP0_T0VN[i]); 
     }
     for (int i=0; i<MTOF_FP0_T1VM;i++){
         m_time->SetTS_MWPC14(MTOF_FP0_T1VTS[i]);
@@ -95,6 +96,7 @@ void convert(int run=204){
     for (int i=0; i<MTOF_FP1_T0VM;i++){
         m_time->SetTS_MWPC23(MTOF_FP1_T0VTS[i]); 
         m_time->SetTime_MWPC23(MTOF_FP1_T0V[i]); 
+        m_time->SetSection_MWPC3(MTOF_FP1_T0VN[i]); 
     }
 
     for (int i=0; i<MTOF_FP1_T1VM;i++){
-- 
GitLab