Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
RearTransitionModule.java+107added 1.1
RTM is now a driver; adjusted input stage gain to match HPS test run

hps-java/src/main/java/org/lcsim/hps/recon/tracking
RearTransitionModule.java added at 1.1
diff -N RearTransitionModule.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ RearTransitionModule.java	7 Jul 2012 00:35:49 -0000	1.1
@@ -0,0 +1,107 @@
+package org.lcsim.hps.recon.tracking;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.hps.recon.tracking.apv25.Apv25AnalogData;
+import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData;
+import org.lcsim.util.Driver;
+
+public class RearTransitionModule extends Driver {
+
+    String apv25AnalogDataCollectionName = "APV25AnalogData";
+    String apv25DigitalDataCollectionName = "AVP25DigitalData";
+    
+    double adcVHighRef = 1000;   // mVolts
+    double adcVLowRef = -1000;   // mVolts
+    int    adcResolution = 14;   // bits
+    double adcVoltageResolution = 1;  // mV
+    int quantizationLevels = 256; 
+    
+    // Should these be put in the constants? 
+    double resistorValue = 100;  // Ohms
+    double inputStageGain = 1.5;
+
+    /**
+     * Default Ctor
+     */
+    public RearTransitionModule(){
+        
+        // Find the number of quantization levels
+        int quantizationLevels = (int) Math.pow(2, adcResolution);
+        
+        // Find the ADC voltage resolution
+        adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV
+    }    
+
+    /**
+     * 
+     */
+    public void setResolution(int bits){
+        adcResolution = bits;
+        
+        // Find the number of quantization levels
+        quantizationLevels = (int) Math.pow(2, adcResolution);
+        
+        
+        // Find the ADC voltage resolution
+        adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV
+    }
+    
+    /**
+     * 
+     */
+    public void setADCSpan(double adcVHighRef, double adcVLowRef){
+        this.adcVHighRef = adcVHighRef;
+        this.adcVLowRef = adcVLowRef;
+        
+        // Find the ADC voltage resolution
+        adcVoltageResolution = (adcVHighRef - adcVLowRef)/quantizationLevels; // mV
+    }
+    
+    /**
+     * 
+     */
+    @Override
+    protected void process(EventHeader event){
+        super.process(event);
+        
+        // If the event does not contain any analog data that needs to be digitized, skip the event
+        if(!event.hasCollection(Apv25AnalogData.class, apv25AnalogDataCollectionName)) return;
+    
+        // Get the analog data from the event
+        List<Apv25AnalogData> analogData = event.get(Apv25AnalogData.class, apv25AnalogDataCollectionName);
+        
+        // Create a list hold the digital data
+        List<Apv25DigitalData> digitalData = new ArrayList<Apv25DigitalData>();
+        
+        // Amplify the analog data
+        for(Apv25AnalogData analogDatum : analogData){
+            
+            // Make a hard copy of the APV25 analog output to avoid modification of the original
+            double[] apv25Output = new double[140];
+            System.arraycopy(analogDatum.getApv25AnalogOutput(), 0, apv25Output, 0, apv25Output.length);        
+            
+            
+            for(int index = 0; index < apv25Output.length; index++){
+                
+                // Convert input current to voltage
+                apv25Output[index] *= resistorValue;
+                
+                // Amplify the input signal 
+                apv25Output[index] *= inputStageGain;
+            
+                // Digitize the APV25 analog output
+                // TODO: Verify that this is correct
+                apv25Output[index] = Math.floor((apv25Output[index] - adcVLowRef)/adcVoltageResolution);
+            }
+            
+            // Add the digital data to the list
+            digitalData.add(new Apv25DigitalData(apv25Output));
+        }
+    
+        event.put(apv25DigitalDataCollectionName, digitalData, Apv25DigitalData.class, 0);
+    }
+}
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