Print

Print


Commit in lcsim/test/org/lcsim/detector/driver on MAIN
TrackerHitDriverTest.java+1221.4 -> 1.5


lcsim/test/org/lcsim/detector/driver
TrackerHitDriverTest.java 1.4 -> 1.5
diff -N TrackerHitDriverTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackerHitDriverTest.java	8 Dec 2007 11:55:35 -0000	1.5
@@ -0,0 +1,122 @@
+package org.lcsim.detector.driver;
+
+import hep.physics.matrix.SymmetricMatrix;
+import hep.physics.vec.BasicHep3Vector;
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.lcsim.contrib.RobKutschke.TKNHits.TKNRawHitsDriverV1;
+import org.lcsim.contrib.SiStripSim.ClusterMaker;
+import org.lcsim.contrib.SiStripSim.Kpix;
+import org.lcsim.contrib.SiStripSim.ReadoutChip;
+import org.lcsim.contrib.SiStripSim.StripClusterMaker;
+import org.lcsim.detector.tracker.silicon.DopedSilicon;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.TrackerHit;
+import org.lcsim.event.base.BaseTrackerHitMC;
+import org.lcsim.util.Driver;
+import org.lcsim.util.cache.FileCache;
+import org.lcsim.util.loop.LCSimLoop;
+
+/**
+ * Reads single muon events generated in sid01_polyhedra, which uses
+ * SiTrackerBarrel.  For DetectorElements where there is a
+ * Readout containing one hit, check that the hit from the event
+ * and the DE's have matching cell id.
+ */
+public class TrackerHitDriverTest extends TestCase
+{
+    public TrackerHitDriverTest(String testName)
+    {
+        super(testName);
+    }
+    
+    public static Test suite()
+    {
+        return new TestSuite(TrackerHitDriverTest.class);
+    }
+    
+    public void setUp()
+    {
+        java.lang.Runtime.getRuntime().gc();
+    }
+    
+    public void testReadout() throws Exception
+    {
+        URL url =
+                new URL("http://www.lcsim.org/test/lcio/mu_10.0GeV_Theta90_SLIC-v2r3p7_geant4-v9r0p1_LCPhys_SiTrackerBarrelTest00.slcio");
+        FileCache cache = new FileCache();
+        File file = cache.getCachedFile(url);
+        
+        LCSimLoop loop = new LCSimLoop();
+        loop.setLCIORecordSource(file);
+        loop.add( new SimTrackerHitIdentifierReadoutDriver(new String[] {"SiTrackerBarrel_RO"} ) );
+        loop.add( new TKNRawHitsDriverV1(new String[]{"SiTrackerBarrel_RO"},new String[]{"RawBarrelTrackerHits"}));
+        loop.add( new TestDriver() );
+        loop.loop(10, null);
+        loop.dispose();
+    }
+    
+    class TestDriver
+            extends Driver
+    {
+        
+        ReadoutChip kpix = new Kpix();
+        ClusterMaker cluster_maker = new StripClusterMaker(kpix);
+        
+        protected void process(EventHeader header)
+        {
+            // Create the list of RawTrackerHits and add it to the event.
+            super.process(header);
+            
+            // Get the list of RawTrackerHits from the event.
+            List<RawTrackerHit> raw_hits = header.get(RawTrackerHit.class, "RawBarrelTrackerHits");
+            List<TrackerHit> hits = cluster_maker.makeClusters(raw_hits);
+            
+//            System.out.println("# hits in event: "+hits.size());
+//            for (TrackerHit hit : hits)
+//            {
+//                BaseTrackerHitMC mc_hit = (BaseTrackerHitMC)hit;
+//                System.out.println("    # MCParticles contributing: "+mc_hit.mcParticles().size());
+//                for (MCParticle particle : mc_hit.mcParticles())
+//                {
+//                    System.out.println("        MCParticle type: "+particle.getPDGID());
+//                    System.out.println("        MCParticle momentum: "+particle.getMomentum());
+//                }
+//                System.out.println("    Charge in cluster (electrons): "+mc_hit.getdEdx()/DopedSilicon.ENERGY_EHPAIR);
+//                System.out.println("    Position: "+new BasicHep3Vector(mc_hit.getPosition()));
+//                System.out.println("    Covariance matrix: \n"+(new SymmetricMatrix(3,mc_hit.getCovMatrix(),true)));
+//                System.out.println("    # SimTrackerHits contributing to cluster: "+mc_hit.getRawHits().size());
+//                for (RawTrackerHit raw_hit : (List<RawTrackerHit>)mc_hit.getRawHits())
+//                {
+//                    IExpandedIdentifier id = new ExpandedIdentifier(raw_hit.getExpandedIdentifier());
+//                    int strip_field;
+//                    try
+//                    {
+//                        strip_field = raw_hit.getIdentifierHelper().getFieldIndex("strip");
+//                    }
+//                    catch (FieldNotFoundException exception)
+//                    {
+//                        throw new RuntimeException(exception);
+//                    }
+//                    int strip_id = id.getValue(strip_field);
+//                    
+//                    System.out.println("        Strip number: "+strip_id);
+//                    System.out.println("        Charge: "+kpix.decodeCharge(raw_hit));
+//                }
+//                
+//                System.out.println("\n");
+//                
+//            }
+            
+        }
+    }
+}
+
CVSspam 0.2.8