From 2a597eccf82f8eaf90c30ca3b603fd3cbbe9114f Mon Sep 17 00:00:00 2001
From: "Stephen A. Wood" <saw@jlab.org>
Date: Wed, 6 Dec 2017 10:28:21 -0500
Subject: [PATCH] Suppress missing ref time messages for THcTrigDet when not
 expected.   To do this suppression, a trigger detector object needs to know
 the   name of spectrometer it is associated with.  By default it will get  
 this name from the first character of the it's own name.  This can   be
 overridden with the SetSpectName method.

---
 src/THcTrigDet.cxx | 23 +++++++++++++++++++++--
 src/THcTrigDet.h   |  5 +++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/THcTrigDet.cxx b/src/THcTrigDet.cxx
index 455367a..8c94610 100644
--- a/src/THcTrigDet.cxx
+++ b/src/THcTrigDet.cxx
@@ -129,7 +129,11 @@ THcTrigDet::THcTrigDet(
   fAdcPedRaw(), fAdcPulseIntRaw(), fAdcPulseAmpRaw(), fAdcPulseTimeRaw(),
   fAdcPed(), fAdcPulseInt(), fAdcPulseAmp(), fAdcPulseTime(),
   fTdcMultiplicity(), fAdcMultiplicity()
-{}
+{
+  // Guess at spectrometer name that this trigger detector is associated with
+  // Can override with SetSpectName
+  fSpectName = name[0];
+}
 
 
 THcTrigDet::~THcTrigDet() {}
@@ -178,6 +182,12 @@ THaAnalysisObject::EStatus THcTrigDet::Init(const TDatime& date) {
   // printf(" Init trig det hitlist\n");
   InitHitList(fDetMap, "THcTrigRawHit", 100);
 
+  fPresentP = 0;
+  THaVar* vpresent = gHaVars->Find(Form("%s.present",fSpectName.Data()));
+  if(vpresent) {
+    fPresentP = (Bool_t *) vpresent->GetValuePointer();
+  }
+
   fStatus = kOK;
   return fStatus;
 }
@@ -208,7 +218,11 @@ void THcTrigDet::Clear(Option_t* opt) {
 
 Int_t THcTrigDet::Decode(const THaEvData& evData) {
   // Decode raw data for this event.
-  Int_t numHits = DecodeToHitList(evData);
+  Bool_t present = kTRUE;	// Suppress reference time warnings
+  if(fPresentP) {		// if this spectrometer not part of trigger
+    present = *fPresentP;
+  }
+  Int_t numHits = DecodeToHitList(evData, !present);
 
   // Process each hit and fill variables.
   Int_t iHit = 0;
@@ -426,6 +440,11 @@ Int_t THcTrigDet::DefineVariables(THaAnalysisObject::EMode mode) {
 
   return DefineVarsFromList(vars.data(), mode);
 }
+void THcTrigDet::SetSpectName( const char* name)
+{
+  fSpectName = name;
+}
+
 
 
 ClassImp(THcTrigDet)
diff --git a/src/THcTrigDet.h b/src/THcTrigDet.h
index c2d4a90..b6144f2 100644
--- a/src/THcTrigDet.h
+++ b/src/THcTrigDet.h
@@ -26,6 +26,8 @@ class THcTrigDet : public THaDetector, public THcHitList {
     virtual void Clear(Option_t* opt="");
     Int_t Decode(const THaEvData& evData);
 
+    virtual void SetSpectName( const char* name);
+
   protected:
     void Setup(const char* name, const char* description);
     virtual Int_t ReadDatabase(const TDatime& date);
@@ -62,6 +64,9 @@ class THcTrigDet : public THaDetector, public THcHitList {
     Int_t fTdcMultiplicity[fMaxTdcChannels];
     Int_t fAdcMultiplicity[fMaxAdcChannels];
 
+    TString fSpectName;
+    Bool_t* fPresentP;
+
   private:
     THcTrigDet();
     ClassDef(THcTrigDet, 0);
-- 
GitLab