Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25 on MAIN
HPSSiSensorReadout.java+168-131.2 -> 1.3
Added support to process triggers and readout sensors

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
HPSSiSensorReadout.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HPSSiSensorReadout.java	12 Jan 2012 22:41:29 -0000	1.2
+++ HPSSiSensorReadout.java	30 Jan 2012 00:31:20 -0000	1.3
@@ -6,9 +6,11 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Queue;
 import java.util.Random;
 import java.util.Set;
 
@@ -21,27 +23,53 @@
 
 
 //--- org.lcsim ---//
+import org.lcsim.detector.IDetectorElement;
 import org.lcsim.detector.tracker.silicon.ChargeCarrier;
 import org.lcsim.detector.tracker.silicon.SiSensor;
 import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
+import org.lcsim.detector.tracker.silicon.SiTrackerModule; 
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
 import org.lcsim.math.probability.Erf;
 import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeData;
 import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeDataCollection;
 import org.lcsim.recon.tracking.digitization.sisim.SiSensorSim;
+import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
+import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver;
 import org.lcsim.util.aida.AIDA;
+import org.lcsim.util.Driver;
+
 
 //--- hps-java ---//
 import org.lcsim.hps.recon.tracking.apv25.HPSAPV25.APV25Channel.APV25AnalogPipeline;
 import org.lcsim.hps.recon.tracking.HPSDataProcessingModule;
 import org.lcsim.hps.recon.tracking.HPSRTM;
+import org.lcsim.hps.util.ClockSingleton;
 
 
 /**
  *
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSSiSensorReadout.java,v 1.2 2012/01/12 22:41:29 omoreno Exp $
+ * @version $Id: HPSSiSensorReadout.java,v 1.3 2012/01/30 00:31:20 omoreno Exp $
  */
-public class HPSSiSensorReadout {
+public class HPSSiSensorReadout extends Driver {
+    
+    // Array to store the trigger time
+    public static final List<Double> triggerTimeStamp 
+       = new ArrayList<Double>();
+    
+    //
+    List<String> processPaths = new ArrayList<String>();
+    List<IDetectorElement> processDetectorElements 
+       = new ArrayList<IDetectorElement>();
+    List<String> readouts = new ArrayList<String>();
+    
+    //
+    Set<SiSensor> processSensors = new HashSet<SiSensor>();
+    Set<SiTrackerModule> processModules = new HashSet<SiTrackerModule>();
+    
+    // FIFO queue to store trigger times
+    public Queue<Integer> triggerQueue;
     
     // # of strips per Si sensor
     private static final int STRIPS_PER_SENSOR = 667;
@@ -80,15 +108,21 @@
     /**
      * Constructor
      */
-    public HPSSiSensorReadout(SiSensorSim siliconSimulation,
-                              HPSAPV25 apv,
-                              HPSDataProcessingModule datapm  )
+    public HPSSiSensorReadout(HPSDataProcessingModule datapm)
     {
-        // Set the sensor simulation
-        siSimulation = siliconSimulation;
-        
-        // Set the APV25 simulation
-        apv25 = apv;
+        //--- Sensor Simulation ---//
+        //-------------------------//
+        siSimulation = new CDFSiSensorSim();
+        
+        //--- APV25 Simulation ---//
+        //------------------------//
+        apv25 = new HPSAPV25();
+        // Set the APV25 Shaping time [ns]
+        apv25.setShapingTime(35);
+        // Set the APV25 operating mode
+        apv25.setAPV25Mode("multi-peak");
+        // Set the APV25 analog pipeline sampling time
+        apv25.setSamplingTime(24);
         
         
         // 
@@ -97,7 +131,115 @@
         // Set the data processing module
         dpm = datapm;
         
-//        pipe = (Profile1D) aida.histogramFactory().createProfile1D("pipeline", 192, 0, 191);    
+        // Instantiate trigger time queue
+        triggerQueue = new LinkedList<Integer>();
+        
+        // Specify the readouts to process
+        readouts.add("TrackerHits");
+        
+        // Specify the detectors to process
+        processPaths.add("Tracker");
+        
+    }
+    
+    /**
+     * 
+     */
+    @Override
+    public void detectorChanged(Detector detector)
+    {
+        super.detectorChanged(detector);
+        
+        // Proces detectors specified by path, otherwise process the entire
+        // detector
+        IDetectorElement detectorElement = detector.getDetectorElement();
+        for(String detectorElementPath : processPaths ){
+            processDetectorElements.add(
+               detectorElement.findDetectorElement(detectorElementPath));
+        }
+        
+        if(processDetectorElements.isEmpty()) 
+            processDetectorElements.add(detectorElement);
+        
+        for(IDetectorElement dElement : processDetectorElements ){
+            processSensors.addAll(dElement.findDescendants(SiSensor.class));
+            processModules.addAll(
+               dElement.findDescendants(SiTrackerModule.class));
+        }
+    }
+    
+    /**
+     * 
+     */
+    @Override
+    public void process(EventHeader event)
+    {
+        super.process(event);
+        
+        if((ClockSingleton.getTime() + ClockSingleton.getDt())%24 == 0){
+            apv25.incrementAllPointerPositions(analogPipelineMap);
+            apv25.stepAPV25Clock();
+        }                                                                                                
+        
+        // Loop over all sensors
+        for(SiSensor sensor : processSensors){
+            // Readout the sensors
+            readoutSensor(sensor);
+        }
+        
+        // If a trigger is received readout the APV25 and digitize all hits
+        if(HPSAPV25.triggerBit){
+            
+            triggerTimeStamp.add(ClockSingleton.getTime());
+            
+            // Only add the trigger if there isn't another trigger being 
+            // processed
+            if(!triggerQueue.contains(apv25.apv25ClockCycle)){
+            // Add the time at which each of the six samples should be 
+            // collected to the trigger queue
+                for(int sample = 0; sample < 6; sample++){
+                    triggerQueue.offer(apv25.apv25ClockCycle + sample);
+                    //--->
+                    System.out.println(triggerQueue.toString());
+                    //--->
+                }
+            }
+            // Reset the APV25 trigger bit
+            HPSAPV25.triggerBit = false;
+        }
+        
+        // Process any triggers in the queue
+        if(triggerQueue.peek() != null){
+            
+            // Remove any samples that might have already been processed
+            if(triggerQueue.peek() < apv25.apv25ClockCycle){
+                for(int sample = 0; sample < 6; sample++){
+                    triggerQueue.remove();
+                    System.out.println(triggerQueue.toString());
+                }
+            }
+            else if(triggerQueue.peek() == apv25.apv25ClockCycle){
+                readoutAPV25();
+                triggerQueue.remove();
+                System.out.println(triggerQueue.toString());
+            }
+        }
+    }
+    
+    /**
+     * 
+     */
+    @Override
+    public void startOfData()
+    {
+        // Set up readouts if they haven't been set
+        if(!readouts.isEmpty()){
+            super.add(new SimTrackerHitReadoutDriver(readouts));
+        }
+        
+        super.startOfData();
+        readouts.clear();
+        
     }
     
     /**
@@ -110,7 +252,10 @@
     }
     
     /**
+     * Readout the electrodes of an HPS Si sensor and inject the charge into 
+     * the APV25 readout chip.
      * 
+     * @param sensor : HPS Si sensor
      */
     public void readoutSensor(SiSensor sensor)
     {
@@ -140,7 +285,7 @@
                 SiSensorElectrodes readoutElectrodes
                    = sensor.getReadoutElectrodes(carrier);
                 
-                // Add noise hits to the electrodes
+                // Add noise to the electrodes
                 addNoise(electrodeDataCol, readoutElectrodes);
                 
                 // Loop over all channels
@@ -153,14 +298,21 @@
                     // Get the charge in units of electrons
                     double charge = electrodeData.getCharge();
                     
-                    //---> Histogram <---//
+                    //====> Charge deposition on electrode 
                     aida.histogram1D("Charge", 100,0 ,200000).fill(charge);
+                    //====>
                     
                     // Get the RMS noise for this channel
                     double noise 
                        = apv25.getChannel().computeNoise(
                             readoutElectrodes.getCapacitance(channel));
                     
+                    //===>
+//                    System.out.println(this.getClass().getName() + ": RMS Noise: " + noise);
+                    aida.histogram1D(this.getClass().getName() + " - RMS Noise - All Channels", 1000, 3500, 4500).fill(noise);
+                    //===>
+                    
+                    
                     // Check to see if an analog pipeline for this channel
                     // exist.  If it doesn't, create one.
                     Integer channelNumber
@@ -184,7 +336,9 @@
                     APV25AnalogPipeline pipeline 
                        = analogPipelineMap.get(channelNumber);
                     
+                    //--->
 //                    System.out.println(this.getClass().getName() + ": Analog Map Size: " + analogPipelineMap.size());
+                    //--->
                     
                     // Inject the charge into the APV25 amplifier chain
                     pipeline = apv25.injectCharge(charge, noise, pipeline);
@@ -213,6 +367,7 @@
             }   
         }
         
+        // Clear the sensors of all deposited charge
         siSimulation.clearReadout();
     }
     
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