1 package org.lcsim.detector.converter.compact;
2
3 import java.io.InputStream;
4
5 import junit.framework.TestCase;
6 import junit.framework.TestSuite;
7
8 import org.lcsim.detector.IDetectorElement;
9 import org.lcsim.detector.IDetectorElementContainer;
10 import org.lcsim.geometry.Detector;
11 import org.lcsim.geometry.GeometryReader;
12 import org.lcsim.geometry.Subdetector;
13
14
15
16
17
18
19
20
21
22
23 public class MultiLayerTrackerTest
24 extends TestCase
25 {
26 private Detector detector;
27
28 public MultiLayerTrackerTest(String name)
29 {
30 super(name);
31 }
32
33 public static junit.framework.Test suite()
34 {
35 return new TestSuite(MultiLayerTrackerTest.class);
36 }
37
38 private static final String resource =
39 "/org/lcsim/detector/converter/compact/MultiLayerTrackerTest.xml";
40
41 public void setUp()
42 {
43 InputStream in =
44 this.getClass().
45 getResourceAsStream(resource);
46
47 GeometryReader reader = new GeometryReader();
48
49 try {
50 detector = reader.read(in);
51 }
52 catch ( Throwable x )
53 {
54 throw new RuntimeException(x);
55 }
56 }
57
58 public void testLayers()
59 {
60 Subdetector compact = detector.getSubdetector("MultiLayerTracker");
61 IDetectorElement subdet = compact.getDetectorElement();
62 IDetectorElementContainer layers = subdet.getChildren();
63 assertEquals("Expected number of sensors is wrong!",layers.size(),2);
64 IDetectorElement layer = layers.get(0);
65 try {
66 assertEquals(layer.getIdentifierHelper().getValue(layer.getIdentifier(), "system"),compact.getIDDecoder().getSystemNumber());
67 assertEquals(layer.getIdentifierHelper().getValue(layer.getIdentifier(), "barrel"),0);
68 assertTrue(layers.get(0).getIdentifierHelper().getValue(layers.get(0).getIdentifier(), "layer") == 0);
69 assertTrue(layers.get(1).getIdentifierHelper().getValue(layers.get(1).getIdentifier(), "layer") == 1);
70 }
71 catch (Exception x)
72 {
73 throw new RuntimeException(x);
74 }
75 }
76 }