From 4ffdc1aa9b379112552572f18fc3f45b236a61d2 Mon Sep 17 00:00:00 2001
From: "Stephen A. Wood" <saw@jlab.org>
Date: Thu, 19 Feb 2015 15:41:42 -0500
Subject: [PATCH] Use nominal particle mass in central and per track beta
 calculation

---
 src/THcHallCSpectrometer.h   |  5 +++++
 src/THcHodoscope.cxx         | 11 +++++++----
 src/THcHodoscope.h           |  4 ++++
 src/THcScintillatorPlane.cxx | 13 ++++++-------
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/src/THcHallCSpectrometer.h b/src/THcHallCSpectrometer.h
index 1e132ad..0f8ecac 100644
--- a/src/THcHallCSpectrometer.h
+++ b/src/THcHallCSpectrometer.h
@@ -50,6 +50,11 @@ public:
   Bool_t SetTrSorting( Bool_t set = kFALSE );
   Bool_t GetTrSorting() const;
 
+  // Mass of nominal detected particle type
+  Double_t GetParticleMass() const {return fPartMass; }
+  Double_t GetBetaAtPcentral() const { return
+      fPcentral/TMath::Sqrt(fPcentral*fPcentral+fPartMass*fPartMass);}
+
 protected:
   void InitializeReconstruction();
 
diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx
index 8ab6845..3fee655 100644
--- a/src/THcHodoscope.cxx
+++ b/src/THcHodoscope.cxx
@@ -175,6 +175,10 @@ void THcHodoscope::Setup(const char* name, const char* description)
   gHcParms->Define(Form("%shodo_did",prefix),"Total hodo tracks",fScinDid);
   gHcParms->Define(Form("%shodo_should",prefix),"Total hodo triggers",fScinShould);
 
+  // Save the nominal particle mass
+  fPartMass = app->GetParticleMass();
+  fBetaNominal = app->GetBetaAtPcentral();
+
   delete [] desc;
 }
 
@@ -752,10 +756,9 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
   Int_t fJMax, fMaxHit;
   Int_t fRawIndex = -1;
   Double_t fScinTrnsCoord, fScinLongCoord, fScinCenter, fSumfpTime, fSlope;
-  Double_t fP, fXcoord, fYcoord, fTMin, fBestXpScin, fBestYpScin;
+  Double_t fXcoord, fYcoord, fTMin, fBestXpScin, fBestYpScin;
   // -------------------------------------------------
 
-  Double_t hpartmass=0.00051099; // Fix it
   fGoodScinHits = 0;
   fScinShould = 0; fScinDid = 0;
 
@@ -786,8 +789,8 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
       //      fTimeAtFP[itrack] = 0.;
       fSumfpTime = 0.; // Line 138
       fNScinHit.push_back(0);
-      fP = theTrack->GetP(); // Line 142 
-      Double_t betaP = fP/( TMath::Sqrt( fP * fP + hpartmass * hpartmass) );
+      Double_t p = theTrack->GetP(); // Line 142 
+      Double_t betaP = p/( TMath::Sqrt( p * p + fPartMass * fPartMass) );
       
       //! Calculate all corrected hit times and histogram
       //! This uses a copy of code below. Results are save in time_pos,neg
diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h
index d76c579..90a5d93 100644
--- a/src/THcHodoscope.h
+++ b/src/THcHodoscope.h
@@ -58,6 +58,7 @@ public:
   Double_t GetTdcMax() const {return fScinTdcMax;}
   Double_t GetTofTolerance() const {return fTofTolerance;}
   Double_t GetTdcToTime() const {return fScinTdcToTime;}
+  Double_t GetBetaNominal() const {return fBetaNominal;}
   Double_t GetHodoPosPhcCoeff(Int_t iii) const {return fHodoPosPhcCoeff[iii];}
   Double_t GetHodoNegPhcCoeff(Int_t iii) const {return fHodoNegPhcCoeff[iii];}
   Double_t GetHodoPosMinPh(Int_t iii) const {return fHodoPosMinPh[iii];}
@@ -135,6 +136,9 @@ protected:
   Double_t* fHodoPosInvAdcAdc;
   Double_t* fHodoNegInvAdcAdc;
 
+  Double_t fPartMass;		// Nominal particle mass
+  Double_t fBetaNominal;	// Beta for central ray of nominal particle type
+
   THcScintillatorPlane** fPlanes; // List of plane objects
 
   TClonesArray*  fTrackProj;  // projection of track onto scintillator plane
diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx
index afca7a3..e94e599 100644
--- a/src/THcScintillatorPlane.cxx
+++ b/src/THcScintillatorPlane.cxx
@@ -374,7 +374,7 @@ Int_t THcScintillatorPlane::PulseHeightCorrection()
   Double_t pos_ph[53],neg_ph[53],postime[53],negtime[53],scin_corrected_time[53]; // the 53 should go in a param file (was hmax_scin_hits originally)
   // Bool_t keep_pos[53],keep_neg[53]; // are these all really needed?
   Bool_t two_good_times[53];
-  Double_t dist_from_center,scint_center,hit_position,time_pos[100],time_neg[100],hbeta_pcent;
+  Double_t dist_from_center,scint_center,hit_position,time_pos[100],time_neg[100];
   Int_t timehist[200],jmax,maxhit,nfound=0; // This seems as a pretty old-fashioned way of doing things. Is there a better way?
 
 
@@ -397,9 +397,8 @@ Int_t THcScintillatorPlane::PulseHeightCorrection()
   maxtdc=((THcHodoscope *)GetParent())->GetTdcMax();
   tdctotime=((THcHodoscope *)GetParent())->GetTdcToTime();
   toftolerance=((THcHodoscope *)GetParent())->GetTofTolerance();
-  //  hbeta_pcent=(TH((THcHodoscope *)GetParent())->GetParent()
-  // Horrible hack until I find out where to get the central beta from momentum!! GN
-  hbeta_pcent=1.0;
+  Double_t betanominal=((THcHodoscope *)GetParent())->GetBetaNominal();
+
   fpTime=-1e5;
   for (i=0;i<fNScinHits;i++) {
     if ((((THcSignalHit*) fPosTDCHits->At(i))->GetData()>=mintdc) &&
@@ -440,8 +439,8 @@ Int_t THcScintillatorPlane::PulseHeightCorrection()
 	  postime[i]=postime[i]-(fPosLeft-hit_position)/((THcHodoscope *)GetParent())->GetHodoVelLight(index);
 	  negtime[i]=negtime[i]-(hit_position-fPosRight)/((THcHodoscope *)GetParent())->GetHodoVelLight(index);
 
-	  time_pos[i]=postime[i]-(fZpos+(j%2)*fDzpos)/(29.979*hbeta_pcent);
-	  time_neg[i]=negtime[i]-(fZpos+(j%2)*fDzpos)/(29.979*hbeta_pcent);
+	  time_pos[i]=postime[i]-(fZpos+(j%2)*fDzpos)/(29.979*betanominal);
+	  time_neg[i]=negtime[i]-(fZpos+(j%2)*fDzpos)/(29.979*betanominal);
 	  nfound++;
 	  for (int k=0;k<200;k++) {
 	    tmin=0.5*(k+1);
@@ -521,7 +520,7 @@ Int_t THcScintillatorPlane::PulseHeightCorrection()
     j=((THcSignalHit*)fNegTDCHits->At(i))->GetPaddleNumber()-1;  
     index=((THcHodoscope *)GetParent())->GetScinIndex(fPlaneNum-1,j);
     if (two_good_times[i]) { // both tubes fired
-      fpTimes[fNScinGoodHits]=scin_corrected_time[i]-(fZpos+(j%2)*fDzpos)/(29.979*hbeta_pcent);
+      fpTimes[fNScinGoodHits]=scin_corrected_time[i]-(fZpos+(j%2)*fDzpos)/(29.979*betanominal);
       fScinTime[fNScinGoodHits]=scin_corrected_time[i];
       fScinSigma[fNScinGoodHits]=TMath::Sqrt(((THcHodoscope *)GetParent())->GetHodoPosSigma(index)*((THcHodoscope *)GetParent())->GetHodoPosSigma(index)+((THcHodoscope *)GetParent())->GetHodoNegSigma(index)*((THcHodoscope *)GetParent())->GetHodoNegSigma(index)); // not ideal by any stretch!!!
       fScinZpos[fNScinGoodHits]=fZpos+(j%2)*fDzpos; // see comment above
-- 
GitLab