Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd on MAIN
EcalBarrel.java+50-161.7 -> 1.8
JM: Make an envelope volume for EcalBarrel.

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
EcalBarrel.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- EcalBarrel.java	12 Sep 2006 01:20:54 -0000	1.7
+++ EcalBarrel.java	16 Sep 2006 22:26:20 -0000	1.8
@@ -4,8 +4,8 @@
 import static java.lang.Math.acos;
 import static java.lang.Math.cos;
 import static java.lang.Math.sin;
-import static java.lang.Math.tan;
 import static java.lang.Math.sqrt;
+import static java.lang.Math.tan;
 import static java.lang.Math.toDegrees;
 
 import java.util.Iterator;
@@ -13,15 +13,17 @@
 import org.jdom.Attribute;
 import org.jdom.Element;
 import org.jdom.JDOMException;
-
 import org.lcsim.geometry.compact.converter.lcdd.util.Box;
+import org.lcsim.geometry.compact.converter.lcdd.util.Define;
 import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
 import org.lcsim.geometry.compact.converter.lcdd.util.LCDDFactory;
 import org.lcsim.geometry.compact.converter.lcdd.util.Material;
 import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
+import org.lcsim.geometry.compact.converter.lcdd.util.PolyhedraRegular;
 import org.lcsim.geometry.compact.converter.lcdd.util.Position;
 import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
 import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
+import org.lcsim.geometry.compact.converter.lcdd.util.Solids;
 import org.lcsim.geometry.compact.converter.lcdd.util.Trapezoid;
 import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
 import org.lcsim.geometry.layer.LayerFromCompactCnv;
@@ -30,7 +32,7 @@
  * Class to convert from Ecal model similar to Mokka's "ecal02" to LCDD.
  * 
  * @author jeremym
- * @version $Id: EcalBarrel.java,v 1.7 2006/09/12 01:20:54 jeremy Exp $
+ * @version $Id: EcalBarrel.java,v 1.8 2006/09/16 22:26:20 jeremy Exp $
  */
 // FIXME: needs subdetector envelope
 public class EcalBarrel extends LCDDSubdetector
@@ -46,7 +48,12 @@
 	/** Add the EcalBarrel geometry to an LCDD instance. */
 	public void addToLCDD(LCDD lcdd, SensitiveDetector sens)
 			throws JDOMException
-	{
+	{		
+		Solids solids = lcdd.getSolids();
+		Define define = lcdd.getDefine();
+		
+		int id = node.getAttribute("id").getIntValue();
+		
 		// dimensions element
 		Element dimensions = node.getChild("dimensions");
 
@@ -66,7 +73,7 @@
 		// module Z dimension, corresponding to Z of subdetector
 		double module_y1 = dimensions.getAttribute("z").getDoubleValue();
 		double module_y2 = module_y1;
-
+				
 		// delta phi per module
 		double dphi = PI * 2.0 / nsides;
 		double hphi = dphi / 2;
@@ -74,7 +81,7 @@
 		// thickness of the subdetector
 		double module_z = LayerFromCompactCnv
 				.computeDetectorTotalThickness(node);
-
+			
 		// center Y coord of a single module, untransformed
 		double module_y_offset = inner_radius + module_z / 2;
 
@@ -83,7 +90,32 @@
 
 		// name of the detector
 		String name = node.getAttributeValue("name");
-
+		
+        double totalThickness = org.lcsim.geometry.layer.LayerFromCompactCnv.computeDetectorTotalThickness(node);
+        
+        /* envelope volume */
+        PolyhedraRegular polyhedra = new PolyhedraRegular(
+                name + "_polyhedra",
+                nsides, inner_radius, inner_radius+totalThickness, module_y1);
+        lcdd.getSolids().addSolid(polyhedra);
+        
+        Volume envelopeVolume = new Volume(name + "_envelope");
+        envelopeVolume.setSolid(polyhedra);
+        Material air = lcdd.getMaterial("Air");
+        envelopeVolume.setMaterial(air);
+        
+        /* polyhedra rotation so it lays "flat" */
+        double zrot = Math.PI / nsides;
+        Rotation rot = new Rotation(name + "_rotation");
+        rot.setZ(zrot);
+        define.addRotation(rot);
+        
+        PhysVol envelopePhysvol = new PhysVol(envelopeVolume);
+        envelopePhysvol.setRotation(rot);
+        envelopePhysvol.addPhysVolID("system",id);
+        envelopePhysvol.addPhysVolID("barrel",0);
+        motherVolume.addPhysVol(envelopePhysvol);
+		
 		// outer radius, which is really just inner_radius + thickness
 		double outer_radius = inner_radius + module_z;
 
@@ -110,8 +142,7 @@
 				module_x2, // inner side, the "long" X side
 				module_y1, // corresponds to subdetector (or module) Z
 				module_y2, // ditto
-				module_z); // thickness (in Y for top module, when it is
-		// reoriented)
+				module_z); // thickness (in Y for top module, when it is reoriented)
 		lcdd.add(module_trd);
 
 		// logical volume for the module
@@ -152,19 +183,19 @@
 		lcdd.add(module_volume);
 
 		// phi start for a module
-		double phi = 0;
-
+		double phi = ((PI) / nsides);
+					
 		// make nsides modules
 		for (int i = 0; i < nsides; i++)
 		{
 			// add one to counter so module numbers are always positive
 			int module_number = i + 1;
 
-			// rotation of this module
+			// rotation of this module			
 			Rotation rotation = LCDDFactory.createRotation(name + "_module"
 					+ module_number + "_rotation", PI * 0.5, phi, 0);
 			lcdd.add(rotation);
-
+		
 			// XY position calculation from Mokka's Geometry/Tesla/Ecal02.cc
 			Position position = LCDDFactory.createPosition(name + "_module"
 					+ module_number + "_position", module_x_offset * cos(phi)
@@ -181,11 +212,14 @@
 			pv.addPhysVolID("system", node.getAttribute("id").getIntValue());
 			pv.addPhysVolID("barrel", 0);
 
-			motherVolume.addPhysVol(pv);
+			//motherVolume.addPhysVol(pv);
+			envelopeVolume.addPhysVol(pv);
 
 			// increment phi
-			phi += dphi;
+			phi += dphi;			
 		}
+		
+		lcdd.getStructure().addVolume(envelopeVolume);
 	}
 
 	/** Build the barrel stave logical volume for this component. */
@@ -350,7 +384,7 @@
 				++layerNum;
 			}
 
-		}
+		}			
 	}
 
 	public boolean isCalorimeter()
CVSspam 0.2.8