Print

Print


Commit in lcsim on MAIN
test/org/lcsim/util/event/SamplingFractionManagerTest.java+76added 1.1
                         /SamplingFractionManager_Test.java-581.2 removed
src/org/lcsim/util/event/SamplingFractionManager.java+4-31.6 -> 1.7
+80-61
1 added + 1 removed + 1 modified, total 3 files
Add test plus bug fixes for per-layer sampling fractions

lcsim/test/org/lcsim/util/event
SamplingFractionManagerTest.java added at 1.1
diff -N SamplingFractionManagerTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SamplingFractionManagerTest.java	9 Jun 2006 22:55:15 -0000	1.1
@@ -0,0 +1,76 @@
+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 SamplingFractionManagerTest extends TestCase
+{
+    private Map<String, Double> fracMap = new HashMap<String, Double>();
+    
+    public static Test suite()
+    {
+       return new TestSuite(SamplingFractionManagerTest.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);
+        assertNotNull(detector);
+        SamplingFractionManager smgr = SamplingFractionManager.defaultInstance();
+        
+        for (Subdetector subdet : detector.getSubdetectors().values())
+        {
+            if (subdet.isCalorimeter())
+            {
+                double sf = smgr.getCorrectedEnergy(10,0,subdet);
+                assertEquals(fracMap.get(subdet.getName()),10/sf,1e-10);
+            }
+        }
+    }
+    public void testSamplingLayerDependence() throws Exception
+    {
+        ConditionsManager mgr = ConditionsManager.defaultInstance();        
+        Detector detector = DetectorLocator.findDetector("acme0605",0,mgr);
+        assertNotNull(detector);
+        
+        SamplingFractionManager smgr = SamplingFractionManager.defaultInstance();
+        assertNotNull(smgr);
+        
+        Subdetector emBarrel = detector.getSubdetector("EMBarrel");
+        assertNotNull(emBarrel);
+        
+        double sf = smgr.getCorrectedEnergy(10,0,emBarrel);
+        assertEquals(.015996,10/sf,1e-10);
+        sf = smgr.getCorrectedEnergy(10,20,emBarrel);
+        assertEquals(.007998,10/sf,1e-10);
+    }
+    
+}

lcsim/test/org/lcsim/util/event
SamplingFractionManager_Test.java removed after 1.2
diff -N SamplingFractionManager_Test.java
--- SamplingFractionManager_Test.java	23 May 2006 17:30:32 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,58 +0,0 @@
-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);
-        assertNotNull(detector);
-        SamplingFractionManager smgr = SamplingFractionManager.defaultInstance();
-        
-        for (Subdetector subdet : detector.getSubdetectors().values())
-        {
-            if (subdet.isCalorimeter())
-            {
-                double sf = smgr.getCorrectedEnergy(10,0,subdet);
-                assertEquals(fracMap.get(subdet.getName()),10/sf,1e-10);
-            }
-        }
-    }
-}

lcsim/src/org/lcsim/util/event
SamplingFractionManager.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- SamplingFractionManager.java	7 Jun 2006 00:12:39 -0000	1.6
+++ SamplingFractionManager.java	9 Jun 2006 22:55:15 -0000	1.7
@@ -1,6 +1,6 @@
 package org.lcsim.util.event;
 
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -42,7 +42,7 @@
    {
       private final double defaultSamplingFraction;
       private final boolean digital;
-      private final Map<Integer,Double> layerMap = Collections.emptyMap();
+      private final Map<Integer,Double> layerMap = new HashMap<Integer,Double>();
       
       private SamplingFraction(ConditionsSet set)
       {
@@ -54,11 +54,12 @@
          for (Object o : set.keySet())
          {
             String key = o.toString();
-            double s = set.getDouble(key);
+
             // Get rid of embedded whitespace, and match
             Matcher matcher = pattern.matcher(key.replaceAll("\\s",""));
             if (matcher.matches())
             {
+               double s = set.getDouble(key);
                String layers = matcher.group(1);
                Matcher m2 = p2.matcher(layers);
                while (m2.find())
CVSspam 0.2.8