From 818bd894484677bd1a6fe68e3beae6b7989c3eee Mon Sep 17 00:00:00 2001
From: Mark Jones <jones@jlab.org>
Date: Fri, 6 Sep 2013 12:00:32 -0400
Subject: [PATCH] Replicate ENGINE tracking better. 1.  nplusminus was not
 initialized corectly so small angle approximation was never used. 2.  Change
 MAXTRACKS from 50 to 10 to match ENGINE.

---
 src/THcDC.h             | 2 +-
 src/THcDriftChamber.cxx | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/THcDC.h b/src/THcDC.h
index 097a68e..6a46a9c 100644
--- a/src/THcDC.h
+++ b/src/THcDC.h
@@ -132,7 +132,7 @@ protected:
   // double tan_angle, sin_angle, cos_angle;
   
   // Intermediate structure for building 
-  static const char MAXTRACKS = 50;
+  static const char MAXTRACKS = 10;
 
   std::vector<THcDriftChamberPlane*> fPlanes; // List of plane objects
   std::vector<THcDriftChamber*> fChambers; // List of chamber objects
diff --git a/src/THcDriftChamber.cxx b/src/THcDriftChamber.cxx
index 4ac8419..33c1b65 100644
--- a/src/THcDriftChamber.cxx
+++ b/src/THcDriftChamber.cxx
@@ -962,6 +962,7 @@ void THcDriftChamber::LeftRight()
     Int_t plane_list[nhits];
     Double_t stub[4];
     Double_t tmp_stub[4];
+    Int_t nplusminus;
 
     if(nhits < 0) {
       if (fDebugDriftCh) cout << "THcDriftChamber::LeftRight() nhits < 0" << endl;
@@ -980,6 +981,7 @@ void THcDriftChamber::LeftRight()
       if(pindex == YPlaneInd) hasy1 = ihit;
       if(pindex == YPlanePInd) hasy2 = ihit;
     }
+    nplusminus = 1<<nhits;
     Int_t smallAngOK = (hasy1>=0) && (hasy2>=0);
     if(fSmallAngleApprox !=0 && smallAngOK) { // to small Angle L/R for Y,Y' planes
       if(sp->GetHit(hasy2)->GetPos() <=
@@ -990,6 +992,7 @@ void THcDriftChamber::LeftRight()
 	plusminusknown[hasy1] = 1;
 	plusminusknown[hasy2] = -1;
       }
+      nplusminus = 1<<(nhits-2);
       if (fDebugDriftCh) cout << " Small angle approx = " << smallAngOK << " " << plusminusknown[hasy1] << endl;
       if (fDebugDriftCh) cout << "pm =  " << plusminusknown[hasy2] << " " << hasy1 << " " << hasy2 << endl;
       if (fDebugDriftCh) cout << " Plane index " << YPlaneInd << " " << YPlanePInd << endl;
@@ -1000,7 +1003,6 @@ void THcDriftChamber::LeftRight()
       if (fDebugDriftCh) cout << "THcDriftChamber::LeftRight: numhits-2 = 0" << endl;
     }
     Int_t nplaneshit = Count1Bits(bitpat);
-    Int_t nplusminus = 1<<(nhits-2);
     if (fDebugDriftCh) cout << " num of pm = " << nplusminus << " num of hits =" << nhits << endl;
     // Use bit value of integer word to set + or -
     // Loop over all combinations of left right.
-- 
GitLab