From 1d2232e013f87be271c45c4f93267907268a5355 Mon Sep 17 00:00:00 2001
From: Mark Jones <jones@jlab.org>
Date: Thu, 23 Apr 2020 12:51:56 -0400
Subject: [PATCH] Update THcTrigDet, add RefTime

---
 src/THcTrigDet.cxx | 16 +++++++++++++---
 src/THcTrigDet.h   |  1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/THcTrigDet.cxx b/src/THcTrigDet.cxx
index 5127337..46357fd 100644
--- a/src/THcTrigDet.cxx
+++ b/src/THcTrigDet.cxx
@@ -211,7 +211,8 @@ void THcTrigDet::Clear(Option_t* opt) {
   THaAnalysisObject::Clear(opt);
 
   // Reset all data.
-  for (int i=0; i<fNumAdc; ++i) {
+  fTdcRefTime = kBig;
+ for (int i=0; i<fNumAdc; ++i) {
     fAdcPedRaw[i] = 0;
     fAdcPulseIntRaw[i] = 0;
     fAdcPulseAmpRaw[i] = 0;
@@ -272,7 +273,7 @@ Int_t THcTrigDet::Decode(const THaEvData& evData) {
     }
     else if (hit->fPlane == 2) {
       THcRawTdcHit rawTdcHit = hit->GetRawTdcHit();
-
+    if (rawTdcHit.GetNHits() >0 && rawTdcHit.HasRefTime() && fTdcRefTime == kBig) fTdcRefTime=rawTdcHit.GetRefTime() ;
       UInt_t good_hit=999;
            for (UInt_t thit=0; thit<rawTdcHit.GetNHits(); ++thit) {
 	    Int_t TestTime= rawTdcHit.GetTimeRaw(thit);
@@ -397,7 +398,16 @@ Int_t THcTrigDet::DefineVariables(THaAnalysisObject::EMode mode) {
   std::vector<TString> adcPulseIntTitle(fNumAdc), adcPulseIntVar(fNumAdc);
   std::vector<TString> adcPulseAmpTitle(fNumAdc), adcPulseAmpVar(fNumAdc);
   std::vector<TString> adcMultiplicityTitle(fNumAdc), adcMultiplicityVar(fNumAdc);
-
+  
+  TString RefTimeTitle= "TdcRefTime";
+   TString RefTimeVar= "fTdcRefTime";
+   RVarDef entryRefTime {
+      RefTimeTitle.Data(),
+      RefTimeTitle.Data(),
+      RefTimeVar.Data()
+    };
+     vars.push_back(entryRefTime);
+ 
   for (int i=0; i<fNumAdc; ++i) {
     adcPedRawTitle.at(i) = fAdcNames.at(i) + "_adcPedRaw";
     adcPedRawVar.at(i) = TString::Format("fAdcPedRaw[%d]", i);
diff --git a/src/THcTrigDet.h b/src/THcTrigDet.h
index 20b4838..dfde554 100644
--- a/src/THcTrigDet.h
+++ b/src/THcTrigDet.h
@@ -82,6 +82,7 @@ class THcTrigDet : public THaDetector, public THcHitList {
 
     Int_t fTdcMultiplicity[fMaxTdcChannels];
     Int_t fAdcMultiplicity[fMaxAdcChannels];
+    Double_t fTdcRefTime;
 
     TString fSpectName;
     std::vector<Int_t> eventtypes;
-- 
GitLab