lcsim/test/org/lcsim/detector/driver
diff -N SimTrackerHitIdentifierTest.java
--- SimTrackerHitIdentifierTest.java 11 Sep 2007 00:21:01 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-package org.lcsim.detector.driver;
-
-import java.util.List;
-
-import java.io.File;
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.lcsim.util.cache.FileCache;
-import org.lcsim.util.loop.LCSimLoop;
-
-import org.lcsim.util.Driver;
-import org.lcsim.event.*;
-import org.lcsim.detector.identifier.*;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
-
-import org.lcsim.geometry.IDDecoder;
-
-/**
- * Checks whether the {@link org.lcsim.identifier} package
- * can unpack the value from {@link org.lcsim.event.SimTrackerHit#getCellI}
- * and get the same results as {@link org.lcsim.geometry.IDDecoder}
- * on some {@link org.lcsim.event.SimTrackerHit} objects from SiTrackerBarrel00.
- *
- * @see org.lcsim.identifier
- * @see org.lcsim.detector.identifier.IIdentifier
- * @see org.lcsim.detector.identifier.IExpandedIdentifier
- * @see org.lcsim.geometry.IDDecoder
- * @see org.lcsim.detector.IDetectorElement
- * @see org.lcsim.geometry.Subdetector
- *
- * @version $Id: SimTrackerHitIdentifierTest.java,v 1.6 2007/09/11 00:21:01 tonyj Exp $
- * @author jeremym
- */
-public class SimTrackerHitIdentifierTest
-extends TestCase
-{
- public SimTrackerHitIdentifierTest(String testName)
- {
- super(testName);
- }
-
- public static Test suite()
- {
- return new TestSuite(SimTrackerHitIdentifierTest.class);
- }
-
- public void testReadLcio() throws Exception
- {
- URL url =
- new URL("http://www.lcsim.org/test/lcio/mu-_10GeV_SiTrackerBarrelTest00.slcio");
- FileCache cache = new FileCache();
- File file = cache.getCachedFile(url);
-
- LCSimLoop loop = new LCSimLoop();
- loop.setLCIORecordSource(file);
- loop.add( new SimTrackerHitPositionalReadoutDriver(
- new String[] { "SiTrackerBarrel_RO" } ) );
- loop.add( new TestDriver() );
- loop.loop(1, null);
- loop.dispose();
- }
-
- class TestDriver
- extends Driver
- {
- protected void process( EventHeader event )
- {
- List<SimTrackerHit> collection = event.get( SimTrackerHit.class, "SiTrackerBarrel_RO" );
- IDDecoder decoder = event.getMetaData( collection ).getIDDecoder();
- IIdentifierHelper helper = decoder.getSubdetector().getDetectorElement().getIdentifierHelper();
- for ( SimTrackerHit hit : collection )
- {
- // Setup the IDDecoder.
- decoder.setID( hit.getCellID() );
-
- // Create an Identifier from the CellID.
- Identifier id = new Identifier( hit.getCellID() );
-
- IExpandedIdentifier exp = null;
- try {
- // Create an ExpandedIdentifier from the CellID.
- exp = helper.unpack( id );
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
-
- // Test that IDDecoder and ExpandedIdentifier have the same number of fields.
- assertEquals( "IDs have different number of fields.", decoder.getFieldCount(), exp.size() );
-
- // Check that the packed values are equal.
- assertEquals( "Packed values not equal.", hit.getCellID(), (int)id.getValue() );
-
- // Test that the IDDecoder and ExpandedIdentifier have the same values.
- for ( int i=0; i<decoder.getFieldCount(); i++ )
- {
- assertEquals( "Field value <" + i + "> is different." + decoder.getFieldName( i ), decoder.getValue( i ), exp.getValue( i ) );
- }
- }
- }
- }
-}