From 13c301075349ecb6f770cbee8decfc5df88c0c9c Mon Sep 17 00:00:00 2001
From: hallc-online <hallconline@gmail.com>
Date: Tue, 6 Mar 2018 17:21:34 -0500
Subject: [PATCH] Updated THcCherenkov.cxx and h

Add new ntuple variables
goodAdcMult == the number of hits in raw ADc for that channel
goodAdcHitUsed == which hit number of the raw ADC hits passed the
                      the ADC time window cut

Modified fAdcTimeWindowMin  and fAdcTimeWindowMax to be arrays
  that are the size of the number of Cerenkov pmts.
---
 src/THcCherenkov.cxx | 22 +++++++++++++++++-----
 src/THcCherenkov.h   |  6 ++++--
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/THcCherenkov.cxx b/src/THcCherenkov.cxx
index 8486c08..1ac7a34 100644
--- a/src/THcCherenkov.cxx
+++ b/src/THcCherenkov.cxx
@@ -64,6 +64,8 @@ THcCherenkov::THcCherenkov( const char* name, const char* description,
   fNumTracksFired     = vector<Int_t>    (MaxNumCerPmt, 0.0);
   fNpe                = vector<Double_t> (MaxNumCerPmt, 0.0);
   fGoodAdcPed         = vector<Double_t> (MaxNumCerPmt, 0.0);
+  fGoodAdcMult         = vector<Double_t> (MaxNumCerPmt, 0.0);
+  fGoodAdcHitUsed         = vector<Double_t> (MaxNumCerPmt, 0.0);
   fGoodAdcPulseInt    = vector<Double_t> (MaxNumCerPmt, 0.0);
   fGoodAdcPulseIntRaw = vector<Double_t> (MaxNumCerPmt, 0.0);
   fGoodAdcPulseAmp    = vector<Double_t> (MaxNumCerPmt, 0.0);
@@ -204,7 +206,8 @@ Int_t THcCherenkov::ReadDatabase( const TDatime& date )
   fPedLimit = new Int_t[fNelem];
   fGain     = new Double_t[fNelem];
   fPedMean  = new Double_t[fNelem];
-
+  fAdcTimeWindowMin =  new Double_t[fNelem];
+  fAdcTimeWindowMax=  new Double_t[fNelem];
   // Region parameters
   fRegionsValueMax = fNRegions * 8;
   fRegionValue     = new Double_t[fRegionsValueMax];
@@ -223,14 +226,17 @@ Int_t THcCherenkov::ReadDatabase( const TDatime& date )
     {"_mirror_zpos",      &fMirrorZPos,       kDouble},
     {"_npe_thresh",       &fNpeThresh,        kDouble},
     {"_debug_adc",        &fDebugAdc,         kInt, 0, 1},
-    {"_adcTimeWindowMin", &fAdcTimeWindowMin, kDouble},
-    {"_adcTimeWindowMax", &fAdcTimeWindowMax, kDouble},
+    {"_adcTimeWindowMin", fAdcTimeWindowMin, kDouble,(UInt_t) fNelem,1},
+    {"_adcTimeWindowMax", fAdcTimeWindowMax, kDouble, (UInt_t) fNelem,1},
     {"_adc_tdc_offset",   &fAdcTdcOffset,     kDouble, 0, 1},
     {"_region",           &fRegionValue[0],   kDouble,  (UInt_t) fRegionsValueMax},
     {"_adcrefcut",        &fADC_RefTimeCut,   kInt,    0, 1},
     {0}
   };
-
+  for (Int_t i=0;i<fNelem;i++) {
+    fAdcTimeWindowMin[i]=-1000.;
+    fAdcTimeWindowMax[i]=1000.;
+  }
   fDebugAdc = 0; // Set ADC debug parameter to false unless set in parameter file
   fAdcTdcOffset = 0.0;
   fADC_RefTimeCut = 0;
@@ -302,6 +308,8 @@ Int_t THcCherenkov::DefineVariables( EMode mode )
     {"npeSum",       "Total Number of PEs",            "fNpeSum"},
 
     {"goodAdcPed",          "Good ADC pedestals",           "fGoodAdcPed"},
+    {"goodAdcMult",          "Good ADC Multiplicity",           "fGoodAdcMult"},
+    {"goodAdcHitUsed",          "Good ADC Hit Used",           "fGoodAdcHitUsed"},
     {"goodAdcPulseInt",     "Good ADC pulse integrals",     "fGoodAdcPulseInt"},
     {"goodAdcPulseIntRaw",  "Good ADC raw pulse integrals", "fGoodAdcPulseIntRaw"},
     {"goodAdcPulseAmp",     "Good ADC pulse amplitudes",    "fGoodAdcPulseAmp"},
@@ -349,6 +357,8 @@ void THcCherenkov::Clear(Option_t* opt)
     fNumTracksFired.at(ielem) = 0;
   for (UInt_t ielem = 0; ielem < fGoodAdcPed.size(); ielem++) {
     fGoodAdcPed.at(ielem)         = 0.0;
+    fGoodAdcMult.at(ielem)         = 0.0;
+    fGoodAdcHitUsed.at(ielem)         = 0.0;
     fGoodAdcPulseInt.at(ielem)    = 0.0;
     fGoodAdcPulseIntRaw.at(ielem) = 0.0;
     fGoodAdcPulseAmp.at(ielem)    = 0.0;
@@ -438,11 +448,13 @@ Int_t THcCherenkov::CoarseProcess( TClonesArray&  )
     Double_t pulseTime    = ((THcSignalHit*) frAdcPulseTime->ConstructedAt(ielem))->GetData();
    Double_t adctdcdiffTime = StartTime-pulseTime;
      Bool_t   errorFlag    = ((THcSignalHit*) fAdcErrorFlag->ConstructedAt(ielem))->GetData();
-    Bool_t   pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin && adctdcdiffTime < fAdcTimeWindowMax;
+    Bool_t   pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin[npmt] && adctdcdiffTime < fAdcTimeWindowMax[npmt];
 
     // By default, the last hit within the timing cut will be considered "good"
     if (!errorFlag && pulseTimeCut) {
       fGoodAdcPed.at(npmt)         = pulsePed;
+      fGoodAdcHitUsed.at(npmt)         = ielem+1;
+      fGoodAdcMult.at(npmt)         =frAdcPulseInt->GetEntries() ;
       fGoodAdcPulseInt.at(npmt)    = pulseInt;
       fGoodAdcPulseIntRaw.at(npmt) = pulseIntRaw;
       fGoodAdcPulseAmp.at(npmt)    = pulseAmp;
diff --git a/src/THcCherenkov.h b/src/THcCherenkov.h
index 6b852ec..47845c5 100644
--- a/src/THcCherenkov.h
+++ b/src/THcCherenkov.h
@@ -66,6 +66,8 @@ class THcCherenkov : public THaNonTrackingDetector, public THcHitList {
   vector<Int_t>    fNumTracksMatched;
   vector<Int_t>    fNumTracksFired;
   vector<Double_t> fGoodAdcPed;
+  vector<Double_t> fGoodAdcMult;
+  vector<Double_t> fGoodAdcHitUsed;
   vector<Double_t> fGoodAdcPulseInt;
   vector<Double_t> fGoodAdcPulseIntRaw;
   vector<Double_t> fGoodAdcPulseAmp;
@@ -87,8 +89,8 @@ class THcCherenkov : public THaNonTrackingDetector, public THcHitList {
   Double_t  fXAtCer;
   Double_t  fYAtCer;
   Double_t  fNpeThresh;
-  Double_t  fAdcTimeWindowMin;
-  Double_t  fAdcTimeWindowMax;
+  Double_t*  fAdcTimeWindowMin;
+  Double_t*  fAdcTimeWindowMax;
   Double_t  fAdcTdcOffset;
   Double_t* fRegionValue;
 
-- 
GitLab