Print

Print


Commit in lcsim/test/org/lcsim/recon/tracking/digitization/sisim/config on MAIN
SimTrackerHitReadoutDriver_Test.java+74added 1.1
basic test of SimTrackerHitReadoutDriver

lcsim/test/org/lcsim/recon/tracking/digitization/sisim/config
SimTrackerHitReadoutDriver_Test.java added at 1.1
diff -N SimTrackerHitReadoutDriver_Test.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SimTrackerHitReadoutDriver_Test.java	10 Jul 2012 00:16:45 -0000	1.1
@@ -0,0 +1,74 @@
+package org.lcsim.recon.tracking.digitization.sisim.config;
+
+import hep.physics.vec.Hep3Vector;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.lcsim.detector.solids.Inside;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.SimTrackerHit;
+import org.lcsim.util.Driver;
+import org.lcsim.util.cache.FileCache;
+import org.lcsim.util.loop.LCSimLoop;
+
+/**
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: SimTrackerHitReadoutDriver_Test.java,v 1.1 2012/07/10 00:16:45 jeremy Exp $
+ */
+public class SimTrackerHitReadoutDriver_Test extends TestCase {
+    
+    String url = "http://www.lcsim.org/test/lcio/muons100_Theta4-176_1-10GeV_SLIC-v3r0p0_geant4-v9r5p1_QGSP_BERT_sidloi3-0-10.slcio";
+    
+    public void testMe() throws Exception {
+        FileCache cache = new FileCache();
+        cache.setCacheDirectory(new File("."));
+        File file = cache.getCachedFile(new URL(url));
+        LCSimLoop loop = new LCSimLoop();
+        loop.setLCIORecordSource(file);
+        loop.add(new SimTrackerHitReadoutDriver());
+        loop.add(new TestDriver());
+        loop.loop(-1);
+        System.out.println("Loop read " + loop.getConsumed() + " events.");
+    }
+    
+    private static class TestDriver extends Driver {
+        int nevents = 0;
+        int totalHits = 0;
+        public void process(EventHeader event) {
+            ++nevents;
+            List<List<SimTrackerHit>> collections = event.get(SimTrackerHit.class);
+            int nhits = 0;
+            for (List<SimTrackerHit> hits : collections) {
+                for (SimTrackerHit hit : hits) {
+                    ++nhits;                    
+                    if (hit.getDetectorElement() == null)
+                        throw new RuntimeException("DetectorElement is null.");
+                    if (hit.getPositionVec() == null)
+                        throw new RuntimeException("Position vec is null.");
+                    double v[] = hit.getPosition();
+                    if (v[0] == 0 && v[1] == 0 && v[2] == 0)
+                        throw new RuntimeException("Hit position components are all zero.");
+                    // This doesn't always work due to edge effects.
+                    if (!hit.getDetectorElement().getGeometry().inside(hit.getPositionVec()).equals(Inside.INSIDE))
+                        System.out.println("WARNING: Hit position outside of DetectorElement!");
+                        //throw new RuntimeException("Hit position not inside DetectorElement");
+                    Hep3Vector hitPos = hit.getPositionVec();
+                    Hep3Vector geomPos = hit.getDetectorElement().getGeometry().getPosition();
+                    if (hitPos.equals(geomPos))
+                        throw new RuntimeException("Hit position is same as DetectorElement.");
+                    ++nhits;
+                }
+            }
+            totalHits += nhits;
+            System.out.println("Read " + nhits + " hits in event " + event.getEventNumber() + " OK.");
+        }
+        
+        public void endOfData() {
+            System.out.println(this.getClass().getSimpleName() + " read " + totalHits + " hits from "+ nevents + " events.");
+        }
+    }
+}
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