Commit in lcsim/test on MAIN
HitPositionTest.java+24-161.7 -> 1.8
Added tests on both barr and endcap colls.  Also, added 2 additional test files.  Test now covers all 4 types of segmentations.

lcsim/test
HitPositionTest.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- HitPositionTest.java	13 Jul 2005 18:35:47 -0000	1.7
+++ HitPositionTest.java	13 Jul 2005 23:39:24 -0000	1.8
@@ -18,8 +18,9 @@
  */
 public class HitPositionTest extends TestCase
 {
+    /* Collections to test. */
     public static final String colls[] = {"EcalBarrHits", "EcalEndcapHits"};
-    //public static final String colls[] = {"EcalBarrHits"};
+    private int recordCount = 0;
     
     public HitPositionTest(String testName)
     {
@@ -33,19 +34,23 @@
     
     public void testHitPosition() throws Exception
     {
-        //runTestFile("http://www.lcsim.org/datasamples/rho+_pi+gamma_Theta90_10GeV.slcio");        
+        /* Test ProjectiveCylinder and ProjectiveZPlane segmentations. */
+        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");
-    }    
+        
+        /* Test NonprojectiveCylinder and GridXYZ (in a cylindrical endcap) segmentations. */
+        runTestFile("http://www.lcsim.org/datasamples/SLIC_v1r9p1_sidmay05_np_muons_Theta4-176_1-10GeV.slcio");
+    }
     
     public void runTestFile(String s) throws Exception
     {
-        System.out.println("HitPositionTest on file: " + s);
+        System.out.println("Running HitPositionTest on file: " + s);
         
         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());
@@ -53,28 +58,32 @@
         loop.dispose();
     }
     
+    /** Tests whether position from hit matches the decoder's position from Id and segmentation calculations. */
     private class HitPositionDriver extends Driver
     {
         protected void process(EventHeader event)
         {
+            //System.out.println("proc event: " + recordCount);
+            ++recordCount;
             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();                
+                CalorimeterIDDecoder decoder = (CalorimeterIDDecoder) event.getMetaData(hits).getIDDecoder();
                 for (SimCalorimeterHit hit: hits)
                 {
                     long id = hit.getCellID();
-                    decoder.setID(id);                                        
+                    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() );
-                    }
+                    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") );
+//                    }
                     assertEquals(decoder.getX(),pos[0], 0.001);
                     assertEquals(decoder.getY(),pos[1], 0.001);
                     assertEquals(decoder.getZ(),pos[2], 0.001);
@@ -84,4 +93,3 @@
     }
 }
 
-    
\ No newline at end of file
CVSspam 0.2.8