5 added + 22 modified, total 27 files
GeomConverter/src/org/lcsim/detector
diff -N DetectorElementContainer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DetectorElementContainer.java 17 Mar 2007 00:10:40 -0000 1.1
@@ -0,0 +1,8 @@
+package org.lcsim.detector;
+
+import java.util.ArrayList;
+
+public class DetectorElementContainer
+extends ArrayList<IDetectorElement>
+implements IDetectorElementContainer
+{}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector
diff -N IPhysicalVolumeNavigatorStore.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IPhysicalVolumeNavigatorStore.java 17 Mar 2007 00:10:40 -0000 1.1
@@ -0,0 +1,15 @@
+package org.lcsim.detector;
+
+import java.util.List;
+
+public interface IPhysicalVolumeNavigatorStore
+extends IObjectStore<IPhysicalVolumeNavigator>
+{
+ public IPhysicalVolumeNavigator create(String name, IPhysicalVolume world);
+ public IPhysicalVolumeNavigator createDefault(IPhysicalVolume topVolume);
+ public IPhysicalVolumeNavigator get(IPhysicalVolume world);
+ public IPhysicalVolumeNavigator get(String name);
+ public List<IPhysicalVolumeNavigator> find(IPhysicalVolume world);
+ public IPhysicalVolumeNavigator getDefaultNavigator();
+ public void reset();
+}
GeomConverter/src/org/lcsim/detector
diff -N PhysicalVolumeNavigatorStore.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PhysicalVolumeNavigatorStore.java 17 Mar 2007 00:10:40 -0000 1.1
@@ -0,0 +1,98 @@
+package org.lcsim.detector;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PhysicalVolumeNavigatorStore
+extends ArrayList<IPhysicalVolumeNavigator>
+implements IPhysicalVolumeNavigatorStore
+{
+ Map<String,IPhysicalVolumeNavigator> navigators = new HashMap<String,IPhysicalVolumeNavigator>();
+ private static PhysicalVolumeNavigatorStore store;
+ private String defaultNavigator="default";
+
+ public static IPhysicalVolumeNavigatorStore getInstance()
+ {
+ if ( store == null )
+ {
+ store = new PhysicalVolumeNavigatorStore();
+ }
+ return store;
+ }
+
+ public boolean add(IPhysicalVolumeNavigator nav)
+ {
+ add(nav,nav.getName());
+ return true;
+ }
+
+ public void add(IPhysicalVolumeNavigator nav, String name)
+ {
+ navigators.put(name, nav);
+ }
+
+ public IPhysicalVolumeNavigator createDefault(IPhysicalVolume topVolume)
+ {
+ //System.out.println("PhysicalVolumeNavigatorStore.createDefault");
+ return create("default",topVolume);
+ }
+
+ public IPhysicalVolumeNavigator create(String name, IPhysicalVolume topVolume)
+ {
+ //System.out.println("PhysicalVolumeNavigatorStore.create - " + name);
+ IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(name, topVolume);
+ add(nav, name);
+ return nav;
+ }
+
+ public IPhysicalVolumeNavigator get(String name)
+ {
+ return navigators.get(name);
+ }
+
+ public IPhysicalVolumeNavigator get(IPhysicalVolume world)
+ {
+ List<IPhysicalVolumeNavigator> search = find(world);
+ IPhysicalVolumeNavigator nav;
+ if ( search.size() == 0 )
+ {
+ nav = new PhysicalVolumeNavigator(defaultNavigator, world);
+ }
+ else {
+ nav = search.get(0);
+ }
+ return nav;
+ }
+
+ public List<IPhysicalVolumeNavigator> find(IPhysicalVolume world)
+ {
+ List<IPhysicalVolumeNavigator> navList = new ArrayList<IPhysicalVolumeNavigator>();
+ for ( IPhysicalVolumeNavigator nav : navList )
+ {
+ if ( nav.getTopPhysicalVolume() == world )
+ {
+ navList.add(nav);
+ }
+ }
+ return navList;
+ }
+
+ public IPhysicalVolumeNavigator getDefaultNavigator()
+ {
+ if ( !navigators.containsKey(defaultNavigator) )
+ {
+ throw new RuntimeException("No default navigator was found!");
+ }
+ else {
+ return navigators.get(defaultNavigator);
+ }
+ }
+
+ public void reset()
+ {
+ this.clear();
+ navigators = new HashMap<String,IPhysicalVolumeNavigator>();
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector
diff -u -r1.5 -r1.6
--- DetectorElement.java 15 Mar 2007 02:09:14 -0000 1.5
+++ DetectorElement.java 17 Mar 2007 00:10:40 -0000 1.6
@@ -6,87 +6,110 @@
extends Named
implements IDetectorElement
{
- private IDetectorElementContainer children;
- private IGeometryInfo geometry;
- IDetectorElement parent;
- IIdentifier id;
-
- public DetectorElement(
- String name)
- {
- super(name);
- }
-
- public void createGeometryInfo(IPhysicalVolumePath path)
- {
- geometry = new GeometryInfo(this,path);
- }
-
- public void createGeometryInfo()
- {
- if ( geometry == null )
- {
- geometry = new GeometryInfo(this, null);
- }
- }
-
- /**
- * Create a DE with support in the geometry tree.
- *
- * @param name
- * @param parent
- * @param support
- * @param id
- */
- public DetectorElement(
- String name,
- IDetectorElement parent,
- IPhysicalVolumePath support,
- IIdentifier id)
- {
- super(name);
- this.parent = parent;
- this.geometry = new GeometryInfo(this,support);
- this.id = id;
-
- DetectorElementStore.getInstance().add(this);
- }
-
- protected void setup(
- IDetectorElement parent,
- IPhysicalVolumePath support,
- IIdentifier id
- )
- {
- this.parent = parent;
- this.geometry=new GeometryInfo(this,support);
- this.id = id;
-
- DetectorElementStore.getInstance().add(this);
- }
-
- public void addChild(IDetectorElement child)
- {
- children.add(child);
- }
-
- public IDetectorElementContainer getChildren()
- {
- return children;
- }
-
- public IGeometryInfo getGeometry()
- {
- return geometry;
- }
-
- public IDetectorElement getParent()
- {
- return parent;
- }
-
- public IIdentifier getIdentifier()
- {
- return id;
- }
+ private IDetectorElementContainer children = new DetectorElementContainer();
+ private IGeometryInfo geometry;
+ IDetectorElement parent;
+ IIdentifier id;
+
+ /**
+ * Create a DE with support in the geometry tree.
+ *
+ * @param name
+ * @param parent
+ * @param support
+ * @param id
+ */
+ public DetectorElement(
+ String name,
+ IDetectorElement parent,
+ IPhysicalVolumePath support,
+ IIdentifier id)
+ {
+ super(name);
+
+ setup(parent, support, id);
+
+ register();
+ }
+
+ public DetectorElement(
+ String name)
+ {
+ super(name);
+
+ register();
+ }
+
+ private void register()
+ {
+ if ( !DetectorElementStore.getInstance().contains(this) )
+ {
+ DetectorElementStore.getInstance().add(this);
+ }
+ }
+
+ protected void setup(
+ IDetectorElement parent,
+ IPhysicalVolumePath support,
+ IIdentifier id
+ )
+ {
+ this.parent = parent;
+ this.geometry = new GeometryInfo( this, support );
+ this.id = id;
+ }
+
+ public void createGeometryInfo(IPhysicalVolumePath path)
+ {
+ geometry = new GeometryInfo(this,path);
+ }
+
+ public void createGeometryInfo(String path)
+ {
+ IPhysicalVolumeNavigator nav = PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
+ geometry = new GeometryInfo(this,nav.getPath(path));
+ }
+
+ public void createGeometryInfo()
+ {
+ if ( geometry == null )
+ {
+ geometry = new GeometryInfo(this, null);
+ }
+ }
+
+ public void addChild(IDetectorElement child)
+ {
+ children.add(child);
+ }
+
+ public IDetectorElementContainer getChildren()
+ {
+ return children;
+ }
+
+ public boolean hasChildren()
+ {
+ return children.size() != 0;
+ }
+
+ public IGeometryInfo getGeometry()
+ {
+ return geometry;
+ }
+
+ public IDetectorElement getParent()
+ {
+ return parent;
+ }
+
+ public IIdentifier getIdentifier()
+ {
+ return id;
+ }
+
+ public void setIdentifier(IIdentifier id)
+ {
+ this.id = id;
+ }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector
diff -u -r1.3 -r1.4
--- DetectorFactory.java 9 Mar 2007 22:47:38 -0000 1.3
+++ DetectorFactory.java 17 Mar 2007 00:10:40 -0000 1.4
@@ -110,10 +110,16 @@
}
public IPhysicalVolumeNavigator createPhysicalVolumeNavigator(
+ String name,
IPhysicalVolume worldVolume)
{
- return new PhysicalVolumeNavigator(worldVolume);
+ return new PhysicalVolumeNavigator(name, worldVolume);
}
+
+ public IPhysicalVolumeNavigator createPhysicalVolumeNavigator(IPhysicalVolume world)
+ {
+ return PhysicalVolumeNavigatorStore.getInstance().get(world);
+ }
public IRotation3D createRotation3D()
{
GeomConverter/src/org/lcsim/detector
diff -u -r1.1 -r1.2
--- DetectorStore.java 7 Mar 2007 00:43:41 -0000 1.1
+++ DetectorStore.java 17 Mar 2007 00:10:40 -0000 1.2
@@ -43,5 +43,20 @@
{
return SolidStore.getInstance();
}
+
+ public IPhysicalVolumeNavigatorStore getPhysicalVolumeNavigatorStore()
+ {
+ return PhysicalVolumeNavigatorStore.getInstance();
+ }
+
+ public void reset()
+ {
+ getDetectorElementStore().clear();
+ getLogicalVolumeStore().clear();
+ getMaterialStore().clear();
+ getPhysicalVolumeNavigatorStore().clear();
+ getPhysicalVolumeStore().clear();
+ getSolidStore().clear();
+ }
}
GeomConverter/src/org/lcsim/detector
diff -u -r1.5 -r1.6
--- GeometryInfo.java 9 Mar 2007 22:47:38 -0000 1.5
+++ GeometryInfo.java 17 Mar 2007 00:10:40 -0000 1.6
@@ -84,7 +84,7 @@
this.support = support;
// Cache a PhysicalVolumeNavigator.
- navigator = new PhysicalVolumeNavigator(support.getTopVolume());
+ navigator = new PhysicalVolumeNavigator(support.toString(), support.getTopVolume());
// Set ref to LogicalVolume.
logicalVolume = support.get(support.size()-1).getLogicalVolume();
GeomConverter/src/org/lcsim/detector
diff -u -r1.2 -r1.3
--- IDetectorElement.java 4 Mar 2007 05:03:00 -0000 1.2
+++ IDetectorElement.java 17 Mar 2007 00:10:40 -0000 1.3
@@ -8,7 +8,7 @@
*
* @author Tim Nelson <[log in to unmask]>
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: IDetectorElement.java,v 1.2 2007/03/04 05:03:00 jeremy Exp $
+ * @version $Id: IDetectorElement.java,v 1.3 2007/03/17 00:10:40 jeremy Exp $
*/
public interface IDetectorElement
extends IIdentifiable, INamed
@@ -31,6 +31,8 @@
*/
public IDetectorElementContainer getChildren();
+ public boolean hasChildren();
+
/**
* Get the name of this DE.
* @return The name this DE.
GeomConverter/src/org/lcsim/detector
diff -u -r1.1 -r1.2
--- IDetectorElementContainer.java 28 Feb 2007 21:52:00 -0000 1.1
+++ IDetectorElementContainer.java 17 Mar 2007 00:10:40 -0000 1.2
@@ -1,7 +1,7 @@
package org.lcsim.detector;
-import java.util.Collection;
+import java.util.List;
-interface IDetectorElementContainer
-extends Collection<IDetectorElement>
+public interface IDetectorElementContainer
+extends List<IDetectorElement>
{}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector
diff -u -r1.6 -r1.7
--- IDetectorFactory.java 9 Mar 2007 22:47:38 -0000 1.6
+++ IDetectorFactory.java 17 Mar 2007 00:10:40 -0000 1.7
@@ -9,37 +9,41 @@
public interface IDetectorFactory
{
- IRotation3D createRotation3D();
+ public IRotation3D createRotation3D();
- ITransform3D createTransform3D();
+ public ITransform3D createTransform3D();
- IDetectorElement createDetectorElement(
+ public IDetectorElement createDetectorElement(
String name,
IDetectorElement parent,
IPhysicalVolumePath support,
IIdentifier id);
- ILogicalVolume createLogicalVolume(
+ public ILogicalVolume createLogicalVolume(
String name,
ISolid solid,
IMaterial material);
- IPhysicalVolume createPhysicalVolume(
+ public IPhysicalVolume createPhysicalVolume(
ITransform3D transform,
String name,
ILogicalVolume logicalVolume,
ILogicalVolume motherLogicalVolume,
int copyNum);
- IPhysicalVolumeNavigator createPhysicalVolumeNavigator(IPhysicalVolume world);
+ public IPhysicalVolumeNavigator createPhysicalVolumeNavigator(IPhysicalVolume world);
+
+ public IPhysicalVolumeNavigator createPhysicalVolumeNavigator(
+ String name,
+ IPhysicalVolume worldVolume);
- IMaterial createMaterialElement(
+ public IMaterial createMaterialElement(
String name,
double Z,
double A,
double density);
- IMaterial createMaterialElement(
+ public IMaterial createMaterialElement(
String name,
int Z,
int A,
@@ -51,19 +55,19 @@
double meltingPoint,
double boilingPoint);
- IMaterial createMaterialMixture(
+ public IMaterial createMaterialMixture(
String name,
int nComponents,
double density,
State state);
- Box createBox(
+ public Box createBox(
String name,
double xHalfLength,
double yHalfLength,
double zHalfLength);
- Tube createTube(
+ public Tube createTube(
String name,
double innerRadius,
double outerRadius,
GeomConverter/src/org/lcsim/detector
diff -u -r1.2 -r1.3
--- IDetectorStore.java 7 Mar 2007 00:43:41 -0000 1.2
+++ IDetectorStore.java 17 Mar 2007 00:10:40 -0000 1.3
@@ -5,6 +5,7 @@
public interface IDetectorStore
{
+ public IPhysicalVolumeNavigatorStore getPhysicalVolumeNavigatorStore();
public IPhysicalVolumeStore getPhysicalVolumeStore();
public ILogicalVolumeStore getLogicalVolumeStore();
public ISolidStore getSolidStore();
GeomConverter/src/org/lcsim/detector
diff -u -r1.7 -r1.8
--- IPhysicalVolumeNavigator.java 9 Mar 2007 22:23:55 -0000 1.7
+++ IPhysicalVolumeNavigator.java 17 Mar 2007 00:10:40 -0000 1.8
@@ -11,9 +11,10 @@
* transform of an IPhysicalVolumePath.
*
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: IPhysicalVolumeNavigator.java,v 1.7 2007/03/09 22:23:55 jeremy Exp $
+ * @version $Id: IPhysicalVolumeNavigator.java,v 1.8 2007/03/17 00:10:40 jeremy Exp $
*/
public interface IPhysicalVolumeNavigator
+extends INamed
{
/**
* Get the top physical volume assigned to
GeomConverter/src/org/lcsim/detector
diff -u -r1.9 -r1.10
--- PhysicalVolumeNavigator.java 9 Mar 2007 22:23:55 -0000 1.9
+++ PhysicalVolumeNavigator.java 17 Mar 2007 00:10:40 -0000 1.10
@@ -35,6 +35,7 @@
*
*/
public class PhysicalVolumeNavigator
+extends Named
implements IPhysicalVolumeNavigator
{
/**
@@ -297,31 +298,62 @@
private IPhysicalVolume pvTop;
+ public PhysicalVolumeNavigator(String name, IPhysicalVolume pvTop)
+ {
+ super(name);
+ setTopPhysicalVolume(pvTop);
+ PhysicalVolumeNavigatorStore.getInstance().add(this);
+ }
+
+ public PhysicalVolumeNavigator(String name, IPhysicalVolumePath path)
+ {
+ super(name);
+
+ if ( path == null )
+ {
+ throw new IllegalArgumentException("The path is null!");
+ }
+
+ setTopPhysicalVolume(path);
+
+ PhysicalVolumeNavigatorStore.getInstance().add(this);
+ }
+
/**
* Create a PhysicalVolumeNavigator with @param pvTop
* as the top level.
* @param pvTop
*/
+ /*
public PhysicalVolumeNavigator(IPhysicalVolume pvTop)
{
- setTopPhysicalVolume(pvTop);
- }
-
+ super("default");
+
+ setTopPhysicalVolume(pvTop);
+
+ PhysicalVolumeNavigatorStore.getInstance().add(this);
+ }*/
+
/**
* Create a PhysicalVolumeNavigator with the top volume
* of @param path as the navigator's top volume.
*
* @param path
*/
+ /*
public PhysicalVolumeNavigator(IPhysicalVolumePath path)
{
- if ( path == null )
+ super("default");
+
+ if ( path == null )
{
throw new IllegalArgumentException("The path is null!");
}
setTopPhysicalVolume(path);
- }
+
+ PhysicalVolumeNavigatorStore.getInstance().add(this);
+ }*/
public void traversePreOrder(
IPhysicalVolumeVisitor visitor)
GeomConverter/src/org/lcsim/detector/converter/compact
diff -N CylindricalEndcapCalorimeterConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CylindricalEndcapCalorimeterConverter.java 17 Mar 2007 00:10:41 -0000 1.1
@@ -0,0 +1,115 @@
+package org.lcsim.detector.converter.compact;
+
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.IPhysicalVolumePath;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.PhysicalVolumeNavigatorStore;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.solids.Tube;
+import org.lcsim.geometry.Subdetector;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.layer.Layer;
+import org.lcsim.geometry.layer.Layering;
+import org.lcsim.geometry.subdetector.CylindricalEndcapCalorimeter;
+
+public class CylindricalEndcapCalorimeterConverter
+implements ISubdetectorConverter
+{
+ public void convert( Subdetector subdet, Detector detector)
+ {
+ //System.out.println("CylindricalEndcapCalorimeterConverter.convert");
+
+ CylindricalEndcapCalorimeter cal = (CylindricalEndcapCalorimeter)subdet;
+
+ IPhysicalVolume world = detector.getWorldVolume();
+
+ ILogicalVolume envelope = buildEnvelope( cal, world.getLogicalVolume().getMaterial() );
+
+ buildLayers(cal, envelope);
+
+ new PhysicalVolume(
+ null,
+ cal.getName(),
+ envelope,
+ world.getLogicalVolume(),
+ subdet.getSystemID()
+ );
+
+ IPhysicalVolumeNavigator nav =
+ PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
+ IPhysicalVolumePath path = nav.getPath(cal.getName());
+ cal.createGeometryInfo(path);
+ }
+
+ private ILogicalVolume buildEnvelope(
+ CylindricalEndcapCalorimeter cal,
+ IMaterial material)
+ {
+ String name = cal.getName();
+ Tube tube = new Tube(
+ name + "envelope_tube",
+ cal.getInnerRadius(),
+ cal.getOuterRadius(),
+ cal.getZMax() - cal.getZMin()
+ );
+
+ ILogicalVolume lv =
+ new LogicalVolume(
+ name + "_envelope",
+ tube,
+ material);
+
+ return lv;
+ }
+
+ private void buildLayers(
+ CylindricalEndcapCalorimeter cal,
+ ILogicalVolume envelope
+ )
+ {
+ Layering layering = cal.getLayering();
+
+ double innerRadius = cal.getInnerRadius();
+ double outerRadius = cal.getOuterRadius();
+
+ String name = cal.getName();
+
+ double zLayer = cal.getZMin();
+
+ for (int i=0; i<layering.getNumberOfLayers(); i++)
+ {
+ Layer layer = layering.getLayer(i);
+
+ Tube tubeLayer = new Tube(
+ name + "layer" + i + "_tube",
+ innerRadius,
+ outerRadius,
+ layer.getThickness()
+ );
+
+ ILogicalVolume lvLayer =
+ new LogicalVolume(
+ name + "layer" + i,
+ tubeLayer,
+ envelope.getMaterial()
+ );
+
+ // TODO: Make layer physical volume here
+
+ for (int j=0; j<layer.getNumberOfSlices(); j++)
+ {
+ // TODO: Make slice here
+ }
+
+ zLayer += layer.getThickness();
+ }
+ }
+
+ public Class getSubdetectorType()
+ {
+ return CylindricalEndcapCalorimeter.class;
+ }
+}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.1 -r1.2
--- CylindricalBarrelCalorimeterConverter.java 15 Mar 2007 02:09:14 -0000 1.1
+++ CylindricalBarrelCalorimeterConverter.java 17 Mar 2007 00:10:41 -0000 1.2
@@ -1,16 +1,17 @@
package org.lcsim.detector.converter.compact;
+import org.lcsim.detector.DetectorElement;
import org.lcsim.detector.ILogicalVolume;
import org.lcsim.detector.IPhysicalVolume;
import org.lcsim.detector.IPhysicalVolumeNavigator;
import org.lcsim.detector.IPhysicalVolumePath;
import org.lcsim.detector.LogicalVolume;
import org.lcsim.detector.PhysicalVolume;
-import org.lcsim.detector.PhysicalVolumeNavigator;
+import org.lcsim.detector.PhysicalVolumeNavigatorStore;
import org.lcsim.detector.material.IMaterial;
-import org.lcsim.detector.material.MaterialElement;
import org.lcsim.detector.material.MaterialStore;
import org.lcsim.detector.solids.Tube;
+import org.lcsim.geometry.Detector;
import org.lcsim.geometry.Subdetector;
import org.lcsim.geometry.layer.Layer;
import org.lcsim.geometry.layer.LayerSlice;
@@ -22,17 +23,22 @@
{
public void convert(
Subdetector subdet,
- IPhysicalVolume world)
+ Detector detector)
{
+ // Cast to subtype.
CylindricalBarrelCalorimeter cal = (CylindricalBarrelCalorimeter)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(cal, matWorld);
-
- buildLayers(cal, envelope);
-
+
+ // Create the PhysicalVolume.
new PhysicalVolume(
null,
cal.getName(),
@@ -41,9 +47,14 @@
subdet.getSystemID()
);
- IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(world);
- IPhysicalVolumePath path = nav.getPath(cal.getName());
- cal.createGeometryInfo(path);
+ // Setup the geometry.
+ IPhysicalVolumeNavigator nav =
+ PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
+ IPhysicalVolumePath path = nav.getPath( cal.getName() );
+ cal.createGeometryInfo(path);
+
+ // Build the layers.
+ buildLayers(cal, envelope);
}
private ILogicalVolume buildEnvelope(
@@ -74,13 +85,17 @@
String name = cal.getName();
double zHalfLength = cal.getZMax();
+
+ int sensorNumber = 1;
for (int i=0; i<layering.getNumberOfLayers(); i++)
{
Layer layer = layering.getLayer(i);
double layerInnerRadius = layering.getDistanceToLayer(i);
-
+
+ String layerName = "layer" + i;
+
Tube tubeLayer = new Tube(
name + "_layer" + i + "_tube",
layerInnerRadius,
@@ -96,7 +111,7 @@
new PhysicalVolume(
null,
- name + "_layer" + i,
+ layerName,
lvLayer,
envelope,
i);
@@ -109,11 +124,11 @@
double sliceThickness = slice.getThickness();
- // TODO: Use real materials engine.
String materialName = slice.getMaterial().getName();
IMaterial material = MaterialStore.getInstance().get(materialName);
- //IMaterial material = new MaterialElement("DUMMY_MATERIAL_"+name, 1, 1, 1);
+ String sliceName = "slice" + j;
+
Tube sliceLayer = new Tube(
name + "_layer" + i + "_slice" + j + "_tube",
sliceInnerRadius,
@@ -128,11 +143,26 @@
new PhysicalVolume(
null,
- "slice"+j,
+ sliceName,
lvSlice,
lvLayer,
j);
-
+
+ // Setup a DE for each sensitive slice.
+ if ( slice.isSensitive() )
+ {
+ // Path to the PhysicalVolume of this sensor.
+ String sensorPath = "/" + cal.getName() + "/" + layerName + "/" + sliceName;
+
+ DetectorElement sensor = new DetectorElement("sensor"+sensorNumber);
+ sensor.createGeometryInfo(sensorPath);
+
+ // Increment the number of sensors.
+ ++sensorNumber;
+
+ cal.addChild(sensor);
+ }
+
sliceInnerRadius += sliceThickness;
}
}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.2 -r1.3
--- DetectorConverter.java 15 Mar 2007 22:49:35 -0000 1.2
+++ DetectorConverter.java 17 Mar 2007 00:10:41 -0000 1.3
@@ -8,8 +8,10 @@
import org.jdom.Element;
import org.jdom.JDOMException;
import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
import org.lcsim.detector.LogicalVolume;
import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.PhysicalVolumeNavigatorStore;
import org.lcsim.detector.converter.lcdd.MaterialElementConverter;
import org.lcsim.detector.converter.lcdd.MaterialMixtureConverter;
import org.lcsim.detector.converter.lcdd.MaterialsConverter;
@@ -27,7 +29,8 @@
public DetectorConverter()
{
- addSubdetectorConverter(new CylindricalBarrelCalorimeterConverter());
+ addSubdetectorConverter( new CylindricalBarrelCalorimeterConverter() );
+ addSubdetectorConverter( new CylindricalEndcapCalorimeterConverter() );
}
private void addSubdetectorConverter(ISubdetectorConverter s)
@@ -53,18 +56,24 @@
public IPhysicalVolume convert(Detector detector, Document doc) throws JDOMException, IOException
{
IPhysicalVolume pvWorld = buildWorldVolume(detector);
-
+
+ // Create the default navigator.
+ PhysicalVolumeNavigatorStore.getInstance().reset();
+ PhysicalVolumeNavigatorStore.getInstance().createDefault(pvWorld);
+ detector.createGeometryInfo("/");
+ detector.setWorldVolume(pvWorld);
+
convertMaterials("/org/lcsim/material/elements.xml");
convertMaterials("/org/lcsim/material/materials.xml");
convertMaterials(doc);
- convertSubdetectors(detector, pvWorld);
-
+ convertSubdetectors(detector);
+
//System.out.println("DetectorConverter.convert - end");
return pvWorld;
}
-
+
private void convertMaterials(Document doc) throws JDOMException
{
(new MaterialsConverter()).convert(doc);
@@ -91,8 +100,9 @@
}
}
- private void convertSubdetectors(Detector detector, IPhysicalVolume pvWorld)
+ private void convertSubdetectors(Detector detector)
{
+ // Loop over all compact Subdetectors in the Detector.
for ( Map.Entry<String,Subdetector> entry : detector.getSubdetectors().entrySet())
{
Subdetector subdet = entry.getValue();
@@ -100,11 +110,19 @@
ISubdetectorConverter cnv = getSubdetectorConverter(subdet.getClass());
if ( cnv != null )
{
- cnv.convert(subdet, pvWorld);
- }
- //else {
- // System.err.println("No converter found for <" + subdet.getName() + "> with type <" + subdet.getClass().getCanonicalName() + "> !");
- //}
+ //System.out.println("Converting " + subdet.getName());
+
+ // Convert from a compact type to the
+ // generic detector description.
+ cnv.convert(subdet, detector);
+
+ // This adds the Subdetector as a child
+ // DetectorElement of the Detector.
+ detector.addChild(subdet);
+ }
+ else {
+ System.err.println("No ISubdetectorConverter for <" + subdet.getClass().getCanonicalName() + ">.");
+ }
}
}
@@ -143,7 +161,7 @@
lvWorld,
null,
0);
-
+
return pvWorld;
}
}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.1 -r1.2
--- ISubdetectorConverter.java 15 Mar 2007 02:09:14 -0000 1.1
+++ ISubdetectorConverter.java 17 Mar 2007 00:10:41 -0000 1.2
@@ -1,10 +1,10 @@
package org.lcsim.detector.converter.compact;
-import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.geometry.Detector;
import org.lcsim.geometry.Subdetector;
public interface ISubdetectorConverter
{
- public void convert(Subdetector subdet, IPhysicalVolume world);
+ public void convert(Subdetector subdet, Detector detector);
public Class getSubdetectorType();
}
GeomConverter/src/org/lcsim/geometry
diff -u -r1.31 -r1.32
--- Detector.java 5 May 2006 23:43:09 -0000 1.31
+++ Detector.java 17 Mar 2007 00:10:41 -0000 1.32
@@ -8,15 +8,18 @@
import hep.graphics.heprep.HepRepTypeTree;
import org.jdom.Element;
+import org.lcsim.detector.IDetectorElement;
import org.lcsim.geometry.compact.Field;
-import org.lcsim.geometry.field.FieldOverlay;
import org.lcsim.geometry.compact.Readout;
+import org.lcsim.geometry.field.FieldOverlay;
import org.lcsim.geometry.util.BaseIDDecoder;
/**
* @author tonyj
*/
-public class Detector extends org.lcsim.geometry.compact.Detector implements HepRepProvider
+public class Detector
+extends org.lcsim.geometry.compact.Detector
+implements HepRepProvider, IDetectorElement
{
private FieldOverlay fieldOverlay = new FieldOverlay();
GeomConverter/src/org/lcsim/geometry
diff -u -r1.6 -r1.7
--- GeometryReader.java 15 Mar 2007 22:49:35 -0000 1.6
+++ GeometryReader.java 17 Mar 2007 00:10:41 -0000 1.7
@@ -51,6 +51,9 @@
detector,
getDocument()
);
+
+ // Clear the cached document.
+ resetDocument();
return detector;
}
GeomConverter/src/org/lcsim/geometry/compact
diff -u -r1.17 -r1.18
--- Detector.java 12 Sep 2006 01:20:52 -0000 1.17
+++ Detector.java 17 Mar 2007 00:10:41 -0000 1.18
@@ -3,7 +3,10 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+
import org.jdom.Element;
+import org.lcsim.detector.DetectorElement;
+import org.lcsim.detector.IPhysicalVolume;
import org.lcsim.material.XMLMaterialManager;
/**
@@ -11,6 +14,7 @@
* @author tonyj
*/
public class Detector
+extends DetectorElement
{
private Header header;
private Map<String,Constant> constants = new HashMap<String,Constant>();
@@ -24,15 +28,29 @@
private SystemIDMap idmap = new SystemIDMap();
+ private IPhysicalVolume worldVolume;
+
/**
* Called by the reader to create a new Detector
* @param element The JDOM element corresponding to the detector definition in the XML file.
*/
protected Detector(Element element)
{
+ super(element.getChild("info").getAttributeValue("name"));
+
materialMgr = XMLMaterialManager.create(XMLMaterialManager.materials() );
}
+ public IPhysicalVolume getWorldVolume()
+ {
+ return worldVolume;
+ }
+
+ public void setWorldVolume(IPhysicalVolume worldVolume)
+ {
+ this.worldVolume = worldVolume;
+ }
+
/**
* Called by the reader to associate a header with this detector
* @param header The header.
GeomConverter/src/org/lcsim/geometry/layer
diff -u -r1.9 -r1.10
--- Layer.java 22 Jul 2006 23:01:55 -0000 1.9
+++ Layer.java 17 Mar 2007 00:10:41 -0000 1.10
@@ -91,6 +91,11 @@
return slices;
}
+ public int getNumberOfSlices()
+ {
+ return slices.size();
+ }
+
public double getSensorThickness()
{
return sensorThickness;
GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.1 -r1.2
--- DESubdetectorBox.java 15 Mar 2007 02:09:15 -0000 1.1
+++ DESubdetectorBox.java 17 Mar 2007 00:10:42 -0000 1.2
@@ -36,8 +36,7 @@
super("dummy",null,support,null);
}
}
-
-
+
DESubdetectorBox(Element element) throws JDOMException
{
super(element);
GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.1 -r1.2
--- DESubdetectorTube.java 15 Mar 2007 02:09:15 -0000 1.1
+++ DESubdetectorTube.java 17 Mar 2007 00:10:42 -0000 1.2
@@ -15,7 +15,7 @@
import org.lcsim.detector.IPhysicalVolumePath;
import org.lcsim.detector.LogicalVolume;
import org.lcsim.detector.PhysicalVolume;
-import org.lcsim.detector.PhysicalVolumeNavigator;
+import org.lcsim.detector.PhysicalVolumeNavigatorStore;
import org.lcsim.detector.Transform3D;
import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
import org.lcsim.detector.material.IMaterial;
@@ -61,7 +61,11 @@
world.getLogicalVolume(),
0);
- IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(world);
+ IPhysicalVolumeNavigator nav =
+ PhysicalVolumeNavigatorStore
+ .getInstance()
+ .get(world);
+
IPhysicalVolumePath path = nav.getPath("/tube1");
detelem = new DummyDE(path);
}
GeomConverter/test/org/lcsim/detector
diff -u -r1.7 -r1.8
--- SimpleDetectorTest.java 9 Mar 2007 22:47:38 -0000 1.7
+++ SimpleDetectorTest.java 17 Mar 2007 00:10:42 -0000 1.8
@@ -50,7 +50,7 @@
private String[] testnames = {"/box1","box1","box1/","/box1"};
public void testNavigator()
{
- IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(world);
+ IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator("nav1",world);
// The string "/" should give back a reference
// to the top volume, which is encoded by a
@@ -187,7 +187,7 @@
public void testTraverse()
{
- IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(world);
+ IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator("nav2", world);
VisitorTest visitorTest = new VisitorTest();
System.out.println("---PreOrder Traversal---");
GeomConverter/test/org/lcsim/detector/converter/compact
diff -N DetectorConverterTest.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DetectorConverterTest.xml 17 Mar 2007 00:10:42 -0000 1.1
@@ -0,0 +1,64 @@
+<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="test_detector">
+ <comment>Compact file for testing org.lcsim.detector.</comment>
+ </info>
+
+ <!-- Constants -->
+ <define>
+
+ <!-- world -->
+ <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" />
+
+ <!-- tracking region -->
+ <constant name="tracking_region_radius" value="0.1*cm"/>
+ <constant name="tracking_region_zmax" value="0.1*cm"/>
+
+ </define>
+
+ <materials>
+ </materials>
+
+ <detectors>
+
+<!-- Electromagnetic calorimeter -->
+
+ <detector id="1" name="ecal_barrel" type="CylindricalBarrelCalorimeter" readout="EcalBarrHits">
+ <dimensions inner_r = "100.0*cm" outer_z = "200.0*cm" />
+ <layer repeat="2">
+ <slice material = "Silicon" thickness = "10.0*cm" sensitive = "yes" />
+ </layer>
+ </detector>
+
+ <detector id="2" name="ecal_endcap" reflect="true" type="CylindricalEndcapCalorimeter" readout="EcalEndcapHits">
+ <dimensions inner_r = "20.0*cm" inner_z = "168.0*cm" outer_r = "125.0*cm" />
+ <layer repeat="2">
+ <slice material = "Silicon" thickness = "10.0*cm" sensitive = "yes" />
+ </layer>
+ </detector>
+ </detectors>
+
+ <readouts>
+ <readout name="EcalEndcapHits">
+ <segmentation type="ProjectiveZPlane" thetaBins="1024" phiBins="1024"/>
+ <id>layer:7,system:3,barrel:3,theta:32:11,phi:11</id>
+ </readout>
+ <readout name="EcalBarrHits">
+ <segmentation type="ProjectiveCylinder" thetaBins="1000" phiBins="2000"/>
+ <id>layer:7,system:3,barrel:3,theta:32:11,phi:11</id>
+ </readout>
+ </readouts>
+
+ <fields>
+ <field type="Solenoid" name="GlobalSolenoid"
+ inner_field="5.0"
+ outer_field="-0.6"
+ zmax="1000"
+ outer_radius="(221.0+ 5.0 + 17.5 + 40./2.)*cm"/> <!-- SolenoidCoilBarrel inner_radius + Al support + Oxygen gap + half coil-->
+ </fields>
+</lccdd>
GeomConverter/test/org/lcsim/detector/converter/compact
diff -u -r1.1 -r1.2
--- DetectorConverterTest.java 15 Mar 2007 02:09:16 -0000 1.1
+++ DetectorConverterTest.java 17 Mar 2007 00:10:42 -0000 1.2
@@ -1,12 +1,19 @@
package org.lcsim.detector.converter.compact;
+import static org.lcsim.units.clhep.SystemOfUnits.cm;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.lcsim.detector.IPhysicalVolume;
-import org.lcsim.detector.PhysicalVolumeStore;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.detector.solids.Tube;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.GeometryReader;
@@ -23,7 +30,13 @@
return new TestSuite(DetectorConverterTest.class);
}
- private static final String resource = "/org/lcsim/geometry/subdetector/CylindricalCalorimeterTest.xml";
+ private static final String resource = "/org/lcsim/detector/converter/compact/DetectorConverterTest.xml";
+
+ /**
+ * Read in a Detector and test the detailed geometry that is created.
+ *
+ * @throws Exception
+ */
public void testDetectorConverter() throws Exception
{
InputStream in =
@@ -31,10 +44,40 @@
getResourceAsStream(resource);
GeometryReader reader = new GeometryReader();
Detector det = reader.read(in);
- IPhysicalVolume worldVolume = (new DetectorConverter()).convert(det, resource);
+
+ /*
for ( IPhysicalVolume physvol : PhysicalVolumeStore.getInstance() )
{
System.out.println("physvol <"+physvol.getName()+">");
}
+ */
+
+
+ List<Hep3Vector> points = new ArrayList<Hep3Vector>();
+ points.add(new BasicHep3Vector(0,105*cm,0));
+ points.add(new BasicHep3Vector(0,115*cm,0));
+
+ System.out.println(det.getName());
+
+ for ( IDetectorElement child : det.getChildren() )
+ {
+ //System.out.println(" "+child.getName());
+ for ( IDetectorElement sensor : child.getChildren() )
+ {
+ //System.out.println(" "+sensor.getName());
+ IGeometryInfo sensorGeo = sensor.getGeometry();
+
+ Tube sensorTube = (Tube)sensorGeo.getLogicalVolume().getSolid();
+
+ for ( Hep3Vector point : points )
+ {
+ if ( point.y() > sensorTube.getInnerRadius() &&
+ point.y() < sensorTube.getOuterRadius() )
+ {
+ assert(sensorGeo.isInside(point));
+ }
+ }
+ }
+ }
}
}
\ No newline at end of file
GeomConverter/test/org/lcsim/detector/material
diff -u -r1.1 -r1.2
--- MaterialConverterTest.java 15 Mar 2007 02:09:16 -0000 1.1
+++ MaterialConverterTest.java 17 Mar 2007 00:10:42 -0000 1.2
@@ -19,6 +19,8 @@
public class MaterialConverterTest
extends TestCase
{
+ double tolerance = 1e-10;
+
public MaterialConverterTest(String name)
{
super(name);
@@ -107,25 +109,25 @@
org.lcsim.material.Material oldmaterial =
MaterialManager.findMaterial(material.getName());
//System.out.println("old material <" + oldmaterial.getName() + ">");
- System.out.println(oldmaterial.toString());
+ //System.out.println(oldmaterial.toString());
//System.out.println("--");
//System.out.println("new material <" + material.getName() + ">");
- System.out.println(material.toString());
+ //System.out.println(material.toString());
//System.out.println("----------------------------------");
-
+
assertTrue(
- oldmaterial.getAeff() - material.getA() < 1e-10 );
+ oldmaterial.getAeff() - material.getA() < tolerance );
assertTrue(
- oldmaterial.getZeff() - material.getZ() < 1e-10 );
+ oldmaterial.getZeff() - material.getZ() < tolerance );
assertTrue(
oldmaterial.getNuclearInteractionLength() -
- material.getNuclearInteractionLength() < 1e-10 );
+ material.getNuclearInteractionLength() < tolerance );
assertTrue(
oldmaterial.getRadiationLength() -
- material.getRadiationLength() < 1e-10 );
+ material.getRadiationLength() < tolerance );
}
}
}
CVSspam 0.2.8