lcsim/test
diff -u -r1.4 -r1.5
--- HitPositionTest.java 8 Apr 2005 20:58:45 -0000 1.4
+++ HitPositionTest.java 13 Jul 2005 07:12:10 -0000 1.5
@@ -1,5 +1,4 @@
import java.io.File;
-import java.io.IOException;
import java.net.URL;
import java.util.List;
import junit.framework.Test;
@@ -11,6 +10,7 @@
import org.lcsim.util.Driver;
import org.lcsim.util.cache.FileCache;
import org.lcsim.util.loop.LCSimLoop;
+import org.lcsim.geometry.segmentation.GridXYZ;
/**
*
@@ -18,44 +18,70 @@
*/
public class HitPositionTest extends TestCase
{
-
- public HitPositionTest(String testName)
- {
- super(testName);
- }
-
- public static Test suite()
- {
- return new TestSuite(HitPositionTest.class);
- }
-
- public void testHitPosition() throws Exception
- {
- URL url = new URL("http://www.lcsim.org/datasamples/rho+_pi+gamma_Theta90_10GeV.slcio");
- FileCache cache = new FileCache();
- File file = cache.getCachedFile(url);
-
- LCSimLoop loop = new LCSimLoop();
- loop.setLCIORecordSource(file);
- loop.add(new HitPositionDriver());
- loop.loop(-1);
- loop.dispose();
- }
- private class HitPositionDriver extends Driver
- {
- protected void process(EventHeader event)
- {
- List<SimCalorimeterHit> hits = event.get(SimCalorimeterHit.class,"EcalBarrHits");
- CalorimeterIDDecoder decoder = (CalorimeterIDDecoder) event.getMetaData(hits).getIDDecoder();
- for (SimCalorimeterHit hit: hits)
- {
- long id = hit.getCellID();
- decoder.setID(id);
- double[] pos = hit.getPosition();
- assertEquals(decoder.getX(),pos[0], 0.001);
- assertEquals(decoder.getY(),pos[1], 0.001);
- assertEquals(decoder.getZ(),pos[2], 0.001);
- }
- }
- }
+ //public static final String colls[] = {"EcalBarrHits", "EcalEndcapHits"};
+ public static final String colls[] = {"EcalBarrHits"};
+
+ public HitPositionTest(String testName)
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(HitPositionTest.class);
+ }
+
+ public void testHitPosition() throws Exception
+ {
+ //runTestFile("http://www.lcsim.org/datasamples/rho+_pi+gamma_Theta90_10GeV.slcio");
+ runTestFile("http://www.lcsim.org/datasamples/SLIC_v1r9p1_sdjan03_muons_Theta4-176_1-10GeV.slcio");
+ runTestFile("http://www.lcsim.org/datasamples/SLIC_v1r9p1_sidmay05_np_muons_Theta4-176_1-10GeV-0-5.slcio");
+ }
+
+ public void runTestFile(String s) throws Exception
+ {
+ System.out.println("HitPositionTest on file: " + s);
+
+ URL url = new URL(s);
+ FileCache cache = new FileCache();
+ File file = cache.getCachedFile(url);
+
+ LCSimLoop loop = new LCSimLoop();
+ loop.setLCIORecordSource(file);
+ loop.add(new HitPositionDriver());
+ loop.loop(-1);
+ loop.dispose();
+ }
+
+ private class HitPositionDriver extends Driver
+ {
+ protected void process(EventHeader event)
+ {
+ for ( String s : colls )
+ {
+ //System.out.println("coll: " + s);
+
+ List<SimCalorimeterHit> hits = event.get(SimCalorimeterHit.class, s);
+ CalorimeterIDDecoder decoder = (CalorimeterIDDecoder) event.getMetaData(hits).getIDDecoder();
+ for (SimCalorimeterHit hit: hits)
+ {
+ long id = hit.getCellID();
+ decoder.setID(id);
+
+ double[] pos = hit.getPosition();
+ //if ( s == colls[1] )
+ //{
+ // System.out.println("hit x y z: " + pos[0] + " " + pos[1] + " " + pos[2]);
+ // System.out.println("decoder x y z eta phi: " + decoder.getX() + " " + decoder.getY() + " " + decoder.getZ() +
+ // " " + decoder.getTheta() + " " + decoder.getPhi() );
+ //}
+ assertEquals(decoder.getX(),pos[0], 0.001);
+ assertEquals(decoder.getY(),pos[1], 0.001);
+ assertEquals(decoder.getZ(),pos[2], 0.001);
+ }
+ }
+ }
+ }
}
+
+
\ No newline at end of file