Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
HPSReadoutChip.java | +186 | added 1.1 |
Class implementing readout chip for HPS...
diff -N HPSReadoutChip.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSReadoutChip.java 22 Apr 2012 19:24:10 -0000 1.1 @@ -0,0 +1,186 @@
+/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.lcsim.hps.recon.tracking; + +import java.util.List; +import java.util.SortedMap; +import org.lcsim.detector.tracker.silicon.SiSensorElectrodes; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.recon.tracking.digitization.sisim.ReadoutChip; +import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeDataCollection; + +/** + * + * @author mgraham + */ +public class HPSReadoutChip implements ReadoutChip { + + private double _noise_threshold = 4; + private double _neighbor_threshold = 4; + private HPSChannel _channel = new HPSChannel();// make 128 (128*5) channels instead of 1 + private HPSADC _adc = new HPSADC(); + + @Override + public SortedMap<Integer, List<Integer>> readout(SiElectrodeDataCollection data, SiSensorElectrodes electrodes) { + throw new UnsupportedOperationException("Not supported yet."); + } + + /** + * Decode the hit charge stored in the RawTrackerHit + * + * @param hit raw hit + * @return hit charge in units of electrons ...this only gets the "charge" + * of the first measurement + */ + public double decodeCharge(RawTrackerHit hit) { + return getADC().decodeCharge(hit.getADCValues()[0]); + } + + /** + * Decode the hit time. Currently, the basic readout chip ignores the hit + * time and returns 0. + * + * @param hit raw hit data + * @return hit time + */ + public int decodeTime(RawTrackerHit hit) { + return 0; + } + + public HPSChannel getChannel(int channel_number) { + return _channel; + } + + private HPSADC getADC() { + return _adc; + } + + // here, put in call to the Amplitude vs time fitting.... + public double getFittedTime(RawTrackerHit hit, int channel_number) { + return 0; + } + //here, put in call to the Amplitude vs time fitting.... + + public double getFittedAmplitude(RawTrackerHit hit, int channel_number) { + return 0; + } + + /** + * Creates a new instance of BasicReadoutChip + */ + public HPSReadoutChip() { + } + + private class HPSChannel implements ReadoutChannel { + + private double _noise; + private double _Tp; + private double _pedestal; + + public void setNoise(double Noise) { + _noise = Noise; + } + + public void setPedestal(double Pedestal) { + _pedestal = Pedestal; + } + + public void setTp(double Tp) { + _Tp = Tp; + } + + public double computeNoise(double capacitance) { + return _noise; + } + + public double getNoise() { + return _noise; + } + + public double getPedestal() { + return _pedestal; + } + + public double getTp() { + return _Tp; + } + } + + /** + * ADC class representing analog to digital converter. + */ + private class HPSADC { + + private int _nbits = 8; + private double _dynamic_range = 20.; + + /** + * Set the ADC resolution in number of bits. + * + * @param nbits number of bits + */ + private void setNbits(int nbits) { + _nbits = nbits; + } + + /** + * Set the dynamic range in fC + * + * @param dynamic range + */ + private void setDynamicRange(double dynamic_range) { + _dynamic_range = dynamic_range; + } + + /** + * Compute the maximum ADC value + * + * @return largest possible ADC value according to # of bits + */ + private int maxADCValue() { + return (int) Math.pow(2, _nbits) - 1; + } + + /** + * Compute the conversion constant in ADC/fC + * + * @return conversion constant for ADC + */ + private double conversionConstant() { + return maxADCValue() / _dynamic_range; + } + + /** + * Perform analog to digital conversion + * + * @return digital ADC output between 0 and maxADCValue + */ + public int convert(double charge) { + if (_nbits != 1) { + return Math.max(0, Math.min(maxADCValue(), (int) Math.floor(charge * 1.602e-4 * conversionConstant()))); + } else { + if (charge <= 0.0) { + return 0; + } else { + return 1; + } + } + } + + /** + * Decode charge from ADC value + * + * @return charge specified by a given ADC value + */ + public double decodeCharge(int adc_value) { + if (_nbits != 1) { + return (adc_value + 0.5) / (1.602e-4 * conversionConstant()); + } else { + return adc_value * _dynamic_range; + } + + } + } +}
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