From 2daa34a12f1b4e773cf2146bd154194e484f811d Mon Sep 17 00:00:00 2001
From: Zafar Ahmed <zahmed@jlab.org>
Date: Thu, 21 May 2015 21:20:11 -0400
Subject: [PATCH] beta in hodoscope

---
 podd                         |  2 +-
 src/THcCherenkov.cxx         | 51 ++++++++++++++++--------------------
 src/THcHodoscope.cxx         | 25 ++++++++++--------
 src/THcHodoscope.h           |  2 ++
 src/THcScintillatorPlane.cxx | 18 +++++--------
 5 files changed, 46 insertions(+), 52 deletions(-)

diff --git a/podd b/podd
index 993f6aa..afce4df 160000
--- a/podd
+++ b/podd
@@ -1 +1 @@
-Subproject commit 993f6aaf52920ee7c8f441c88be19343823bcb38
+Subproject commit afce4df317bf88ff161519ee1ee94bd9eb85744f
diff --git a/src/THcCherenkov.cxx b/src/THcCherenkov.cxx
index 31a3418..da3232e 100644
--- a/src/THcCherenkov.cxx
+++ b/src/THcCherenkov.cxx
@@ -168,7 +168,8 @@ Int_t THcCherenkov::ReadDatabase( const TDatime& date )
   fNelem = (Int_t)gHcParms->Find(parname)->GetValue(); // class.
 
   //    fNelem = 2;      // Default if not defined  
-
+  fCerNRegions = 3;
+  
   fNPMT = new Int_t[fNelem];
   fADC = new Double_t[fNelem];
   fADC_P = new Double_t[fNelem];
@@ -188,7 +189,6 @@ Int_t THcCherenkov::ReadDatabase( const TDatime& date )
   fPedLimit = new Int_t[fNelem];
   fPedMean = new Double_t[fNelem];
   
-  fCerNRegions = 3; // This value should be in parameter file
 
   fCerTrackCounter = new Int_t [fCerNRegions];
   fCerFiredCounter = new Int_t [fCerNRegions];
@@ -197,22 +197,22 @@ Int_t THcCherenkov::ReadDatabase( const TDatime& date )
     fCerFiredCounter[ireg] = 0;
   }
 
-
   fCerRegionsValueMax = fCerNRegions * 8; // This value 8 should also be in paramter file
   fCerRegionValue = new Double_t [fCerRegionsValueMax];
 
   DBRequest list[]={
-    {"cer_adc_to_npe", fGain,     kDouble, (UInt_t) fNelem},              // Ahmed
-    {"cer_ped_limit",  fPedLimit, kInt,    (UInt_t) fNelem},              // Ahmed
-    {"cer_width",      fCerWidth, kDouble, (UInt_t) fNelem},              // Ahmed
-    {"cer_chi2max",     &fCerChi2Max,        kDouble},                       // Ahmed
-    {"cer_beta_min",    &fCerBetaMin,        kDouble},                       // Ahmed
-    {"cer_beta_max",    &fCerBetaMax,        kDouble},                       // Ahmed
-    {"cer_et_min",      &fCerETMin,          kDouble},                       // Ahmed
-    {"cer_et_max",      &fCerETMax,          kDouble},                       // Ahmed
-    {"cer_mirror_zpos", &fCerMirrorZPos,     kDouble},                       // Ahmed
-    {"cer_region",      &fCerRegionValue[0], kDouble, (UInt_t) fCerRegionsValueMax},  // Ahmed
-    {"cer_threshold",   &fCerThresh,         kDouble},                       // Ahmed
+    {"cer_adc_to_npe", fGain,     kDouble, (UInt_t) fNelem},             
+    {"cer_ped_limit",  fPedLimit, kInt,    (UInt_t) fNelem},             
+    {"cer_width",      fCerWidth, kDouble, (UInt_t) fNelem},             
+    {"cer_chi2max",     &fCerChi2Max,        kDouble},                   
+    {"cer_beta_min",    &fCerBetaMin,        kDouble},                   
+    {"cer_beta_max",    &fCerBetaMax,        kDouble},                   
+    {"cer_et_min",      &fCerETMin,          kDouble},                   
+    {"cer_et_max",      &fCerETMax,          kDouble},                   
+    {"cer_mirror_zpos", &fCerMirrorZPos,     kDouble},                   
+    {"cer_region",      &fCerRegionValue[0], kDouble, (UInt_t) fCerRegionsValueMax}, 
+    {"cer_threshold",   &fCerThresh,         kDouble},                    
+    //    {"cer_regions",     &fCerNRegions,       kInt},                       
     {0}
   };
 
@@ -220,6 +220,7 @@ Int_t THcCherenkov::ReadDatabase( const TDatime& date )
 
   fIsInit = true;
 
+
   for (Int_t i1 = 0; i1 < fCerNRegions; i1++ ) {
     cout << "Region " << i1 << endl;
     for (Int_t i2 = 0; i2 < 8; i2++ ) {
@@ -250,12 +251,12 @@ Int_t THcCherenkov::DefineVariables( EMode mode )
   // No.  They show up in tree as Ndata.H.aero.postdchits for example
 
   RVarDef vars[] = {
-    {"phototubes",  "Nuber of Cherenkov photo tubes",            "fNPMT"},
-    {"adc",         "Raw ADC values",                            "fADC"},
-    {"adc_p",       "Pedestal Subtracted ADC values",            "fADC_P"},
-    {"npe",         "Number of Photo electrons",                 "fNPE"},
-    {"npesum",      "Sum of Number of Photo electrons",          "fNPEsum"},
-    {"ncherhit",    "Number of Hits(Cherenkov)",                 "fNCherHit"},
+    {"phototubes",      "Nuber of Cherenkov photo tubes",        "fNPMT"},
+    {"adc",             "Raw ADC values",                        "fADC"},
+    {"adc_p",           "Pedestal Subtracted ADC values",        "fADC_P"},
+    {"npe",             "Number of Photo electrons",             "fNPE"},
+    {"npesum",          "Sum of Number of Photo electrons",      "fNPEsum"},
+    {"ncherhit",        "Number of Hits(Cherenkov)",             "fNCherHit"},
     {"certrackcounter", "Tracks inside Cherenkov region",        "fCerTrackCounter"},
     {"cerfiredcounter", "Tracks with engough Cherenkov NPEs ",   "fCerFiredCounter"},
     { 0 }
@@ -374,7 +375,7 @@ Int_t THcCherenkov::FineProcess( TClonesArray& tracks )
 
     THaTrack* theTrack = dynamic_cast<THaTrack*>( tracks.At(0) );
     if (!theTrack) return -1;
-    
+
     if ( ( ( tracks.GetLast() + 1 ) == 1 ) && 
 	 ( theTrack->GetChi2()/theTrack->GetNDoF() > 0. ) && 
 	 ( theTrack->GetChi2()/theTrack->GetNDoF() <  fCerChi2Max ) && 
@@ -405,18 +406,12 @@ Int_t THcCherenkov::FineProcess( TClonesArray& tracks )
 	  fCerTrackCounter[ir] ++;	  
 	  
 	  // *     increment the 'did fire' counters
-
 	  if ( fNPEsum > fCerThresh ) {
 	    fCerFiredCounter[ir] ++;
 	  }
-
 	}
-		
-      } // loop over regions
-      //      cout << endl;
-      
+      } // loop over regions 
     }
-    
   }
 
   return 0;
diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx
index 297e51b..6f82178 100644
--- a/src/THcHodoscope.cxx
+++ b/src/THcHodoscope.cxx
@@ -259,6 +259,7 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date )
   //  Int_t plen=strlen(parname);
   cout << " readdatabse hodo fnplanes = " << fNPlanes << endl;
 
+  fBetaP = 0.;
   fBetaNoTrk = 0.;
   fBetaNoTrkChiSq = 0.;
   
@@ -432,15 +433,16 @@ Int_t THcHodoscope::DefineVariables( EMode mode )
 
   RVarDef vars[] = {
     // Move these into THcHallCSpectrometer using track fTracks
+    {"betap",             "betaP",                "fBetaP"},
     {"betanotrack",       "Beta from scintillator hits",                "fBetaNoTrk"},
     {"betachisqnotrack",  "Chi square of beta from scintillator hits",  "fBetaNoTrkChiSq"},
-    {"fpHitsTime",      "Time at focal plane from all hits",         "fFPTime"},
-    {"starttime",       "Hodoscope Start Time",                      "fStartTime"},
-    {"goodstarttime",   "Hodoscope Good Start Time",                 "fGoodStartTime"},
-    {"goodscinhit",     "Hit in fid area",                           "fGoodScinHits"},
-    //    {"goodscinhitx",    "Hit in fid x range",                        "fGoodScinHitsX"},
-    {"scinshould",      "Total scin Hits in fid area",               "fScinShould"},
-    {"scindid",         "Total scin Hits in fid area with a track",  "fScinDid"},
+    {"fpHitsTime",        "Time at focal plane from all hits",            "fFPTime"},
+    {"starttime",         "Hodoscope Start Time",                         "fStartTime"},
+    {"goodstarttime",     "Hodoscope Good Start Time",                    "fGoodStartTime"},
+    {"goodscinhit",       "Hit in fid area",                              "fGoodScinHits"},
+    //    {"goodscinhitx",    "Hit in fid x range",                     "fGoodScinHitsX"},
+    {"scinshould",        "Total scin Hits in fid area",                  "fScinShould"},
+    {"scindid",           "Total scin Hits in fid area with a track",     "fScinDid"},
     { 0 }
   };
   return DefineVarsFromList( vars, mode );
@@ -509,6 +511,7 @@ inline
 void THcHodoscope::ClearEvent()
 {
 
+  fBetaP = 0.;
   fBetaNoTrk = 0.0;
   fBetaNoTrkChiSq = 0.0;
 
@@ -820,7 +823,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
       Double_t sumFPTime = 0.; // Line 138
       fNScinHit.push_back(0);
       Double_t p = theTrack->GetP(); // Line 142 
-      Double_t betaP = p/( TMath::Sqrt( p * p + fPartMass * fPartMass) );
+      fBetaP = 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
@@ -895,7 +898,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
 	    Double_t pathp = fPlanes[ip]->GetPosLeft() - scinLongCoord;
 	    Double_t timep = ((THcHodoHit*)hodoHits->At(iphit))->GetPosCorrectedTime();
 	    timep = timep - ( pathp / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() +  
-								( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) *
+								( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * fBetaP ) *
 	      TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() +
 			   theTrack->GetPhi() * theTrack->GetPhi() );
 	    fTOFPInfo[iphit].time_pos = timep;
@@ -909,7 +912,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
 	    Double_t pathn =  scinLongCoord - fPlanes[ip]->GetPosRight();
 	    Double_t timen = ((THcHodoHit*)hodoHits->At(iphit))->GetNegCorrectedTime();
 	    timen = timen - ( pathn / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() +
-								( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) *
+								( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * fBetaP ) *
 	      TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() +
 			   theTrack->GetPhi() * theTrack->GetPhi() );
 	    fTOFPInfo[iphit].time_neg = timen;
@@ -1052,7 +1055,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
 	      // scin_time_fp doesn't need to be an array
 	      Double_t scin_time_fp = fTOFCalc[ihhit].scin_time -
 	       	( fPlanes[ip]->GetZpos() + ( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) /
-	       	( 29.979 * betaP ) *
+	       	( 29.979 * fBetaP ) *
 	       	TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() +
 	       		     theTrack->GetPhi() * theTrack->GetPhi() );
 
diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h
index 514d046..d113af1 100644
--- a/src/THcHodoscope.h
+++ b/src/THcHodoscope.h
@@ -107,6 +107,8 @@ protected:
   Double_t fStartTime; 
   Int_t fNfptimes;
 
+  Double_t     fBetaP;
+
   Double_t     fBetaNoTrk;
   Double_t     fBetaNoTrkChiSq;
   // Per-event data
diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx
index 01f1ae6..5a6ada3 100644
--- a/src/THcScintillatorPlane.cxx
+++ b/src/THcScintillatorPlane.cxx
@@ -222,18 +222,12 @@ Int_t THcScintillatorPlane::DefineVariables( EMode mode )
 
   // Register variables in global list
   RVarDef vars[] = {
-    {"postdchits", "List of Positive TDC hits", 
-     "frPosTDCHits.THcSignalHit.GetPaddleNumber()"},
-    {"negtdchits", "List of Negative TDC hits", 
-     "frNegTDCHits.THcSignalHit.GetPaddleNumber()"},
-    {"posadchits", "List of Positive ADC hits", 
-     "frPosADCHits.THcSignalHit.GetPaddleNumber()"},
-    {"negadchits", "List of Negative ADC hits", 
-     "frNegADCHits.THcSignalHit.GetPaddleNumber()"},
-    //    {"fptime", "Time at focal plane", 
-    //     "GetFpTime()"},
-    {"nhits", "Number of hits",      
-     "GetNScinHits() "},
+    {"postdchits", "List of Positive TDC hits",      "frPosTDCHits.THcSignalHit.GetPaddleNumber()"},
+    {"negtdchits", "List of Negative TDC hits",      "frNegTDCHits.THcSignalHit.GetPaddleNumber()"},
+    {"posadchits", "List of Positive ADC hits",      "frPosADCHits.THcSignalHit.GetPaddleNumber()"},
+    {"negadchits", "List of Negative ADC hits",      "frNegADCHits.THcSignalHit.GetPaddleNumber()"},
+    //    {"fptime", "Time at focal plane",     //     "GetFpTime()"},
+    {"nhits", "Number of hits",           "GetNScinHits() "},
     { 0 }
   };
 
-- 
GitLab