GeomConverter/test/org/lcsim/geometry
diff -u -r1.5 -r1.6
--- GeometryReaderTest.java 19 Jul 2005 07:03:42 -0000 1.5
+++ GeometryReaderTest.java 19 Jul 2005 20:31:38 -0000 1.6
@@ -1,11 +1,23 @@
package org.lcsim.geometry;
+
+import org.lcsim.geometry.compact.Segmentation;
+import org.lcsim.geometry.subdetector.TrackerBase;
+import org.lcsim.geometry.subdetector.CalorimeterBase;
+import org.lcsim.geometry.subdetector.CylindricalCalorimeter;
+import org.lcsim.geometry.layer.*;
+
import junit.framework.*;
import java.io.InputStream;
-import org.lcsim.geometry.layer.Layering;
+import org.lcsim.geometry.compact.Header;
/**
*
- * @author tonyj
+ * @author jeremym
+ *
+ * Checks that basic dimensions, quantities and analysis objects
+ * were created correctly by the GeometryReader from a compact
+ * XML file (similar to sdjan03).
+ *
*/
public class GeometryReaderTest extends TestCase
{
@@ -15,11 +27,28 @@
Detector detector;
int nDetectors = 10;
int nConstants = 10;
+
int nTrackerLayers = 5;
int nTrackerEndcapLayers = 10;
int nFields = 1;
+
int nEMLayers = 30;
+ double EMThick = 150.0;
+ int nEMSlices = 5;
+
+ double EMBarrelir = 1270.0;
+ double EMBarreloz = 1840.0;
+ double EMBarrelor = EMBarrelir + EMThick;
+
+ double EMEndcapir = 200.0;
+ double EMEndcapiz = 1680.0;
+ double EMEndcapor = 1250.0;
+ double EMEndcapoz = EMEndcapiz + EMThick;
+
int nHADLayers = 34;
+ int nMuonLayers = 32;
+
+ double tol = 0.0001;
public GeometryReaderTest(String testName)
{
@@ -45,7 +74,17 @@
}
}
- public void testSizes()
+ public void testHeader()
+ {
+ Header hdr = detector.getHeader();
+ assert(hdr.getDetectorName().equals("GeometryReaderTest") );
+ assert(hdr.getTitle().equals("GeometryReaderTest from sdjan03") );
+ assert(hdr.getComment().equals("Test comment.") );
+ assert(hdr.getAuthor().equals("Jeremy McCormick") );
+ assert(hdr.getURL().equals("http://www.example.com") );
+ }
+
+ public void testCollSizes()
{
assertEquals(nDetectors, detector.getSubdetectors().size() );
assertEquals(nDetectors, detector.getReadouts().size() );
@@ -53,38 +92,160 @@
assertEquals(nFields, detector.getFields().size() );
}
- public void testAttributes()
+ public void testLayers()
{
- assertEquals("GeometryReaderTest", detector.getName() );
+ assertEquals(detName, detector.getName() );
org.lcsim.geometry.Subdetector subdetector = null;
for ( String sn : detector.getSubdetectorNames() )
- {
+ {
subdetector = detector.getSubdetector(sn);
assert(sn != null);
Layering layers = subdetector.getLayering();
assert(layers != null);
+ //System.out.println("layer count: " + layers.getLayerCount() );
+
+ int nLayers = -1;
+ int nSlices = -1;
+
if ( sn.equals("BarrelVertex") || sn.equals("BarrelTracker") ||
sn.equals("EndcapVertex") )
{
- assertEquals(layers.getLayerCount(), nTrackerLayers);
+ nLayers = nTrackerLayers;
}
if ( sn.equals("EndcapTracker") )
{
- assertEquals(layers.getLayerCount(), nTrackerEndcapLayers );
+ nLayers = nTrackerEndcapLayers;
}
if ( sn.equals("EMBarrel") || sn.equals("EMEndcap") )
{
- assertEquals(layers.getLayerCount(), nEMLayers);
+ nLayers = nEMLayers;
+ nSlices = nEMSlices;
}
if ( sn.equals("HADBarrel") || sn.equals("HADEndcap") )
{
- assertEquals(layers.getLayerCount(), nHADLayers);
+ nLayers = nHADLayers;
+ }
+
+ if ( sn.equals("MuonBarrel") || sn.equals("MuonEndcap") )
+ {
+ nLayers = nMuonLayers;
+ }
+
+ /* look at basic attributes if got known subdet */
+ if ( nLayers != -1 )
+ {
+ /* has # of layers from above */
+ assertEquals(layers.getLayerCount(), nLayers);
+
+ for ( int i = 0; i < nLayers; i++)
+ {
+ /* layer exists at this idx */
+ assert(layers.getLayerStack().getLayer(i) != null);
+
+ /* has # of slices from above (if set) */
+ if ( nSlices != -1 )
+ {
+ assert(layers.getLayerStack().getLayer(i).getSlices().size() == nSlices);
+ }
+
+ /* has a valid set of slices at each layer */
+ boolean gotLayers = false;
+
+ for (LayerSlice slice : layers.getLayerStack().getLayer(i).getSlices() )
+ {
+ assert(slice != null);
+ assert(slice.getMaterial() != null);
+ assert(slice.getThickness() >= 0);
+ gotLayers = true;
+ }
+
+ /* got at least one layer */
+ assert(gotLayers);
+ }
+
+ /* has Readout */
+ Readout readout = detector.getReadout(sn);
+ assert(readout != null);
+
+ /* has IDDecoder */
+ IDDecoder dec = subdetector.getIDDecoder();
+ assert(dec != null);
+
+ /* if tracker, test for TrackerIDDecoder */
+ if ( subdetector.isTracker() )
+ {
+ TrackerIDDecoder tdec = ((TrackerBase)subdetector).getTrackerIDDecoder();
+ assert(tdec != null);
+ }
+ /* test for CalorimeterIDDecoder */
+ else
+ {
+ CalorimeterIDDecoder cdec = ((CalorimeterBase)subdetector).getCalorimeterIDDecoder();
+
+ /* test for segmentation */
+ Segmentation seg = ((Segmentation)cdec);
+ assert(seg != null);
+ }
+ }
+ }
+ }
+
+ public void testAttributes()
+ {
+ for ( String sn : detector.getSubdetectorNames() )
+ {
+ Subdetector subdetector = detector.getSubdetector(sn);
+
+ if ( sn.equals("EMBarrel") || sn.equals("EMEndcap") )
+ {
+ double totThick = subdetector.getLayering().getLayerStack().getTotalThickness();
+
+ /* test thickness */
+ assertEquals( totThick, EMThick, tol );
+
+ CylindricalCalorimeter cyl = (CylindricalCalorimeter) subdetector;
+ assert(cyl != null);
+
+ /* test barrel attributes */
+ if ( sn.equals("EMBarrel") )
+ {
+ assertEquals(cyl.getInnerRadius(), EMBarrelir, tol);
+ assertEquals(cyl.getZMax(), EMBarreloz, tol);
+ assertEquals(cyl.getZMin(), -EMBarreloz, tol);
+ assertEquals(cyl.getOuterRadius(), EMBarrelor, tol);
+ }
+ /* test endcap attributes */
+ else if ( sn.equals("EMEndcap") )
+ {
+ assertEquals(cyl.getInnerRadius(), EMEndcapir, tol);
+ assertEquals(cyl.getZMin(), EMEndcapiz, tol);
+ assertEquals(cyl.getOuterRadius(), EMEndcapor, tol);
+ assertEquals(cyl.getZMax(), EMEndcapoz, tol);
+ }
+
+ /* test whether manually adding up slice thicknesses = total thickness */
+ double compThick = 0;
+ int lnum = 0;
+ int nlay = subdetector.getLayering().getLayerStack().getNumberOfLayers();
+ for ( int i = 0; i < nlay; i++ )
+ {
+ Layer l = subdetector.getLayering().getLayerStack().getLayer(i);
+
+ assert(l != null);
+
+ for ( LayerSlice sl : l.getSlices() )
+ {
+ compThick += sl.getThickness();
+ }
+ }
+
+ assert(compThick == totThick);
}
}
}
GeomConverter/test/org/lcsim/geometry
diff -u -r1.1 -r1.2
--- GeometryReaderTest.xml 18 Jul 2005 22:16:32 -0000 1.1
+++ GeometryReaderTest.xml 19 Jul 2005 20:31:38 -0000 1.2
@@ -14,9 +14,9 @@
<info name="GeometryReaderTest"
title="GeometryReaderTest from sdjan03"
author="Jeremy McCormick"
- url="none">
+ url="http://www.example.com">
<comment>
- Geometry to test org.lcsim.geometry.GeometryReader.
+ Test comment.
</comment>
</info>
@@ -45,7 +45,7 @@
<!-- so can easily replace references
with something more realistic later -->
- <material name="MuonAir" >
+ <material name="MuonAir">
<D type="density" unit="g/cm3" value="0.0012"/>
<fraction n="0.7803" ref="N"/>
<fraction n="0.2103" ref="O"/>
@@ -55,7 +55,7 @@
</materials>
<detectors>
- <detector id="0" name="BarrelVertex" type="MultiLayerTracker" readout="VtxBarrHits">
+ <detector id="0" name="VertexBarrel" type="MultiLayerTracker" readout="VtxBarrHits">
<layer id="1" inner_r = "vertex_inner_r" outer_z = "2.5*cm">
<slice material = "Silicon" thickness = "0.01*cm" sensitive = "yes" />
</layer>
@@ -155,28 +155,28 @@
<slice material = "Polystyrene" thickness = "1.0*cm" sensitive = "yes" />
</layer>
</detector>
- <detector id ="7" name="HAD_ENDCAP" reflect="true" type="CylindricalEndcapCalorimeter" readout="HcalEndcapHits">
+ <detector id ="7" name="HADEndcap" reflect="true" type="CylindricalEndcapCalorimeter" readout="HcalEndcapHits">
<dimensions inner_r = "20.0*cm" inner_z = "184.0*cm" outer_r = "142.0*cm" />
<layer repeat="34" >
<slice material = "Steel235" thickness = "2.0*cm" />
<slice material = "Polystyrene" thickness = "1.0*cm" sensitive = "yes" />
</layer>
</detector>
- <detector id="4" name="MUON_BARREL" type="CylindricalBarrelCalorimeter" readout="MuonBarrHits" detectorType="calorimeter">
+ <detector id="4" name="MuonBarrel" type="CylindricalBarrelCalorimeter" readout="MuonBarrHits" detectorType="calorimeter">
<dimensions inner_r = "337.0*cm" outer_z = "287.0*cm" />
<layer repeat="32">
<slice material = "Iron" thickness = "5.0*cm" />
<slice material = "Air" thickness = "1.5*cm" sensitive = "yes" />
</layer>
</detector>
- <detector id="8" name="MUON_ENDCAP" reflect="true" type="CylindricalEndcapCalorimeter" readout="MuonEndcapHits">
+ <detector id="8" name="MuonEndcap" reflect="true" type="CylindricalEndcapCalorimeter" readout="MuonEndcapHits">
<dimensions inner_r = "20.0*cm" inner_z = "287.0*cm" outer_r = "636.0*cm" />
<layer repeat="32">
<slice material = "Iron" thickness = "5.0*cm" />
<slice material = "Air" thickness = "1.5*cm" sensitive = "yes" />
</layer>
</detector>
- <detector id="9" name="LUM_ENDCAP" reflect="true" type="CylindricalEndcapCalorimeter" readout="LumEndcapHits">
+ <detector id="9" name="LumEndcap" reflect="true" type="CylindricalEndcapCalorimeter" readout="LumEndcapHits">
<dimensions inner_r = "0.0001*cm" inner_z = "310.0*cm" outer_r = "9.2*cm" />
<layer repeat="1">
<slice material="Beryllium" thickness = "10.*cm" />