Print

Print


Commit in lcsim/src/org/lcsim/contrib/RobKutschke/TKNHits on MAIN
TKNRawHitsDriverV1.java+145added 1.1
TrackerIdentifierIndexCache.java+120added 1.1
+265
2 added files
First release.

lcsim/src/org/lcsim/contrib/RobKutschke/TKNHits
TKNRawHitsDriverV1.java added at 1.1
diff -N TKNRawHitsDriverV1.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TKNRawHitsDriverV1.java	1 Nov 2007 22:54:24 -0000	1.1
@@ -0,0 +1,145 @@
+package org.lcsim.contrib.RobKutschke.TKNHits;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.Set;
+import java.util.HashSet;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+
+import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.base.BaseRawTrackerHit;
+
+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;
+
+import org.lcsim.detector.driver.SimTrackerHitIdentifierReadoutDriver;
+
+/**
+ *
+ * Run Tim Nelson's code to create RawTrackerHits from SimTrackerHits.
+ * This version puts all of the hits from each system into a single unsorted container.
+ * Subsequent versions will be smarter.
+ * System = track barrel, tracker endcap ....
+ *
+ * As of 11/01/07 only the tracker barrel is tested.
+ *
+ * The driver SimTrackerHitIdentifierReadoutDriver must be called before this code is run.
+ *
+ *@author $Author: kutschke $
+ *@version $Id: TKNRawHitsDriverV1.java,v 1.1 2007/11/01 22:54:24 kutschke Exp $
+ *
+ * Date $Date: 2007/11/01 22:54:24 $
+ *
+ */
+
+
+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
+     * and are used pairwise.  Each pair of elements specifies the name of an input collection
+     * 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);
+	}
+    }
+
+    /**
+     *  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,Integer> digitized_hits = 
+			    kpix.readout(si_simulation.getReadoutData(carrier).getChargeMap(),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).shortValue() };
+			    List<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,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/RobKutschke/TKNHits
TrackerIdentifierIndexCache.java added at 1.1
diff -N TrackerIdentifierIndexCache.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackerIdentifierIndexCache.java	1 Nov 2007 22:54:25 -0000	1.1
@@ -0,0 +1,120 @@
+package org.lcsim.contrib.RobKutschke.TKNHits;
+
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.base.BaseRawTrackerHit;
+
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.IIdentifierDictionary;
+import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
+
+/**
+ *
+ * Class to cache the results of some expensive operations that only need to be
+ * performed when the detector changes.
+ * <p>
+ * The expensive operation is using the getFieldIndex(String) method of IIdentifierDictionary
+ * to find the index that corresponds to a quantity of interest.  The return value will
+ * not change unless the detector changes.
+ * <p>
+ *@author $Author: kutschke $
+ *@version $Id: TrackerIdentifierIndexCache.java,v 1.1 2007/11/01 22:54:25 kutschke Exp $
+ *
+ * Date $Date: 2007/11/01 22:54:25 $
+ *
+ */
+
+public class TrackerIdentifierIndexCache {
+
+    // Names of fields that we expect to find.
+    private String[] field = { "system", "barrel", "layer", "module", "sensor", "side", "strip" };
+
+    // Corresponding indices.
+    private int[] index    = null;
+
+    /**
+     * The only constructor.
+     * <p>
+     * The first argument can be any BaseRawTrackerHit object.  To the best of my knowledge,
+     * all such objects within one event use the same dictionary.  The second argument, if true,
+     * enables some printout.
+     * <p>
+     * The constructor will stop the job if it does not find the expected fields in the dictionary.
+     *
+     */
+    public TrackerIdentifierIndexCache( RawTrackerHit raw, boolean printheader ){
+	BaseRawTrackerHit base     = (BaseRawTrackerHit)raw;
+	IIdentifierHelper help     = base.getIdentifierHelper();
+	IIdentifierDictionary dict =  help.getIdentifierDictionary();
+	
+	if ( printheader ){
+	    System.out.println ("Setting RawTrackerHit Indices from Dictionary: " 
+				+ dict.getName() + " " 
+				+ dict.getFieldNameMap().keySet()
+				);
+	}
+	
+	index = new int[field.length];
+	
+	for ( int i=0; i<field.length; ++i ){
+	    try{
+		index[i] = dict.getFieldIndex(field[i]);
+	    } 
+	    catch (FieldNotFoundException x){
+		System.out.println ("Fatal error in TrackerIdentifierIndexCache.  Could not find the field " + field[i]);
+		System.out.println ("Known fields: " +  dict.getFieldNameMap().keySet() );
+		System.out.println ("Exiting now.");
+		System.exit(-1);
+	    }
+	}
+    }
+    
+    /**
+     *  @return the system id: Tracker Barrel/Endcap, Vertex Detector Barrel/Endcap, Forward Tracker
+     */
+    public int getSystem(){
+	return index[0];
+    }
+    
+    /**
+     *  @return the barrel number within the system.
+     */
+    public int getBarrel(){
+	return index[1];
+    }
+    
+    /**
+     *  @return the layer number within the barrel.
+     */
+    public int getLayer(){
+	return index[2];
+    }
+
+    /**
+     *  @return the module number within the layer.
+     */
+    public int getModule(){
+	return index[3];
+    }
+    
+    /**
+     *  @return the sensor number within the module.
+     */
+    public int getSensor(){
+	return index[4];
+    }
+    
+    /**
+     *  @return the side number within the sensor (to support two-sided readout).
+     */
+    public int getSide(){
+	return index[5];
+    }
+
+    /**
+     *  @return the strip/pixel number within the side.
+     */
+    public int getStrip(){
+	return index[6];
+    }
+
+} 
CVSspam 0.2.8