Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25 on MAIN
Apv25Full.java+237added 1.1
Apv25AnalogData.java+81added 1.1
Apv25Constants.java+27added 1.1
Apv25DigitalData.java+70added 1.1
SvtHalfModule.java+43added 1.1
SvtReadout.java+154added 1.1
APV25Constants.java-251.1 removed
APV25Full.java-2311.1 removed
+612-256
6 added + 2 removed, total 8 files
Analog and Digital Data is now stored in the event; New SVT readout driver; SvtHalfModule is used to encapsulate Sensor and APV's

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
Apv25Full.java added at 1.1
diff -N Apv25Full.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Apv25Full.java	7 Jul 2012 00:32:05 -0000	1.1
@@ -0,0 +1,237 @@
+package org.lcsim.hps.recon.tracking.apv25;
+
+//--- Constants ---//
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.ANALOG_PIPELINE_LENGTH;
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.FRONT_END_GAIN;
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.MIP;
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.SAMPLING_TIME;
+
+//--- hps-java ---//
+import org.lcsim.hps.util.ClockSingleton;
+import org.lcsim.hps.util.RingBuffer;
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: Apv25Full.java,v 1.1 2012/07/07 00:32:05 omoreno Exp $
+ */
+public class Apv25Full {
+    
+    // APV25 trigger bit
+    public static boolean triggerBit = false;
+    
+    // APV25 Channels; An APV25 Readout Chip contains a total of 128 channels
+    private APV25Channel[] channels = new APV25Channel[128];
+    private String apv25Mode = "multi-peak";
+        
+    public Apv25Full(){
+        
+        // Instantiate all APV25 channels
+        for(int channel = 0; channel < channels.length; channel++){
+            channels[channel] = new APV25Channel();
+        }
+        
+        // TODO: Load channel constants from the conditions database. Channel
+        // constants need to be loaded on a run by run basis
+        this.loadChannelConstants();
+    }
+    
+    /**
+     * Return an instance of an APV25 channel
+     * 
+     * @return an instance of APV25Channel
+     */
+    public APV25Channel getChannel(int channel){
+        return channels[channel];
+    }
+    
+    /**
+     * Inject charge into a channel and shape the signal.  The resulting 
+     * shaper signal is then sampled into the analog pipeline
+     * 
+     * @param charge   : Total charge being injected
+     * @param pipeline : Analog pipeline associated with a channel
+     */
+    public void injectCharge(int channel, double charge) {
+        
+        // Shape the injected charge
+        this.getChannel(channel).shapeSignal(charge);
+
+        // Sample the resulting shaper signal
+        this.getChannel(channel).sampleShaperSignal();
+    }
+    
+    /**
+     * 
+     */
+    public void loadChannelConstants(){
+    }
+    
+    /**
+     * 
+     */
+    public Apv25AnalogData readOut(){
+        
+        Apv25AnalogData data = new Apv25AnalogData();
+        for(int channel = 0; channel < channels.length; channel++){
+            data.setChannelData(channel, channels[channel].pipeline.readout());
+        }
+        
+        return data;
+    }
+    
+    //------------------------------------------//
+    //               APV25 Channel              //
+    //------------------------------------------//
+    public class APV25Channel {
+        
+        private APV25ShaperSignal shaperSignal;
+        private APV25Pipeline pipeline;
+        
+        private double shapingTime = 50; // [ns]
+        
+        /**
+         * Default Constructor
+         */
+        public APV25Channel(){
+        }
+        
+        /**
+         * Set the shaping time
+         * 
+         * @param shapingTime : APV25 shaping time. The default Tp is set to 50 ns.
+         */
+        public void setShapingTime(int shapingTime) {
+            this.shapingTime = shapingTime;
+        }
+               
+        /**
+         * Shape the injected charge
+         * 
+         * @param charge 
+         */
+        public void shapeSignal(double charge){
+            shaperSignal = new APV25ShaperSignal(charge);
+        }
+        
+        public void sampleShaperSignal(){
+            
+            // Obtain the beam time
+            double beamTime = ClockSingleton.getTime();
+            
+            // Fill the analog pipeline starting with the cell to which the writer pointer is pointing 
+            // to. Signals arriving within the same bucket of length <samplingTime> will be shifted in
+            // time depending on when they arrive.
+            for(int cell = 0; cell < ANALOG_PIPELINE_LENGTH; cell++){
+                
+                // Time at which the shaper signal will be sampled
+                int sampleTime = cell*SAMPLING_TIME - ((int) beamTime)%SAMPLING_TIME;
+                
+                // Sample the shaper signal
+                double sample = shaperSignal.getAmplitudeAtTime(sampleTime, shapingTime);
+                
+                // Add the value to the pipeline
+                pipeline.addToCell(cell, sample);
+            }
+        }
+    }
+    
+    //-------------------------------------//
+    //       APV25 Analog Pipeline         //
+    //-------------------------------------//
+    public class APV25Pipeline extends RingBuffer {
+
+        // TODO: Possibly store the pipeline in the event
+        
+        // Note: ptr gives the position of the trigger pointer
+        
+        private int triggerLatency = (int) Math.floor(200 /* ns */ / SAMPLING_TIME);
+        private int writerPointer = 0;
+        
+        /**
+         * Constructor
+         */
+        public APV25Pipeline(){
+            
+            // Initialize the pipeline to the APV25 pipeline length
+            super(ANALOG_PIPELINE_LENGTH);
+            
+            // Initialize the position of the trigger pointer to a random position
+            this.ptr = (int) (Math.random()*(ANALOG_PIPELINE_LENGTH + 1));
+            
+            // Set the position of the writer pointer
+            writerPointer = (ptr + triggerLatency)%ANALOG_PIPELINE_LENGTH;
+        }
+        
+        /**
+         * 
+         */
+        public void setLatency(int triggerLatency /*ns*/){
+            triggerLatency = (int) Math.floor(triggerLatency/SAMPLING_TIME);
+        }
+        
+        /**
+         * 
+         */
+        @Override
+        public void addToCell(int position, double element){
+            if((writerPointer + position)%ANALOG_PIPELINE_LENGTH == this.ptr) return;
+            super.addToCell(position, element);
+        }
+        
+        /**
+         * 
+         */
+        public double readout(){
+            double triggerPointerValue = this.currentValue();
+            array[ptr] = 0;
+            return triggerPointerValue;
+        }
+        
+        /**
+         * 
+         */
+        @Override
+        public String toString(){
+            String analogPipeline = "[ ";
+            for(int element = 0; element < ANALOG_PIPELINE_LENGTH; element++){
+                if(element == ptr) analogPipeline += " TP ===>";
+                else if(element == writerPointer) analogPipeline += " WP ===>";
+                analogPipeline += (array[element] + ", ");
+            }
+            analogPipeline += "] ";
+            return analogPipeline;
+        }
+    }
+
+    //-----------------------------------//
+    //        APV25 Shaper Signal        //
+    //-----------------------------------//
+    public class APV25ShaperSignal {
+
+        // Shaper signal maximum amplitude
+        private double maxAmp = 0;
+
+        /**
+         * Constructor
+         * 
+         * @param charge: Charge injected into a channel
+         */
+        APV25ShaperSignal(double charge) {
+            // Find the maximum amplitude of the shaper signal
+            maxAmp = (charge/MIP)*FRONT_END_GAIN;  // mV
+        }
+
+        /**
+         * Get the amplitude at a time t
+         * 
+         * @param time: time at which the shaper signal is to be sampled
+         */
+        public double getAmplitudeAtTime(double time, double shapingTime) {
+            return maxAmp * (Math.max(0, time) / shapingTime) * Math.exp(1 - (time / shapingTime));
+        }
+
+    }
+    
+
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
Apv25AnalogData.java added at 1.1
diff -N Apv25AnalogData.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Apv25AnalogData.java	7 Jul 2012 00:32:05 -0000	1.1
@@ -0,0 +1,81 @@
+package org.lcsim.hps.recon.tracking.apv25;
+
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: Apv25AnalogData.java,v 1.1 2012/07/07 00:32:05 omoreno Exp $ 
+ */
+public class Apv25AnalogData {
+    
+    // TODO: Add ability to associate the analog data to a SiSensor and APV25
+    
+    // APV25 output stream
+    private double[] apv25AnalogOutput = new double[140];
+    private double[] header = {4.0, 4.0, 4.0};
+    private double[] address = {-4.0, -4.0, -4.0, -4.0, -4.0, -4.0, -4.0, -4.0};
+    private double   error = 4.0;
+    private double[] samples = new double[128];
+
+
+    /**
+     * Default Ctor
+     */
+    public Apv25AnalogData(){
+        
+        // Create the array which will contain the output.  The array values will range
+        // from -4 microAmps to 4 microAmps
+        for(int index = 0; index < samples.length; index++){
+            samples[index] = -4.0; // microAmps
+        }
+
+        // Copy the header, address, error and samples
+        System.arraycopy(header, 0, apv25AnalogOutput, 0, header.length);
+        System.arraycopy(address, 0, apv25AnalogOutput, 3, address.length);
+        apv25AnalogOutput[11] = error;
+        System.arraycopy(samples, 0, apv25AnalogOutput, 12, samples.length);
+    }
+    
+    /**
+     * 
+     */
+    public double[] getHeader(){
+        return header;
+    }
+    
+    /**
+     * 
+     */
+    public double[] getAddress(){
+        return address;
+    }
+    
+    /**
+     * 
+     */
+    public double getErrorBit(){
+        return error;
+    }
+    
+    /**
+     * 
+     */
+    public double[] getSamples(){
+        return samples;
+    }
+    
+    /**
+     * 
+     */
+    public double[] getApv25AnalogOutput(){
+        return apv25AnalogOutput;
+    }
+
+    /**
+     * 
+     */
+    public void setChannelData(int channel, double data){
+        samples[channel] = data;
+        apv25AnalogOutput[12 + channel] = data;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
Apv25Constants.java added at 1.1
diff -N Apv25Constants.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Apv25Constants.java	7 Jul 2012 00:32:05 -0000	1.1
@@ -0,0 +1,27 @@
+package org.lcsim.hps.recon.tracking.apv25;
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: Apv25Constants.java,v 1.1 2012/07/07 00:32:05 omoreno Exp $
+ */
+public class Apv25Constants {
+
+    // Total number of channels an APV25 asic contains
+    public static final int CHANNELS = 128;
+    
+    // Number of electron-hole pairs created by a min. ionizing particle
+    // in 300 micrometers of Si
+    public static final int MIP = 25000;
+    
+    //
+    public static final int SAMPLING_TIME = 24; // [ns]
+    
+    //
+    public static final double FRONT_END_GAIN = 100.0;
+    public static final int    ANALOG_PIPELINE_LENGTH = 192;
+    
+    //
+    public static final int APV25S_PER_HALF_MODULE = 5;
+
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
Apv25DigitalData.java added at 1.1
diff -N Apv25DigitalData.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Apv25DigitalData.java	7 Jul 2012 00:32:05 -0000	1.1
@@ -0,0 +1,70 @@
+package org.lcsim.hps.recon.tracking.apv25;
+
+import java.util.Arrays;
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: Apv25DigitalData.java,v 1.1 2012/07/07 00:32:05 omoreno Exp $  
+ */
+public class Apv25DigitalData {
+    
+    // TODO: Add ability to associate the analog data to a SiSensor and APV25
+    
+    // APV25 output stream
+    private double[] apv25DigitalOutput = new double[140];
+    private double[] header = new double[3];
+    private double[] address = new double[8];
+    private double   error;
+    private double[] samples = new double[128];
+    
+    /**
+     * Default Ctor
+     */
+    public Apv25DigitalData(double[] apv25DigitalOutput){
+        
+        // Check if the output format is valid
+        if(apv25DigitalOutput.length != this.apv25DigitalOutput.length) 
+            throw new RuntimeException("APV25 output format is invalid!");
+        
+        System.arraycopy(apv25DigitalOutput, 0, header, 0, header.length);
+        System.arraycopy(apv25DigitalOutput, 3, address, 0, address.length);
+        error   = apv25DigitalOutput[11];
+        System.arraycopy(apv25DigitalOutput, 12, samples, 0, samples.length);
+    }
+    
+    /**
+     * 
+     */
+    public double[] getHeader(){
+        return header;
+    }
+    
+    /**
+     * 
+     */
+    public double[] getAddress(){
+        return address;
+    }
+    
+    /**
+     * 
+     */
+    public double getErrorBit(){
+        return error;
+    }
+    
+    /**
+     * 
+     */
+    public double[] getSamples(){
+        return samples;
+    }
+    
+    /**
+     * 
+     */
+    public double[] getApv25DigitalOutput(){
+        return apv25DigitalOutput;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
SvtHalfModule.java added at 1.1
diff -N SvtHalfModule.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtHalfModule.java	7 Jul 2012 00:32:05 -0000	1.1
@@ -0,0 +1,43 @@
+package org.lcsim.hps.recon.tracking.apv25;
+
+//--- constants ---//
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.APV25S_PER_HALF_MODULE;
+import static org.lcsim.hps.recon.tracking.apv25.Apv25Constants.CHANNELS;
+
+//--- lcsim ---//
+import org.lcsim.detector.tracker.silicon.SiSensor;
+
+/**
+ * 
+ * @author Omar Moreno
+ * @version $Id: SvtHalfModule.java,v 1.1 2012/07/07 00:32:05 omoreno Exp $
+ */
+public class SvtHalfModule {
+
+    private SiSensor sensor;
+    private Apv25Full[] apv25 = new Apv25Full[5];
+    
+    public SvtHalfModule(SiSensor sensor){
+        
+        // Set the sensor associated with this half-module
+        this.sensor = sensor;
+        
+        // Instantiate the APV25's
+        for(int chip = 0; chip < APV25S_PER_HALF_MODULE; chip++){
+            apv25[chip] = new Apv25Full();
+        }
+    }
+    
+    public SiSensor getSensor(){
+        return sensor;
+    }
+    
+    public Apv25Full getAPV25(int physicalChannel){
+        int apv = (int) ((APV25S_PER_HALF_MODULE - 1) - Math.floor(physicalChannel/CHANNELS));
+        return apv25[apv];
+    }
+    
+    public Apv25Full[] getAllApv25s(){
+        return apv25;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
SvtReadout.java added at 1.1
diff -N SvtReadout.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtReadout.java	7 Jul 2012 00:32:05 -0000	1.1
@@ -0,0 +1,154 @@
+package org.lcsim.hps.recon.tracking.apv25;
+
+//--- java ---//
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+
+//--- lcsim ---//
+import org.lcsim.detector.tracker.silicon.ChargeCarrier;
+import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.hps.recon.tracking.SvtUtils;
+import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
+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.util.Driver;
+
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: SvtReadout.java,v 1.1 2012/07/07 00:32:05 omoreno Exp $
+ */
+public class SvtReadout extends Driver {
+
+    Set<SvtHalfModule> halfModules = new HashSet<SvtHalfModule>();
+    private SiSensorSim siSimulation = new CDFSiSensorSim(); 
+    String apv25AnalogDataCollectioName = "APV25AnalogData";
+    
+    // FIFO queue to store "local" triggers by time
+    private Queue<Integer> triggerQueue = new LinkedList<Integer>();
+    
+    public SvtReadout(){
+    }
+    
+    /**
+     * 
+     */
+    @Override
+    public void detectorChanged(Detector detector){
+        super.detectorChanged(detector);
+        
+        // Instantiate all SVT Half modules
+        for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+            halfModules.add(new SvtHalfModule(sensor));
+        }
+    }
+    
+    /**
+     * 
+     */
+    @Override
+    public void process(EventHeader event){
+        super.process(event);
+
+        // Create a list to hold the analog data
+        List<Apv25AnalogData> analogData = new ArrayList<Apv25AnalogData>();
+
+        // Loop over all half-modules, perform charge deposition simulation and read them out
+        for(SvtHalfModule halfModule : halfModules){
+            this.readoutSensor(halfModule);
+            
+            // If an Ecal trigger is received, generate six local triggers in order to read out six
+            // samples
+            if(Apv25Full.triggerBit){
+                
+                // Only generate a set of triggers if there isn't another trigger being processed
+                // TODO: Verify that this is how the APV25 is actually read out
+                // TODO: Where should pending triggers be stored? 
+            }
+            
+            // Clear the analog data and readout all APV25's
+            analogData.addAll(this.readoutAPV25s(halfModule));
+        }
+        
+        event.put(apv25AnalogDataCollectioName, analogData, Apv25AnalogData.class, 0);
+
+    }
+    
+    /**
+     * Readout the electrodes of an HPS Si sensor and inject the charge into 
+     * the APV25 readout chip.
+     * 
+     * @param halfModule : SVT Half Module
+     */
+    public void readoutSensor(SvtHalfModule halfModule){
+        
+        // Set the sensor to be used in the charge deposition simulation
+        siSimulation.setSensor(halfModule.getSensor());
+        
+        // Perform the charge deposition simulation
+        Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap = siSimulation.computeElectrodeData();
+        
+        for (ChargeCarrier carrier : ChargeCarrier.values()) {
+            
+            // If the sensor is capable of collecting the given charge carrier
+            // then obtain the electrode data for the sensor
+            if (halfModule.getSensor().hasElectrodesOnSide(carrier)) {
+                
+                SiElectrodeDataCollection electrodeDataCol = electrodeDataMap.get(carrier);
+                
+                // If there is no electrode data available create a new instance of electrode data
+                if (electrodeDataCol == null) {
+                    electrodeDataCol = new SiElectrodeDataCollection();
+                }
+                
+                // Get the readout electrodes
+//                SiSensorElectrodes readoutElectrodes = halfModule.getSensor().getReadoutElectrodes(carrier);
+                
+                // Add noise to the electodes 
+                // TODO: Noise simulation needs to be improved to be more realistic
+                
+                // Loop over all sensor 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();
+                    
+                    // Inject the charge into the APV25 amplifier chain
+                    halfModule.getAPV25(channel).injectCharge(channel, charge);
+                }
+            }
+        }
+        
+        // Clear the sensors of all deposited charge
+        siSimulation.clearReadout();
+    }
+    
+    /**
+     * 
+     */
+    public List<Apv25AnalogData> readoutAPV25s(SvtHalfModule halfModule){
+        
+        // Create a list to hold the analog data
+        List<Apv25AnalogData> analogData = new ArrayList<Apv25AnalogData>();
+        
+        // Readout all APV25's 
+        for(Apv25Full apv25 : halfModule.getAllApv25s()){
+            analogData.add(apv25.readOut());
+        }
+        
+        return analogData;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
APV25Constants.java removed after 1.1
diff -N APV25Constants.java
--- APV25Constants.java	3 Jul 2012 00:34:12 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-package org.lcsim.hps.recon.tracking.apv25;
-
-/**
- * 
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: APV25Constants.java,v 1.1 2012/07/03 00:34:12 omoreno Exp $
- */
-public class APV25Constants {
-
-    // Total number of channels an APV25 asic contains
-    public static final int CHANNELS = 128;
-    
-    // Number of electron-hole pairs created by a min. ionizing particle
-    // in 300 micrometers of Si
-    public static final int MIP = 25000;
-    
-    //
-    public static final int SAMPLING_TIME = 24; // [ns]
-    
-    //
-    public static final double FRONT_END_GAIN = 100.0;
-    public static final int    ANALOG_PIPELINE_LENGTH = 192;
-    
-
-}

hps-java/src/main/java/org/lcsim/hps/recon/tracking/apv25
APV25Full.java removed after 1.1
diff -N APV25Full.java
--- APV25Full.java	3 Jul 2012 00:34:12 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,231 +0,0 @@
-package org.lcsim.hps.recon.tracking.apv25;
-
-//--- Constants ---//
-import static org.lcsim.hps.recon.tracking.apv25.APV25Constants.ANALOG_PIPELINE_LENGTH;
-import static org.lcsim.hps.recon.tracking.apv25.APV25Constants.FRONT_END_GAIN;
-import static org.lcsim.hps.recon.tracking.apv25.APV25Constants.MIP;
-import static org.lcsim.hps.recon.tracking.apv25.APV25Constants.SAMPLING_TIME;
-
-//--- hps-java ---//
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.hps.util.RingBuffer;
-
-/**
- * 
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: APV25Full.java,v 1.1 2012/07/03 00:34:12 omoreno Exp $
- */
-public class APV25Full {
-    
-    // APV25 Channels; An APV25 Readout Chip contains a total of 128 channels
-    private APV25Channel[] channels = new APV25Channel[128];
-    private String apv25Mode = "multi-peak";
-        
-    public APV25Full(){
-        
-        // Instantiate all APV25 channels
-        for(int channel = 0; channel < channels.length; channel++){
-            channels[channel] = new APV25Channel();
-        }
-        
-        // TODO: Load channel constants from the conditions database. Channel
-        // constants need to be loaded on a run by run basis
-        this.loadChannelConstants();
-    }
-    
-    /**
-     * Set the operating mode of the APV25 to either "peak", 
-     * "deconvolution", or "multi-peak".
-     * 
-     * @param mode : APV25 operating mode 
-     */
-    public void setAPV25Mode(String mode) {
-        apv25Mode = mode;
-    }
-    
-    /**
-     * Return an instance of an APV25 channel
-     * 
-     * @return an instance of APV25Channel
-     */
-    public APV25Channel getChannel(int channel){
-        return channels[channel];
-    }
-    
-    /**
-     * Inject charge into a channel and shape the signal.  The resulting 
-     * shaper signal is then sampled into the analog pipeline
-     * 
-     * @param charge   : Total charge being injected
-     * @param pipeline : Analog pipeline associated with a channel
-     */
-    public void injectCharge(int channel, double charge) {
-        
-        // Shape the injected charge
-        this.getChannel(channel).shapeSignal(charge);
-
-        // Sample the resulting shaper signal
-        this.getChannel(channel).sampleShaperSignal();
-    }
-    
-    /**
-     * 
-     */
-    public void loadChannelConstants(){
-    }
-    
-    //------------------------------------------//
-    //               APV25 Channel              //
-    //------------------------------------------//
-    public class APV25Channel {
-        
-        private APV25ShaperSignal shaperSignal;
-        private APV25Pipeline pipeline;
-        
-        private double shapingTime = 50; // [ns]
-        
-        /**
-         * Default Constructor
-         */
-        public APV25Channel(){
-        }
-        
-        /**
-         * Set the shaping time
-         * 
-         * @param shapingTime : APV25 shaping time. The default Tp is set to 50 ns.
-         */
-        public void setShapingTime(int shapingTime) {
-            this.shapingTime = shapingTime;
-        }
-               
-        /**
-         * Shape the injected charge
-         * 
-         * @param charge 
-         */
-        public void shapeSignal(double charge){
-            shaperSignal = new APV25ShaperSignal(charge);
-        }
-        
-        public void sampleShaperSignal(){
-            
-            // Obtain the beam time
-            double beamTime = ClockSingleton.getTime();
-            
-            // Fill the analog pipeline starting with the cell to which the writer pointer is pointing 
-            // to. Signals arriving within the same bucket of length <samplingTime> will be shifted in
-            // time depending on when they arrive.
-            for(int cell = 0; cell < ANALOG_PIPELINE_LENGTH; cell++){
-                
-                // Time at which the shaper signal will be sampled
-                int sampleTime = cell*SAMPLING_TIME - ((int) beamTime)%SAMPLING_TIME;
-                
-                // Sample the shaper signal
-                double sample = shaperSignal.getAmplitudeAtTime(sampleTime, shapingTime);
-                
-                // Add the value to the pipeline
-                pipeline.addToCell(cell, sample);
-            }
-        }
-    }
-    
-    //-------------------------------------//
-    //       APV25 Analog Pipeline         //
-    //-------------------------------------//
-    public class APV25Pipeline extends RingBuffer {
-
-        // TODO: Possibly store the pipeline in the event
-        
-        // Note: ptr gives the position of the trigger pointer
-        
-        private int triggerLatency = (int) Math.floor(200 /* ns */ / SAMPLING_TIME);
-        private int writerPointer = 0;
-        
-        /**
-         * Constructor
-         */
-        public APV25Pipeline(){
-            
-            // Initialize the pipeline to the APV25 pipeline length
-            super(ANALOG_PIPELINE_LENGTH);
-            
-            // Initialize the position of the trigger pointer to a random position
-            this.ptr = (int) (Math.random()*(ANALOG_PIPELINE_LENGTH + 1));
-            
-            // Set the position of the writer pointer
-            writerPointer = (ptr + triggerLatency)%ANALOG_PIPELINE_LENGTH;
-        }
-        
-        /**
-         * 
-         */
-        public void setLatency(int triggerLatency /*ns*/){
-            triggerLatency = (int) Math.floor(triggerLatency/SAMPLING_TIME);
-        }
-        
-        /**
-         * 
-         */
-        @Override
-        public void addToCell(int position, double element){
-            if((writerPointer + position)%ANALOG_PIPELINE_LENGTH == this.ptr) return;
-            super.addToCell(position, element);
-        }
-        
-        /**
-         * 
-         */
-        public double readout(){
-            double triggerPointerValue = this.currentValue();
-            array[ptr] = 0;
-            return triggerPointerValue;
-        }
-        
-        /**
-         * 
-         */
-        @Override
-        public String toString(){
-            String analogPipeline = "[ ";
-            for(int element = 0; element < ANALOG_PIPELINE_LENGTH; element++){
-                if(element == ptr) analogPipeline += " TP ===>";
-                else if(element == writerPointer) analogPipeline += " WP ===>";
-                analogPipeline += (array[element] + ", ");
-            }
-            analogPipeline += "] ";
-            return analogPipeline;
-        }
-    }
-
-    //-----------------------------------//
-    //        APV25 Shaper Signal        //
-    //-----------------------------------//
-    public class APV25ShaperSignal {
-
-        // Shaper signal maximum amplitude
-        private double maxAmp = 0;
-
-        /**
-         * Constructor
-         * 
-         * @param charge: Charge injected into a channel
-         */
-        APV25ShaperSignal(double charge) {
-            // Find the maximum amplitude of the shaper signal
-            maxAmp = (charge/MIP)*FRONT_END_GAIN;  // mV
-        }
-
-        /**
-         * Get the amplitude at a time t
-         * 
-         * @param time: time at which the shaper signal is to be sampled
-         */
-        public double getAmplitudeAtTime(double time, double shapingTime) {
-            return maxAmp * (Math.max(0, time) / shapingTime) * Math.exp(1 - (time / shapingTime));
-        }
-
-    }
-    
-
-}
\ No newline at end of file
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