From 0b50c1e951f214fd59737d615bb01441de1e4f5e Mon Sep 17 00:00:00 2001
From: Jure Bericic <bericic@jlab.org>
Date: Tue, 17 Jan 2017 16:18:11 -0500
Subject: [PATCH] Added const modifier to Get methods of the THcRawAdcHit.
 Added channel to time coefficients to the Adc and Tdc raw hit classes.

---
 src/THcRawAdcHit.cxx | 46 +++++++++++++++++++++++++-------------------
 src/THcRawAdcHit.h   | 45 ++++++++++++++++++++++---------------------
 src/THcRawTdcHit.cxx |  1 +
 src/THcRawTdcHit.h   |  2 ++
 4 files changed, 52 insertions(+), 42 deletions(-)

diff --git a/src/THcRawAdcHit.cxx b/src/THcRawAdcHit.cxx
index 03e12f9..0eea62f 100644
--- a/src/THcRawAdcHit.cxx
+++ b/src/THcRawAdcHit.cxx
@@ -18,6 +18,7 @@ THcRawAdcHit::THcRawAdcHit() :
   TObject(),
   fNPedestalSamples(4), fNPeakSamples(9),
   fPeakPedestalRatio(1.0*fNPeakSamples/fNPedestalSamples),
+  fChannelToTimeFactor(0.0625),
   fAdc(), fAdcTime(), fAdcPedestal(), fAdcPulse(), fAdcSample(),
   fHasMulti(kFALSE), fNPulses(0), fNSamples(0)
 {}
@@ -105,7 +106,7 @@ void THcRawAdcHit::SetDataTimePedestalPeak(
 }
 
 
-Int_t THcRawAdcHit::GetRawData(UInt_t iPulse) {
+Int_t THcRawAdcHit::GetRawData(UInt_t iPulse) const {
   if (iPulse >= fNPulses && iPulse != 0) {
     TString msg = TString::Format(
       "`THcRawAdcHit::GetRawData`: requested pulse %d where only %d pulses available!",
@@ -122,7 +123,7 @@ Int_t THcRawAdcHit::GetRawData(UInt_t iPulse) {
 }
 
 
-Int_t THcRawAdcHit::GetAdcTime(UInt_t iPulse) {
+Int_t THcRawAdcHit::GetAdcTime(UInt_t iPulse) const {
   if (iPulse >= fNPulses && iPulse != 0) {
     TString msg = TString::Format(
       "`THcRawAdcHit::GetAdcTime`: requested pulse %d where only %d pulses available!",
@@ -139,7 +140,7 @@ Int_t THcRawAdcHit::GetAdcTime(UInt_t iPulse) {
 }
 
 
-Int_t THcRawAdcHit::GetAdcPedestal(UInt_t iPulse) {
+Int_t THcRawAdcHit::GetAdcPedestal(UInt_t iPulse) const {
   if (iPulse >= fNPulses && iPulse != 0) {
     TString msg = TString::Format(
       "`THcRawAdcHit::GetAdcPedestal`: requested pulse %d where only %d pulses available!",
@@ -156,7 +157,7 @@ Int_t THcRawAdcHit::GetAdcPedestal(UInt_t iPulse) {
 }
 
 
-Int_t THcRawAdcHit::GetAdcPulse(UInt_t iPulse) {
+Int_t THcRawAdcHit::GetAdcPulse(UInt_t iPulse) const {
   if (iPulse >= fNPulses && iPulse != 0) {
     TString msg = TString::Format(
       "`THcRawAdcHit::GetAdcPulse`: requested pulse %d where only %d pulses available!",
@@ -173,7 +174,7 @@ Int_t THcRawAdcHit::GetAdcPulse(UInt_t iPulse) {
 }
 
 
-Int_t THcRawAdcHit::GetSample(UInt_t iSample) {
+Int_t THcRawAdcHit::GetSample(UInt_t iSample) const {
   if (iSample >= fNSamples && iSample != 0) {
     TString msg = TString::Format(
       "`THcRawAdcHit::GetSample`: requested sample %d where only %d sample available!",
@@ -190,7 +191,7 @@ Int_t THcRawAdcHit::GetSample(UInt_t iSample) {
 }
 
 
-Double_t THcRawAdcHit::GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh) {
+Double_t THcRawAdcHit::GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh) const {
   if (iSampleHigh >= fNSamples || iSampleLow >= fNSamples) {
     TString msg = TString::Format(
       "`THcRawAdcHit::GetAverage`: not this many samples available!"
@@ -207,7 +208,7 @@ Double_t THcRawAdcHit::GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh) {
 }
 
 
-Int_t THcRawAdcHit::GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh) {
+Int_t THcRawAdcHit::GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh) const {
   if (iSampleHigh >= fNSamples || iSampleLow >= fNSamples) {
     TString msg = TString::Format(
       "`THcRawAdcHit::GetAverage`: not this many samples available!"
@@ -226,64 +227,69 @@ Int_t THcRawAdcHit::GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh) {
 
 Double_t THcRawAdcHit::GetData(
   UInt_t iPedLow, UInt_t iPedHigh, UInt_t iIntLow, UInt_t iIntHigh
-) {
+) const {
   return
     GetIntegral(iIntLow, iIntHigh)
     - GetAverage(iPedHigh, iPedLow) * (iIntHigh - iIntLow + 1);
 }
 
 
-UInt_t THcRawAdcHit::GetNPulses() {
+UInt_t THcRawAdcHit::GetNPulses() const {
   return fNPulses;
 }
 
 
-UInt_t THcRawAdcHit::GetNSamples() {
+UInt_t THcRawAdcHit::GetNSamples() const {
   return fNSamples;
 }
 
 
-Bool_t THcRawAdcHit::HasMulti() {
+Bool_t THcRawAdcHit::HasMulti() const {
   return fHasMulti;
 }
 
 
-Int_t THcRawAdcHit::GetPedRaw() {
+Int_t THcRawAdcHit::GetPedRaw() const {
   return fAdcPedestal[0];
 }
 
 
-Int_t THcRawAdcHit::GetPulseIntRaw(UInt_t iPulse) {
+Int_t THcRawAdcHit::GetPulseIntRaw(UInt_t iPulse) const {
   return fAdc[iPulse];
 }
 
 
-Int_t THcRawAdcHit::GetPulseAmpRaw(UInt_t iPulse) {
+Int_t THcRawAdcHit::GetPulseAmpRaw(UInt_t iPulse) const {
   return fAdcPulse[iPulse];
 }
 
 
-Int_t THcRawAdcHit::GetPulseTimeRaw(UInt_t iPulse) {
+Int_t THcRawAdcHit::GetPulseTimeRaw(UInt_t iPulse) const {
   return fAdcTime[iPulse];
 }
 
 
-Double_t THcRawAdcHit::GetPed() {
+Double_t THcRawAdcHit::GetPed() const {
   return static_cast<Double_t>(fAdcPedestal[0])/static_cast<Double_t>(fNPedestalSamples);
 }
 
 
-Double_t THcRawAdcHit::GetPulseInt(UInt_t iPulse) {
+Double_t THcRawAdcHit::GetPulseInt(UInt_t iPulse) const {
   return static_cast<Double_t>(fAdc[iPulse]) - static_cast<Double_t>(fAdcPedestal[0])*fPeakPedestalRatio;
 }
 
 
-Double_t THcRawAdcHit::GetPulseAmp(UInt_t iPulse) {
+Double_t THcRawAdcHit::GetPulseAmp(UInt_t iPulse) const {
   return static_cast<Double_t>(fAdcPulse[iPulse]) - static_cast<Double_t>(fAdcPedestal[0])/static_cast<Double_t>(fNPedestalSamples);
 }
 
 
-Int_t THcRawAdcHit::GetSampleIntRaw() {
+//Int_t THcRawAdcHit::GetPulseTime(UInt_t iPulse) const {
+//  return static_cast<Double_t>(fAdcTime[iPulse]);
+//}
+
+
+Int_t THcRawAdcHit::GetSampleIntRaw() const {
   Int_t integral = 0;
 
   for (UInt_t iSample=0; iSample<fNSamples; ++iSample) {
@@ -294,7 +300,7 @@ Int_t THcRawAdcHit::GetSampleIntRaw() {
 }
 
 
-Double_t THcRawAdcHit::GetSampleInt() {
+Double_t THcRawAdcHit::GetSampleInt() const {
   return static_cast<Double_t>(GetSampleIntRaw()) - GetPed()*static_cast<Double_t>(fNSamples);
 }
 
diff --git a/src/THcRawAdcHit.h b/src/THcRawAdcHit.h
index 42c812d..e824dd5 100644
--- a/src/THcRawAdcHit.h
+++ b/src/THcRawAdcHit.h
@@ -18,35 +18,35 @@ class THcRawAdcHit : public TObject {
       Int_t data, Int_t time, Int_t pedestal, Int_t peak
     );
 
-    Int_t GetRawData(UInt_t iPulse=0);
-    Int_t GetAdcTime(UInt_t iPulse=0);
-    Int_t GetAdcPedestal(UInt_t iPulse=0);
-    Int_t GetAdcPulse(UInt_t iPulse=0);
-    Int_t GetSample(UInt_t iSample);
-
-    Double_t GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh);
-    Int_t GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh);
+    Int_t GetRawData(UInt_t iPulse=0) const;
+    Int_t GetAdcTime(UInt_t iPulse=0) const;
+    Int_t GetAdcPedestal(UInt_t iPulse=0) const;
+    Int_t GetAdcPulse(UInt_t iPulse=0) const;
+    Int_t GetSample(UInt_t iSample) const;
+
+    Double_t GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh) const;
+    Int_t GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh) const;
     Double_t GetData(
       UInt_t iPedLow, UInt_t iPedHigh, UInt_t iIntLow, UInt_t iIntHigh
-    );
+    ) const;
 
-    UInt_t GetNPulses();
-    UInt_t GetNSamples();
+    UInt_t GetNPulses() const;
+    UInt_t GetNSamples() const;
 
-    Bool_t HasMulti();
+    Bool_t HasMulti() const;
 
-    Int_t GetPedRaw();
-    Int_t GetPulseIntRaw(UInt_t iPulse=0);
-    Int_t GetPulseAmpRaw(UInt_t iPulse=0);
-    Int_t GetPulseTimeRaw(UInt_t iPulse=0);
+    Int_t GetPedRaw() const;
+    Int_t GetPulseIntRaw(UInt_t iPulse=0) const;
+    Int_t GetPulseAmpRaw(UInt_t iPulse=0) const;
+    Int_t GetPulseTimeRaw(UInt_t iPulse=0) const;
 
-    Double_t GetPed();
-    Double_t GetPulseInt(UInt_t iPulse=0);
-    Double_t GetPulseAmp(UInt_t iPulse=0);
-    //Double_t GetPulseTime(UInt_t iPulse=0);  // TODO: Figure out what to do with time.
+    Double_t GetPed() const;
+    Double_t GetPulseInt(UInt_t iPulse=0) const;
+    Double_t GetPulseAmp(UInt_t iPulse=0) const;
+    //Int_t GetPulseTime(UInt_t iPulse=0) const;
 
-    Int_t GetSampleIntRaw();
-    Double_t GetSampleInt();
+    Int_t GetSampleIntRaw() const;
+    Double_t GetSampleInt() const;
 
   protected:
     static const UInt_t fMaxNPulses = 4;
@@ -55,6 +55,7 @@ class THcRawAdcHit : public TObject {
     Int_t fNPedestalSamples;  // TODO: Get this from prestart event...
     Int_t fNPeakSamples;
     Double_t fPeakPedestalRatio;
+    Double_t fChannelToTimeFactor;
 
     Int_t fAdc[fMaxNPulses];  // TODO: Rename these...
     Int_t fAdcTime[fMaxNPulses];
diff --git a/src/THcRawTdcHit.cxx b/src/THcRawTdcHit.cxx
index 8fa1937..6850206 100644
--- a/src/THcRawTdcHit.cxx
+++ b/src/THcRawTdcHit.cxx
@@ -14,6 +14,7 @@
 
 THcRawTdcHit::THcRawTdcHit() :
   TObject(),
+  fChannelToTimeFactor(0.1),
   fTime(), fRefTime(0), fHasRefTime(kFALSE), fNHits(0)
 {}
 
diff --git a/src/THcRawTdcHit.h b/src/THcRawTdcHit.h
index e04dad3..daa7e96 100644
--- a/src/THcRawTdcHit.h
+++ b/src/THcRawTdcHit.h
@@ -26,6 +26,8 @@ class THcRawTdcHit : public TObject {
   protected:
     static const UInt_t fMaxNHits = 16;
 
+    Double_t fChannelToTimeFactor;
+
     Int_t fTime[fMaxNHits];
     Int_t fRefTime;
 
-- 
GitLab