From 8e059719fb13dc699b812fbdeb2f574b8cfea926 Mon Sep 17 00:00:00 2001 From: Mark Jones <jones@jlab.org> Date: Mon, 27 Apr 2020 09:35:40 -0400 Subject: [PATCH] Modify THCTrigDet::Decode Previously if none of the TDC hits was not within the time cut window the TDC value was set to 0. Now if there are TDC hits it selections the first one in the cut window. If no hit is found in the cut window then it selects the hit that is closest in time to the lower window limit. --- src/THcTrigDet.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/THcTrigDet.cxx b/src/THcTrigDet.cxx index 46357fd..18bc16e 100644 --- a/src/THcTrigDet.cxx +++ b/src/THcTrigDet.cxx @@ -275,12 +275,19 @@ Int_t THcTrigDet::Decode(const THaEvData& evData) { THcRawTdcHit rawTdcHit = hit->GetRawTdcHit(); if (rawTdcHit.GetNHits() >0 && rawTdcHit.HasRefTime() && fTdcRefTime == kBig) fTdcRefTime=rawTdcHit.GetRefTime() ; UInt_t good_hit=999; + UInt_t closest_hit=999; + Int_t TimeDiff=1000000; for (UInt_t thit=0; thit<rawTdcHit.GetNHits(); ++thit) { Int_t TestTime= rawTdcHit.GetTimeRaw(thit); + if (abs(TestTime-fTdcTimeWindowMin[cnt]) < TimeDiff) { + closest_hit=thit; + TimeDiff=abs(TestTime-fTdcTimeWindowMin[cnt]); + } if (TestTime>=fTdcTimeWindowMin[cnt]&&TestTime<=fTdcTimeWindowMax[cnt]&&good_hit==999) { good_hit=thit; } } + if (good_hit == 999 and closest_hit != 999) good_hit=closest_hit; if (good_hit<rawTdcHit.GetNHits()) { fTdcTimeRaw[cnt] = rawTdcHit.GetTimeRaw(good_hit); fTdcTime[cnt] = rawTdcHit.GetTime(good_hit)*fTdcChanperNS+fTdcOffset; -- GitLab