From 87bb8d6e3743d149b2a3fc1a63aff5b3cce14041 Mon Sep 17 00:00:00 2001
From: Cdaq Account <cdaq@cdaql1.jlab.org>
Date: Wed, 1 Mar 2017 18:32:12 -0500
Subject: [PATCH] Modify THcHodoHit.h and THcScintillatorPlane.cxx THcHodoHit.h
 add methods to set and get the ADC peak amp and time
 THcScintillatorPlane::ProcessHits changed to set the ADC peak amp and time in
 the Hodohit DefineVariable added variables to tree

---
 src/THcHodoHit.h             | 26 +++++++++++++++++++++++++-
 src/THcScintillatorPlane.cxx | 25 ++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/THcHodoHit.h b/src/THcHodoHit.h
index e9adecf..c5b86ef 100644
--- a/src/THcHodoHit.h
+++ b/src/THcHodoHit.h
@@ -30,6 +30,10 @@ public:
   // Get and Set Functions
   Double_t GetPosADC() const { return fPosADC_Ped; }
   Double_t GetNegADC() const { return fNegADC_Ped; }
+  Double_t GetPosADCpeak() const { return fPosADC_Peak; }
+  Double_t GetNegADCpeak() const { return fNegADC_Peak; }
+  Double_t GetPosADCtime() const { return fPosADC_Time; }
+  Double_t GetNegADCtime() const { return fNegADC_Time; }
   Int_t GetPosTDC() const { return fPosTDC; }
   Int_t GetNegTDC() const { return fNegTDC; }
   Double_t GetPosCorrectedTime() const { return fPosCorrectedTime;}
@@ -40,6 +44,7 @@ public:
   Bool_t GetTwoGoodTimes() const { return fTwoGoodTimes;}
   Bool_t GetHasCorrectedTimes() const { return fHasCorrectedTimes;}
   Int_t GetPaddleNumber() const { return fPaddleNumber; }
+  Double_t GetPaddleCenter() const { return fPaddleCenter; }
 
   void SetCorrectedTimes(Double_t pos, Double_t neg, Double_t) {
     fPosCorrectedTime = pos; fNegCorrectedTime = neg;
@@ -55,7 +60,21 @@ public:
   void SetTwoGoodTimes(Bool_t flag) {
     fTwoGoodTimes = flag;
   }
-
+  void SetPaddleCenter(Double_t padcenter) {
+    fPaddleCenter = padcenter;
+  }
+  void  SetPosADCpeak( Double_t adc) {
+      fPosADC_Peak =adc;
+ }
+  void  SetNegADCpeak( Double_t adc) {
+      fNegADC_Peak =adc;
+ }
+  void  SetPosADCtime( Double_t ptime) {
+      fPosADC_Time =ptime;
+ }
+  void  SetNegADCtime( Double_t ptime) {
+      fNegADC_Time =ptime;
+ }
 protected:
   static const Double_t kBig;  //!
 
@@ -63,6 +82,10 @@ protected:
   Int_t fNegTDC;
   Double_t fPosADC_Ped;		// Pedestal subtracted ADC
   Double_t fNegADC_Ped;		// Pedestal subtracted ADC
+  Double_t fPosADC_Peak;		// ADC peak amplitude
+  Double_t fNegADC_Peak;		// ADC peak amplitude
+  Double_t fPosADC_Time;		// ADC time
+  Double_t fNegADC_Time;		// ADC time
   Int_t fPaddleNumber;
 
   Double_t fPosCorrectedTime;	// Pulse height corrected time
@@ -74,6 +97,7 @@ protected:
 
   Bool_t fHasCorrectedTimes;
   Bool_t fTwoGoodTimes;
+  Double_t fPaddleCenter;
 
   THcScintillatorPlane* fPlane;	// Pointer to parent scintillator plane
 
diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx
index 86d3e65..ffa690b 100644
--- a/src/THcScintillatorPlane.cxx
+++ b/src/THcScintillatorPlane.cxx
@@ -346,6 +346,10 @@ Int_t THcScintillatorPlane::DefineVariables( EMode mode )
     {"GoodPosTdcTimeCorr",         "List of positive corrected TDC values (corrected for PMT offset and ADC)",               "fHodoHits.THcHodoHit.GetPosCorrectedTime()"},
     {"GoodPosTdcTimeTOFCorr",         "List of positive corrected TDC values (corrected for TOF)",               "fHodoHits.THcHodoHit.GetPosTOFCorrectedTime()"},
     {"GoodPosAdcPulseInt",         "List of positive ADC values (passed TDC Min and Max cuts for either end)",               "fHodoHits.THcHodoHit.GetPosADC()"},
+    {"GoodPosAdcPulseAmp",         "List of positive ADC peak amp (passed TDC Min and Max cuts for either end)",               "fHodoHits.THcHodoHit.GetPosADCpeak()"},
+    {"GoodNegAdcPulseAmp",         "List of Negative ADC peak amp (passed TDC Min and Max cuts for either end)",               "fHodoHits.THcHodoHit.GetNegADCpeak()"},
+    {"GoodPosAdcPulseTime",         "List of positive ADC peak amp (passed TDC Min and Max cuts for either end)",               "fHodoHits.THcHodoHit.GetPosADCtime()"},
+    {"GoodNegAdcPulseTime",         "List of Negative ADC peak amp (passed TDC Min and Max cuts for either end)",               "fHodoHits.THcHodoHit.GetNegADCtime()"},
     {"ngoodhits", "Number of paddle hits (passed tof tolerance and used to determine the focal plane time )",           "GetNGoodHits() "},
     { 0 }
   };
@@ -492,7 +496,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
   // cout << "THcScintillatorPlane::ProcessHits " << fPlaneNum << " " << nexthit << "/" << nrawhits << endl;
   Int_t ihit = nexthit;
 
-  //  cout << "THcScintillatorPlane: raw htis = " << nrawhits << endl;
+  //cout << "THcScintillatorPlane: " << GetName() << " raw hits = " << nrawhits << endl;
 
   // A THcRawHodoHit contains all the information (tdc and adc for both
   // pmts) for a single paddle for a single trigger.  The tdc information
@@ -500,6 +504,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
   // Use "ihit" as the index over THcRawHodoHit objects.  Use
   // "thit" to index over multiple tdc hits within an "ihit".
   while(ihit < nrawhits) {
+    //cout << " ihit = " << ihit << endl;
     THcRawHodoHit* hit = (THcRawHodoHit *) rawhits->At(ihit);
     if(hit->fPlane > fPlaneNum) {
       break;
@@ -595,6 +600,14 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
     Int_t tdc_pos=-999;
     Int_t tdc_neg=-999;
     // Find first in range hit from multihit tdc
+    /*
+    for(UInt_t thit=0; thit<hit->GetRawTdcHitPos().GetNHits(); thit++) {
+      cout << " plane = " << hit->fPlane << " pos paddle = " << hit->fCounter << " " <<  hit->GetRawTdcHitPos().GetTime(thit)<< " hit = " << thit << endl;
+    }    
+    for(UInt_t thit=0; thit<hit->GetRawTdcHitNeg().GetNHits(); thit++) {
+      cout <<  " plane = " << hit->fPlane << " Neg paddle = " << hit->fCounter << " " <<  hit->GetRawTdcHitNeg().GetTime(thit) << " hit = " << thit << endl;
+    } 
+    */   
     for(UInt_t thit=0; thit<hit->GetRawTdcHitPos().GetNHits(); thit++) {
       tdc_pos = hit->GetRawTdcHitPos().GetTime(thit)+fTdcOffset;
       if(tdc_pos >= fScinTdcMin && tdc_pos <= fScinTdcMax) {
@@ -617,6 +630,14 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
       new( (*fHodoHits)[fNScinHits]) THcHodoHit(tdc_pos, tdc_neg,
 						adc_pos, adc_neg,
 						hit->fCounter, this);
+      Double_t adc_peak=hit->GetRawAdcHitPos().GetPulseAmp();
+        ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCpeak(adc_peak);
+      adc_peak=hit->GetRawAdcHitNeg().GetPulseAmp();
+        ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCpeak(adc_peak);
+      Double_t time_peak=hit->GetRawAdcHitPos().GetPulseTimeRaw();
+        ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCtime(time_peak);
+      time_peak=hit->GetRawAdcHitNeg().GetPulseTimeRaw();
+        ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCtime(time_peak);
     // Do corrections if valid TDC on both ends of bar
       if(btdcraw_pos && btdcraw_neg) {
 
@@ -664,6 +685,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
 	  negtime = negtime-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal);
 	}
 	//        cout << fNScinHits<< " " << timec_pos << " " << timec_neg << endl;
+        ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPaddleCenter(fPosCenter[index]);
 	((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg,
 								     postime, negtime,
 								     scin_corrected_time);
@@ -693,6 +715,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
 	    - fHodoNegTimeOffset[index];
 	}
       }
+        ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPaddleCenter(fPosCenter[index]);
 	((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg,
 								     timec_pos,timec_neg,
 								     0.0);
-- 
GitLab