Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd on MAIN
HPSEcal.java+23-121.2 -> 1.3
checkpoint

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
HPSEcal.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HPSEcal.java	13 Apr 2011 18:11:43 -0000	1.2
+++ HPSEcal.java	13 Apr 2011 19:47:31 -0000	1.3
@@ -29,7 +29,7 @@
  * @author Jeremy McCormick
  * @author Tim Nelson
  * 
- * @version $Id: HPSEcal.java,v 1.2 2011/04/13 18:11:43 jeremy Exp $
+ * @version $Id: HPSEcal.java,v 1.3 2011/04/13 19:47:31 jeremy Exp $
  */
 public class HPSEcal extends LCDDSubdetector
 {
@@ -90,29 +90,39 @@
         // Always 0. (no rotation about Z)
         double thetaz = 0;
         
-        //boolean evenx = (nx % 2 == 0);
+        // Odd or even number of crystals in X.
         boolean oddx = (nx % 2 != 0);
         
-        if (!oddx)
-            throw new RuntimeException("No soup for you!");
-
         double thetax = 0;
         double ycenter = 0;
         double zcorrtot = 0;
         double xcorrtot = 0;
-        
+                        
         //double fudgeFactor = .01;
         
         for (int ix=0; ix<nx; ix++)
         {
             System.out.println("ix="+ix);
             
-            double thetay = 2*ix*dthetay;
-            double zcorr = dx1*(sin(2*ix*dthetay)+sin(2*(ix-1)*dthetay));
-            double xcorr = zcorr*tan((2*ix-1)*dthetay);
+            // Factor for even/odd.
+            int coeff = 2*ix;
+            if (!oddx)
+            {
+                coeff -= 1;
+                if (ix==0)
+                    continue;
+            }
+            
+            System.out.println("coffee="+coeff);
+            
+            double thetay = coeff*dthetay;
+            double zcorr = dx1*(2*sin(coeff*dthetay));
+            // Center point of trap front face along line instead of edge.
+            // double zcorr = dx1*(sin(2*ix*dthetay))+sin(2*(ix-1)*dthetay));            
+            double xcorr = zcorr*tan((coeff-1)*dthetay);
             //+ fudgeFactor;
-            double xcenter = z0*sin(2*ix*dthetay)+xcorr+xcorrtot;
-            double zcenter = z0*(cos(2*ix*dthetay)-1)+zcorr+zcorrtot;
+            double xcenter = z0*sin(coeff*dthetay)+xcorr+xcorrtot;
+            double zcenter = z0*(cos(coeff*dthetay)-1)+zcorr+zcorrtot;
                         
             System.out.println("xcorr="+xcorr);
             System.out.println("xcorrtot="+xcorrtot);
@@ -132,7 +142,8 @@
             define.addRotation(irot);            
                 
             // Place crystal.
-            PhysVol crystalPlacement = new PhysVol(crystalLogVol, mother, ipos, irot);            
+            PhysVol crystalPlacement = new PhysVol(crystalLogVol, mother, ipos, irot);
+            // TODO Add PhysVolID.
             
             // Increment running X and Z totals.
             xcorrtot += xcorr;
CVSspam 0.2.8