From b99f35d0670782fb51004dfed4dcd10e556e2f5b Mon Sep 17 00:00:00 2001
From: "Stephen A. Wood" <saw@jlab.org>
Date: Fri, 17 Oct 2014 10:42:22 -0400
Subject: [PATCH] Convert some arrays to vectors and move from class to method 
  Convert some arrays that were fixed length to vectors.   Since these arrays
 are only used local to the method   ThcHallCSpectrometer::TrackCalc(), they
 were moved out of the class   into the method.   The affected arrays are
 fX2D, fY2D, f2XHits and f2YHits

---
 src/THcHallCSpectrometer.cxx | 25 ++++++++++---------------
 src/THcHallCSpectrometer.h   |  8 --------
 src/THcHodoscope.cxx         |  2 --
 src/THcHodoscope.h           |  1 -
 4 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/src/THcHallCSpectrometer.cxx b/src/THcHallCSpectrometer.cxx
index b5ff683..341e14d 100644
--- a/src/THcHallCSpectrometer.cxx
+++ b/src/THcHallCSpectrometer.cxx
@@ -105,12 +105,6 @@ THcHallCSpectrometer::~THcHallCSpectrometer()
 {
   // Destructor
 
-  delete [] fX2D;                 fX2D = NULL;               // Ahmed
-  delete [] fY2D;                 fY2D = NULL;               // Ahmed
-  
-  delete [] f2XHits;              f2XHits = NULL;            // Ahmed  
-  delete [] f2YHits;              f2YHits = NULL;            // Ahmed  
-
   DefineVariables( kDelete );
 }
 
@@ -179,14 +173,6 @@ Int_t THcHallCSpectrometer::ReadDatabase( const TDatime& date )
   cout << "In THcHallCSpectrometer::ReadDatabase()" << endl;
 #endif
 
-  MAXHODHITS = 53;
-  
-  fX2D           = new Double_t [MAXHODHITS];
-  fY2D           = new Double_t [MAXHODHITS];
-
-  f2XHits        = new Int_t [16];
-  f2YHits        = new Int_t [16];
-
   // --------------- To get energy from THcShower ----------------------
 
   const char* detector_name = "hod";  
@@ -201,6 +187,7 @@ Int_t THcHallCSpectrometer::ReadDatabase( const TDatime& date )
   }
   
   fHodo = static_cast<THcHodoscope*>(det);     // fHodo is a membervariable
+
   // fShower = static_cast<THcShower*>(det);     // fShower is a membervariable
   
   // --------------- To get energy from THcShower ----------------------
@@ -445,6 +432,12 @@ Int_t THcHallCSpectrometer::FindVertices( TClonesArray& tracks )
 Int_t THcHallCSpectrometer::TrackCalc()
 {
 
+  Double_t* fX2D           = new Double_t [fNtracks];
+  Double_t* fY2D           = new Double_t [fNtracks];
+  Int_t* f2XHits        = new Int_t [fHodo->GetNPaddles(2)];
+  Int_t* f2YHits        = new Int_t [fHodo->GetNPaddles(3)];
+
+
   if ( ( fSelUsingScin == 0 ) && ( fSelUsingPrune == 0 ) ) {
     
     if( GetTrSorting() )
@@ -501,7 +494,9 @@ Int_t THcHallCSpectrometer::TrackCalc()
 	    {
 	      	      
 	      for ( j = 0; j < fHodo->GetNPaddles(2); j++ ){ 
-		f2XHits[j] = -1; 
+		f2XHits[j] = -1;
+	      }
+	      for ( j = 0; j < fHodo->GetNPaddles(3); j++ ){ 
 		f2YHits[j] = -1; 
 	      }
 	      
diff --git a/src/THcHallCSpectrometer.h b/src/THcHallCSpectrometer.h
index 56bce13..f5c80ab 100644
--- a/src/THcHallCSpectrometer.h
+++ b/src/THcHallCSpectrometer.h
@@ -53,8 +53,6 @@ public:
 protected:
   void InitializeReconstruction();
 
-  Int_t        MAXHODHITS;
-
   Bool_t*      fKeep;
   Int_t*       fReject;
 
@@ -75,12 +73,6 @@ protected:
   Int_t        fNPlanes;
   Int_t        fNtracks;
 
-  Int_t*       f2XHits;
-  Int_t*       f2YHits;
-
-  Double_t*    fX2D;
-  Double_t*    fY2D;
-
   Double_t     fChi2Min;
   Double_t     fSelNDegreesMin;
   Double_t     fSeldEdX1Min;
diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx
index a5031d8..979f85f 100644
--- a/src/THcHodoscope.cxx
+++ b/src/THcHodoscope.cxx
@@ -333,8 +333,6 @@ void THcHodoscope::DefineArray(const char* fName, char** Suffix, const Int_t ind
 Int_t THcHodoscope::ReadDatabase( const TDatime& date )
 {
 
-  MAXHODHITS = 53;
-
   // Read this detector's parameters from the database file 'fi'.
   // This function is called by THaDetectorBase::Init() once at the
   // beginning of the analysis.
diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h
index ec8fc07..74ad2ab 100644
--- a/src/THcHodoscope.h
+++ b/src/THcHodoscope.h
@@ -145,7 +145,6 @@ protected:
   Int_t        fCheckEvent;
 
   Int_t        fGoodTrack;
-  Int_t        MAXHODHITS;
   Int_t        fSelNDegreesMin;
   Double_t     fSeldEdX1Min;
   Double_t     fSeldEdX1Max;
-- 
GitLab