GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.1 -r1.2
--- PolyhedraEndcapCalorimeter3.java 14 Sep 2010 00:46:57 -0000 1.1
+++ PolyhedraEndcapCalorimeter3.java 21 Sep 2010 18:48:16 -0000 1.2
@@ -1,6 +1,6 @@
/**
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: PolyhedraEndcapCalorimeter3.java,v 1.1 2010/09/14 00:46:57 jeremy Exp $
+ * @version $Id: PolyhedraEndcapCalorimeter3.java,v 1.2 2010/09/21 18:48:16 jeremy Exp $
*/
package org.lcsim.geometry.compact.converter.lcdd;
@@ -19,6 +19,7 @@
import org.lcsim.geometry.compact.converter.lcdd.util.Structure;
import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
import org.lcsim.geometry.compact.converter.lcdd.util.ZPlane;
+import org.lcsim.geometry.layer.LayerSlice;
import org.lcsim.geometry.layer.LayerStack;
import org.lcsim.geometry.layer.Layering;
@@ -49,16 +50,10 @@
int numsides = dimensions.getAttribute("numsides").getIntValue();
double innerAngle = dimensions.getAttribute("angle").getDoubleValue();
- System.out.println("detector...");
- System.out.println("rmin = " + rmin);
- System.out.println("rmax = " + rmax);
- System.out.println(" angle = " + innerAngle);
-
- // Compute outer angle.
- //double outerAngle = Math.PI - Math.PI / 2 - innerAngle;
- //double outerAngle = Math.PI / 2 - innerAngle;
-
- //System.out.println("outerAngle="+outerAngle);
+ //System.out.println("detector...");
+ //System.out.println("rmin = " + rmin);
+ //System.out.println("rmax = " + rmax);
+ //System.out.println("angle = " + innerAngle);
// Make layering to get thickness.
// FIXME: This should happen automatically.
@@ -66,13 +61,13 @@
double thickness = layers.getTotalThickness();
- System.out.println("thickness="+thickness);
+ //System.out.println("thickness="+thickness);
// Compute radius at last zplane of envelope.
double r3 = thickness * Math.tan(innerAngle);
- System.out.println("r3="+r3);
- System.out.println();
+ //System.out.println("r3="+r3);
+ //System.out.println();
// Setup envelope volume so that rmin increases along +z.
ArrayList<ZPlane> zplanes = new ArrayList<ZPlane>();
@@ -89,14 +84,7 @@
Volume envelopeVolume = new Volume(subdetectorName + "_volume", envelopePolyhedra, air);
// Orientation of polyhedras with flat side down.
- double zrot = Math.PI / numsides;
- Rotation positiveEndcapRotation = new Rotation(subdetectorName + "_positive");
- positiveEndcapRotation.setZ(zrot);
- lcdd.getDefine().addRotation(positiveEndcapRotation);
-
- //
- // Setup some layering variables for the loop...
- //
+ double zrot = Math.PI / numsides;
// The absolute z coordinate of the layer front face.
double layerZ = zmin;
@@ -107,20 +95,20 @@
// Loop over layers.
for (int i=0, l=layers.getNumberOfLayers(); i<l; i++)
{
- System.out.println("layer" + i);
- System.out.println(" zmin = " + layerZ);
+ //System.out.println("layer" + i);
+ //System.out.println(" zmin = " + layerZ);
// Get this layer's thickness.
double layerThickness = layers.getLayer(i).getThickness();
- System.out.println(" layerThickness = " + layerThickness);
+ //System.out.println(" layerThickness = " + layerThickness);
// Increment inner radius by dx as rmin of layer increases along z.
double layerdx = Math.tan(innerAngle) * layerThickness;
layerRmin += layerdx;
- System.out.println(" dx = " + layerdx);
- System.out.println(" rmin = " + layerRmin);
+ //System.out.println(" dx = " + layerdx);
+ //System.out.println(" rmin = " + layerRmin);
// Make layer polyhedra.
ArrayList<ZPlane> layerZplanes = new ArrayList<ZPlane>();
@@ -138,28 +126,87 @@
// Make layer volume.
Volume layerVolume =
- new Volume(subdetectorName + "_layer" + i + "_volume", layerPolyhedra, air);
- structure.addVolume(layerVolume);
+ new Volume(subdetectorName + "_layer" + i + "_volume", layerPolyhedra, air);
+
+ // Build slices in the layer.
+ double sliceZ = layerZ;
+ int sliceCount = 0;
+ for (LayerSlice slice : layers.getLayer(i).getSlices())
+ {
+ double sliceThickness = slice.getThickness();
+
+ ArrayList<ZPlane> sliceZplanes = new ArrayList<ZPlane>();
+ ZPlane sliceFrontZPlane = new ZPlane(layerRmin, rmax, sliceZ);
+ ZPlane sliceBackZPlane = new ZPlane(layerRmin, rmax, sliceZ + sliceThickness);
+ sliceZplanes.add(sliceFrontZPlane);
+ sliceZplanes.add(sliceBackZPlane);
+ Polyhedra slicePolyhedra = new Polyhedra(
+ subdetectorName + "_layer" + i + "_slice" + sliceCount + "_polyhedra",
+ numsides,
+ sliceZplanes
+ );
+
+ // Add slice volume to solids.
+ solids.addContent(slicePolyhedra);
+
+ // Make slice volume.
+ Volume sliceVolume =
+ new Volume(
+ subdetectorName + "_layer" + i + "_slice" + sliceCount + "_volume",
+ slicePolyhedra,
+ lcdd.getMaterial(slice.getMaterial().getName()));
+ structure.addContent(sliceVolume);
+
+ // Make slice physical volume.
+ PhysVol slicePhysVol = new PhysVol(sliceVolume);
+
+ // Add slice physical volume to layer.
+ layerVolume.addPhysVol(slicePhysVol);
+
+ // Increment slice count.
+ ++sliceCount;
+
+ // Add thickness to get Z for next slice.
+ sliceZ += sliceThickness;
+ }
+
+ // Add layer volume after slices are built.
+ structure.addVolume(layerVolume);
- // Make layer placement.
+ // Make layer placement into envelope.
PhysVol layerPhysVol = new PhysVol(layerVolume);
- //layerPhysVol.setRotation(positiveEndcapRotation);
envelopeVolume.addPhysVol(layerPhysVol);
// Set z to edge of next layer.
- layerZ += layerThickness;
+ layerZ += layerThickness;
}
- // Add envelope volume to structure (TEST).
+ // Add envelope's logical volume to structure.
structure.addVolume(envelopeVolume);
+
+ // Make rotation for positive endcap.
+ Rotation positiveEndcapRotation = new Rotation(subdetectorName + "_positive");
+ positiveEndcapRotation.setZ(zrot);
+ lcdd.getDefine().addRotation(positiveEndcapRotation);
- PhysVol envelopePhysVol = new PhysVol(envelopeVolume);
- //envelopePhysVol.setZ(zmin+thickness/2);
- envelopePhysVol.addPhysVolID("system",id);
- envelopePhysVol.addPhysVolID("barrel",1);
-
- //envelopePhysVol.setRotation(positiveEndcapRotation);
-
- motherVolume.addPhysVol(envelopePhysVol);
+ // Positive endcap placement.
+ PhysVol endcapPositivePhysVol = new PhysVol(envelopeVolume);
+ endcapPositivePhysVol.addPhysVolID("system",id);
+ endcapPositivePhysVol.addPhysVolID("barrel",1);
+ endcapPositivePhysVol.setRotation(positiveEndcapRotation);
+ motherVolume.addPhysVol(endcapPositivePhysVol);
+
+ // Make rotation for negative endcap.
+ Rotation negativeEndcapRotation = new Rotation(subdetectorName + "_negative");
+ negativeEndcapRotation.setZ(zrot);
+ negativeEndcapRotation.setY(Math.PI);
+ lcdd.getDefine().addRotation(negativeEndcapRotation);
+
+ // Negative endcap placement.
+ PhysVol endcapNegativePhysVol = new PhysVol(envelopeVolume);
+ endcapNegativePhysVol.addPhysVolID("system",id);
+ endcapNegativePhysVol.addPhysVolID("barrel",2);
+ endcapNegativePhysVol.setRotation(negativeEndcapRotation);
+ motherVolume.addPhysVol(endcapNegativePhysVol);
}
-}
+}
\ No newline at end of file