Commit in lcsim/test/org/lcsim/util/event on MAIN
SamplingFractionManager_Test.java+58added 1.1
JM: add test that makes sure sampling fractions are read correctly by SamplingFractionManager

lcsim/test/org/lcsim/util/event
SamplingFractionManager_Test.java added at 1.1
diff -N SamplingFractionManager_Test.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SamplingFractionManager_Test.java	8 Feb 2006 01:46:19 -0000	1.1
@@ -0,0 +1,58 @@
+package org.lcsim.util.event;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.DetectorLocator;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.Subdetector;
+
+/**
+ * 
+ * Test that SamplingFractionManager returns correct results for web
+ * copy of sidmay05.
+ * 
+ * @author jeremym
+ *
+ */
+public class SamplingFractionManager_Test extends TestCase
+{
+    private Map<String, Double> fracMap = new HashMap<String, Double>();
+    
+    public static Test suite()
+    {
+       return new TestSuite(SamplingFractionManager_Test.class);
+    }
+    
+    protected void setUp()
+    {
+        fracMap.put("EMBarrel",0.021805);
+        fracMap.put("EMEndcap",0.017703);
+        fracMap.put("HADBarrel",0.06338);
+        fracMap.put("MuonEndcap",5.7E-5);
+        fracMap.put("MuonBarrel",5.7E-5);
+        fracMap.put("HADEndcap",0.06338);
+    }
+    
+    public void testSamplingFractionManager() throws Exception
+    {
+        ConditionsManager mgr = ConditionsManager.defaultInstance();        
+        Detector detector = DetectorLocator.findDetector("sidmay05",0,mgr);
+        assert(detector != null);
+        SamplingFractionManager smgr = SamplingFractionManager.defaultInstance();
+        
+        for (Subdetector subdet : detector.getSubdetectors().values())
+        {
+            if (subdet.isCalorimeter())
+            {
+                double sf = smgr.getSamplingFraction(subdet);
+                assert(fracMap.get(subdet.getName()) == sf);
+            }
+        }
+    }
+}
CVSspam 0.2.8