Print

Print


Commit in GeomConverter/src/org/lcsim/geometry/segmentation on MAIN
NonprojectiveCylinder.java+11-221.11 -> 1.12
Fix: reset encoder/decoder status after neighbor finding

GeomConverter/src/org/lcsim/geometry/segmentation
NonprojectiveCylinder.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- NonprojectiveCylinder.java	18 Jul 2005 18:00:05 -0000	1.11
+++ NonprojectiveCylinder.java	20 Jul 2005 20:52:19 -0000	1.12
@@ -123,18 +123,12 @@
      * Cell neighbors are found based on the direction (theta,phi) of
      * the reference cell w.r.t the origin.
      *
-     * @see org.lcsim.geometry.segmentation.SegmentationImpl#setID()
+     * @see org.lcsim.geometry.segmentation.SegmentationBase#setID()
      * @return array of cellIDs for the neighbouring cells
      */
     public long[] getNeighbourIDs(int layerRange, int zRange, int phiRange)
     {
       encoder.setValues(values);
-//       int klay = decoder.getValue("layer");
-//       int kz   = decoder.getValue("z");
-//       int kphi = decoder.getValue("phi");
-//       System.out.println("NeighborID: ref="+klay+" "+kz+" "+kphi+" (hex "
-// 			 +Long.toHexString(encoder.getID())+")");
-
       int nMax = (2*layerRange + 1)*(2*zRange + 1)*(2*phiRange + 1) - 1;
       long[] result = new long[nMax];
       
@@ -158,9 +152,6 @@
 	double x = cylR * Math.cos(phi);
 	double y = cylR * Math.sin(phi);
 	double z = cylR / Math.tan(theta);
-// 	System.out.println("layer "+ilay+", cylR="+cylR
-// 			   +", theta="+theta+", phi="+phi
-// 			   +", rvec=( "+x+", "+y+", "+z+")");
 
 	long id = this.findCellContainingXYZ(x,y,z);
 	if(id==0) continue;
@@ -185,26 +176,24 @@
 	    if(iphi>=phiBins) iphi -= phiBins;
 	    if (iphi<0 || iphi>=phiBins) continue; 
 
-// 	    System.out.println("Adding neighbor: "+ilay+" "+iz+" "+iphi);
 	    result[size++] = encoder.setValue(phiIndex,iphi);
 	  }
 	}
       }
+
+      // reset encoder and decoder
+      encoder.setValues(values);
+      decoder.setID(saveID);
       if(size < result.length) {
-	int klay = decoder.getValue("layer");
-	int kz   = decoder.getValue("z");
-	int kphi = decoder.getValue("phi");
-// 	System.out.println("Neighbors="+size+"/"+result.length
-// 			   +", ref="+klay+" "+kz+" "+kphi);
-
-	long[] temp = new long[size];
-	System.arraycopy(result,0,temp,0,size);
-	result = temp;
+	  long[] temp = new long[size];
+	  System.arraycopy(result,0,temp,0,size);
+	  result = temp;
       }
-      return result;
+ 
+     return result;
     }
 
-    // Not for public use, but this is needed to calculate positions
+    // Not for public use, this is needed to calculate positions
     // and number of cells, etc.
     private double getZMin() {
 	return ((CylindricalCalorimeter)detector).getZMin();
CVSspam 0.2.8