hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.7 -r1.8
--- HPSDataProcessingModule.java 29 Mar 2012 03:57:16 -0000 1.7
+++ HPSDataProcessingModule.java 30 Mar 2012 23:57:15 -0000 1.8
@@ -1,7 +1,6 @@
package org.lcsim.hps.recon.tracking;
//--- Java ---//
-import java.lang.Integer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -13,21 +12,18 @@
import java.util.Set;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.IReadout;
-import org.lcsim.detector.identifier.IIdentifier;
import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper;
import org.lcsim.event.EventHeader;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.SimTrackerHit;
import org.lcsim.event.base.BaseRawTrackerHit;
import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
-import org.lcsim.util.aida.AIDA;
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSDataProcessingModule.java,v 1.7 2012/03/29 03:57:16 omoreno Exp $
+ * @version $Id: HPSDataProcessingModule.java,v 1.8 2012/03/30 23:57:15 omoreno Exp $
*/
public class HPSDataProcessingModule extends Driver {
@@ -39,38 +35,38 @@
// Relate a sensor Identifier to the actual sensor
Map<Long, SiSensor> sensorMap = new HashMap<Long, SiSensor>();
- // Set of all sensors
+ // Collection of all sensors
Set<SiSensor> sensorSet = new HashSet<SiSensor>();
- // List of raw tracker hits
- List<RawTrackerHit> rawHits;
- List<RawTrackerHit> rawHitCuts;
+ // Collections of RawTrackerHits
+ List<RawTrackerHit> rawHits; // No cuts are applied
+ List<RawTrackerHit> rawHitsNoCuts; // Cuts are applied to samples
- // List of data
+ // Collection of all SVT data
List<HPSSVTData> svtData;
// 1-5 rms noise [ADC Counts] <--- This is going to change
// int[] noiseThreshold = {1657, 1675, 1692, 1709, 1728};
- int numberOfSamples = 0;
- int nSamplesAboveThresh = 0; // Number of samples above noise threshold
- int flags = 0;
- int noise = 0; // RMS noise [ADC Counts]
- int noiseThreshold = 0; // Units of RMS noise
+ int numberOfSamples = 0; // Total number of APV25 samples
+ int nSamplesAboveThresh = 3; // Number of samples above noise threshold
+ int pedestal = 1638; // [ADC counts] For now, all channels have the same pedestal
+ int flags = 0; //
+ int noise = 18; // [ADC Counts] RMS noise
+ int noiseThreshold = 3; // Units of RMS noise
+
+ boolean thresholdCut = false; // Apply threshold cut?
+ boolean tailCut = false; // Apply tail cut?
+ boolean noiseSuppression = false; // Apply noise supression?
double[] apv25DataStream;
List<Double> samples;
String RawTrackerHitsCollectionName = "RawTrackerHits";
- String RawTrackerHitsCutsCollectionName = "RawTrackerHitsCuts";
- //String dataStreamCollectionName = "dataStream";
-
+ String RawTrackerHitsNoCutsCollectionName = "RawTrackerHitsNoCuts";
String svtCollectionName = "SVTData";
- // Histograms
- protected AIDA aida = AIDA.defaultInstance();
-
/**
* Default Constructor
*/
@@ -79,15 +75,11 @@
channelToBlock = new HashMap<Integer, List<Double>>();
sensorToBlocksMap = new HashMap<Long, Map<Integer, List<Double>>>();
rawHits = new ArrayList<RawTrackerHit>();
- rawHitCuts = new ArrayList<RawTrackerHit>();
+ rawHitsNoCuts = new ArrayList<RawTrackerHit>();
svtData = new ArrayList<HPSSVTData>();
}
- public void setSvtCollectionName(String svtCollectionName) {
- this.svtCollectionName = svtCollectionName;
- }
-
/**
*
*/
@@ -113,7 +105,15 @@
}
/**
- *
+ * Set the SVT collection name
+ */
+ public void setSvtCollectionName(String svtCollectionName)
+ {
+ this.svtCollectionName = svtCollectionName;
+ }
+
+ /**
+ * Set the number of samples above threshold a signal must have
*/
public void setSamplesAboveThresh(int nSamplesAboveThresh)
{
@@ -121,7 +121,7 @@
}
/**
- *
+ * Set the noise RMS [ADC Counts]
*/
public void setNoise(int noise)
{
@@ -129,7 +129,7 @@
}
/**
- *
+ * Set the noise threshold in units of RMS noise
*/
public void setNoiseThreshold(int noiseThreshold)
{
@@ -137,8 +137,47 @@
}
/**
+ * Set the pedestal value for all channels
+ */
+ public void setPedestal(int pedestal)
+ {
+ this.pedestal = pedestal;
+ }
+
+ /**
+ * Enable the threshold cut. The threshold cut requires a certain number
+ * of samples per hit to be above a noise threshold.
+ */
+ public void enableThresholdCut()
+ {
+ this.noiseSuppression = true;
+ }
+
+ /**
+ * Enable the tail cut. The tail cut requires sample 1 to be greater than
+ * sample 0 or sample 2 to be greater than sample 1. This eliminates
+ * hits that may arise due to shaper signal tails.
+ */
+ public void enableTailCut()
+ {
+ this.tailCut = true;
+ }
+
+ /**
+ * Enable noise suppression cut. Requires samples 2 or 3 to be above a
+ * threshold noiseThreshold + noise.
+ */
+ public void enableNoiseSuppressionCut()
+ {
+ this.noiseSuppression = true;
+ }
+
+ /**
+ * Buffer a sample that has been readout from a sensor.
*
- *
+ * @param sensorToDigitalMap
+ * A map relating a sensor to the digital samples readout from the
+ * sensor
*/
public void addSample(Map<Long, Map<Integer, double[]>> sensorToDigitalMap)
{
@@ -147,7 +186,6 @@
* Long: Sensor Identifier
* Integer: Chip Number
* double[]: APV25 Data Stream
- *
*/
int channelN = 0;
@@ -183,13 +221,12 @@
}
}
}
-
- // ---> Possibly change ...
numberOfSamples++;
}
/**
- *
+ * Finds hits that satisfied all required cuts and creates both
+ * RawTrackerHits and SVTData
*/
public void findHits()
{
@@ -201,7 +238,7 @@
// Clear the list of raw tracker hits
rawHits.clear();
- rawHitCuts.clear();
+ rawHitsNoCuts.clear();
svtData.clear();
// Loop through all sensors and the corresponding blocks
@@ -214,12 +251,22 @@
adc[index] = block.getValue().get(index).shortValue();
}
- // Moved list creation above cuts because cuts messed up. --JM
+ // Create RawTrackerHits from all hits before applying cuts
+ rawHitsNoCuts.add(makeRawTrackerHit(block.getKey(), sensorMap.get(sensor.getKey()), adc));
+
+ // Check if a block has the appropriate number of blocks above
+ // threshold
+ if(!(samplesAboveThreshold(adc) >= nSamplesAboveThresh) && thresholdCut) continue;
+
+ // Apply the tail cut
+ if(!tailCut(adc) && tailCut) continue;
+
+ // Apply noise suppression cut
+ if(!noiseSuppresionCut(adc) && noiseSuppression) continue;
// If all cuts are satisfied, create a RawTrackerHit
rawHits.add(makeRawTrackerHit(block.getKey(), sensorMap.get(sensor.getKey()), adc));
-
// Get the FPGA address
fpgaAddress = HPSSVTDAQMaps.sensorToDAQPair.get(sensorMap.get(sensor.getKey())).getSecondElement();
@@ -229,43 +276,28 @@
// Find the APV number
apvNumber = (int) Math.floor(block.getKey()/128);
-
// Create an svtData packet
svtData.add(new HPSSVTData(hybridNumber, apvNumber, block.getKey()%128, fpgaAddress, adc ));
-
- // Check if a block has the appropriate number of blocks above
- // threshold
- if(samplesAboveThreshold(adc) >= nSamplesAboveThresh) continue;
-
- // Apply the tail cut
- if(!tailCut(adc)) continue;
-
- // Apply noise suppression cut
- if(!noiseSuppresionCut(adc)) continue;
block.getValue().clear();
}
}
- System.out.println(this.getClass().getSimpleName() + " created " + rawHits.size());
+ System.out.println(this.getClass().getName() + ": Total RawTrackerHits before cuts: " + rawHitsNoCuts.size());
+ System.out.println(this.getClass().getName() + ": Total RawTrackerHits: " + rawHits.size());
+ System.out.println(this.getClass().getName() + ": Total SVTData: " + svtData.size());
}
/**
+ * Creates a rawTrackerHit
*
- */
- public void clearBlocks()
- {
- for(Map.Entry<Long, Map<Integer, List<Double>>> sensor : sensorToBlocksMap.entrySet()){
- for(Map.Entry<Integer, List<Double>> block : sensor.getValue().entrySet()){
-
- block.getValue().clear();
-
- }
- }
- }
-
- /**
- *
+ * @param channelNumber
+ * Si Strip from which the hit originates from
+ * @param sensor
+ * Sensor from which the hit originates from
+ * @param adcValues
+ * Shaper signal samples
+ * @return RawTrackerHit
*/
private RawTrackerHit makeRawTrackerHit( Integer channelNumber, SiSensor sensor, short[] adcValues)
{
@@ -285,8 +317,9 @@
/**
* Finds how many samples are above a given threshold
*
- * @param samples
- * @return
+ * @param adc
+ * Shaper signal samples
+ * @return Number of samples above threshold
*/
private int samplesAboveThreshold(short[] adc)
{
@@ -294,15 +327,17 @@
int nSamplesAboveThreshold = 0;
for(int sample = 0; sample < adc.length; sample++){
- if(adc[sample] >= noiseThreshold*noise) nSamplesAboveThreshold++;
+ if(adc[sample] >= pedestal + noiseThreshold*noise) nSamplesAboveThreshold++;
}
return nSamplesAboveThreshold;
}
/**
+ * Applies tail cut
*
* @param adc
- * @return
+ * Shaper signal samples
+ * @return true if the cut is satisfied, false otherwise
*/
private boolean tailCut(short[] adc)
{
@@ -311,11 +346,15 @@
}
/**
+ * Applies noise suppression cut
*
+ * @param adc
+ * Shaper signal samples
+ * @return true if the cut is satisfied, false otherwise
*/
private boolean noiseSuppresionCut(short[] adc)
{
- if(adc[3] > noiseThreshold*noise || adc[4] > noiseThreshold*noise) return true;
+ if(adc[3] > pedestal + noiseThreshold*noise || adc[4] > pedestal + noiseThreshold*noise) return true;
return false;
}
@@ -326,18 +365,17 @@
public void process(EventHeader event)
{
super.process(event);
-
- List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
// If six samples have been collected process the data
if(numberOfSamples == 6){
// Find hits
findHits();
- event.put(RawTrackerHitsCollectionName, raw_hits, RawTrackerHit.class, flags);
- // Add SVTData to event. This collection will not be persisted by LCSim.
- System.out.println("adding svtCollection " + svtCollectionName + " with " + this.svtData.size() + " samples");
+ // Add RawTrackerHits to the event
+ event.put(RawTrackerHitsCollectionName, rawHits, RawTrackerHit.class, flags);
+
+ // Add SVTData to event
event.put(this.svtCollectionName, this.svtData, HPSSVTData.class, 0);
//