Print

Print


Commit in lcsim on MAIN
test/org/lcsim/detector/driver/TrackerBarrelDigitizationDriverTest.java+161added 1.1
                              /TrackerEndcapDigitizationDriverTest.java+14-151.2 -> 1.3
                              /TrackerHitDriverTest.java+9-111.5 -> 1.6
src/org/lcsim/contrib/RobKutschke/TKNHits/TKNRawHitsDriverV1.java+89-781.2 -> 1.3
src/org/lcsim/contrib/SiStripSim/CDFSiSensorSim.java+40-51.7 -> 1.8
                                /StripClusterMaker.java+8-11.7 -> 1.8
                                /SiSensorSim.java+10-41.2 -> 1.3
+331-114
1 added + 6 modified, total 7 files
Modifications to silicon simulation and clustering to correct for Lorentz drift.  Data files used for testing in the barrel now have the nominal magnetic field.

lcsim/test/org/lcsim/detector/driver
TrackerBarrelDigitizationDriverTest.java added at 1.1
diff -N TrackerBarrelDigitizationDriverTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackerBarrelDigitizationDriverTest.java	11 Dec 2007 18:51:07 -0000	1.1
@@ -0,0 +1,161 @@
+package org.lcsim.detector.driver;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.base.BaseRawTrackerHit;
+import org.lcsim.util.Driver;
+import org.lcsim.util.cache.FileCache;
+import org.lcsim.util.loop.LCSimLoop;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IReadout;
+
+import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.detector.tracker.silicon.ChargeCarrier;
+
+import org.lcsim.contrib.SiStripSim.SiSensorSim;
+import org.lcsim.contrib.SiStripSim.CDFSiSensorSim;
+import org.lcsim.contrib.SiStripSim.ReadoutChip;
+import org.lcsim.contrib.SiStripSim.Kpix;
+import org.lcsim.contrib.SiStripSim.SiElectrodeDataCollection;
+
+/**
+ * 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 TrackerBarrelDigitizationDriverTest extends TestCase
+{
+    public TrackerBarrelDigitizationDriverTest(String testName)
+    {
+        super(testName);
+    }
+    
+    public static Test suite()
+    {
+        return new TestSuite(TrackerBarrelDigitizationDriverTest.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");
+        URL url = new URL("http://www.lcsim.org/test/lcio/mu-_10GeV_SLIC-v2r3p10_geant4-v9r0p1_LCPhys_SiTrackerBarrelTest01.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 TestDriver() );
+        loop.loop(10, null);
+        loop.dispose();
+    }
+    
+    class TestDriver
+            extends Driver
+    {
+        protected void process(EventHeader header)
+        {
+            
+            boolean found_hits = false;
+            
+            // Setup simulation and readout
+            SiSensorSim si_simulation = new CDFSiSensorSim();
+            ReadoutChip kpix = new Kpix();
+            
+            IDetectorElement tkr = header.getDetector().getSubdetector("SiTrackerBarrel").getDetectorElement();
+            for ( IDetectorElement layer : tkr.getChildren() )
+            {
+                for ( IDetectorElement module : layer.getChildren() )
+                {
+                    for ( IDetectorElement sensorDE : module.getChildren() )
+                    {
+                        SiSensor sensor = (SiSensor)sensorDE;
+                        
+                        IReadout ro = sensor.getReadout();
+                        List<SimTrackerHit> hits = ro.getHits(SimTrackerHit.class);
+                        
+                        if (!hits.isEmpty())
+                        {
+                            
+//                            System.out.println("\n"+"Simulating sensor: "+sensor.getName());
+                            
+                            List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
+                            
+                            si_simulation.setSensor(sensor);
+                            Map<ChargeCarrier,SiElectrodeDataCollection> electrode_data = si_simulation.computeElectrodeData();
+                            
+                            for (ChargeCarrier carrier : ChargeCarrier.values())
+                            {
+                                if (sensor.hasElectrodesOnSide(carrier))
+                                {
+                                    
+//                                    System.out.println("Readout data: "+si_simulation.getReadoutData(carrier).getChargeMap());
+                                    
+                                    SortedMap<Integer,List<Integer>> digitized_hits = kpix.readout(electrode_data.get(carrier),sensor.getReadoutElectrodes(carrier));
+                                    
+//                                    System.out.println("# digitized hits: "+digitized_hits.size());
+                                    
+                                    // Create RawTrackerHits
+                                    
+                                    for (Integer readout_cell : digitized_hits.keySet())
+                                    {
+                                        int time = 0;
+                                        long cell_id = sensor.makeStripId(readout_cell,carrier.charge()).getValue();
+                                        short[] adc_values = {digitized_hits.get(readout_cell).get(0).shortValue(),digitized_hits.get(readout_cell).get(1).shortValue()};
+                                        
+                                        Set<SimTrackerHit> simulated_hits = electrode_data.get(carrier).get(readout_cell).getSimulatedHits();
+                                        IDetectorElement detector_element = sensor;
+                                        
+                                        RawTrackerHit raw_hit = new BaseRawTrackerHit(time,cell_id,adc_values,new ArrayList<SimTrackerHit>(simulated_hits),detector_element);
+                                        raw_hits.add(raw_hit);
+                                        found_hits = true;
+                                        
+//                                        System.out.println("ADC data for cell "+readout_cell+": "+
+//                                                raw_hit.getADCValues()[0]+", "+raw_hit.getADCValues()[1]);
+                                        
+                                        double signal = kpix.decodeCharge(raw_hit);
+//                                        System.out.println("Readout data for cell "+readout_cell+": "+signal);
+                                        
+                                    }
+                                    
+                                }
+                            }
+                            
+                            // Clear simulation and add RawTrackerHits to event
+                            si_simulation.clearReadout();
+                            header.put("RawBarrelTrackerHits",raw_hits,RawTrackerHit.class,0,"Kpix");
+                            
+                        }
+                        
+                    }
+                }
+            }
+            
+            assertTrue(found_hits);
+            
+        }
+        
+        
+        
+    }
+}
+

lcsim/test/org/lcsim/detector/driver
TrackerEndcapDigitizationDriverTest.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- TrackerEndcapDigitizationDriverTest.java	7 Dec 2007 22:19:50 -0000	1.2
+++ TrackerEndcapDigitizationDriverTest.java	11 Dec 2007 18:51:07 -0000	1.3
@@ -4,6 +4,7 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
 
@@ -19,7 +20,6 @@
 import org.lcsim.util.cache.FileCache;
 import org.lcsim.util.loop.LCSimLoop;
 import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.IDetectorElementContainer;
 import org.lcsim.detector.IReadout;
 
 import org.lcsim.detector.tracker.silicon.SiSensor;
@@ -29,6 +29,7 @@
 import org.lcsim.contrib.SiStripSim.CDFSiSensorSim;
 import org.lcsim.contrib.SiStripSim.ReadoutChip;
 import org.lcsim.contrib.SiStripSim.Kpix;
+import org.lcsim.contrib.SiStripSim.SiElectrodeDataCollection;
 
 /**
  * Reads single muon events generated in sid01_polyhedra, which uses
@@ -54,11 +55,7 @@
     }
     
     public void testReadout() throws Exception
-    {
-        
-        System.out.println("\n"+"STARTING!!!!!!!!!!!!!!!!!!!!!!!!!!! ");
-        
-        
+    {     
         URL url = new URL("http://www.lcsim.org/test/lcio/mu-_10GeV_SLIC-v2r3p10_geant4-v9r0p1_LCPhys_SiTrackerEndcapTest00.slcio");
         
         FileCache cache = new FileCache();
@@ -78,7 +75,7 @@
         protected void process(EventHeader header)
         {
             
-            System.out.println("\n"+"Processing endcap event: ");
+//            System.out.println("\n"+"Processing endcap event: ");
             
             boolean found_hits = false;
             
@@ -102,19 +99,21 @@
                 if (!hits.isEmpty())
                 {
                     
-                    System.out.println("\n"+"Simulating sensor: "+sensor.getName());
+//                    System.out.println("\n"+"Simulating sensor: "+sensor.getName());
                     
                     List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
-                    si_simulation.simulate(sensor);
+                    
+                    si_simulation.setSensor(sensor);
+                    Map<ChargeCarrier,SiElectrodeDataCollection> electrode_data = si_simulation.computeElectrodeData();
                     
                     for (ChargeCarrier carrier : ChargeCarrier.values())
                     {
                         if (sensor.hasElectrodesOnSide(carrier))
                         {
                             
-                            System.out.println("Readout data: "+si_simulation.getReadoutData(carrier).getChargeMap());
+//                            System.out.println("Readout data: "+electrode_data.get(carrier).getChargeMap());
                             
-                            SortedMap<Integer,List<Integer>> digitized_hits = kpix.readout(si_simulation.getReadoutData(carrier),sensor.getReadoutElectrodes(carrier));
+                            SortedMap<Integer,List<Integer>> digitized_hits = kpix.readout(electrode_data.get(carrier),sensor.getReadoutElectrodes(carrier));
                             
                             // Create RawTrackerHits
                             
@@ -124,18 +123,18 @@
                                 long cell_id = sensor.makeStripId(readout_cell,carrier.charge()).getValue();
                                 short[] adc_values = {digitized_hits.get(readout_cell).get(0).shortValue(),digitized_hits.get(readout_cell).get(1).shortValue()};
                                 
-                                Set<SimTrackerHit> simulated_hits = si_simulation.getReadoutData(carrier).get(readout_cell).getSimulatedHits();
+                                Set<SimTrackerHit> simulated_hits = electrode_data.get(carrier).get(readout_cell).getSimulatedHits();
                                 IDetectorElement detector_element = sensor;
                                 
                                 RawTrackerHit raw_hit = new BaseRawTrackerHit(time,cell_id,adc_values,new ArrayList<SimTrackerHit>(simulated_hits),detector_element);
                                 raw_hits.add(raw_hit);
                                 found_hits = true;
                                 
-                                System.out.println("ADC data for cell "+readout_cell+": "+
-                                        raw_hit.getADCValues()[0]+", "+raw_hit.getADCValues()[1]);
+//                                System.out.println("ADC data for cell "+readout_cell+": "+
+//                                        raw_hit.getADCValues()[0]+", "+raw_hit.getADCValues()[1]);
                                 
                                 double signal = kpix.decodeCharge(raw_hit);
-                                System.out.println("Readout data for cell "+readout_cell+": "+signal);
+//                                System.out.println("Readout data for cell "+readout_cell+": "+signal);
                                 
                             }
                             

lcsim/test/org/lcsim/detector/driver
TrackerHitDriverTest.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- TrackerHitDriverTest.java	8 Dec 2007 11:55:35 -0000	1.5
+++ TrackerHitDriverTest.java	11 Dec 2007 18:51:07 -0000	1.6
@@ -1,7 +1,5 @@
 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;
@@ -10,17 +8,16 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 import org.lcsim.contrib.RobKutschke.TKNHits.TKNRawHitsDriverV1;
+import org.lcsim.contrib.SiStripSim.CDFSiSensorSim;
 import org.lcsim.contrib.SiStripSim.ClusterMaker;
 import org.lcsim.contrib.SiStripSim.Kpix;
 import org.lcsim.contrib.SiStripSim.ReadoutChip;
+import org.lcsim.contrib.SiStripSim.SiSensorSim;
 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;
@@ -50,8 +47,8 @@
     
     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");
+//        URL url = new URL("http://www.lcsim.org/test/lcio/mu_10.0GeV_Theta90_SLIC-v2r3p7_geant4-v9r0p1_LCPhys_SiTrackerBarrelTest00.slcio");
+        URL url = new URL("http://www.lcsim.org/test/lcio/mu-_10GeV_SLIC-v2r3p10_geant4-v9r0p1_LCPhys_SiTrackerBarrelTest01.slcio");
         FileCache cache = new FileCache();
         File file = cache.getCachedFile(url);
         
@@ -69,7 +66,8 @@
     {
         
         ReadoutChip kpix = new Kpix();
-        ClusterMaker cluster_maker = new StripClusterMaker(kpix);
+        SiSensorSim simulation = new CDFSiSensorSim();
+        ClusterMaker cluster_maker = new StripClusterMaker(kpix,simulation);
         
         protected void process(EventHeader header)
         {
@@ -107,13 +105,13 @@
 //                        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");
-//                
+//
 //            }
             
         }

lcsim/src/org/lcsim/contrib/RobKutschke/TKNHits
TKNRawHitsDriverV1.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- TKNRawHitsDriverV1.java	6 Nov 2007 19:58:03 -0000	1.2
+++ TKNRawHitsDriverV1.java	11 Dec 2007 18:51:07 -0000	1.3
@@ -5,6 +5,7 @@
 import java.util.SortedMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.Map;
 import org.lcsim.event.EventHeader;
 import org.lcsim.util.Driver;
 
@@ -21,6 +22,7 @@
 import org.lcsim.contrib.SiStripSim.CDFSiSensorSim;
 import org.lcsim.contrib.SiStripSim.ReadoutChip;
 import org.lcsim.contrib.SiStripSim.Kpix;
+import org.lcsim.contrib.SiStripSim.SiElectrodeDataCollection;
 
 /**
  *
@@ -34,20 +36,20 @@
  * The driver SimTrackerHitIdentifierReadoutDriver must be called before this code is run.
  *
  *@author $Author: tknelson $
- *@version $Id: TKNRawHitsDriverV1.java,v 1.2 2007/11/06 19:58:03 tknelson Exp $
+ *@version $Id: TKNRawHitsDriverV1.java,v 1.3 2007/12/11 18:51:07 tknelson Exp $
  *
- * Date $Date: 2007/11/06 19:58:03 $
+ * Date $Date: 2007/12/11 18:51:07 $
  *
  */
 
 
 public class TKNRawHitsDriverV1 extends Driver
 {
-
+    
     // Names of input and output collections.
     private String[] input  = null;
     private String[] output = null;
-
+    
     /**
      * Constructor:
      * The arguments are two arrays of strings.  The arrays must be of the same length
@@ -55,86 +57,95 @@
      * and the name of an output collection.
      *
      */
-    public TKNRawHitsDriverV1( String[] in, String[] out){
-	input  = in;
-	output = out;
-	
-	// If lengths of arrays are not equal, abort.
-	if ( in.length != out.length ){
-	    System.out.println ("Fatal error from TKNRawHitsDriverV1.  Different length lists for input and outputs!");
-	    System.out.println ("Number of inputs/outputs: " + input.length + "/" + output.length );
-	    System.out.println ("Inputs:  " + input );
-	    System.out.println ("Outputs: " + output );
-	    System.exit(-1);
-	}
+    public TKNRawHitsDriverV1( String[] in, String[] out)
+    {
+        input  = in;
+        output = out;
+        
+        // If lengths of arrays are not equal, abort.
+        if ( in.length != out.length )
+        {
+            System.out.println("Fatal error from TKNRawHitsDriverV1.  Different length lists for input and outputs!");
+            System.out.println("Number of inputs/outputs: " + input.length + "/" + output.length );
+            System.out.println("Inputs:  " + input );
+            System.out.println("Outputs: " + output );
+            System.exit(-1);
+        }
     }
-
+    
     /**
      *  The main work of the class.
      */
     protected void process(EventHeader header)
     {
-
-	// Loop over all of the collections to process.
-	for ( int i=0; i<input.length; ++i ){
-
-	    List<SimTrackerHit> eventHits = header.get(SimTrackerHit.class, input[i]);
-	
-	    // Set of sensors with hits.
-	    Set<SiSensor> hit_sensors = new HashSet<SiSensor>();
-	    for (SimTrackerHit hit : eventHits){
-		SiSensor sensor = (SiSensor)hit.getDetectorElement();
-		hit_sensors.add(sensor);
-	    }
-	
-	    // Instantiate simulation.
-	    SiSensorSim si_simulation = new CDFSiSensorSim();
-	    ReadoutChip kpix = new Kpix();
-
-	    // Output container.
-	    List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
-	
-	    // Loop over sensors with hits.
-	    for (SiSensor sensor : hit_sensors){
-		
-		// Deposit charge with CDF/Padova model
-		si_simulation.simulate(sensor);
-	    
-		for (ChargeCarrier carrier : ChargeCarrier.values()){
-		    if (sensor.hasElectrodesOnSide(carrier)){
-			
-			// Create digitized hit strips/pixels.
-			SortedMap<Integer,List<Integer>> digitized_hits = 
-			    kpix.readout(si_simulation.getReadoutData(carrier),sensor.getReadoutElectrodes(carrier));
-			
-			// Create RawTrackerHits.
-			for (Integer readout_cell : digitized_hits.keySet()){
-
-			    // Need to fix this.
-			    int time = 0;
-
-			    long cell_id = sensor.makeStripId(readout_cell,carrier.charge()).getValue();			    
+        
+        // Loop over all of the collections to process.
+        for ( int i=0; i<input.length; ++i )
+        {
+            
+            List<SimTrackerHit> eventHits = header.get(SimTrackerHit.class, input[i]);
+            
+            // Set of sensors with hits.
+            Set<SiSensor> hit_sensors = new HashSet<SiSensor>();
+            for (SimTrackerHit hit : eventHits)
+            {
+                SiSensor sensor = (SiSensor)hit.getDetectorElement();
+                hit_sensors.add(sensor);
+            }
+            
+            // Instantiate simulation.
+            SiSensorSim si_simulation = new CDFSiSensorSim();
+            ReadoutChip kpix = new Kpix();
+            
+            // Output container.
+            List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
+            
+            // Loop over sensors with hits.
+            for (SiSensor sensor : hit_sensors)
+            {
+                
+                // Deposit charge with CDF/Padova model
+                si_simulation.setSensor(sensor);
+                Map<ChargeCarrier,SiElectrodeDataCollection> electrode_data = si_simulation.computeElectrodeData();
+                
+                for (ChargeCarrier carrier : ChargeCarrier.values())
+                {
+                    if (sensor.hasElectrodesOnSide(carrier))
+                    {
+                        
+                        // Create digitized hit strips/pixels.
+                        SortedMap<Integer,List<Integer>> digitized_hits =
+                                kpix.readout(electrode_data.get(carrier),sensor.getReadoutElectrodes(carrier));
+                        
+                        // Create RawTrackerHits.
+                        for (Integer readout_cell : digitized_hits.keySet())
+                        {
+                            
+                            // Need to fix this.
+                            int time = 0;
+                            
+                            long cell_id = sensor.makeStripId(readout_cell,carrier.charge()).getValue();
                             short[] adc_values = {digitized_hits.get(readout_cell).get(0).shortValue(),digitized_hits.get(readout_cell).get(1).shortValue()};
-			    Set<SimTrackerHit> simulated_hits = 
-				si_simulation.getReadoutData(carrier).get(readout_cell).getSimulatedHits();
-			    IDetectorElement detector_element = sensor;
-			    
-			    // Create the hit and add it to the output list.
-			    RawTrackerHit raw_hit = new BaseRawTrackerHit(time,cell_id,adc_values,new ArrayList<SimTrackerHit>(simulated_hits),detector_element);
-			    raw_hits.add(raw_hit);
-
-			}                        
-		    }
-		} // Charge carriers.
-		
-		// Clear simulation.
-		si_simulation.clearReadout();
-		
-	    } // Loop over hit sensors.
-	    
-	    // Add to event.
-	    header.put(output[i], raw_hits, RawTrackerHit.class, 0, "Kpix");
-	} 
-
+                            Set<SimTrackerHit> simulated_hits =
+                                    electrode_data.get(carrier).get(readout_cell).getSimulatedHits();
+                            IDetectorElement detector_element = sensor;
+                            
+                            // Create the hit and add it to the output list.
+                            RawTrackerHit raw_hit = new BaseRawTrackerHit(time,cell_id,adc_values,new ArrayList<SimTrackerHit>(simulated_hits),detector_element);
+                            raw_hits.add(raw_hit);
+                            
+                        }
+                    }
+                } // Charge carriers.
+                
+                // Clear simulation.
+                si_simulation.clearReadout();
+                
+            } // Loop over hit sensors.
+            
+            // Add to event.
+            header.put(output[i], raw_hits, RawTrackerHit.class, 0, "Kpix");
+        }
+        
     } // process()
 }

lcsim/src/org/lcsim/contrib/SiStripSim
CDFSiSensorSim.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- CDFSiSensorSim.java	3 Dec 2007 23:30:10 -0000	1.7
+++ CDFSiSensorSim.java	11 Dec 2007 18:51:07 -0000	1.8
@@ -24,12 +24,17 @@
 import hep.physics.vec.BasicHep3Vector;
 import hep.physics.matrix.BasicMatrix;
 import hep.physics.vec.VecOp;
+import java.util.ArrayList;
 
 import java.util.List;
 
 import java.util.Map;
 import java.util.EnumMap;
 import java.util.SortedMap;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.Translation3D;
+import org.lcsim.detector.solids.Line3D;
+import org.lcsim.detector.solids.Point3D;
 
 /**
  *
@@ -75,18 +80,27 @@
         return _readout_data.get(carrier);
     }
     
+    // SiSensorSim interface
+    //======================
+    
     // Simulate charge deposition
-    public void simulate(SiSensor sensor)
+    public void setSensor(SiSensor sensor)
+    {
+        _sensor = sensor;
+    }
+    
+    public Map<ChargeCarrier,SiElectrodeDataCollection> computeElectrodeData()
     {
 //        System.out.println("# Sense strips: " + sensor.getSenseElectrodes(ChargeCarrier.HOLE).getNCells(0));
 //        System.out.println("# Readout strips: " + sensor.getReadoutElectrodes(ChargeCarrier.HOLE).getNCells(0));
         
-        _sensor = sensor;
         depositChargeOnSense();
         transferChargeToReadout();
-        clearSense();
+
+        return _readout_data;
     }
     
+    // Clear readout data
     public void clearReadout()
     {
         for (ChargeCarrier carrier : ChargeCarrier.values())
@@ -95,6 +109,24 @@
         }
     }
     
+    public void lorentzCorrect(Hep3Vector position, ChargeCarrier carrier)
+    {
+        Line3D drift_line = new Line3D(new Point3D(position), driftDirection(carrier,new BasicHep3Vector(0,0,0))); // use drift direction at origin for now
+        
+        List<Point3D> intersection_points = new ArrayList<Point3D>();
+        
+        for (ChargeCarrier bias_carrier : ChargeCarrier.values())
+        {
+            intersection_points.add(GeomOp3D.intersection(drift_line,_sensor.getBiasSurface(bias_carrier).getPlane()));
+        }
+                
+        Hep3Vector corrected_position = VecOp.mult(0.5,VecOp.add(intersection_points.get(0),intersection_points.get(1)));
+        
+        ITransform3D transform = new Transform3D(new Translation3D(VecOp.sub(corrected_position,position)));
+        
+        transform.transform(position);
+    }
+    
     // Private
     private void clearSense()
     {
@@ -112,7 +144,7 @@
         {
             if (_sensor.hasElectrodesOnSide(carrier))
             {
-                _drift_direction.put( carrier, this.driftDirection(carrier,new BasicHep3Vector(0.0,0.0,0.0)) );
+                _drift_direction.put( carrier, driftDirection(carrier,new BasicHep3Vector(0.0,0.0,0.0)) );
             }
         }
         
@@ -309,6 +341,9 @@
 //                System.out.println("Final readout charge map: " + _readout_data.get(carrier).getChargeMap());
             }
         }
+        
+        clearSense();
+        
     }
     
     private int nSegments(TrackSegment track, ChargeCarrier carrier, double deposition_granularity)
@@ -447,7 +482,7 @@
             // Project-to-plane would definitely be convenient here!!!
             
             double cos_theta_lorentz = VecOp.dot(_drift_direction.get(carrier),_sensor.getBiasSurface(carrier).getNormal());
-//        double cos_theta_lorentz = VecOp.cosTheta(_drift_direction.get(carrier));                                 // FIXME: careful with cosTheta here!            
+//        double cos_theta_lorentz = VecOp.cosTheta(_drift_direction.get(carrier));                                 // FIXME: careful with cosTheta here!
 //        System.out.println("Cos theta lorentz: "+cos_theta_lorentz);
             
             minor_axis_length = sigma*(1.0/cos_theta_lorentz); // drift time correction

lcsim/src/org/lcsim/contrib/SiStripSim
StripClusterMaker.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- StripClusterMaker.java	11 Dec 2007 07:28:38 -0000	1.7
+++ StripClusterMaker.java	11 Dec 2007 18:51:07 -0000	1.8
@@ -53,10 +53,14 @@
     // Readout chip needed to decode hit information
     ReadoutChip _readout_chip;
     
+    // Sensor simulation needed to correct for Lorentz drift
+    SiSensorSim _simulation;
+    
     /** Creates a new instance of StripClusterMaker */
-    public StripClusterMaker(ReadoutChip readout_chip)
+    public StripClusterMaker(ReadoutChip readout_chip, SiSensorSim simulation)
     {
         _readout_chip = readout_chip;
+        _simulation = simulation;
     }
     
     public List<TrackerHit> makeClusters(List<RawTrackerHit> raw_hits)
@@ -213,6 +217,9 @@
         }
         position = VecOp.mult(1/total_charge,position);
         
+        _simulation.setSensor((SiSensor)electrodes.getDetectorElement());
+        _simulation.lorentzCorrect(position,electrodes.getChargeCarrier());
+        
         return electrodes.getLocalToGlobal().transformed(position).v();
     }
     

lcsim/src/org/lcsim/contrib/SiStripSim
SiSensorSim.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SiSensorSim.java	3 Jul 2007 23:36:52 -0000	1.2
+++ SiSensorSim.java	11 Dec 2007 18:51:07 -0000	1.3
@@ -9,6 +9,8 @@
 
 package org.lcsim.contrib.SiStripSim;
 
+import hep.physics.vec.Hep3Vector;
+import java.util.Map;
 import org.lcsim.detector.tracker.silicon.SiSensor;
 import org.lcsim.detector.tracker.silicon.ChargeCarrier;
 
@@ -18,13 +20,17 @@
  */
 public interface SiSensorSim
 {
-    // process a sensor
-    void simulate(SiSensor sensor);
     
-    // get charge maps for this sensor
-    SiElectrodeDataCollection getReadoutData(ChargeCarrier carrier);
+    // Set sensor to process
+    void setSensor(SiSensor sensor);
+    
+    // Process hits and produce electrode data
+    Map<ChargeCarrier,SiElectrodeDataCollection> computeElectrodeData();
     
     // clear readout strips
     void clearReadout();
     
+    // Correct position to centerplane of active sensor
+    void lorentzCorrect(Hep3Vector position, ChargeCarrier carrier);
+    
 }
CVSspam 0.2.8