From f64afe8cda9babdb808f7952d33d36fe596c07d8 Mon Sep 17 00:00:00 2001
From: hallc-online <hallc-online@jlab.org>
Date: Tue, 4 Apr 2017 17:29:01 -0400
Subject: [PATCH] Fix problem in THcAerogel::CoarseProcess with fNpeSum

The line fNpeSum += fNegNpeSum
was basically double counting the fNegNpeSum
Same for fNpeSum += fPosNpeSum
since they were in a loop over Neg and Pos hits.

Just set
fNpeSum = fNegNpeSum + fPosNpeSum
after the two loops over Neg and Pos hits
---
 src/THcAerogel.cxx | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/THcAerogel.cxx b/src/THcAerogel.cxx
index 1105450..78e4b75 100644
--- a/src/THcAerogel.cxx
+++ b/src/THcAerogel.cxx
@@ -645,9 +645,8 @@ Int_t THcAerogel::CoarseProcess( TClonesArray&  ) //tracks
     	fGoodPosAdcPulseTime.at(npmt)   = pulseTime;
 
     	fPosNpe.at(npmt) = fPosGain[npmt]*fGoodPosAdcPulseInt.at(npmt);
-	fPosNpeSum += fPosNpe.at(npmt);
-    	fNpeSum += fPosNpeSum;
-
+ 	fPosNpeSum += fPosNpe.at(npmt);
+ 
 	fTotNumGoodAdcHits++;
     	fTotNumGoodPosAdcHits++;
     	fNumGoodPosAdcHits.at(npmt) = npmt + 1;
@@ -675,15 +674,16 @@ Int_t THcAerogel::CoarseProcess( TClonesArray&  ) //tracks
     	fGoodNegAdcPulseTime.at(npmt)   = pulseTime;
 
     	fNegNpe.at(npmt) = fNegGain[npmt]*fGoodNegAdcPulseInt.at(npmt);
-	fNegNpeSum += fNegNpe.at(npmt);
-    	fNpeSum += fNegNpeSum;
-
+ 	fNegNpeSum += fNegNpe.at(npmt);
+ 
 	fTotNumGoodAdcHits++;
    	fTotNumGoodNegAdcHits++;
     	fNumGoodNegAdcHits.at(npmt) = npmt + 1;
       }
     }
 
+       fNpeSum = fNegNpeSum + fPosNpeSum;
+
     for(Int_t ihit=0; ihit < fNhits; ihit++) {
 
       Int_t nPosTDCHits = 0;
-- 
GitLab