Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25 on MAIN
HPSSiSensorReadout.java+84-721.3 -> 1.4
Added sensor to chip map; now handles the readout of APV25s

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
HPSSiSensorReadout.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- HPSSiSensorReadout.java	30 Jan 2012 00:31:20 -0000	1.3
+++ HPSSiSensorReadout.java	12 Mar 2012 23:01:42 -0000	1.4
@@ -29,6 +29,7 @@
 import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
 import org.lcsim.detector.tracker.silicon.SiTrackerModule; 
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.SimTrackerHit;
 import org.lcsim.geometry.Detector;
 import org.lcsim.math.probability.Erf;
 import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeData;
@@ -50,10 +51,13 @@
 /**
  *
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSSiSensorReadout.java,v 1.3 2012/01/30 00:31:20 omoreno Exp $
+ * @version $Id: HPSSiSensorReadout.java,v 1.4 2012/03/12 23:01:42 omoreno Exp $
  */
 public class HPSSiSensorReadout extends Driver {
     
+    //
+    boolean debug = true;
+    
     // Array to store the trigger time
     public static final List<Double> triggerTimeStamp 
        = new ArrayList<Double>();
@@ -88,28 +92,47 @@
     
     private double noiseThreshold = 4;  // e- RMS
     
-    // Initialize the map which will be used to associate a channel to 
-    // its respective analog pipeline.  The key value is determined using
-    // the following
-    //        sensorId*(# of strips per sensor) + channel number
-    public static Map<Integer /* channel */, 
-                      APV25AnalogPipeline> analogPipelineMap 
-       = new HashMap<Integer, APV25AnalogPipeline>();
+    // A map used to associate a sensor to the channels and analog pipelines 
+    // of the APV25s being used to readout the sensor
+    public Map< Long /* sensor number */, 
+                Map<Integer /* channel */, APV25AnalogPipeline>> sensorToPipelineMap;
+    
+    // A map used to associate an APV25 channel to its analog pipeline
+    public Map<Integer /* channel */, 
+               APV25AnalogPipeline> analogPipelineMap;
+    
+    // A map used to associate a sensor to the output of the APV25s being 
+    // used to readout the sensor
+    public Map<Long, Map<Integer /* chip # */, double[]>> sensorToAnalogDataMap;
+    
+    // A map used to associate a sensor to the digitzed output of the APV25s
+    // being used to readout the sensor
+    public Map<Long, Map<Integer /*chip # */, double[]>> sensorToDigitalDataMap;
 
     //
     public Map<Integer, double[]> analogData;
     public Map<Integer, double[]> digitalData;
     
+    public Map<Integer, List<SimTrackerHit> > eventToSimTrackerHitMap;
+    
     //
     protected AIDA aida = AIDA.defaultInstance();
     public Profile1D pipe;
     
+    int n_events = 0;
+    
     
     /**
      * Constructor
      */
     public HPSSiSensorReadout(HPSDataProcessingModule datapm)
     {
+        sensorToPipelineMap = new HashMap<Long, Map<Integer, APV25AnalogPipeline>>();
+        sensorToAnalogDataMap = new HashMap<Long, Map<Integer, double[]>>();
+        sensorToDigitalDataMap = new  HashMap<Long, Map<Integer, double[]>>();
+
+        eventToSimTrackerHitMap = new HashMap<Integer, List<SimTrackerHit> >();
+        
         //--- Sensor Simulation ---//
         //-------------------------//
         siSimulation = new CDFSiSensorSim();
@@ -166,6 +189,23 @@
             processModules.addAll(
                dElement.findDescendants(SiTrackerModule.class));
         }
+        
+        // Initialize the sensor maps
+        for(SiSensor sensor: processSensors){
+            
+            sensorToPipelineMap.put(sensor.getIdentifier().getValue(), 
+                            new HashMap<Integer, APV25AnalogPipeline>());
+            for(int channel = 0; channel < STRIPS_PER_SENSOR; channel++){
+                sensorToPipelineMap.get(sensor.getIdentifier().getValue()).put(channel,apv25.getChannel().new APV25AnalogPipeline());
+            }
+            
+            sensorToAnalogDataMap.put(sensor.getIdentifier().getValue(), 
+                                      new HashMap<Integer, double[]>() );
+            
+            sensorToDigitalDataMap.put(sensor.getIdentifier().getValue(), 
+                                      new HashMap<Integer, double[]>() );                
+
+        }
     }
     
     /**
@@ -174,13 +214,17 @@
     @Override
     public void process(EventHeader event)
     {
+
+        
         super.process(event);
         
         if((ClockSingleton.getTime() + ClockSingleton.getDt())%24 == 0){
-            apv25.incrementAllPointerPositions(analogPipelineMap);
+            for(Map.Entry<Long, Map<Integer, APV25AnalogPipeline>> sensor : sensorToPipelineMap.entrySet()){
+                apv25.incrementAllPointerPositions(sensor.getValue());
+            }
             apv25.stepAPV25Clock();
         }                                                                                                
-        
+                
         // Loop over all sensors
         for(SiSensor sensor : processSensors){
             // Readout the sensors
@@ -199,9 +243,6 @@
             // 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
@@ -215,13 +256,11 @@
             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());
             }
         }
     }
@@ -259,8 +298,9 @@
      */
     public void readoutSensor(SiSensor sensor)
     {
-        // Set the sensor to be used for the charge deposition simulation
+        // Set the sensor to be used in the charge deposition simulation
         siSimulation.setSensor(sensor);
+        
         // Perform the charge deposition simulation
         Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap
            = siSimulation.computeElectrodeData();
@@ -281,20 +321,24 @@
                     electrodeDataCol = new SiElectrodeDataCollection();
                 }
                 
-                // Obtain the electrodes to be readout
+                // Get the readout electrodes
                 SiSensorElectrodes readoutElectrodes
                    = sensor.getReadoutElectrodes(carrier);
                 
                 // Add noise to the electrodes
                 addNoise(electrodeDataCol, readoutElectrodes);
                 
+                // Get the analog pipeline map associated with this sensor
+                analogPipelineMap 
+                   = sensorToPipelineMap.get(sensor.getIdentifier().getValue());
+                
                 // Loop over all channels
                 for(Integer channel : electrodeDataCol.keySet()){
                    
                     // Get the electrode data for this channel
                     SiElectrodeData electrodeData 
                        = electrodeDataCol.get(channel);
-                   
+                    
                     // Get the charge in units of electrons
                     double charge = electrodeData.getCharge();
                     
@@ -306,67 +350,36 @@
                     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
-                       = sensor.getSensorID()*STRIPS_PER_SENSOR + channel;
-                    
-                    if(!analogPipelineMap.containsKey(channelNumber)){
-                        
-                        //--->
-//                        System.out.println(this.getClass().getName() + ": Creating Pipeline for channel " + channelNumber.toString());
-                        //--->
+                    if(!analogPipelineMap.containsKey(channel)){
+
                         
-                        analogPipelineMap.put(channelNumber, 
+                        analogPipelineMap.put(channel, 
                            apv25.getChannel().new APV25AnalogPipeline());
                     }
-                    
-                    //--->
-//                    System.out.println(this.getClass().getName() + ": The Channel Number is: " + channelNumber);
-                    //--->
 
                     // Get the analog pipeline associated with this channel
                     APV25AnalogPipeline pipeline 
-                       = analogPipelineMap.get(channelNumber);
-                    
-                    //--->
-//                    System.out.println(this.getClass().getName() + ": Analog Map Size: " + analogPipelineMap.size());
-                    //--->
+                       = analogPipelineMap.get(channel);
                     
                     // Inject the charge into the APV25 amplifier chain
                     pipeline = apv25.injectCharge(charge, noise, pipeline);
                     // Store the analog pipeline for later use
-                    analogPipelineMap.put(channelNumber, pipeline);
+                    analogPipelineMap.put(channel, pipeline);
                    
-
-                    //----> 
-//                    if(channelKey.equals("5")){
-//                        Iterator<Double> pipelineIterator = pipeline.iterator();
-//                        int index = 0;
-//                        
-//                        //pipe = (Profile1D) aida.histogramFactory().createProfile1D("pipeline", 192, 0, 191);
-//                        
-//                       // pipeline.printAnalogPipeline();
-//                        while(pipelineIterator.hasNext()){
-//                                                             
-//                            pipe.fill(index, pipelineIterator.next());
-//                            index++;
-//                        }
-//                        index = 0;
-//                        
-//                    }
-                    //---->
                 }
             }   
         }
         
+        // Place the analog pipeline back into the sensor map
+        sensorToPipelineMap.put(sensor.getIdentifier().getValue(), analogPipelineMap);
+        
         // Clear the sensors of all deposited charge
         siSimulation.clearReadout();
     }
@@ -376,20 +389,19 @@
      */
     public void readoutAPV25()
     {
-        // Readout all apv25's
-        analogData 
-           = apv25.APV25Multiplexer(HPSSiSensorReadout.analogPipelineMap); 
-   
-        //--->
-        System.out.println(this.getClass().getName() + " : Analog Data Size: " + analogData.size());
-        //--->
-        
-       // Digitize all signals
-       digitalData = rtm.digitize(analogData);
-
-       // Buffer the samples for further processing
-       dpm.addSample(digitalData);
-       
+        // Readout all apv25s
+        for(Map.Entry<Long, Map<Integer, APV25AnalogPipeline>> sensor : sensorToPipelineMap.entrySet()){
+            sensorToAnalogDataMap.put(sensor.getKey(), apv25.APV25Multiplexer(sensor.getValue()));
+        }        
+ 
+        // Digitize all signals
+        for(Map.Entry<Long, Map<Integer, double[]>> sensor : sensorToAnalogDataMap.entrySet()){
+            sensorToDigitalDataMap.put(sensor.getKey(), rtm.digitize(sensor.getValue()));
+        }
+        
+        // Buffer the samples for further processing
+        dpm.addSample(sensorToDigitalDataMap);
+
     }
     
     
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