Print

Print


Commit in GeomConverter on MAIN
src/org/lcsim/detector/solids/Polycone.java+39-11.3 -> 1.4
test/org/lcsim/detector/solids/PolyconeTest.java+27-21.1 -> 1.2
+66-3
2 modified files
CD - some additional Polycone functionality (getZHalfLength, getRadiusatZ) + tests

GeomConverter/src/org/lcsim/detector/solids
Polycone.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- Polycone.java	13 Feb 2008 23:10:57 -0000	1.3
+++ Polycone.java	18 Feb 2008 23:25:50 -0000	1.4
@@ -18,7 +18,10 @@
 extends AbstractSolid
 {
     List<ZPlane> zplanes = new ArrayList<ZPlane>();
-
+    private double zHalfLength = 0; 
+    private double zMax; 
+    private double zMin; 
+    
     public Polycone(String name, List<ZPlane> zplanes)
     {
     	super(name);
@@ -37,6 +40,13 @@
             }
         });
         
+        //calculate zmax,min,halflength
+        if(zplanes.size()>0){
+            zMax = zplanes.get(zplanes.size()-1).z;
+            zMin = zplanes.get(0).z;
+            zHalfLength = (zMax - zMin)/2.0;
+            
+        }
     }    
         
     public List<ZPlane> getZPlanes()
@@ -54,6 +64,11 @@
         return zplanes.get(idx);
     }
     
+ 
+    public double getZHalfLength(){
+        return zHalfLength;
+    }
+    
     public static class ZPlane
     {
         double rmin, rmax, z;
@@ -140,6 +155,29 @@
                 return Inside.OUTSIDE; 
 	}           
         
+       public double getInnerRadiusAtZ(double z) {
+           return getRadiusAtZ(z,INNER);
+       }
+       
+       public double getOuterRadiusAtZ(double z) {
+           return getRadiusAtZ(z,OUTER);
+       }
+        
+       private double getRadiusAtZ(double z, boolean whichR){
+            
+            if (z<zMin || z>zMax) return 0; 
+            
+            for (int i = 1; i <zplanes.size(); i++){
+                if (z<=zplanes.get(i).z){
+                    return f(z,whichR,zplanes.get(i-1),zplanes.get(i));
+                }
+            }
+            
+            return 0; 
+        }
+        
+        
+        
         private static boolean INNER = true; 
         private static boolean OUTER = false; 
         //Calculates the radius at any z of either the outer or inner part of the segment

GeomConverter/test/org/lcsim/detector/solids
PolyconeTest.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- PolyconeTest.java	13 Feb 2008 23:10:57 -0000	1.1
+++ PolyconeTest.java	18 Feb 2008 23:25:50 -0000	1.2
@@ -6,7 +6,6 @@
 package org.lcsim.detector.solids;
 
 import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
 import java.util.ArrayList;
 import java.util.List;
 import junit.framework.TestCase;
@@ -127,6 +126,7 @@
         
         assertEquals(Inside.INSIDE,pc.inside(new BasicHep3Vector(0,2.5,14)));
         assertEquals(Inside.INSIDE,pc.inside(new BasicHep3Vector(1.1,0,5)));
+        assertEquals(Inside.INSIDE,pc.inside(new BasicHep3Vector(1.1,0,10)));
         assertEquals(Inside.INSIDE,pc.inside(new BasicHep3Vector(1.1,1.1,5)));
         assertEquals(Inside.INSIDE,pc.inside(new BasicHep3Vector(1.8,0,13)));
         
@@ -135,8 +135,33 @@
         assertEquals(Inside.SURFACE,pc.inside(new BasicHep3Vector(1,0,4)));
         assertEquals(Inside.SURFACE,pc.inside(new BasicHep3Vector(2.5,0,12.5)));
         assertEquals(Inside.SURFACE,pc.inside(new BasicHep3Vector(1.5,0,12.5)));
-        
+        assertEquals(Inside.SURFACE,pc.inside(new BasicHep3Vector(2.5,0,15)));        
     }
     
+    
+    public void testRadiusAtZ(){
+        
+        
+        ZPlane p1 = new ZPlane(1,2,0);
+        ZPlane p2 = new ZPlane(1,2,10);
+        ZPlane p3 = new ZPlane(2,3,15);
+        
+        List<ZPlane> l1 = new ArrayList<ZPlane>(); 
+        l1.add(p1);
+        l1.add(p2);
+        l1.add(p3);
+        
+        Polycone pc = new Polycone("test",l1);
+        
+        assertEquals(1.0,pc.getInnerRadiusAtZ(0));
+        assertEquals(2.0,pc.getOuterRadiusAtZ(0));
+        assertEquals(2.0,pc.getOuterRadiusAtZ(5));
+        assertEquals(2.0,pc.getOuterRadiusAtZ(10));
+        assertEquals(1.5,pc.getInnerRadiusAtZ(12.5));
+        assertEquals(2.5,pc.getOuterRadiusAtZ(12.5));
+        assertEquals(3.0,pc.getOuterRadiusAtZ(15));
+        assertEquals(0.0,pc.getOuterRadiusAtZ(16));
+        
+    }
 }
 
CVSspam 0.2.8