17 added files
GeomConverter/sandbox/tknelson_snapshot
diff -N SiTrackerBarrelLayerVolume.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SiTrackerBarrelLayerVolume.java 27 Feb 2007 19:59:19 -0000 1.1
@@ -0,0 +1,62 @@
+/*
+ * SiTrackerBarrelLayerVolume.java
+ *
+ * Created on October 9, 2006, 3:15 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import org.lcsim.material.Material;
+import org.lcsim.material.MaterialManager;
+import org.lcsim.material.MaterialNotFoundException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class SiTrackerBarrelLayerVolume extends LVolume
+{
+
+ public SiTrackerBarrelLayerVolume(Element layer) throws JDOMException
+ {
+ super(layer);
+ buildFromXML(layer);
+ }
+
+ public void buildFromXML(Element lvolume)
+ {
+ // Create name
+ _name = lvolume.getAttributeValue("name");
+
+ // Create material
+ try
+ {
+ _material = MaterialManager.findMaterial(lvolume.getAttributeValue("material"));
+ }
+ catch (MaterialNotFoundException mnfe)
+ {
+ throw new RuntimeException(mnfe);
+ }
+
+ // Create solid
+ Element solid = lvolume.getChild("solid");
+ String shape = solid.getAttributeValue("shape");
+ if (shape=="box") _solid = new Box(solid);
+ if (shape=="tubesegment") _solid = new TubeSegment(solid);
+
+ // Add physical volumes
+ for (Iterator i = lvolume.getChildren("pvolume").iterator(); i.hasNext();)
+ {
+ _pvolumes.add( new PVolume((Element)i.next()) ) ;
+ }
+
+ }
+
+}
\ No newline at end of file
GeomConverter/sandbox/tknelson_snapshot
diff -N SiTrackerBarrel.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SiTrackerBarrel.java 27 Feb 2007 19:59:19 -0000 1.1
@@ -0,0 +1,351 @@
+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 java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jdom.DataConversionException;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.geometry.layer.Layer;
+import org.lcsim.geometry.layer.LayerSlice;
+import org.lcsim.geometry.layer.LayerStack;
+import org.lcsim.geometry.layer.Layering;
+import org.lcsim.geometry.subdetector.tracker.silicon.TubeSegment;
+import org.lcsim.geometry.subdetector.tracker.silicon.Box;
+import org.lcsim.geometry.subdetector.tracker.silicon.LVolume;
+import org.lcsim.geometry.subdetector.tracker.silicon.SiTrackerBarrelLayer;
+import org.lcsim.geometry.subdetector.tracker.silicon.SiTrackerModule;
+import org.lcsim.geometry.subdetector.tracker.silicon.ISolid;
+import org.lcsim.geometry.subdetector.tracker.silicon.GeometryInfo;
+import org.lcsim.geometry.subdetector.tracker.silicon.CoordinateTransformation3D;
+import org.lcsim.material.Material;
+import org.lcsim.material.MaterialManager;
+import org.lcsim.material.MaterialNotFoundException;
+
+/**
+ *
+ * Reconstruction object for a planar silicon tracker
+ * of type SiTrackerBarrel.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @author Tim Nelson <[log in to unmask]>
+ *
+ */
+public class SiTrackerBarrel extends AbstractTracker
+{
+
+ // Fields
+ //=======
+ Map<String, LVolume> _lvolumes = new HashMap<String, LVolume>();
+
+ Map<String, SiTrackerModule> _modules = new HashMap<String, SiTrackerModule>();
+ List<SiTrackerBarrelLayer> _layers = new ArrayList<SiTrackerBarrelLayer>();
+
+ SiTrackerBarrel(Element node) throws JDOMException
+ {
+ super(node);
+ build(node);
+ makeLayering();
+ }
+
+
+
+
+
+
+
+
+ private void build(Element node) throws DataConversionException
+ {
+ //System.out.println("SiTrackerBarrel.build");
+
+ Element detector = node;
+
+ // Loop over modules.
+ for (Iterator i = detector.getChildren("module").iterator(); i.hasNext();)
+ {
+ Element module_element = (Element) i.next();
+
+ String module_name = module_element.getAttributeValue("name");
+ Element module_envelope = module_element.getChild("module_envelope");
+
+ double module_width = module_envelope.getAttribute("width").getDoubleValue();
+ double module_length = module_envelope.getAttribute("length").getDoubleValue();
+ double module_thickness = module_envelope.getAttribute("thickness").getDoubleValue();
+
+ // Make logical volume for Module
+ ISolid module_solid = new Box(module_width,module_length,module_thickness);
+ Material air;
+ try
+ {
+ air = MaterialManager.findMaterial("Air");
+ }
+ catch (MaterialNotFoundException mnfe)
+ {
+ System.out.println("Material not found: Air");
+ }
+ LVolume module_volume = new LVolume(module_name, module_solid, air);
+
+
+ // Loop over module components
+ for (Iterator j = module_element.getChildren("module_component").iterator(); j.hasNext();)
+ {
+ Element module_component_element = (Element) j.next();
+
+ // module_component parameters.
+ double module_component_width = module_component_element.getAttribute("width").getDoubleValue();
+ double module_component_length = module_component_element.getAttribute("length").getDoubleValue();
+ double module_component_thickness = module_component_element.getAttribute("thickness").getDoubleValue();
+
+ //System.out.println("looking up material --> " + module_component_element.getAttributeValue("material"));
+
+ // Make logical volume for Component
+ ISolid module_component_solid = new Box(module_component_width,module_component_length,module_component_thickness);
+ Material module_component_material;
+ try
+ {
+ module_component_material = MaterialManager.findMaterial(module_component_element.getAttributeValue("material"));
+ }
+ catch (MaterialNotFoundException mnfe)
+ {
+ throw new RuntimeException(mnfe);
+ }
+ //System.out.println("module_component_material="+module_component_material.getName());
+
+ // Build component
+ // FIXME: need to have a name in .xml description for each component
+ LVolume module_component = new LVolume("dummy_name", module_component_solid, module_component_material);
+
+ // What do we do with sensitive flag???
+ boolean sensitive = (module_component_element.getAttribute("sensitive") == null) ? false : module_component_element.getAttribute("sensitive").getBooleanValue();
+
+ // module_component positions
+ double module_component_x, module_component_y, module_component_z = 0.0;
+ if (module_component_element.getChild("position") != null)
+ {
+ Element position = (Element) module_component_element.getChild("position");
+
+ if (position.getAttribute("x") != null)
+ {
+ module_component_x = position.getAttribute("x").getDoubleValue();
+ }
+
+ if (position.getAttribute("y") != null)
+ {
+ module_component_y = position.getAttribute("y").getDoubleValue();
+ }
+
+ if (position.getAttribute("z") != null)
+ {
+ module_component_z = position.getAttribute("z").getDoubleValue();
+ }
+ }
+
+ // module_component rotations
+ double module_component_rx, module_component_ry, module_component_rz = 0.0;
+ if (module_component_element.getChild("rotation") != null)
+ {
+ Element rotation = (Element) module_component_element.getChild("rotation");
+
+ if (rotation.getAttribute("x") != null)
+ {
+ module_component_x = rotation.getAttribute("x").getDoubleValue();
+ }
+
+ if (rotation.getAttribute("y") != null)
+ {
+ module_component_y = rotation.getAttribute("y").getDoubleValue();
+ }
+
+ if (rotation.getAttribute("z") != null)
+ {
+ module_component_z = rotation.getAttribute("z").getDoubleValue();
+ }
+ }
+
+ // FIXME: position the component
+
+ // Add the module_component to the module.
+ module.addComponent(component);
+
+ }
+
+ // Store the module
+ _modules.put(module_name, module);
+
+
+
+ // Make detector element for Module
+ SiTrackerModule module = new SiTrackerModule(new Box(module_width, module_length, module_thickness));
+
+
+
+ }
+
+
+
+
+
+ // Loop over layers.
+ int layern = 0;
+ for (Iterator i = detector.getChildren("layer").iterator(); i.hasNext(); ++layern)
+ {
+ Element layer_element = (Element) i.next();
+
+ // Name of the module associated with this layer.
+ String module_lkp = layer_element.getAttributeValue("module");
+
+ // barrel_envelope parameters.
+ Element barrel_envelope = layer_element.getChild("barrel_envelope");
+ double layer_inner_r = barrel_envelope.getAttribute("inner_r").getDoubleValue();
+ double layer_outer_r = barrel_envelope.getAttribute("outer_r").getDoubleValue();
+ double layer_z_length = barrel_envelope.getAttribute("z_length").getDoubleValue();
+
+ // rphi_layout parameters.
+ Element rphi_layout = layer_element.getChild("rphi_layout");
+ double phi_tilt = rphi_layout.getAttribute("phi_tilt").getDoubleValue();
+ int nphi = rphi_layout.getAttribute("nphi").getIntValue();
+ double phi0 = rphi_layout.getAttribute("phi0").getDoubleValue();
+ double rc = rphi_layout.getAttribute("rc").getDoubleValue();
+ double dr = rphi_layout.getAttribute("dr").getDoubleValue();
+
+ // z_layout parameters.
+ Element z_layout = layer_element.getChild("z_layout");
+ double z_dr = z_layout.getAttribute("dr").getDoubleValue();
+ double z0 = z_layout.getAttribute("z0").getDoubleValue();
+ int nz = z_layout.getAttribute("nz").getIntValue();
+
+ // Make logical volume for Layer
+ ISolid layer_solid = new TubeSegment(layer_inner_r,layer_outer_r,layer_z_length);
+ Material air;
+ try
+ {
+ air = MaterialManager.findMaterial("Air");
+ }
+ catch (MaterialNotFoundException mnfe)
+ {
+ System.out.println("Material not found: Air");
+ }
+ // FIXME: need to have a name in .xml for each layer
+ LVolume layer_volume = new LVolume("dummy_name", layer_solid, air);
+ Add physical volumes
+
+ // Make detector element for Layer
+ GeometryInfo layer_geometry = new GeometryInfo(new CoordinateTransformation3D(), layer_volume);
+ SiTrackerBarrelLayer layer = new SiTrackerBarrelLayer(layer_geometry);
+ layer.setPhiLayout(rc, nphi, phi0, phi_tilt, dr);
+ layer.setZLayout(nz, z0, z_dr);
+ layer.setModule(_modules.get(module_lkp));
+ this._layers.add(layer);
+ }
+ }
+
+
+
+
+ private void makeLayering()
+ {
+ //System.out.println("SiTrackerBarrel.makeLayering");
+
+ //System.out.println("nlayers=" + this._layers.size());
+
+ LayerStack layerStack = new LayerStack();
+ for (SiTrackerBarrelLayer tkrlayer : this._layers)
+ {
+ Map<Material, Double> matMap = new HashMap<Material, Double>();
+
+ TubeSegment layer_envelope = (TubeSegment)tkrlayer.getSolid();
+ double ir = layer_envelope.getInnerRadius();
+ double z = layer_envelope.getZLength();
+
+ SiTrackerModule module = tkrlayer.getModule();
+
+ int n_modules = tkrlayer.getNModules();
+
+ for (LVolume component : module.getComponents())
+ {
+ ISolid solid = component.getSolid();
+ Double volume = Double.valueOf(solid.getVolume()) * ((double) n_modules);
+ Material material = component.getMaterial();
+
+ assert (material != null);
+ //System.out.println("component material=" + material.getName());
+
+ if (matMap.get(material) == null)
+ {
+ matMap.put(material, volume);
+ }
+ else
+ {
+ Double volume_update = matMap.get(material);
+ volume_update += volume;
+ matMap.put(material, volume_update);
+ }
+ }
+
+ List<LayerSlice> slices = new ArrayList<LayerSlice>();
+
+ for (Material material : matMap.keySet())
+ {
+ //System.out.println("material=" + material.getName());
+
+ double volume = matMap.get(material);
+
+ double mat_or = Math.sqrt((volume / (Math.PI * z)) + ir * ir);
+
+ double thickness = mat_or - ir;
+
+ LayerSlice slice = new LayerSlice();
+ slice.setMaterial(material);
+ slice.setThickness(thickness);
+ slices.add(slice);
+ }
+
+ Layer l = new Layer(slices);
+ l.setPreOffset(ir);
+ layerStack.addLayer(l);
+ }
+
+ System.out.println(layerStack.toString());
+
+ setLayering(new Layering(layerStack));
+ }
+
+ 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");
+
+ for (SiTrackerBarrelLayer layer : _layers)
+ {
+ TubeSegment layer_envelope = (TubeSegment)layer.getSolid();
+
+ HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
+ instance.addAttValue("radius",layer_envelope.getInnerRadius());
+ factory.createHepRepPoint(instance,0,0,-layer_envelope.getZLength()/2);
+ factory.createHepRepPoint(instance,0,0,layer_envelope.getZLength()/2);
+
+ HepRepInstance instance2 = factory.createHepRepInstance(instanceTree, type);
+ instance2.addAttValue("radius",layer_envelope.getOuterRadius());
+ factory.createHepRepPoint(instance2,0,0,-layer_envelope.getZLength()/2);
+ factory.createHepRepPoint(instance2,0,0,layer_envelope.getZLength()/2);
+ }
+ }
+
+ public boolean isBarrel()
+ {
+ return true;
+ }
+}
\ No newline at end of file
GeomConverter/sandbox/tknelson_snapshot
diff -N LVolume.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LVolume.java 27 Feb 2007 19:59:19 -0000 1.1
@@ -0,0 +1,100 @@
+/*
+ * LVolume.java
+ *
+ * Created on October 9, 2006, 3:15 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import org.lcsim.material.Material;
+import org.lcsim.material.MaterialManager;
+import org.lcsim.material.MaterialNotFoundException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class LVolume
+{
+ // Fields
+ protected String _name;
+ protected Material _material;
+ protected ISolid _solid;
+ protected List<PVolume> _pvolumes = new ArrayList<PVolume>();
+
+ public LVolume(String name, ISolid solid, Material material)
+ {
+ _name = name;
+ _solid = solid;
+ _material = material;
+ }
+
+ public LVolume(Element lvolume) throws JDOMException
+ {
+ buildFromXML(lvolume);
+ }
+
+ // Accessors
+ //==========
+ public String getName()
+ {
+ return _name;
+ }
+
+ public Material getMaterial()
+ {
+ return _material;
+ }
+
+ public ISolid getSolid()
+ {
+ return _solid;
+ }
+
+ public List<PVolume> getPVolumes()
+ {
+ return _pvolumes;
+ }
+
+ public void addPVolume(PVolume pvolume)
+ {
+ _pvolumes.add(pvolume);
+ }
+
+ public void buildFromXML(Element lvolume)
+ {
+ // Create name
+ _name = lvolume.getAttributeValue("name");
+
+ // Create material
+ try
+ {
+ _material = MaterialManager.findMaterial(lvolume.getAttributeValue("material"));
+ }
+ catch (MaterialNotFoundException mnfe)
+ {
+ throw new RuntimeException(mnfe);
+ }
+
+ // Create solid
+ Element solid = lvolume.getChild("solid");
+ String shape = solid.getAttributeValue("shape");
+ if (shape=="box") _solid = new Box(solid);
+ if (shape=="tubesegment") _solid = new TubeSegment(solid);
+
+ // Add physical volumes
+ for (Iterator i = lvolume.getChildren("pvolume").iterator(); i.hasNext();)
+ {
+ addPVolume( new PVolume((Element)i.next()) ) ;
+ }
+
+ }
+
+}
\ No newline at end of file
GeomConverter/sandbox/tknelson_snapshot
diff -N Box.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Box.java 27 Feb 2007 19:59:19 -0000 1.1
@@ -0,0 +1,64 @@
+/*
+ * Box.java
+ *
+ * Created on October 6, 2006, 4:41 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class Box implements ISolid
+{
+
+ // Fields
+ //=======
+ private double _dimensions[] = new double[3];
+
+ /** Creates a new instance of Box */
+ public Box(Element box)
+ {
+ buildFromXML(box);
+ }
+
+ // Public methods
+ //===============
+ public double[] getDimensions()
+ {
+ return _dimensions;
+ }
+
+ public double getVolume()
+ {
+ return _dimensions[0]*_dimensions[1]*_dimensions[2];
+ }
+
+ public boolean isInside(Hep3Vector point)
+ {
+ return ( Math.abs(point.x()) < _dimensions[0]/2.0 &&
+ Math.abs(point.y()) < _dimensions[1]/2.0 &&
+ Math.abs(point.z()) < _dimensions[2]/2.0 );
+ }
+
+ public void buildFromXML(Element box)
+ {
+ try
+ {
+ _dimensions[0] = box.getAttribute("x_size").getDoubleValue();
+ _dimensions[1] = box.getAttribute("y_size").getDoubleValue();
+ _dimensions[2] = box.getAttribute("z_size").getDoubleValue();
+ }
+ catch (DataConversionException dce)
+ {
+ System.out.println("Cannot convert Box dimensions to double!");
+ }
+ }
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N SiTrackerModule.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SiTrackerModule.java 27 Feb 2007 19:59:19 -0000 1.1
@@ -0,0 +1,42 @@
+/*
+ * SiTrackerModule_1.java
+ *
+ * Created on October 6, 2006, 4:06 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import java.util.*;
+
+/**
+ *
+ * @author tknelson
+ */
+public class SiTrackerModule
+{
+
+ private Box _envelope = new Box();
+ private List<LVolume> _components = new ArrayList<LVolume>();
+
+ /** Creates a new instance of SiTrackerModule */
+ public SiTrackerModule()
+ {
+ }
+
+ public SiTrackerModule(Box envelope)
+ {
+ _envelope = envelope;
+ }
+
+ // Setters
+ public void addComponent(LVolume component)
+ {
+ _components.add(component);
+ }
+
+ public List<LVolume> getComponents()
+ {
+ return _components;
+ }
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N Hep3Rotation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Hep3Rotation.java 27 Feb 2007 19:59:19 -0000 1.1
@@ -0,0 +1,71 @@
+/*
+ * Hep3Rotation.java
+ *
+ * Created on October 4, 2006, 10:51 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Matrix;
+import hep.physics.vec.BasicHep3Matrix;
+import hep.physics.vec.VecOp;
+
+/**
+ *
+ * @author tknelson
+ */
+public class Hep3Rotation extends BasicHep3Matrix
+{
+
+ // Fields
+ //=======
+ /** Creates a new instance of Hep3Rotation */
+ public Hep3Rotation()
+ {
+ }
+
+ // Static Methods
+ //===============
+ public static Hep3Rotation passiveTaitBryan(double alpha, double beta, double gamma)
+ {
+ return (Hep3Rotation)VecOp.mult(passiveZRotation(gamma),VecOp.mult(passiveYRotation(beta),passiveXRotation(alpha)));
+ }
+
+ public static Hep3Rotation passiveXRotation(double angle)
+ {
+ double sin = Math.sin(angle);
+ double cos = Math.cos(angle);
+ Hep3Rotation rotation = new Hep3Rotation();
+ rotation.setElement(1,1,cos);
+ rotation.setElement(1,2,sin);
+ rotation.setElement(2,1,-sin);
+ rotation.setElement(2,2,cos);
+ return rotation;
+ }
+
+ public static Hep3Rotation passiveYRotation(double angle)
+ {
+ double sin = Math.sin(angle);
+ double cos = Math.cos(angle);
+ Hep3Rotation rotation = new Hep3Rotation();
+ rotation.setElement(0,0,cos);
+ rotation.setElement(1,3,-sin);
+ rotation.setElement(3,1,sin);
+ rotation.setElement(3,3,cos);
+ return rotation;
+ }
+
+ public static Hep3Rotation passiveZRotation(double angle)
+ {
+ double sin = Math.sin(angle);
+ double cos = Math.cos(angle);
+ Hep3Rotation rotation = new Hep3Rotation();
+ rotation.setElement(0,0,cos);
+ rotation.setElement(0,1,sin);
+ rotation.setElement(1,0,-sin);
+ rotation.setElement(1,1,cos);
+ return rotation;
+ }
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N IDetectorElement.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IDetectorElement.java 27 Feb 2007 19:59:19 -0000 1.1
@@ -0,0 +1,27 @@
+/*
+ * IDetectorElement.java
+ *
+ * Created on November 2, 2006, 4:51 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import java.util.List;
+
+/**
+ *
+ * @author tknelson
+ */
+public interface IDetectorElement
+{
+
+ // Get geometry Information
+ public IGeometryInfo getGeometry();
+
+ // Get information about hierarchy
+// public IDetectorElement getParent();
+//
+// public List<IDetectorElement> getChildren();
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N GeometryInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GeometryInfo.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,101 @@
+/*
+ * GeometryInfo.java
+ *
+ * Created on November 6, 2006, 11:12 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+import java.util.List;
+
+/**
+ *
+ * @author tknelson
+ */
+public class GeometryInfo implements IGeometryInfo
+{
+
+ // Fields
+ //=======
+ CoordinateTransformation3D _global_to_local;
+ CoordinateTransformation3D _local_to_global;
+ LVolume _logical_volume;
+ List<PVolume> _daughter_volumes;
+
+ /** Creates a new instance of GeometryInfo */
+ public GeometryInfo(CoordinateTransformation3D global_to_local, LVolume logical_volume)
+ {
+ _global_to_local = global_to_local;
+ _local_to_global = global_to_local.inverse();
+ _logical_volume = logical_volume;
+ }
+
+ // Accessors
+ public CoordinateTransformation3D getGlobalToLocal()
+ {
+ return _global_to_local;
+ }
+
+ public CoordinateTransformation3D getLocalToGlobal()
+ {
+ return _local_to_global;
+ }
+
+ public Hep3Vector globalToLocal(Hep3Vector global_point)
+ {
+ return _global_to_local.transform(global_point);
+ }
+
+ public Hep3Vector localToGlobal(Hep3Vector local_point)
+ {
+ return _local_to_global.transform(local_point);
+ }
+
+ public String childVolumeName(Hep3Vector global_point)
+ {
+ Hep3Vector parent_point = globalToLocal(global_point);
+ List<PVolume> daughter_volumes = getLogicalVolume().getDaughters();
+
+ String volume_name = "";
+ for (PVolume daughter_volume : _daughter_volumes)
+ {
+ if (daughter_volume.getLogicalVolume().getSolid().isInside(daughter_volume.parentToLocal(parent_point)));
+ {
+ volume_name = daughter_volume.getLogicalVolume().getName();
+ break;
+ }
+ }
+ return volume_name;
+ }
+
+ public PVolume childVolume(Hep3Vector global_point)
+ {
+ Hep3Vector parent_point = globalToLocal(global_point);
+ List<PVolume> daughter_volumes = getLogicalVolume().getDaughters();
+
+ PVolume volume = null;
+ for (PVolume daughter_volume : _daughter_volumes)
+ {
+ if (daughter_volume.getLogicalVolume().getSolid().isInside(daughter_volume.parentToLocal(parent_point)));
+ {
+ volume = daughter_volume;
+ break;
+ }
+ }
+ return volume;
+ }
+
+ public boolean isInside(Hep3Vector global_point)
+ {
+ return getLogicalVolume().getSolid().isInside(globalToLocal(global_point));
+ }
+
+ public LVolume getLogicalVolume()
+ {
+ return _logical_volume;
+ }
+
+
+}
\ No newline at end of file
GeomConverter/sandbox/tknelson_snapshot
diff -N IGeometryInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IGeometryInfo.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,48 @@
+/*
+ * IGeometryInfo.java
+ *
+ * Created on November 2, 2006, 4:51 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+
+/**
+ *
+ * @author tknelson
+ */
+public interface IGeometryInfo
+{
+
+ // global to local transformation
+ public CoordinateTransformation3D getGlobalToLocal();
+
+ // local to global transformation
+ public CoordinateTransformation3D getLocalToGlobal();
+
+ // transform a point in local coordinates to global coordinates
+ public Hep3Vector localToGlobal(Hep3Vector local_point);
+
+ // transform a point in global coordinates to local coordinates
+ public Hep3Vector globalToLocal(Hep3Vector global_point);
+
+ // get name of daughter volume containing a point in global coordinates
+ public String childVolumeName(Hep3Vector global_point);
+
+ // get daughter volume containing a point in global coordinates
+ public PVolume childVolume(Hep3Vector global_point);
+
+ // Gaudi has "get the exact full geometry location" What does this mean???
+ // One interpretation, entire heirarchy as map of LVolumes to
+ // positions in coordinates of each volume
+ // public Map<ILVolume,Hep3Vector>
+
+ // determine whether a point is inside the logical volume
+ public boolean isInside(Hep3Vector global_point);
+
+ // get the associated logical volume
+ public LVolume getLogicalVolume();
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N SiTrackerBarrelTest.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SiTrackerBarrelTest.xml 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,291 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+ <info name="subdetectors_test">
+ <comment/>
+ </info>
+ <define>
+ <constant name="cm" value="10"/>
+ <constant name="world_side" value="30000"/>
+ <constant name="world_x" value="world_side"/>
+ <constant name="world_y" value="world_side"/>
+ <constant name="world_z" value="world_side"/>
+ <constant name="tracking_region_radius" value="180.0 * cm"/>
+ <constant name="tracking_region_zmax" value="300.0 * cm"/>
+ </define>
+ <materials>
+ </materials>
+ <display>
+ <vis name="TestVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
+ </display>
+ <detectors>
+ <!--
+ <detector id="1" name="VtxBarrel" type="SiTrackerBarrel" readout="VtxBarrel_RO" vis="TestVis">
+ <module name="VtxBarrelModuleInner">
+ <module_envelope width="9.8" length="63.0 * 2" thickness="0.6"/>
+ <module_component width="7.6" length="125.0" thickness="0.26" material="CarbonFiber" sensitive="false">
+ <position z="-0.08"/>
+ </module_component>
+ <module_component width="7.6" length="125.0" thickness="0.05" material="Epoxy" sensitive="false">
+ <position z="0.075"/>
+ </module_component>
+ <module_component width="9.6" length="125.0" thickness="0.1" material="Silicon" sensitive="true">
+ <position z="0.150"/>
+ </module_component>
+ </module>
+ <module name="VtxBarrelModuleOuter">
+ <module_envelope width="14.0" length="126.0" thickness="0.6"/>
+ <module_component width="11.6" length="125.0" thickness="0.26" material="CarbonFiber" sensitive="false">
+ <position z="-0.08"/>
+ </module_component>
+ <module_component width="11.6" length="125.0" thickness="0.05" material="Epoxy" sensitive="false">
+ <position z="0.075"/>
+ </module_component>
+ <module_component width="13.8" length="125.0" thickness="0.1" material="Silicon" sensitive="true">
+ <position z="0.150"/>
+ </module_component>
+ </module>
+ <layer module="VtxBarrelModuleInner" id="1">
+ <barrel_envelope inner_r="13.0" outer_r="17.0" z_length="63 * 2"/>
+ <rphi_layout phi_tilt="0.0" nphi="12" phi0="0.2618" rc="15.05" dr="-1.15"/>
+ <z_layout dr="0.0" z0="0.0" nz="1"/>
+ </layer>
+ <layer module="VtxBarrelModuleOuter" id="2">
+ <barrel_envelope inner_r="21.0" outer_r="25.0" z_length="63 * 2"/>
+ <rphi_layout phi_tilt="0.0" nphi="12" phi0="0.2618" rc="23.03" dr="-1.13"/>
+ <z_layout dr="0.0" z0="0.0" nz="1"/>
+ </layer>
+ <layer module="VtxBarrelModuleOuter" id="3">
+ <barrel_envelope inner_r="34.0" outer_r="38.0" z_length="63 * 2"/>
+ <rphi_layout phi_tilt="0.0" nphi="18" phi0="0.0" rc="35.79" dr="-0.89"/>
+ <z_layout dr="0.0" z0="0.0" nz="1"/>
+ </layer>
+ <layer module="VtxBarrelModuleOuter" id="4">
+ <barrel_envelope inner_r="46.6" outer_r="50.6" z_length="63 * 2"/>
+ <rphi_layout phi_tilt="0.0" nphi="24" phi0="0.1309" rc="47.5" dr="0.81"/>
+ <z_layout dr="0.0" z0="0.0" nz="1"/>
+ </layer>
+ <layer module="VtxBarrelModuleOuter" id="5">
+ <barrel_envelope inner_r="59.0" outer_r="63.0" z_length="63 * 2"/>
+ <rphi_layout phi_tilt="0.0" nphi="30" phi0="0.0" rc="59.9" dr="0.77"/>
+ <z_layout dr="0.0" z0="0.0" nz="1"/>
+ </layer>
+ </detector>
+-->
+ <detector id="2" name="SiTrackerBarrel" type="SiTrackerBarrel" readout="SiTrackerBarrel_RO" vis="TestVis">
+
+
+
+
+ <!-- Module Components -->
+ <lvolume name="BarrelModuleCF">
+ <solid shape="box" size_x="97.79" size_y="97.79" size_z="0.228" material="CarbonFiber"/>
+ </lvolume>
+ <lvolume name="BarrelModuleRohacell">
+ <box size_x="97.79" size_y="97.79" size_z="3.175" material="Rohacell31"/>
+ </lvolume>
+ <lvolume name="BarrelSensor" sensitive="true">
+ <box size_x="93.531" size_y="93.531" size_z="0.3" material="Silicon"/>
+ </lvolume>
+ <lvolume name="KPiX">
+ <box size_x="63.8" size_y="6.67" size_z="0.3" material="Silicon"/>
+ </lvolume>
+ <lvolume name="Pigtail">
+ <box size_x="97.79" size_y="97.79" size_z="0.1" material="Silicon"/>
+ </lvolume>
+
+ <!-- Modules -->
+ <lvolume name="BarrelModule">
+ <box size_x="97.79" size_y="97.79" size_z="5.5" material="Air"/>
+ <pvolume name="BottomCF" lvolume="BarrelModuleCF">
+ <posXYZ z="-1.702"/>
+ </pvolume>
+ <pvolume name="Rohacell" lvolume="BarrelModuleRohacell">
+ <posXYZ z="0.0"/>
+ </pvolume>
+ <pvolume name="TopCF" lvolume="BarrelModuleCF">
+ <posXYZ z="1.702"/>
+ </pvolume>
+ <pvolume name="Sensor" lvolume="BarrelSensor">
+ <posXYZ z="2.082"/>
+ </pvolume>
+ <pvolume name="KPiX" lvolume="KPiX">
+ <posXYZ z="2.492"/>
+ </pvolume>
+ <pvolume name="PigTail" lvolume="PigTail">
+ <posXYZ z="2.692"/>
+ </pvolume>
+ </lvolume>
+
+ <!-- Barrel Supports -->
+
+ <!-- Layers: custom xml converter required to generate this logical volume! -->
+ <lvolume name="BarrelLayer1">
+ <tubesegment r_inner="195.0" r_outer="245.0" z_length="2.0*267.0" material="Air"/>
+ <specific>
+ <layout module = "BarrelModule">
+ <rphi rc="205.0" nphi="16" phi0="0.196" phi_tilt="0.19" dr="0"/>
+ <z z0="218.0" nz="7" dr="5.5"/>
+ </layout>
+ </specific>
+ </lvolume>
+ <lvolume name="BarrelLayer2">
+ <tubesegment r_inner="451.0" r_outer="501.0" z_length="2.0*608.0" material="Air"/>
+ <specific>
+ <layout module = "BarrelModule">
+ <rphi rc="461.0" nphi="36" phi0="0.087" phi_tilt="0.19" dr="0"/>
+ <z z0="559.0" nz="15" dr="5.5"/>
+ </layout>
+ </specific>
+ </lvolume>
+ <lvolume name="BarrelLayer3">
+ <tubesegment r_inner="706.0" r_outer="756.0" z_length="2.0*948.0" material="Air"/>
+ <specific>
+ <layout module = "BarrelModule">
+ <rphi rc="716.0" nphi="54" phi0="0.058" phi_tilt="0.19" dr="0"/>
+ <z z0="899.0" nz="23" dr="5.5"/>
+ </layout>
+ </specific>
+ </lvolume>
+ <lvolume name="BarrelLayer4">
+ <tubesegment r_inner="962.0" r_outer="1012.0" z_length="2.0*1289.0*" material="Air"/>
+ <specific>
+ <layout module = "BarrelModule">
+ <rphi rc="972.0" nphi="72" phi0="0.0436" phi_tilt="0.19" dr="0"/>
+ <z z0="1240.0" nz="29" dr="5.5"/>
+ </layout>
+ </specific>
+ </lvolume>
+ <lvolume name="BarrelLayer5">
+ <tubesegment r_inner="1218.0" r_outer="1265.0" z_length="2.0*1630.0" material="Air"/>
+ <specific>
+ <layout module = "BarrelModule">
+ <rphi rc="1228.0" nphi="90" phi0="0.01745" phi_tilt="0.19" dr="0"/>
+ <z z0="1581.0" nz="37" dr="5.5"/>
+ </layout>
+ </specific>
+ </lvolume>
+
+ <!-- Tracker Barrel -->
+ <lvolume name="SiTrackerBarrel">
+ <pvolume name="BarrelLayer1" lvolume="BarrelLayer1"/>
+ <pvolume name="BarrelLayer2" lvolume="BarrelLayer2"/>
+ <pvolume name="BarrelLayer3" lvolume="BarrelLayer3"/>
+ <pvolume name="BarrelLayer4" lvolume="BarrelLayer4"/>
+ <pvolume name="BarrelLayer5" lvolume="BarrelLayer5"/>
+ </lvolume>
+
+ <!-- Detector Elements -->
+ <detelem name="SiTrackerBarrel">
+ <child name="BarrelLayer1"/>
+ <child name="BarrelLayer2"/>
+ <child name="BarrelLayer3"/>
+ <child name="BarrelLayer4"/>
+ <child name="BarrelLayer5"/>
+ </detelem>
+
+ <detelem name="BarrelLayer1" lvolume="BarrelLayer1">
+ <child name="BarrelLayer1Module" elref="BarrelModule"/>
+ </detelem>
+ <detelem name="BarrelLayer2" lvolume="BarrelLayer2">
+ <child name="BarrelLayer2Module" elref="BarrelModule"/>
+ </detelem>
+ <detelem name="BarrelLayer3" lvolume="BarrelLayer3">
+ <child name="BarrelLayer3Module" elref="BarrelModule"/>
+ </detelem>
+ <detelem name="BarrelLayer4" lvolume="BarrelLayer4">
+ <child name="BarrelLayer4Module" elref="BarrelModule"/>
+ </detelem>
+ <detelem name="BarrelLayer5" lvolume="BarrelLayer5">
+ <child name="BarrelLayer5Module" elref="BarrelModule"/>
+ </detelem>
+
+ <detelem name="BarrelModule" lvolume="BarrelModule">
+ <child name="BarrelSensor"/>
+ </detelem>
+
+ <detelem name="BarrelSensor" lvolume="BarrelSensor">
+ <param name="doublesided" value="false"/>
+ <param name="pside" value="outside"/>
+ <param name="psensepitch" value="25*microns"/>
+ <param name="preadoutpitch" value="50*microns"/>
+ <param name="guardwidth" value="750*microns"/>
+ <param name="depletionvoltage" value="100*volts"/>
+ <param name="biasvoltage" value="110*volts"/>
+ <child name="KPiX1" elref="KPiX"/>
+ <child name="KPiX2" elref="KPiX"/>
+ </detelem>
+
+ <detelem name="KPiX"/>
+ <param name="foo" value="bar"/>
+ </detelem>
+
+
+
+
+ <detelem name="BarrelLayer1Sensor" elref="BarrelSensor" parent="BarrelLayer1" lvolume="BarrelSensor"/>
+ <detelem name="BarrelLayer2Sensor" elref="BarrelSensor" parent="BarrelLayer2" lvolume="BarrelSensor"/>
+ <detelem name="BarrelLayer3Sensor" elref="BarrelSensor" parent="BarrelLayer3" lvolume="BarrelSensor"/>
+ <detelem name="BarrelLayer4Sensor" elref="BarrelSensor" parent="BarrelLayer4" lvolume="BarrelSensor"/>
+ <detelem name="BarrelLayer5Sensor" elref="BarrelSensor" parent="BarrelLayer5" lvolume="BarrelSensor"/>
+
+ <detelem name="BarrelSensor">
+ <param name="doublesided" value="false"/>
+ <param name="pside" value="outside"/>
+ <param name="psensepitch" value="25*microns"/>
+ <param name="preadoutpitch" value="50*microns"/>
+ <param name="guardwidth" value="750*microns"/>
+ <param name="depletionvoltage" value="100*volts"/>
+ <param name="biasvoltage" value="110*volts"/>
+ </detelem>
+
+ <detelem name="KPiX1"
+
+
+
+
+ </detector>
+ </detectors>
+ <readouts>
+ <readout name="SiTrackerBarrel_RO">
+ <id>system:6,barrel:2,layer:4,phi:8,z:8,sensor:1</id>
+ </readout>
+ <readout name="VtxBarrel_RO">
+ <id>system:6,barrel:2,layer:4,phi:8,z:8,sensor:1</id>
+ </readout>
+ </readouts>
+ <fields>
+ </fields>
+</lccdd>
+
+ <!--
+ <module_component width="97.79" length="97.79" thickness="0.1" material="Kapton" sensitive="false">
+ <position z="-2.692"/>
+ </module_component>
+
+ <module_component width="63.8" length="6.67" thickness="0.3" material="Silicon" sensitive="false">
+ <position z="-2.492"/>
+ </module_component>
+
+ <module_component width="93.031" length="93.031" thickness="0.3" material="Silicon" sensitive="true">
+ <position z="-2.082"/>
+ <rotation z="0.04" />
+ </module_component>
+ -->
+<!--
+ <detector id="1" name="SiTrackerBarrel" type="SiTrackerBarrel" readout="SiTrackerBarrel_RO" vis="TestVis">
+ <module name="MyModule">
+ <module_envelope width="100.0" length="100.0" thickness="5.0"/>
+ <module_component zc="-2.0" width="100" length="100" thickness="1.0" material="Silicon" sensitive="true"/>
+ <module_component zc="-1.0" width="100" length="100" thickness="1.0" material="Silicon" sensitive="false"/>
+ <module_component zc="0" width="100" length="100" thickness="1.0" material="Silicon" sensitive="false"/>
+ <module_component zc="1.0" width="100" length="100" thickness="1.0" material="Silicon" sensitive="false"/>
+ <module_component zc="2.0" width="100" length="100" thickness="1.0" material="Silicon" sensitive="true">
+ <rotation x="0.0"/>
+ </module_component>
+ </module>
+ <layer module="MyModule">
+ <barrel_envelope inner_r="900.0" outer_r="1100.0" z_length="1000.0" />
+ <rphi_layout phi_tilt="0.2" nphi="50" phi0="0.2" rc="1000.0" />
+ <z_layout dr="10" z0="450" nz="10"/>
+ </layer>
+ </detector>
+ -->
GeomConverter/sandbox/tknelson_snapshot
diff -N SiTrackerBarrelLayer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SiTrackerBarrelLayer.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,147 @@
+/*
+ * SiTrackerBarrelLayer.java
+ *
+ * Created on October 6, 2006, 2:01 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import org.lcsim.material.Material;
+
+/**
+ *
+ * @author tknelson
+ */
+public class SiTrackerBarrelLayer implements IDetectorElement
+{
+
+ // Fields
+ //========
+
+ // Geometry Info
+ private IGeometryInfo _geometry;
+
+ // module layout
+ //--------------
+ // module
+ private SiTrackerModule _module;
+
+ // phi
+ private double _r_center = 0.0;
+ private int _n_phi = 0;
+ private double _phi_0 = 0.0;
+ private double _phi_tilt = 0.0;
+ private double _dr_phi = 0.0;
+
+ // z
+ private int _n_z;
+ private double _z_0 = 0.0;
+ private double _dr_z = 0.0;
+
+ // Constructors
+ //=============
+
+ public SiTrackerBarrelLayer(IGeometryInfo geometry)
+ {
+ _geometry = geometry;
+ }
+
+ // Initializers
+ //=============
+// public void setPhiLayout(double r_center, int n_phi, double phi_0, double phi_tilt, double dr_phi)
+// {
+// _r_center = r_center;
+// _n_phi = n_phi;
+// _phi_0 = phi_0;
+// _phi_tilt = phi_tilt;
+// _dr_phi = dr_phi;
+// }
+//
+// public void setZLayout(int n_z, double z_0, double dr_z)
+// {
+// _n_z = n_z;
+// _z_0 = z_0;
+// _dr_z = dr_z;
+// }
+//
+// public void setModule(SiTrackerModule module)
+// {
+// _module = module;
+// }
+
+
+ // Accessors
+ public IGeometryInfo getGeometry()
+ {
+ return _geometry;
+ }
+
+ // Public methods
+ //===============
+
+// public int getNModules()
+// {
+// return _n_phi * _n_z;
+// }
+
+// public int getPhiModuleIndex(double phi)
+// {
+// double phi_slice_size = 2.0*Math.PI/_n_phi;
+// double relative_phi_position = phi - _phi_0;
+// int phi_index = (int)Math.round(relative_phi_position/phi_slice_size);
+// return checkedPhiIndex(phi_index);
+// }
+//
+// public int getZModuleIndex(double z)
+// {
+// double z_slice_size = 2.0*_z_0 / (_n_z - 1);
+// double relative_z_position = z - _z_0;
+// int z_index = (int)Math.round(relative_z_position/z_slice_size);
+// return checkedZIndex(z_index);
+// }
+//
+// public SiTrackerModule getModule()
+// {
+// return this._module;
+// }
+
+// public double getInnerRadius()
+// {
+// return _r_inner;
+// }
+//
+// public double getOuterRadius()
+// {
+// return _r_outer;
+// }
+//
+// public double getZLength()
+// {
+// return _z_length;
+// }
+
+
+// public CoordinateTransformation3D getModuleCoordinates(int phi_index, int z_index)
+// {
+//
+// }
+
+ // Private methods
+ //================
+// private int checkedPhiIndex(int phi_index)
+// {
+// while (phi_index < 0) phi_index += _n_phi;
+// while (phi_index >= _n_phi) phi_index -= _n_phi;
+// return phi_index;
+// }
+//
+// private int checkedZIndex(int z_index)
+// {
+// if (z_index < 0) z_index = 0;
+// if (z_index > _n_z) z_index = _n_z;
+// return z_index;
+// }
+
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N GeometryCatalog.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GeometryCatalog.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,60 @@
+/*
+ * GeometryCatalog.java
+ *
+ * Created on November 9, 2006, 2:42 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ *
+ * @author tknelson
+ */
+public class GeometryCatalog
+{
+
+ // Singleton implementation
+ static private GeometryCatalog _instance;
+
+ /**
+ * Creates a new instance of GeometryCatalog
+ */
+ private GeometryCatalog()
+ {
+ }
+
+ static public GeometryCatalog getInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new GeometryCatalog();
+ }
+ return _instance;
+ }
+
+
+ // Storage of LVolumes
+ //====================
+ private Map<String,LVolume> _lvolumes = new HashMap<String,LVolume>();
+
+ public LVolume getLVolume(String name)
+ {
+ return _lvolumes.get(name);
+ }
+
+ public void addLVolume(String name, LVolume lvolume)
+ {
+ _lvolumes.put(name,lvolume);
+ }
+
+ public void clearLVolumes()
+ {
+ _lvolumes.clear();
+ }
+
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N CoordinateTransformation3D.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CoordinateTransformation3D.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,93 @@
+/*
+ * CoordinateTransformation3D.java
+ *
+ * Created on September 19, 2006, 11:27 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.VecOp;
+
+/**
+ *
+ * @author tknelson
+ */
+public class CoordinateTransformation3D
+{
+
+ // Fields
+ Hep3Vector _translation = new BasicHep3Vector(0.0,0.0,0.0);
+ Hep3Rotation _rotation = new Hep3Rotation();
+
+ /**
+ * Creates a new instance of CoordinateTransformation3D
+ */
+ public CoordinateTransformation3D()
+ {
+ }
+
+ public CoordinateTransformation3D(Hep3Vector translation, Hep3Rotation rotation)
+ {
+ _translation = translation;
+ _rotation = rotation;
+ }
+
+ // Access to translation and rotation
+ public Hep3Vector getTranslation()
+ {
+ return _translation;
+ }
+
+ public Hep3Rotation getRotation()
+ {
+ return _rotation;
+ }
+
+ // Transformations
+ public Hep3Vector transform(Hep3Vector coordinates)
+ {
+ translate(coordinates);
+ rotate(coordinates);
+ return coordinates;
+ }
+
+ public Hep3Vector translate(Hep3Vector coordinates)
+ {
+ return VecOp.add(coordinates,_translation);
+ }
+
+ public Hep3Vector rotate(Hep3Vector coordinates)
+ {
+ return VecOp.mult(_rotation,coordinates);
+ }
+
+ // Invert the transformation
+ public void invert()
+ {
+ _translation = VecOp.mult(-1.0,VecOp.mult(_rotation,_translation));
+ _rotation.invert(); // Need to assure that transpose is used
+ }
+
+ // FIXME: Talk to Tony about supporting this pattern
+
+// public CoordinateTransformation3D inverse()
+// {
+// CoordinateTransformation3D transform = new CoordinateTransformation3D(
+// VecOp.mult(-1.0,VecOp.mult(_rotation,_translation)),
+// _rotation.inverse()); // FIXME: Need to assure that transpose is used
+// return transform;
+// }
+
+ // Static functions
+ public static CoordinateTransformation3D mult(CoordinateTransformation3D transformation1, CoordinateTransformation3D transformation2)
+ {
+ Hep3Rotation rotation = (Hep3Rotation)VecOp.mult(transformation1.getRotation(),transformation2.getRotation());
+ Hep3Vector translation = VecOp.add(VecOp.mult(transformation1.getRotation(),transformation2.getTranslation()),
+ transformation1.getTranslation());
+ return new CoordinateTransformation3D(translation,rotation);
+ }
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N Trapezoid.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Trapezoid.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,78 @@
+/*
+ * Trapezoid.java
+ *
+ * Created on October 6, 2006, 4:41 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class Trapezoid implements ISolid
+{
+
+ // Fields
+ //=======
+ private double _dimensions[] = new double[4];
+
+ /** Creates a new instance of Box */
+ public Trapezoid(double[] dimensions)
+ {
+ _dimensions = dimensions;
+ }
+
+ public Trapezoid(double x1, double x2, double y, double z)
+ {
+ _dimensions[0] = x1;
+ _dimensions[1] = x2;
+ _dimensions[2] = y;
+ _dimensions[3] = z;
+ }
+
+ // Public methods
+ //===============
+ public double[] getDimensions()
+ {
+ return _dimensions;
+ }
+
+ public double getVolume()
+ {
+ return (_dimensions[0]+_dimensions[1])/2.0 * _dimensions[2] * _dimensions[3];
+ }
+
+ public boolean isInside(Hep3Vector point)
+ {
+ double inverse_slope = (_dimensions[1]-_dimensions[0])/(2.0*_dimensions[2]);
+ double x_intercept = (_dimensions[0]+_dimensions[1]/4.0);
+
+ double x_limit = inverse_slope*point.y()+x_intercept;
+
+ return ( Math.abs(point.x()) < x_limit &&
+ Math.abs(point.y()) < _dimensions[2]/2.0 &&
+ Math.abs(point.z()) < _dimensions[3]/2.0 );
+ }
+
+ public void buildFromXML(Element trapezoid)
+ {
+ try
+ {
+ _dimensions[0] = trapezoid.getAttribute("size_x1").getDoubleValue();
+ _dimensions[1] = trapezoid.getAttribute("size_x2").getDoubleValue();
+ _dimensions[2] = trapezoid.getAttribute("size_y").getDoubleValue();
+ _dimensions[3] = trapezoid.getAttribute("size_z").getDoubleValue();
+ }
+ catch (DataConversionException dce)
+ {
+ System.out.println("Cannot convert Trapezoid dimensions to double!");
+ }
+ }
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N TubeSegment.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TubeSegment.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,83 @@
+/*
+ * TubeSegment.java
+ *
+ * Created on November 3, 2006, 2:41 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class TubeSegment implements ISolid
+{
+
+ // Fields
+ //=======
+ private double _dimensions[] = new double[3];
+
+ /** Creates a new instance of Box */
+ public TubeSegment(Element tubesegment)
+ {
+ buildFromXML(tubesegment);
+ }
+
+ // Accessors
+ //==========
+ public double getInnerRadius()
+ {
+ return _dimensions[0];
+ }
+
+ public double getOuterRadius()
+ {
+ return _dimensions[1];
+ }
+
+ public double getZLength()
+ {
+ return _dimensions[2];
+ }
+
+ // Implementation of ISolid
+ //=========================
+ public double[] getDimensions()
+ {
+ return _dimensions;
+ }
+
+ public double getVolume()
+ {
+ return Math.PI*(_dimensions[1]*_dimensions[1] - _dimensions[0]*_dimensions[0])*_dimensions[2];
+ }
+
+ public boolean isInside(Hep3Vector point)
+ {
+ double r_xy = Math.sqrt(point.x()*point.x() + point.y()*point.y());
+
+ return ( r_xy > _dimensions[0] &&
+ r_xy < _dimensions[1] &&
+ Math.abs(point.z()) < _dimensions[2]/2.0 );
+ }
+
+ public void buildFromXML(Element tubesegment)
+ {
+ try
+ {
+ _dimensions[0] = tubesegment.getAttribute("r_inner").getDoubleValue();
+ _dimensions[1] = tubesegment.getAttribute("r_outer").getDoubleValue();
+ _dimensions[2] = tubesegment.getAttribute("z_length").getDoubleValue();
+ }
+ catch (DataConversionException dce)
+ {
+ System.out.println("Cannot convert TubeSegment dimensions to double!");
+ }
+ }
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N ISolid.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ISolid.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,33 @@
+/*
+ * ISolid.java
+ *
+ * Created on October 9, 2006, 3:44 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public interface ISolid
+{
+
+ // Return dimensions
+ public double[] getDimensions();
+
+ // Calculate volume
+ public double getVolume();
+
+ // Is a particular point inside?
+ public boolean isInside(Hep3Vector point);
+
+ // Must be buildable from xml
+ public void buildFromXML(Element solid);
+
+}
GeomConverter/sandbox/tknelson_snapshot
diff -N PVolume.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PVolume.java 27 Feb 2007 19:59:20 -0000 1.1
@@ -0,0 +1,105 @@
+/*
+ * PVolume.java
+ *
+ * Created on November 2, 2006, 5:17 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class PVolume
+{
+
+ private String _name;
+ private String _lvolume_name;
+ private CoordinateTransformation3D _parent_to_local = new CoordinateTransformation3D();
+
+ /** Creates a new instance of PVolume */
+ public PVolume(String name, String lvolume_name, CoordinateTransformation3D parent_to_local)
+ {
+ _name = name;
+ _lvolume_name = lvolume_name;
+ _parent_to_local = parent_to_local;
+ }
+
+ public PVolume(Element pvolume)
+ {
+ buildFromXML(pvolume);
+ }
+
+ // Accessors
+ //==========
+ public String getName()
+ {
+ return _name;
+ }
+
+ public String getLVolumeName()
+ {
+ return _lvolume_name;
+ }
+
+ public LVolume getLVolume(String name)
+ {
+ return GeometryCatalog.getInstance().getLVolume(_lvolume_name);
+ }
+
+ public CoordinateTransformation3D getParentToLocal()
+ {
+ return _parent_to_local;
+ }
+
+ public Hep3Vector parentToLocal(Hep3Vector parent_point)
+ {
+ return _parent_to_local.transform(parent_point);
+ }
+
+ public void buildFromXML(Element pvolume)
+ {
+ // Create name
+ _name = pvolume.getAttributeValue("name");
+
+ // Create lvolume name
+ _lvolume_name = pvolume.getAttributeValue("lvolume");
+
+ // Create CoordinateTransformation3D
+ Element trans = pvolume.getChild("posXYZ");
+ Hep3Vector translation = null;
+ try
+ {
+ translation = new BasicHep3Vector(trans.getAttribute("x").getDoubleValue(),
+ trans.getAttribute("y").getDoubleValue(),
+ trans.getAttribute("z").getDoubleValue());
+ }
+ catch (DataConversionException dce)
+ {
+ System.out.println("Cannot convert translation to double!");
+ }
+
+ Element rot = pvolume.getChild("rotXYZ");
+ Hep3Rotation rotation = null;
+ try
+ {
+ rotation = Hep3Rotation.passiveTaitBryan(rot.getAttribute("rot_x").getDoubleValue(),
+ rot.getAttribute("rot_y").getDoubleValue(),
+ rot.getAttribute("rot_z").getDoubleValue());
+ }
+ catch (DataConversionException dce)
+ {
+ System.out.println("Cannot convert rotation to double!");
+ }
+
+ _parent_to_local = new CoordinateTransformation3D(translation,rotation);
+
+ }
+
+}
CVSspam 0.2.8