Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
SimpleSvtReadout.java+44-1791.12 -> 1.13
clean up unused code

hps-java/src/main/java/org/lcsim/hps/recon/tracking
SimpleSvtReadout.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- SimpleSvtReadout.java	24 Apr 2013 19:07:33 -0000	1.12
+++ SimpleSvtReadout.java	24 Apr 2013 19:19:15 -0000	1.13
@@ -20,7 +20,6 @@
 import org.lcsim.hps.recon.tracking.apv25.Apv25Constants;
 import org.lcsim.hps.util.ClockSingleton;
 import org.lcsim.hps.util.RandomGaussian;
-import org.lcsim.hps.util.RingBuffer;
 import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
 import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeData;
 import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeDataCollection;
@@ -30,22 +29,19 @@
 
 /**
  *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SimpleSvtReadout.java,v 1.12 2013/04/24 19:07:33 meeg Exp $
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: SimpleSvtReadout.java,v 1.13 2013/04/24 19:19:15 meeg Exp $
  */
 public class SimpleSvtReadout extends TriggerableDriver {
 
     private SimTrackerHitReadoutDriver readoutDriver = new SimTrackerHitReadoutDriver();
     private SiSensorSim siSimulation = new CDFSiSensorSim();
     private String outputCollection = "SVTRawTrackerHits";
-    private Map<SiSensor, APV25Pipeline[]> pipelineMap = new HashMap<>();
     private Map<SiSensor, PriorityQueue<StripHit>[]> hitMap = new HashMap<>();
     //readout period time offset in ns
     private double readoutOffset = 0.0;
     private double readoutLatencyT = 240.0;
-    private int readoutLatency = 11;
     private String readout = "TrackerHits";
-    private int readoutCycle = 0;
     private double timeOffset = 30.0;
     private boolean noPileup = false;
     private boolean addNoise = true;
@@ -55,17 +51,12 @@
     private double noiseThreshold = 2.0;
     private boolean enablePileupCut = true;
     private boolean dropBadChannels = true;
-    private boolean oldReadout = false;
 
     public SimpleSvtReadout() {
         add(readoutDriver);
         triggerDelay = 100.0;
     }
 
-    public void setOldReadout(boolean oldReadout) {
-        this.oldReadout = oldReadout;
-    }
-
     public void setAddNoise(boolean addNoise) {
         this.addNoise = addNoise;
     }
@@ -104,21 +95,10 @@
         String[] readouts = {readout};
         readoutDriver.setCollections(readouts);
 
-        pipelineMap.clear();
-
         if (!noPileup) {
             for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-                APV25Pipeline[] pipelines = new APV25Pipeline[HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR];
-                pipelineMap.put(sensor, pipelines);
-
                 PriorityQueue<StripHit>[] hitQueues = new PriorityQueue[HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR];
                 hitMap.put(sensor, hitQueues);
-
-                if (addNoise) {
-                    for (int channel = 0; channel < HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR; channel++) {
-                        pipelines[channel] = new APV25Pipeline(readoutLatency);
-                    }
-                }
             }
         }
     }
@@ -133,40 +113,9 @@
         List<StripHit> stripHits = doSiSimulation();
 
         if (!noPileup) {
-            //if at the end of a readout cycle, step all the pipelines
-            while (ClockSingleton.getTime() - readoutTime() + ClockSingleton.getDt() >= Apv25Constants.SAMPLING_INTERVAL) {
-                for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-                    APV25Pipeline[] pipelines = pipelineMap.get(sensor);
-                    for (int i = 0; i < pipelines.length; i++) {
-                        if (pipelines[i] != null) {
-                            pipelines[i].step();
-                        }
-                    }
-
-                    PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor);
-                    for (int i = 0; i < hitQueues.length; i++) {
-                        if (hitQueues[i] != null) {
-                            while (!hitQueues[i].isEmpty() && hitQueues[i].peek().time < ClockSingleton.getTime() - 500.0) { //TODO: more intelligent time cut
-//                                System.out.format("Time %f: Dump stale hit with time %f\n",ClockSingleton.getTime(),hitQueues[i].peek().time);
-                                hitQueues[i].poll();
-                            }
-                        }
-                    }
-                }
-                readoutCycle++;
-            }
-
             for (StripHit stripHit : stripHits) {
                 SiSensor sensor = stripHit.sensor;
                 int channel = stripHit.channel;
-                double amplitude = stripHit.amplitude;
-                APV25Pipeline[] pipelines = pipelineMap.get(sensor);
-                if (pipelines[channel] == null) {
-                    pipelines[channel] = new APV25Pipeline(readoutLatency);
-                }
-                for (int i = 0; i < 20; i++) {
-                    pipelines[channel].addToCell(i, amplitude * pulseAmplitude((i + 1) * Apv25Constants.SAMPLING_INTERVAL + readoutTime() - ClockSingleton.getTime(), HPSSVTCalibrationConstants.getTShaping(sensor, channel)));
-                }
 
                 PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor);
                 if (hitQueues[channel] == null) {
@@ -187,19 +136,19 @@
                 double amplitude = stripHit.amplitude;
                 short[] samples = new short[6];
 
+                double[] signal = new double[6];
+                for (int i = 0; i < 6; i++) {
+                    signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel);
+                }
                 if (addNoise) {
-                    double[] noise = makeNoise(sensor, channel);
-                    for (int i = 0; i < 6; i++) {
-                        double time = i * Apv25Constants.SAMPLING_INTERVAL - timeOffset;
-                        samples[i] = (short) Math.round(amplitude * pulseAmplitude(time, HPSSVTCalibrationConstants.getTShaping(sensor, channel)) + HPSSVTCalibrationConstants.getPedestal(sensor, channel) + noise[i]);
-                    }
-                } else {
-                    for (int i = 0; i < 6; i++) {
-                        double time = i * Apv25Constants.SAMPLING_INTERVAL - timeOffset;
-                        samples[i] = (short) Math.round(amplitude * pulseAmplitude(time, HPSSVTCalibrationConstants.getTShaping(sensor, channel)) + HPSSVTCalibrationConstants.getPedestal(sensor, channel));
-                    }
+                    addNoise(sensor, channel, signal);
                 }
 
+                for (int i = 0; i < 6; i++) {
+                    double time = i * Apv25Constants.SAMPLING_INTERVAL - timeOffset;
+                    signal[i] += amplitude * pulseAmplitude(time, HPSSVTCalibrationConstants.getTShaping(sensor, channel)) + HPSSVTCalibrationConstants.getPedestal(sensor, channel);
+                    samples[i] = (short) Math.round(signal[i]);
+                }
 
                 long cell_id = SvtUtils.makeCellID(sensor, channel);
 
@@ -249,13 +198,11 @@
 
                         // compute hit time as the unweighted average of SimTrackerHit times; this is dumb but okay since there's generally only one SimTrackerHit
                         double time = 0.0;
-                        if (!oldReadout) {
-                            for (SimTrackerHit hit : simHits) {
-                                time += hit.getTime();
-                            }
-                            time /= simHits.size();
-                            time += ClockSingleton.getTime();
+                        for (SimTrackerHit hit : simHits) {
+                            time += hit.getTime();
                         }
+                        time /= simHits.size();
+                        time += ClockSingleton.getTime();
 
                         // Get the charge in units of electrons
                         double charge = electrodeData.getCharge();
@@ -274,15 +221,6 @@
         return stripHits;
     }
 
-    private double[] makeNoise(SiSensor sensor, int channel) {
-        double[] samples = new double[6];
-        double noise = HPSSVTCalibrationConstants.getNoise(sensor, channel);
-        for (int i = 0; i < 6; i++) {
-            samples[i] = RandomGaussian.getGaussian(0, noise);
-        }
-        return samples;
-    }
-
     private void addNoise(SiSensor sensor, int channel, double[] signal) {
         double noise = HPSSVTCalibrationConstants.getNoise(sensor, channel);
         for (int i = 0; i < 6; i++) {
@@ -345,68 +283,42 @@
             double firstSample = Math.floor((ClockSingleton.getTime() - readoutLatencyT - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
 
             for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-                if (oldReadout) {
-                    APV25Pipeline[] pipelines = pipelineMap.get(sensor);
-                    for (int channel = 0; channel < pipelines.length; channel++) {
-                        if (pipelines[channel] != null) {
-                            short[] samples = new short[6];
-                            if (addNoise) {
-                                double[] noise = makeNoise(sensor, channel);
-                                for (int i = 0; i < 6; i++) {
-                                    samples[i] = (short) Math.round(pipelines[channel].getValue(i) + HPSSVTCalibrationConstants.getPedestal(sensor, channel) + noise[i]);
-                                }
-                            } else {
-                                for (int i = 0; i < 6; i++) {
-                                    samples[i] = (short) Math.round(pipelines[channel].getValue(i) + HPSSVTCalibrationConstants.getPedestal(sensor, channel));
-                                }
-                            }
-                            long cell_id = SvtUtils.makeCellID(sensor, channel);
-
-                            RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
-//                        System.out.println("Making RTH");
-                            if (readoutCuts(hit)) {
-                                hits.add(hit);
-                            }
-                        }
+                PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor);
+                for (int channel = 0; channel < hitQueues.length; channel++) {
+                    if (!addNoise && (hitQueues[channel] == null || hitQueues[channel].isEmpty())) {
+                        continue;
+                    }
+                    short[] samples = new short[6];
+                    double[] signal = new double[6];
+                    for (int i = 0; i < 6; i++) {
+                        signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel);
+                    }
+                    if (addNoise) {
+                        addNoise(sensor, channel, signal);
                     }
-                } else {
-                    PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor);
-                    for (int channel = 0; channel < hitQueues.length; channel++) {
-                        if (!addNoise && (hitQueues[channel] == null || hitQueues[channel].isEmpty())) {
-                            continue;
-                        }
-                        short[] samples = new short[6];
-                        double[] signal = new double[6];
-                        for (int i = 0; i < 6; i++) {
-                            signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel);
-                        }
-                        if (addNoise) {
-                            addNoise(sensor, channel, signal);
-                        }
 
-                        if (hitQueues[channel] != null) {
-                            for (StripHit hit : hitQueues[channel]) {
-                                for (int i = 0; i < 6; i++) {
-                                    double sampleTime = firstSample + i * Apv25Constants.SAMPLING_INTERVAL;
-                                    signal[i] += hit.amplitude * pulseAmplitude(sampleTime - hit.time, HPSSVTCalibrationConstants.getTShaping(sensor, channel));
+                    if (hitQueues[channel] != null) {
+                        for (StripHit hit : hitQueues[channel]) {
+                            for (int i = 0; i < 6; i++) {
+                                double sampleTime = firstSample + i * Apv25Constants.SAMPLING_INTERVAL;
+                                signal[i] += hit.amplitude * pulseAmplitude(sampleTime - hit.time, HPSSVTCalibrationConstants.getTShaping(sensor, channel));
 //                                    System.out.format("new value of signal[%d] = %f\n", i, signal[i]);
-                                }
                             }
                         }
+                    }
 
-                        for (int i = 0; i < 6; i++) {
-                            samples[i] = (short) Math.round(signal[i]);
-                        }
+                    for (int i = 0; i < 6; i++) {
+                        samples[i] = (short) Math.round(signal[i]);
+                    }
 //                        if (hitQueues[channel] != null && !hitQueues[channel].isEmpty()) {
 //                            for (int i = 0; i < 6; i++) {
 //                                System.out.format("samples[%d] = %d\n", i, samples[i]);
 //                            }
 //                        }
-                        long cell_id = SvtUtils.makeCellID(sensor, channel);
-                        RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
-                        if (readoutCuts(hit)) {
-                            hits.add(hit);
-                        }
+                    long cell_id = SvtUtils.makeCellID(sensor, channel);
+                    RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
+                    if (readoutCuts(hit)) {
+                        hits.add(hit);
                     }
                 }
             }
@@ -421,53 +333,10 @@
     public double readoutDeltaT() {
         double triggerTime = ClockSingleton.getTime() + triggerDelay;
         int cycle = (int) Math.floor((triggerTime - readoutOffset + ClockSingleton.getDt()) / Apv25Constants.SAMPLING_INTERVAL);
-        double readoutTime = (cycle - readoutLatency + 1) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset - ClockSingleton.getDt();
-        return readoutTime;
-    }
+        // Calculate time of first sample
+        double firstSample = Math.floor((triggerTime - readoutLatencyT - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
 
-    private class APV25Pipeline extends RingBuffer {
-
-        private int _trigger_latency = (int) Math.floor(270 / Apv25Constants.SAMPLING_INTERVAL); // 11 clocks
-
-        public APV25Pipeline(int latency) {
-            super(Apv25Constants.ANALOG_PIPELINE_LENGTH);
-            _trigger_latency = latency;
-        }
-
-        /**
-         * Set the trigger latency
-         *
-         * @param latency : trigger latency in [ns]
-         */
-        public void setTriggerLatency(int latency) {
-            _trigger_latency = (int) Math.floor(latency / Apv25Constants.SAMPLING_INTERVAL);
-        }
-
-        @Override
-        public void addToCell(int position, double element) {
-            if (position + _trigger_latency > size) {
-                return;
-            }
-            super.addToCell(position + _trigger_latency, element);
-        }
-
-        /**
-         *
-         */
-        @Override
-        public String toString() {
-            String analogPipeline = "[ ";
-            for (int element = 0; element < Apv25Constants.ANALOG_PIPELINE_LENGTH; element++) {
-                if (element == ptr) {
-                    analogPipeline += " TP ===>";
-                } else if (element == ptr + _trigger_latency) {
-                    analogPipeline += " WP ===>";
-                }
-                analogPipeline += (array[element] + ", ");
-            }
-            analogPipeline += "] ";
-            return analogPipeline;
-        }
+        return firstSample;
     }
 
     private class StripHit implements Comparable {
@@ -505,8 +374,4 @@
         }
         return (time / tp) * Math.exp(1.0 - time / tp);
     }
-
-    private double readoutTime() {
-        return readoutCycle * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
-    }
 }
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