From 0f80433b8e064610a316dfc1e324a8d815e684e4 Mon Sep 17 00:00:00 2001
From: "Stephen A. Wood" <saw@jlab.org>
Date: Thu, 30 Nov 2017 11:43:18 -0500
Subject: [PATCH] Add optional flag to THcHitList::DecodeToHitList to suppress
 warnings

---
 src/THcHitList.cxx | 46 +++++++++++++++++++++++++++-------------------
 src/THcHitList.h   |  2 +-
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/src/THcHitList.cxx b/src/THcHitList.cxx
index a48d755..a62908c 100644
--- a/src/THcHitList.cxx
+++ b/src/THcHitList.cxx
@@ -135,7 +135,7 @@ multiple signal types (e.g. ADC+, ADC-, TDC+, TDC-), or multiplehits for multihi
 The hit list is sorted (by plane, counter) after filling.
 
 */
-Int_t THcHitList::DecodeToHitList( const THaEvData& evdata ) {
+Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarnings ) {
 
   // cout << " Clearing TClonesArray " << endl;
   fRawHitList->Clear( );
@@ -235,21 +235,25 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata ) {
 	    Int_t reftime = evdata.GetData(d->crate, d->slot, d->refchan, 0);
 	    rawhit->SetReference(signal, reftime);
 	  } else {
-	    cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan <<
-	      " missing for (" << d->crate << ", " << d->slot <<
-	      ", " << chan << ")" << endl;
+	    if(!suppresswarnings) {
+	      cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan <<
+		" missing for (" << d->crate << ", " << d->slot <<
+		", " << chan << ")" << endl;
+	    }
 	  }
 	} else {
 	  if(d->refindex >=0 && d->refindex < fNRefIndex) {
 	    if(fRefIndexMaps[d->refindex].hashit) {
 	      rawhit->SetReference(signal, fRefIndexMaps[d->refindex].reftime);
 	    } else {
-	      cout << "HitList(event=" << evdata.GetEvNum() << "): refindex " << d->refindex <<
-          " (" << fRefIndexMaps[d->refindex].crate <<
-          ", " << fRefIndexMaps[d->refindex].slot <<
-          ", " << fRefIndexMaps[d->refindex].channel << ")" <<
-		" missing for (" << d->crate << ", " << d->slot <<
-		", " << chan << ")" << endl;
+	      if(!suppresswarnings) {
+		cout << "HitList(event=" << evdata.GetEvNum() << "): refindex " << d->refindex <<
+		  " (" << fRefIndexMaps[d->refindex].crate <<
+		  ", " << fRefIndexMaps[d->refindex].slot <<
+		  ", " << fRefIndexMaps[d->refindex].channel << ")" <<
+		  " missing for (" << d->crate << ", " << d->slot <<
+		  ", " << chan << ")" << endl;
+	      }
 	    }
 	  }
 	}
@@ -288,21 +292,25 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata ) {
 	    Int_t reftime = evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, d->refchan, 0);
 	    rawhit->SetReference(signal, reftime);
 	  } else {
-	    cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan <<
-	      " missing for (" << d->crate << ", " << d->slot <<
-	      ", " << chan << ")" << endl;
+	    if(!suppresswarnings) {
+	      cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan <<
+		" missing for (" << d->crate << ", " << d->slot <<
+		", " << chan << ")" << endl;
+	    }
 	  }
 	} else {
 	  if(d->refindex >=0 && d->refindex < fNRefIndex) {
 	    if(fRefIndexMaps[d->refindex].hashit) {
 	      rawhit->SetReference(signal, fRefIndexMaps[d->refindex].reftime);
 	    } else {
-	      cout << "HitList(event=" << evdata.GetEvNum() << "): refindex " << d->refindex <<
-          " (" << fRefIndexMaps[d->refindex].crate <<
-          ", " << fRefIndexMaps[d->refindex].slot <<
-          ", " << fRefIndexMaps[d->refindex].channel << ")" <<
-		" missing for (" << d->crate << ", " << d->slot <<
-		", " << chan << ")" << endl;
+	      if(!suppresswarnings) {
+		cout << "HitList(event=" << evdata.GetEvNum() << "): refindex " << d->refindex <<
+		  " (" << fRefIndexMaps[d->refindex].crate <<
+		  ", " << fRefIndexMaps[d->refindex].slot <<
+		  ", " << fRefIndexMaps[d->refindex].channel << ")" <<
+		  " missing for (" << d->crate << ", " << d->slot <<
+		  ", " << chan << ")" << endl;
+	      }
 	    }
 	  }
 	}
diff --git a/src/THcHitList.h b/src/THcHitList.h
index 9ab0722..7611e14 100644
--- a/src/THcHitList.h
+++ b/src/THcHitList.h
@@ -28,7 +28,7 @@ public:
 
   THcHitList();
 
-  virtual Int_t DecodeToHitList( const THaEvData& );
+  virtual Int_t DecodeToHitList( const THaEvData&, Bool_t suppress=kFALSE );
   void          InitHitList(THaDetMap* detmap,
 			    const char *hitclass, Int_t maxhits);
 
-- 
GitLab