Commit in hps-java/src/test/java/org/lcsim/hps/conditions on MAIN
ConditionsDriverTest.java+59-31.1 -> 1.2
add check of bad channel count to ConditionsDriver test

hps-java/src/test/java/org/lcsim/hps/conditions
ConditionsDriverTest.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ConditionsDriverTest.java	18 Oct 2013 05:12:26 -0000	1.1
+++ ConditionsDriverTest.java	18 Oct 2013 06:29:59 -0000	1.2
@@ -2,9 +2,16 @@
 
 import java.io.File;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import junit.framework.TestCase;
 
+import org.lcsim.detector.tracker.silicon.HpsSiSensor;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
 import org.lcsim.util.cache.FileCache;
 import org.lcsim.util.loop.LCSimLoop;
 
@@ -14,9 +21,23 @@
  */
 public class ConditionsDriverTest extends TestCase {
     
+    /** This test file has a few events from the "good runs" of the Test Run. */
     private static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps/conditions_test.slcio";
     
+    /** Answer key for number of bad channels by run. */
+    static Map<Integer,Integer> badChannelAnswerKey = new HashMap<Integer,Integer>();
+    
+    /** Setup the bad channel answer key. */
+    static {
+       badChannelAnswerKey.put(1351, 441);
+    }
+
+    /**
+     * Run the test.
+     * @throws Exception 
+     */
     public void test() throws Exception {
+
         // Cache file locally from URL.
         FileCache cache = new FileCache();
         File testFile = cache.getCachedFile(new URL(TEST_FILE_URL));
@@ -24,8 +45,43 @@
         // Run the ConditionsDriver over test data containing multiple runs from the Test Run.
         LCSimLoop loop = new LCSimLoop();
         loop.setLCIORecordSource(testFile);
-        loop.add(new ConditionsDriver());        
+        loop.add(new ConditionsDriver());  
+        loop.add(new SvtBadChannelChecker());
         loop.loop(-1, null);
     }
-
-}
+    
+    /**
+     * This Driver will check the number of bad channels for a run against the answer key.
+     * @author Jeremy McCormick <[log in to unmask]>
+     */
+    class SvtBadChannelChecker extends Driver {
+        
+        int currentRun = Integer.MIN_VALUE;
+        
+        /**
+         * This method will check the number of bad channels against the answer key
+         * for the first event of a new run.
+         */
+        public void process(EventHeader event) {
+            int run = event.getRunNumber();
+            if (run != currentRun) {
+                currentRun = run;
+                Detector detector = event.getDetector();
+                int badChannels = 0;
+                List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
+                for (HpsSiSensor sensor : sensors) {
+                    int nchannels = sensor.getNumberOfChannels();
+                    for (int i=0; i<nchannels; i++) {
+                        if (sensor.isBadChannel(i))
+                            ++badChannels;
+                    }
+                }
+                System.out.println("found <" + badChannels + "> bad channels in run <" + currentRun + ">");
+                Integer badChannelAnswer = badChannelAnswerKey.get(run);
+                if (badChannelAnswer != null) {
+                    TestCase.assertEquals("Wrong number of bad channels found.", (int)badChannelAnswer, (int)badChannels);
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1