Print

Print


Commit in lcsim/test on MAIN
HitPositionTest.java+71-631.14 -> 1.15


lcsim/test
HitPositionTest.java 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- HitPositionTest.java	16 Feb 2006 01:54:59 -0000	1.14
+++ HitPositionTest.java	16 Feb 2006 02:46:00 -0000	1.15
@@ -14,57 +14,59 @@
 import junit.framework.*;
 
 /**
- *
  * @author tonyj
  */
 public class HitPositionTest extends TestCase
 {
-    private static final String[] detectors = {"sdfeb05","sdjan03","sdjan03","sidmay05","sidmay05_20mr","sidmay05_2mr","sidmay05_np","sidmay05_scinthcal"};
-    private static final String[] colls = {"EcalBarrHits", "EcalEndcapHits", "HcalBarrHits", "HcalEndcapHits"};
+    private static final String[] detectors =
+    { "sdfeb05", "sdjan03", "sdjan03", "sidmay05", "sidmay05_20mr", "sidmay05_2mr", "sidmay05_np", "sidmay05_scinthcal" };
+    private static final String[] colls =
+    { "EcalBarrHits", "EcalEndcapHits", "HcalBarrHits", "HcalEndcapHits" };
     private int recordCount = 0;
     private static final int maxEvents = 50;
-    
+
     public void testHitPosition() throws Exception
-    {        
-        for ( String detectorName  : getDetectors() )
+    {
+        for (String detectorName : getDetectors())
         {
             runTestFile(getBaseURL() + getFileChunk() + detectorName + ".slcio");
         }
     }
-    
+
     /** Base URL for test files. */
     private static final String getBaseURL()
     {
         return "http://www.lcsim.org/test/lcio/";
     }
-    
+
     /** Chunk of pathname to detector tag. */
     private static final String getFileChunk()
     {
         return "n/n_Theta90_1GeV_SLIC_v1r9p1_";
     }
-    
+
     public void testMuScan() throws Exception
     {
         runTestFile("http://www.lcsim.org/test/lcio/muons_SLIC_v1r9p1_sidmay05.slcio");
         runTestFile("http://www.lcsim.org/test/lcio/muons_SLIC_v1r9p1_sidmay05_np.slcio");
     }
-    
+
     private void runTestFile(String s) throws Exception
     {
         System.out.println("Running HitPositionTest on file: " + s);
-        
-        try {
-        URL url = new URL(s);
-        FileCache cache = new FileCache();
-        File file = cache.getCachedFile(url);
-        
-        recordCount = 0;
-        LCSimLoop loop = new LCSimLoop();
-        loop.setLCIORecordSource(file);
-        loop.add(new HitPositionDriver());
-        loop.loop(maxEvents);
-        loop.dispose();
+
+        try
+        {
+            URL url = new URL(s);
+            FileCache cache = new FileCache();
+            File file = cache.getCachedFile(url);
+
+            recordCount = 0;
+            LCSimLoop loop = new LCSimLoop();
+            loop.setLCIORecordSource(file);
+            loop.add(new HitPositionDriver());
+            loop.loop(maxEvents);
+            loop.dispose();
         }
         catch (Exception e)
         {
@@ -72,88 +74,94 @@
             throw new RuntimeException(e);
         }
     }
-    
+
     /** Collections to test. */
     private static final String[] getColls()
     {
         return colls;
     }
-    
+
     /** Detectors to test. */
     private static final String[] getDetectors()
     {
         return detectors;
     };
-    
+
     public HitPositionTest(String testName)
     {
         super(testName);
     }
-    
+
     public static Test suite()
     {
         return new TestSuite(HitPositionTest.class);
     }
-    
-    //protected void setUp() throws Exception
-    //{
-    //}
-    
-    /** Tests whether position from hit matches the decoder's position from Id and segmentation calculations. */
+
+    // protected void setUp() throws Exception
+    // {
+    // }
+
+    /**
+     * Tests whether position from hit matches the decoder's position from Id
+     * and segmentation calculations.
+     */
     private class HitPositionDriver extends Driver
     {
         public void process(EventHeader event)
         {
-            //System.out.println("proc event: " + recordCount);
+            // System.out.println("proc event: " + recordCount);
             ++recordCount;
-            for ( String s : colls )
+            for (String s : colls)
             {
-                //System.out.println("coll: " + s);
-                
+                // System.out.println("coll: " + s);
+
                 List<SimCalorimeterHit> hits = event.get(SimCalorimeterHit.class, s);
                 CalorimeterIDDecoder decoder = (CalorimeterIDDecoder) event.getMetaData(hits).getIDDecoder();
-               
-                if ( decoder == null )
+
+                if (decoder == null)
                 {
                     throw new RuntimeException("HitPositionTest - decoder is null");
                 }
-                
-                for (SimCalorimeterHit hit: hits)
+
+                for (SimCalorimeterHit hit : hits)
                 {
                     long id = hit.getCellID();
                     decoder.setID(id);
-                    
+
                     double[] pos = hit.getPosition();
-//                    if ( s == colls[0] )
-//                    {
-//                        System.out.println("");
-//                        System.out.println("hit: " + pos[0] + " " + pos[1] + " " + pos[2]);
-//                        System.out.println("dec: " + decoder.getX() + " " + decoder.getY() + " " + decoder.getZ() +
-//                                " " + decoder.getTheta() + " " + decoder.getPhi() + " " + decoder.getValue("phi") + " " + decoder.getValue("z") );
-//                    }
-                    // FIXME: Could be added to IDDecoder as checkPosition() with tolerance.
+                    // if ( s == colls[0] )
+                    // {
+                    // System.out.println("");
+                    // System.out.println("hit: " + pos[0] + " " + pos[1] + " "
+                    // + pos[2]);
+                    // System.out.println("dec: " + decoder.getX() + " " +
+                    // decoder.getY() + " " + decoder.getZ() +
+                    // " " + decoder.getTheta() + " " + decoder.getPhi() + " " +
+                    // decoder.getValue("phi") + " " + decoder.getValue("z") );
+                    // }
+                    // FIXME: Could be added to IDDecoder as checkPosition()
+                    // with tolerance.
                     assertEquals(decoder.getX(), pos[0], 0.001);
                     assertEquals(decoder.getY(), pos[1], 0.001);
                     assertEquals(decoder.getZ(), pos[2], 0.001);
-                    
+
                     Subdetector subdet = decoder.getSubdetector();
-                    
-                    if ( subdet == null )
+
+                    if (subdet == null)
                     {
                         throw new RuntimeException("IDDecoder's Subdetector is null.");
                     }
-                    
+
                     /* subdetector and decoder should agree on basic flags... */
-//                    BaseIDDecoder = (BaseIDDecoder) bdec;
-//                    if ( subdet.isBarrel() )
-//                    {                        
-//                        assertTrue(bdec.getBarrelEndcapFlag().isBarrel());
-//                    }
-                        
-//                    if ( subdet.isEndcap())
-//                    {
-//                        assertTrue(bdec.getBarrelEndcapFlag().isEndcap());
-//                    }                    
+                    // BaseIDDecoder = (BaseIDDecoder) bdec;
+                    // if ( subdet.isBarrel() )
+                    // {
+                    // assertTrue(bdec.getBarrelEndcapFlag().isBarrel());
+                    // }
+                    // if ( subdet.isEndcap())
+                    // {
+                    // assertTrue(bdec.getBarrelEndcapFlag().isEndcap());
+                    // }
                 }
             }
         }
CVSspam 0.2.8