hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.3 -r1.4
--- RearTransitionModule.java 17 Aug 2012 01:15:34 -0000 1.3
+++ RearTransitionModule.java 28 Aug 2012 07:15:02 -0000 1.4
@@ -7,32 +7,34 @@
//--- org.lcsim ---//
import org.lcsim.event.EventHeader;
import org.lcsim.util.Driver;
-import org.lcsim.detector.tracker.silicon.SiSensor;
//--- hps-java ---//
import org.lcsim.hps.recon.tracking.apv25.Apv25AnalogData;
import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData;
+import org.lcsim.hps.util.RandomGaussian;
//--- Constants ---//
import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.CHANNELS;
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.MULTIPLEXER_GAIN;
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.MIP;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR;
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: RearTransitionModule.java,v 1.3 2012/08/17 01:15:34 omoreno Exp $
+ * @version $Id: RearTransitionModule.java,v 1.4 2012/08/28 07:15:02 omoreno Exp $
*/
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;
@@ -40,10 +42,10 @@
* 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
}
@@ -53,72 +55,77 @@
*/
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 pedestal and noise
- for(int channel = 0; channel < CHANNELS; channel++){
- int physicalChannel = 639 - (analogDatum.getApvNumber()*128 + 127 - channel);
- apv25Output[channel + 12] += HPSSVTCalibrationConstants.getPedestal(analogDatum.getSensor(), physicalChannel);
+ 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++){
+
+ // For now, don't digitize the header
+ if(index < 12) continue;
+
+ // Get the physical channel
+ int physicalChannel = TOTAL_STRIPS_PER_SENSOR
+ - (analogDatum.getApvNumber()*CHANNELS + (CHANNELS - 1) - (index - 12));
+
+ apv25Output[index] += 4; // mA
+ apv25Output[index] *= (MIP/MULTIPLEXER_GAIN);
+
+ // Digitize the signal
+ apv25Output[index] *= HPSSVTCalibrationConstants.getGain(analogDatum.getSensor(), physicalChannel);
+
+ // Add pedestal and noise
+ double pedestal = HPSSVTCalibrationConstants.getPedestal(analogDatum.getSensor(), physicalChannel);
+ double noise = HPSSVTCalibrationConstants.getNoise(analogDatum.getSensor(), physicalChannel);
+ apv25Output[index] += RandomGaussian.getGaussian(pedestal, noise);
+
+ apv25Output[index] = Math.ceil(apv25Output[index]);
+
+ }
+
+ // Add the digital data to the list
+ digitalData.add(new Apv25DigitalData(analogDatum.getSensor(), analogDatum.getApvNumber(), apv25Output));
}
-
- // Add the digital data to the list
- digitalData.add(new Apv25DigitalData(analogDatum.getSensor(), analogDatum.getApvNumber(), apv25Output));
+
+ event.put(apv25DigitalDataCollectionName, digitalData, Apv25DigitalData.class, 0);
}
-
- event.put(apv25DigitalDataCollectionName, digitalData, Apv25DigitalData.class, 0);
- }
}