Print

Print


Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd on MAIN
PolyhedraEndcapCalorimeter3.java+23-171.4 -> 1.5
fix poly muon cal lcdd structure so that GlobalXY segmentation works correctly

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
PolyhedraEndcapCalorimeter3.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- PolyhedraEndcapCalorimeter3.java	21 Sep 2010 22:03:26 -0000	1.4
+++ PolyhedraEndcapCalorimeter3.java	28 Sep 2010 22:17:08 -0000	1.5
@@ -1,6 +1,6 @@
 /**
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: PolyhedraEndcapCalorimeter3.java,v 1.4 2010/09/21 22:03:26 jeremy Exp $
+ * @version $Id: PolyhedraEndcapCalorimeter3.java,v 1.5 2010/09/28 22:17:08 jeremy Exp $
  */
 package org.lcsim.geometry.compact.converter.lcdd;
 
@@ -59,14 +59,16 @@
         
         // Get thickness of calorimeter in z dimension determined by layering.
         double thickness = layers.getTotalThickness();
+        
+        System.out.println("thickness: " + thickness);
                  
         // Compute radius at last zplane of envelope.
-        double r3 = thickness * Math.tan(innerAngle);               
+        double rmax2 = rmin + thickness * Math.tan(innerAngle);               
         
         // Setup envelope volume so that rmin increases along +z.
         ArrayList<ZPlane> zplanes = new ArrayList<ZPlane>();
-        ZPlane frontZPlane = new ZPlane(rmin, rmax, zmin);
-        ZPlane backZPlane = new ZPlane(rmin + r3, rmax, zmin  + thickness);
+        ZPlane frontZPlane = new ZPlane(rmin, rmax, -thickness/2);
+        ZPlane backZPlane = new ZPlane(rmax2, rmax, thickness/2);
         zplanes.add(frontZPlane);
         zplanes.add(backZPlane);
         Polyhedra envelopePolyhedra = new Polyhedra(
@@ -78,13 +80,13 @@
         // Make the calorimeter envelope volume.
         Volume envelopeVolume = new Volume(subdetectorName + "_volume", envelopePolyhedra, air);        
         
-        // Compute z rotation for envelope with flat side down.
+        // Compute z rotation for envelope with flat side down.        
         double moduleInnerAngle = (Math.PI * 2) / numsides;
         double leftover = (Math.PI / 2) % moduleInnerAngle;
         double zrot = moduleInnerAngle / 2 - leftover;
                 
-        // Set the absolute z coordinate of the layer front face for layer loop.
-        double layerZ = zmin;
+        // Set the z coordinate of the layer front face for layer loop.
+        double layerZ = -thickness/2;
         
         // The rmin of the layer which will decrease along z.
         double layerRmin = rmin;
@@ -96,15 +98,15 @@
             double layerThickness = layers.getLayer(i).getThickness();
             
             // Compute change in layer inner radius.
-            double layerdx = Math.tan(innerAngle) * layerThickness;
+            double layerdy = Math.tan(innerAngle) * layerThickness;
             
             // Add dx to inner radius.
-            layerRmin += layerdx;
+            layerRmin += layerdy;
                                                                            
             // Make the layer's polyhedra.
             ArrayList<ZPlane> layerZplanes = new ArrayList<ZPlane>();
-            ZPlane layerFrontZPlane = new ZPlane(layerRmin, rmax, layerZ);
-            ZPlane layerBackZPlane = new ZPlane(layerRmin, rmax, layerZ + layerThickness);
+            ZPlane layerFrontZPlane = new ZPlane(layerRmin, rmax, -layerThickness/2);
+            ZPlane layerBackZPlane = new ZPlane(layerRmin, rmax, layerThickness/2);
             layerZplanes.add(layerFrontZPlane);
             layerZplanes.add(layerBackZPlane);
             Polyhedra layerPolyhedra = new Polyhedra(
@@ -120,17 +122,17 @@
                 new Volume(subdetectorName + "_layer" + i + "_volume", layerPolyhedra, air);                     
             
             // Build slices into the layer volume.
-            double sliceZ = layerZ;
+            double sliceZ = -layerThickness/2;
             int sliceCount = 0;
             for (LayerSlice slice : layers.getLayer(i).getSlices())
-            {
+            {                
             	// Get the slice's thickness.
             	double sliceThickness = slice.getThickness();
             	
             	// Make the slice's polyhedra shape.
             	ArrayList<ZPlane> sliceZplanes = new ArrayList<ZPlane>();
-            	ZPlane sliceFrontZPlane = new ZPlane(layerRmin, rmax, sliceZ);
-            	ZPlane sliceBackZPlane = new ZPlane(layerRmin, rmax, sliceZ + sliceThickness);
+            	ZPlane sliceFrontZPlane = new ZPlane(layerRmin, rmax, -sliceThickness/2);
+            	ZPlane sliceBackZPlane = new ZPlane(layerRmin, rmax, sliceThickness/2);
             	sliceZplanes.add(sliceFrontZPlane);
             	sliceZplanes.add(sliceBackZPlane);
             	Polyhedra slicePolyhedra = new Polyhedra(
@@ -156,6 +158,7 @@
             	
             	// Make slice physical volume.
             	PhysVol slicePhysVol = new PhysVol(sliceVolume);
+            	slicePhysVol.setZ(sliceZ + sliceThickness/2);
             	slicePhysVol.addPhysVolID("slice", sliceCount);
             	
             	// Add slice physical volume to layer.
@@ -174,6 +177,7 @@
             // Make layer placement into envelope.
             PhysVol layerPhysVol = new PhysVol(layerVolume);
             layerPhysVol.addPhysVolID("layer", i);
+            layerPhysVol.setZ(layerZ + layerThickness/2);
             envelopeVolume.addPhysVol(layerPhysVol);              
             
             // Set z to edge of next layer.
@@ -190,12 +194,13 @@
                 
         // Positive endcap placement.
         PhysVol endcapPositivePhysVol = new PhysVol(envelopeVolume);
+        endcapPositivePhysVol.setZ(zmin + thickness/2);
         endcapPositivePhysVol.addPhysVolID("system",id);
         endcapPositivePhysVol.addPhysVolID("barrel",1);                     
         endcapPositivePhysVol.setRotation(positiveEndcapRotation);                       
         motherVolume.addPhysVol(endcapPositivePhysVol);
         
-        // Make rotation for negative endcap.
+        // Make rotation for negative endcap.        
         Rotation negativeEndcapRotation = new Rotation(subdetectorName + "_negative");
         negativeEndcapRotation.setZ(zrot);
         negativeEndcapRotation.setY(Math.PI);
@@ -203,10 +208,11 @@
         
         // Negative endcap placement.
         PhysVol endcapNegativePhysVol = new PhysVol(envelopeVolume);
+        endcapNegativePhysVol.setZ(-zmin - thickness/2);
         endcapNegativePhysVol.addPhysVolID("system",id);
         endcapNegativePhysVol.addPhysVolID("barrel",2);                     
         endcapNegativePhysVol.setRotation(negativeEndcapRotation);                       
-        motherVolume.addPhysVol(endcapNegativePhysVol);        
+        motherVolume.addPhysVol(endcapNegativePhysVol);               
     }   
     
     public boolean isCalorimeter()
CVSspam 0.2.8