Print

Print


Commit in GeomConverter/src/org/lcsim on MAIN
detector/converter/compact/TubeSegmentConverter.java+69added 1.1
                          /DetectorConverter.java+11.38 -> 1.39
geometry/subdetector/TubeSegment.java+92-31.1 -> 1.2
+162-3
1 added + 2 modified, total 3 files
JM: geo implementations for TubeSegment, partly from code sent by Jack Gill (TubeSegmentConverter)

GeomConverter/src/org/lcsim/detector/converter/compact
TubeSegmentConverter.java added at 1.1
diff -N TubeSegmentConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TubeSegmentConverter.java	7 Jul 2008 22:19:04 -0000	1.1
@@ -0,0 +1,69 @@
+package org.lcsim.detector.converter.compact;
+
+import org.lcsim.geometry.compact.Detector;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.subdetector.TubeSegment;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.detector.solids.Tube;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.PhysicalVolumeNavigatorStore;
+import org.lcsim.detector.IPhysicalVolumePath;
+import org.lcsim.detector.DetectorElement;
+import org.lcsim.detector.LogicalVolume;
+
+public class TubeSegmentConverter
+        extends AbstractSubdetectorConverter
+        implements ISubdetectorConverter {
+
+    public void convert(Subdetector subdet, Detector detector) {
+        // Cast to subtype.
+        TubeSegment tube = (TubeSegment) subdet;
+
+        // Get the world volume.
+        IPhysicalVolume world = detector.getWorldVolume();
+
+        // Get the world volume fill material.
+        IMaterial matWorld = world.getLogicalVolume().getMaterial();
+
+        // Create the Subdetector's envelope LogicalVolume.
+        ILogicalVolume envelope = buildEnvelope(tube, matWorld);
+
+        // Create the PhysicalVolume.
+        new PhysicalVolume(
+                tube.getTransform(),
+                tube.getName(),
+                envelope,
+                world.getLogicalVolume(),
+                subdet.getSystemID());
+
+        // Setup the geometry.
+        IPhysicalVolumeNavigator nav = PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
+        IPhysicalVolumePath path = nav.getPath(tube.getName());
+
+        // Create the Subdetector's DetectorElement.
+        ((DetectorElement) tube.getDetectorElement()).setSupport(path);
+
+    }
+
+    private ILogicalVolume buildEnvelope(TubeSegment tubeSeg, IMaterial material) {
+        Tube tube = new Tube(
+                tubeSeg.getName() + "_envelope_tube",
+                tubeSeg.getInnerRadius(),
+                tubeSeg.getOuterRadius(),
+                tubeSeg.getZHalfLength());
+
+        LogicalVolume logvol = new LogicalVolume(
+                tubeSeg.getName() + "_envelope",
+                tube,
+                material);
+
+        return logvol;
+    }
+
+    public Class getSubdetectorType() {
+        return TubeSegment.class;
+    }
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/converter/compact
DetectorConverter.java 1.38 -> 1.39
diff -u -r1.38 -r1.39
--- DetectorConverter.java	29 Feb 2008 01:09:08 -0000	1.38
+++ DetectorConverter.java	7 Jul 2008 22:19:04 -0000	1.39
@@ -92,6 +92,7 @@
         addSubdetectorConverter( new SiTrackerEndcapConverter() );
         addSubdetectorConverter( new PolyhedraBarrelCalorimeterConverter() );
         addSubdetectorConverter( new PolyhedraEndcapCalorimeterConverter() );
+        addSubdetectorConverter( new TubeSegmentConverter() );
     }
 
     private void addSubdetectorConverter(ISubdetectorConverter s)

GeomConverter/src/org/lcsim/geometry/subdetector
TubeSegment.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- TubeSegment.java	30 Oct 2007 18:29:30 -0000	1.1
+++ TubeSegment.java	7 Jul 2008 22:19:04 -0000	1.2
@@ -1,19 +1,108 @@
 package org.lcsim.geometry.subdetector;
 
+import hep.graphics.heprep.HepRep;
+import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstance;
+import hep.graphics.heprep.HepRepInstanceTree;
+import hep.graphics.heprep.HepRepType;
+import hep.graphics.heprep.HepRepTypeTree;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
 import org.jdom.Element;
 import org.jdom.JDOMException;
+import org.lcsim.detector.ITransform3D;
+import org.lcsim.detector.RotationGeant;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.Translation3D;
 
 /**
- * Placehold in compact description for TubeSegment type.
  *
  * @author Jeremy McCormick
- * @version $Id: TubeSegment.java,v 1.1 2007/10/30 18:29:30 jeremy Exp $
+ * @version $Id: TubeSegment.java,v 1.2 2008/07/07 22:19:04 jeremy Exp $
  */
 
 public class TubeSegment extends AbstractSubdetector
 {
+	double rmin, rmax, zhalf;
+	ITransform3D trans;
+		
     public TubeSegment(Element node) throws JDOMException
     {
         super(node);
+        Element tubs = node.getChild("tubs");
+        
+        rmin = tubs.getAttribute("rmin").getDoubleValue();
+        rmax = tubs.getAttribute("rmax").getDoubleValue();
+        zhalf = tubs.getAttribute("zhalf").getDoubleValue();
+        
+        Element pos = node.getChild("position");
+        double x,y,z;
+        x = y = z = 0;
+        if (pos != null)
+        {
+        	try { x = pos.getAttribute("x").getDoubleValue();}  catch (Exception ex) {}
+        	try { y = pos.getAttribute("y").getDoubleValue();}  catch (Exception ex) {}
+        	try { z = pos.getAttribute("z").getDoubleValue();}  catch (Exception ex) {}
+        }
+        
+        Element rot = node.getChild("rotation");
+        double rx, ry, rz;
+        rx = ry = rz = 0;
+        if (rot != null)
+        {
+        	try { rx = rot.getAttribute("x").getDoubleValue();}  catch (Exception ex) {}
+        	try { ry = rot.getAttribute("y").getDoubleValue();}  catch (Exception ex) {}
+        	try { rz = rot.getAttribute("z").getDoubleValue();}  catch (Exception ex) {}
+        }
+        
+        trans = new Transform3D(new Translation3D(x,y,z), new RotationGeant(rx, ry, rz));        
+    }
+    
+    public void appendHepRep(HepRepFactory factory, HepRep heprep)
+    {
+    	HepRepInstanceTree instanceTree = heprep.getInstanceTreeTop("Detector","1.0");
+        HepRepTypeTree typeTree = heprep.getTypeTree("DetectorType","1.0");
+        
+        HepRepType barrel = typeTree.getType("Barrel");
+        
+        HepRepType type = factory.createHepRepType(barrel, getName());
+        type.addAttValue("drawAs","Cylinder");
+        
+        double zmin = -zhalf;
+        double zmax = zhalf;
+        
+        Hep3Vector point1 = trans.transformed(new BasicHep3Vector(0,0,zmin));
+        Hep3Vector point2 = trans.transformed(new BasicHep3Vector(0,0,zmax));
+                        
+        HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
+        instance.addAttValue("radius",rmin);
+        factory.createHepRepPoint(instance,point1.x(),point1.y(),point1.z());
+        factory.createHepRepPoint(instance,point2.x(),point2.y(),point2.z());
+        
+        HepRepInstance instance2 = factory.createHepRepInstance(instanceTree, type);
+        instance2.addAttValue("radius",rmax);
+        factory.createHepRepPoint(instance2,point1.x(),point1.y(),point1.z());
+        factory.createHepRepPoint(instance2,point2.x(),point2.y(),point2.z());
     }
-}
+    
+	public final double getInnerRadius()
+	{
+		return rmin;
+	}
+	
+	public final double getOuterRadius()
+	{
+		return rmax;	
+	}
+	
+	public final double getZHalfLength()
+	{
+		return zhalf;
+	}   
+	
+	public ITransform3D getTransform()
+	{
+		return trans;
+	}
+}
\ No newline at end of file
CVSspam 0.2.8