Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
DataProcessingModule.java | +99 | -73 | 1.2 -> 1.3 |
Added tail cut; use proper threshold
diff -u -r1.2 -r1.3 --- DataProcessingModule.java 17 Aug 2012 01:15:34 -0000 1.2 +++ DataProcessingModule.java 28 Aug 2012 07:12:33 -0000 1.3 @@ -16,7 +16,7 @@
/** * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: DataProcessingModule.java,v 1.2 2012/08/17 01:15:34 omoreno Exp $
+ * @version $Id: DataProcessingModule.java,v 1.3 2012/08/28 07:12:33 omoreno Exp $
*/ public class DataProcessingModule extends Driver {
@@ -25,127 +25,143 @@
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
-
+ + boolean enableTailCut = true; + boolean enableThresholdCut = true; +
/** * Default Ctor */ public DataProcessingModule(){};
-
+
/** * */ public void setNumberOfSamplesAboveTreshold(int nSamplesAboveThreshold){ this.nSamplesAboveTreshold = nSamplesAboveThreshold; }
-
+
/** * */ public void setNoiseThreshold(int noiseThreshold){ this.noiseThreshold = noiseThreshold; }
-
+ + /** + * + */ + public void setEnableTailCut(boolean enableTailCut){ + this.enableTailCut = enableTailCut; + } + + /** + * + */ + public void setEnableThresholdCut(boolean enableThresholdCut){ + this.enableThresholdCut = enableThresholdCut; + } +
/** * */ @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());
+ 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;
-
+ + + if(enableTailCut && !this.tailCut(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())); } }
-
+
System.out.println(this.getClass().getSimpleName() + ": Number of RawTrackerHits created: " + rawHits.size()); 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[128]; - System.arraycopy(digitalDatum.getSamples(), 0, apv25DigitalOutput, 0, apv25DigitalOutput.length); - - for(int channel = 0; channel < apv25DigitalOutput.length; channel++){ - - // Calculate the physical number - int physicalChannel = 639 - (apvN*128 + 127 - channel); - - // if(apv25DigitalOutput[channel] > 3276) - // System.out.println(this.getClass().getSimpleName() + ": Channel " + channel + " Sample " + apv25DigitalOutput[channel]); - - sensorToDataBlocks.get(sensor).addSample(physicalChannel, nSamples, (short) apv25DigitalOutput[channel]);
+ 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[128]; + System.arraycopy(digitalDatum.getSamples(), 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); + nSamples = 0;
} }
- 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); - nSamples = 0; - } - } -
+
public class SvtDataBlocks {
-
+
Map<Integer, short[]> channelToSamples = new HashMap<Integer, short[]>();
-
+
/** * Default Ctor */ public SvtDataBlocks(){ }
-
+
/** * */
@@ -153,34 +169,44 @@
if(!channelToSamples.containsKey(physicalChannel)) channelToSamples.put(physicalChannel, new short[6]); channelToSamples.get(physicalChannel)[sampleN] = value; }
-
+
/** * */ public short[] getSamples(int physicalChannel){ return channelToSamples.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 = 3276 + pedestal + noise*this.noiseThreshold; -
+ + // Calculate the threshold + double threshold = Math.ceil(pedestal + noise*this.noiseThreshold); +
for(short sample : samples){ if(sample > threshold) nSamplesAboveThreshold++; }
-
+ + // If the prerequiste number of samples are above threshold return true
if(nSamplesAboveThreshold >= this.nSamplesAboveTreshold) return true; return false; }
-
+ + /** + * + */ + private boolean tailCut(short[] sample){ + if(sample[2] > sample[1] || sample[3] > sample[4]) return true; + return false; + }
}
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