From b83e56959ac565fca01a07d15feea32a7629d543 Mon Sep 17 00:00:00 2001
From: moukaddam <mhd.moukaddam@gmail.com>
Date: Tue, 6 Dec 2016 12:12:31 +0000
Subject: [PATCH] Adding variables/functions to handle time from TACS

---
 NPLib/Detectors/FPDTamu/TFPDTamuPhysics.cxx | 27 ++++++++++++++++++---
 NPLib/Detectors/FPDTamu/TFPDTamuPhysics.h   |  5 ++--
 NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx   | 11 +++++++++
 NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h     |  1 +
 4 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.cxx b/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.cxx
index 8f420a48c..378cc86c3 100644
--- a/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.cxx
+++ b/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.cxx
@@ -99,7 +99,7 @@ void TFPDTamuPhysics::BuildPhysicalEvent() {
 
    unsigned int mysizeT = m_PreTreatedData->Get_Micro_Time_Mult();
     for (UShort_t t = 0; t< mysizeT ; t++) {
-      MicroTime.push_back(m_EventData->Get_Micro_Time(t));
+      MicroTimeOR.push_back(m_EventData->Get_Micro_Time(t));
     }
 
    //AWire
@@ -203,6 +203,23 @@ void TFPDTamuPhysics::BuildPhysicalEvent() {
     //m_PreTreatedData->Dump();
     //cin.get();
   }
+
+  //separate Left and right detectors 
+  vector<double> PlastRightTime, PlastLeftTime;
+  mysizeT = m_PreTreatedData->Get_Plast_Time_Mult();
+  for (UShort_t t = 0; t < mysizeT ; t++) {
+    //collect info
+    int side = m_PreTreatedData->Get_Plast_T_DetectorSide(t);
+    double time = m_PreTreatedData->Get_Plast_Time(t);
+    // skip values lower than a certain threshold
+    if (time<0) continue;  
+    //redistribute
+    if (side==1)
+      PlastRightTime.push_back(time);
+    else
+      PlastLeftTime.push_back(time);
+  } 
+
 /*
   //model
   // match energy and time together
@@ -494,7 +511,7 @@ void TFPDTamuPhysics::Clear() {
   MicroPositionZ.clear();
   MicroCharge.clear();
   MicroEnergy.clear();
-  MicroTime.clear();
+  MicroTimeOR.clear();
   //Avalanche wire
   AWireDetNumber.clear();
   AWireLeftCharge.clear();
@@ -504,11 +521,11 @@ void TFPDTamuPhysics::Clear() {
   //Plastic scintillator
   PlastLeftCharge.clear();
   PlastRightCharge.clear();
+  PlastTimeLeft.clear();
+  PlastTimeRight.clear();
   PlastCharge.clear();
   PlastPositionX.clear();
   PlastPositionZ.clear();
-  PlastTime.clear();
-
   //Calculated 
   PlastPositionX_AW = -99 ; //from AWire and Plastic Z
   IonDirection.SetXYZ(0,0,0); // from AWire
@@ -1138,6 +1155,8 @@ void TFPDTamuPhysics::InitializeRootInputPhysics() {
   //Plastic scintillator
   inputChain->SetBranchStatus( "PlastLeftCharge" , true );
   inputChain->SetBranchStatus( "PlastRightCharge" , true );
+  inputChain->SetBranchStatus( "PlastLeftTime" , true );
+  inputChain->SetBranchStatus( "PlastRightTime" , true );
   inputChain->SetBranchStatus( "PlastCharge" , true );
   inputChain->SetBranchStatus( "PlastPositionX" , true );
   inputChain->SetBranchStatus( "PlastPositionZ" , true );
diff --git a/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.h b/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.h
index d7e34f0b8..7306c39e4 100644
--- a/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.h
+++ b/NPLib/Detectors/FPDTamu/TFPDTamuPhysics.h
@@ -77,7 +77,7 @@ class TFPDTamuPhysics : public TObject, public NPL::VDetector {
   vector<double> MicroPositionZ;
   vector<double> MicroCharge;
   vector<double> MicroEnergy;
-  vector<double> MicroTime;
+  vector<double> MicroTimeOR;
   //Avalanche wire
   vector<int>    AWireDetNumber;
   vector<double> AWireLeftCharge;
@@ -87,10 +87,11 @@ class TFPDTamuPhysics : public TObject, public NPL::VDetector {
   //Plastic scintillator
   vector<double> PlastLeftCharge;
   vector<double> PlastRightCharge;
+  vector<double> PlastTimeLeft;
+  vector<double> PlastTimeRight;
   vector<double> PlastCharge;
   vector<double> PlastPositionX;
   vector<double> PlastPositionZ;
-  vector<double> PlastTime;
 
   //Calculated AWire and Plastic
   double   PlastPositionX_AW;
diff --git a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx
index 09cb38f8a..bfa8421d0 100644
--- a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx
+++ b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.cxx
@@ -97,6 +97,11 @@ void TGeTAMUPhysics::BuildPhysicalEvent(){
     AddBack_Crystal.push_back(clv_crystal[clv]);
     AddBack_Segment.push_back(clv_segment[clv]);
   }
+
+//Fill the time OR
+for (unsigned i = 0 ; i < m_PreTreatedData->GetMultiplicityCoreT(); i++)
+  GeTimeOR.push_back(m_PreTreatedData->GetCoreTime(i));
+
 }
 
 /////////////////////////////////////////////////
@@ -108,6 +113,7 @@ void TGeTAMUPhysics::PreTreat(){
   double Eraw,Energy;
   double Traw,Time;
   int clover, crystal, segment;
+
   for(unsigned int i = 0 ; i < mysizeE ; i++){
     Eraw = m_EventData->GetCoreEnergy(i);
     if(Eraw>0){
@@ -118,6 +124,7 @@ void TGeTAMUPhysics::PreTreat(){
       m_PreTreatedData->SetCoreE(clover,crystal,Energy);
     }
   }
+
   for(unsigned int i = 0 ; i < mysizeT ; i++){
     Traw = m_EventData->GetCoreTime(i);
     if(Traw>0){
@@ -140,6 +147,7 @@ void TGeTAMUPhysics::PreTreat(){
       m_PreTreatedData->SetSegmentE(clover,crystal,Energy);
     }
   }
+
  mysizeT = m_EventData->GetMultiplicitySegmentT();
   for(unsigned int i = 0 ; i < mysizeT ; i++){
     Traw = m_EventData->GetSegmentTime(i);
@@ -151,6 +159,7 @@ void TGeTAMUPhysics::PreTreat(){
       m_PreTreatedData->SetSegmentT(clover,crystal,Time);
     }
   }
+
 }
 
 /////////////////////////////////////////////////
@@ -374,6 +383,8 @@ void TGeTAMUPhysics::Clear() {
   AddBack_Clover.clear();
   AddBack_Crystal.clear();
   AddBack_Segment.clear();
+  AddBack_T.clear();
+  GeTimeOR.clear();
 }
 ///////////////////////////////////////////////////////////////////////////  
 void TGeTAMUPhysics::ClearEventData() {
diff --git a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h
index fd4157ef4..e2e9a7748 100644
--- a/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h
+++ b/NPLib/Detectors/GeTAMU/TGeTAMUPhysics.h
@@ -95,6 +95,7 @@ class TGeTAMUPhysics :  public TObject, public NPL::VDetector{
     vector<int> AddBack_Clover;
     vector<int> AddBack_Crystal;
     vector<int> AddBack_Segment;
+    vector<double> GeTimeOR; // OR of all time signals, can be used for array or or clover only
 
   private: // use for anlysis
    
-- 
GitLab