lcsim/test/org/lcsim/detector/driver
diff -N SimTrackerHitIdentifierReadoutDriverTest_sid01.java
--- SimTrackerHitIdentifierReadoutDriverTest_sid01.java 11 Sep 2007 00:21:01 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-package org.lcsim.detector.driver;
-
-import hep.physics.vec.BasicHep3Vector;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.lcsim.detector.solids.Inside;
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.IReadout;
-import org.lcsim.detector.identifier.Identifier;
-import org.lcsim.detector.driver.CollectionHandler;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.SimTrackerHit;
-import org.lcsim.geometry.compact.Subdetector;
-import org.lcsim.util.Driver;
-import org.lcsim.util.cache.FileCache;
-import org.lcsim.util.loop.LCSimLoop;
-
-/**
- * Test the {@link org.lcsim.detector.driver.SimTrackerHitIdentifierReadoutDriver} on the sid01 detector.
- */
-public class SimTrackerHitIdentifierReadoutDriverTest_sid01 extends TestCase
-{
- public void setUp()
- {
- java.lang.Runtime.getRuntime().gc();
- }
-
- public void testReadout() throws Exception
- {
- URL url =
- new URL("http://www.lcsim.org/test/lcio/muons10_Theta4-176_1-10GeV_SLIC_v2r2p1_sid01.slcio");
- FileCache cache = new FileCache();
- File file = cache.getCachedFile(url);
-
- LCSimLoop loop = new LCSimLoop();
- loop.setLCIORecordSource(file);
-
- String[] colls = {"TkrBarrHits","TkrEndcapHits"};
-
- loop.add( new SimTrackerHitIdentifierReadoutDriver(colls));
- loop.add( new TestDriver(colls));
- loop.loop(1, null);
- loop.dispose();
- }
-
- class TestDriver
- extends CollectionHandler
- {
- TestDriver(String[] colls)
- {
- super(colls);
- }
-
- protected void process(EventHeader event)
- {
- List<List<SimTrackerHit>> collections = event.get(SimTrackerHit.class);
- for (List<SimTrackerHit> collection : collections)
- {
- if (canHandle(event.getMetaData(collection).getName()))
- {
- for (SimTrackerHit hit : collection)
- {
- //System.out.println("Checking SimTrackerHit at " + hit.getPoint()[0] + "," + hit.getPoint()[1] + " " + hit.getPoint()[2] + " with id: " + new Identifier(hit.getCellID()).toHexString());
- IDetectorElement deHit = hit.getDetectorElement();
- assertTrue("DetectorElement from the hit is null!",deHit!=null);
- assertEquals("IDs do not match",new Identifier(hit.getCellID()),deHit.getIdentifier());
- SimTrackerHit lkpHit = findHitByPosition(hit,deHit.getReadout().getHits(SimTrackerHit.class));
- assertTrue("Failed to find SimTrackerHit in Readout!",lkpHit != null);
- //System.out.println("OK!");
- }
- }
- }
- }
- }
-
- private SimTrackerHit findHitByPosition( SimTrackerHit findHit, List<SimTrackerHit> hits)
- {
- double[] findHitPos = findHit.getPoint();
- for ( SimTrackerHit hit : hits )
- {
- double[] hitPos = hit.getPoint();
- if ( findHitPos[0] == hitPos[0] &&
- findHitPos[1] == hitPos[1] &&
- findHitPos[2] == hitPos[2] )
- {
- return hit;
- }
- }
- return null;
- }
-}