Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
DataProcessingModule.java | +179 | added 1.1 | |
RearTransitionModule.java | +12 | -4 | 1.1 -> 1.2 |
+191 | -4 |
SVT DAQ Simulation ...
diff -N DataProcessingModule.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ DataProcessingModule.java 13 Aug 2012 23:08:12 -0000 1.1 @@ -0,0 +1,179 @@
+package org.lcsim.hps.recon.tracking; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.base.BaseRawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.hps.recon.tracking.apv25.Apv25DigitalData; +import org.lcsim.util.Driver; + +/** + * + * @author Omar Moreno <[log in to unmask]> + * @version $Id: DataProcessingModule.java,v 1.1 2012/08/13 23:08:12 omoreno Exp $ + */ +public class DataProcessingModule extends Driver { + + // A map relating a sensor to all sample blocks collected from that sensor and + // the corresponding channel + Map<SiSensor, Map<Integer, List<Double>>> sensorToSamplesMap + = new HashMap<SiSensor, Map<Integer, List<Double>>>(); + Map<SiSensor, SvtDataBlocks> sensorToDataBlocks = new HashMap<SiSensor, SvtDataBlocks>(); + + // Collection Names + String apv25DigitalDataCollectionName = "AVP25DigitalData"; + String rawTrackerHitsCollectionName = "SVTRawTrackerHits"; + + int nSamples = 0; + int nSamplesAboveTreshold = 3; // Number of samples above noise threshold + int noiseThreshold = 3; // Units of RMS noise + + /** + * Default Ctor + */ + public DataProcessingModule(){}; + + /** + * + */ + public void setNumberOfSamplesAboveTreshold(int nSamplesAboveThreshold){ + this.nSamplesAboveTreshold = nSamplesAboveThreshold; + } + + /** + * + */ + public void setNoiseThreshold(int noiseThreshold){ + this.noiseThreshold = noiseThreshold; + } + + /** + * + */ + @Override + public void detectorChanged(Detector detector){ + + for(SiSensor sensor : SvtUtils.getInstance().getSensors()){ + sensorToSamplesMap.put(sensor, new HashMap<Integer, List<Double>>()); + sensorToDataBlocks.put(sensor, new SvtDataBlocks()); + } + } + + private List<RawTrackerHit> findRawHits(){ + + List<RawTrackerHit> rawHits = new ArrayList<RawTrackerHit>(); + + // Loop through all blocked data + for(Map.Entry<SiSensor, SvtDataBlocks> sensor : sensorToDataBlocks.entrySet()){ + + SvtDataBlocks blocks = sensor.getValue(); + + for(int channel = 0; channel < 640; channel++){ + short[] samples = blocks.getSamples(channel); + + if(!this.samplesAboveThreshold(sensor.getKey(), channel, samples)) continue; + + // Create a RawTrackerHit + int time = 0; + long cellID = sensor.getKey().makeStripId(channel, 1).getValue(); + rawHits.add(new BaseRawTrackerHit(time, cellID, samples, null, sensor.getKey())); + } + } + + return rawHits; + } + + /** + * + */ + @Override + protected void process(EventHeader event){ + + // If the event does not contain any digital data, skip the event + if(!event.hasCollection(Apv25DigitalData.class, apv25DigitalDataCollectionName)) return; + + // Get the digital data from the event + List<Apv25DigitalData> digitalData = event.get(Apv25DigitalData.class, apv25DigitalDataCollectionName); + + // Block the data together + for(Apv25DigitalData digitalDatum : digitalData){ + + SiSensor sensor = digitalDatum.getSensor(); + int apvN = digitalDatum.getApv(); + + double[] apv25DigitalOutput = new double[140]; + System.arraycopy(digitalDatum.getApv25DigitalOutput(), 0, apv25DigitalOutput, 0, apv25DigitalOutput.length); + + for(int channel = 0; channel < apv25DigitalOutput.length; channel++){ + + // Calculate the physical number + int physicalChannel = 639 - (apvN*128 + 127 - channel); + + sensorToDataBlocks.get(sensor).addSample(physicalChannel, nSamples, (short) apv25DigitalOutput[channel]); + } + } + nSamples++; + + + // If the expected number of samples has been collected, process the data + if(nSamples == 6){ + + // Add RawTrackerHits to the event + event.put(rawTrackerHitsCollectionName, this.findRawHits(), RawTrackerHit.class, 0); + } + } + + public class SvtDataBlocks { + + List<short[]> samples = new ArrayList<short[]>(); + + /** + * Default Ctor + */ + public SvtDataBlocks(){ + } + + /** + * + */ + public void addSample(int physicalChannel, int sampleN, short value){ + if(samples.get(physicalChannel) == null) samples.add(physicalChannel, new short[6]); + samples.get(physicalChannel)[sampleN] = value; + } + + /** + * + */ + public short[] getSamples(int physicalChannel){ + return samples.get(physicalChannel); + } + + } + + /** + * + */ + private boolean samplesAboveThreshold(SiSensor sensor, int channel, short[] samples){ + // Number of samples above threshold + int nSamplesAboveThreshold = 0; + + // Get the pedestal and noise for this channel + double pedestal = HPSSVTCalibrationConstants.getPedestal(sensor, channel); + double noise = HPSSVTCalibrationConstants.getNoise(sensor, channel); + double threshold = pedestal + noise*this.noiseThreshold; + + for(short sample : samples){ + if(sample > threshold) nSamplesAboveThreshold++; + } + + if(nSamplesAboveThreshold == this.nSamplesAboveTreshold) return true; + return false; + } + +}
diff -u -r1.1 -r1.2 --- RearTransitionModule.java 7 Jul 2012 00:35:49 -0000 1.1 +++ RearTransitionModule.java 13 Aug 2012 23:08:12 -0000 1.2 @@ -1,14 +1,23 @@
package org.lcsim.hps.recon.tracking;
+//--- java ---//
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
+//--- 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.util.Driver;
+/** + * + * @author Omar Moreno <[log in to unmask]> + * @version $Id: RearTransitionModule.java,v 1.2 2012/08/13 23:08:12 omoreno Exp $ + */
public class RearTransitionModule extends Driver { String apv25AnalogDataCollectionName = "APV25AnalogData";
@@ -84,7 +93,6 @@
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
@@ -99,7 +107,7 @@
} // Add the digital data to the list
- digitalData.add(new Apv25DigitalData(apv25Output));
+ digitalData.add(new Apv25DigitalData(analogDatum.getSensor(), analogDatum.getApv(), apv25Output));
} event.put(apv25DigitalDataCollectionName, digitalData, Apv25DigitalData.class, 0);
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