Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
HPSDataProcessingModule.java | +69 | -51 | 1.4 -> 1.5 |
Now creates HPSSVTData packets
diff -u -r1.4 -r1.5 --- HPSDataProcessingModule.java 22 Mar 2012 20:02:42 -0000 1.4 +++ HPSDataProcessingModule.java 23 Mar 2012 03:52:14 -0000 1.5 @@ -27,7 +27,7 @@
/** * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSDataProcessingModule.java,v 1.4 2012/03/22 20:02:42 omoreno Exp $
+ * @version $Id: HPSDataProcessingModule.java,v 1.5 2012/03/23 03:52:14 omoreno Exp $
*/ public class HPSDataProcessingModule extends Driver {
@@ -42,18 +42,29 @@
// Set of all sensors Set<SiSensor> sensorSet = new HashSet<SiSensor>();
+ // List of raw tracker hits + List<RawTrackerHit> rawHits; + List<RawTrackerHit> rawHitCuts; + + // List of data + List<HPSSVTData> svtData; +
// 1-5 rms noise [ADC Counts] <--- This is going to change
- int[] noiseThreshold = {1657, 1675, 1692, 1709, 1728};
+// int[] noiseThreshold = {1657, 1675, 1692, 1709, 1728};
int numberOfSamples = 0;
- int nSamplesAboveThresh = 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
double[] apv25DataStream; List<Double> samples; String RawTrackerHitsCollectionName = "RawTrackerHits";
+ String RawTrackerHitsCutsCollectionName = "RawTrackerHitsCuts"; + String dataStreamCollectionName = "dataStream";
// Histograms protected AIDA aida = AIDA.defaultInstance();
@@ -65,6 +76,10 @@
{ channelToBlock = new HashMap<Integer, List<Double>>(); sensorToBlocksMap = new HashMap<Long, Map<Integer, List<Double>>>();
+ rawHits = new ArrayList<RawTrackerHit>(); + rawHitCuts = new ArrayList<RawTrackerHit>(); + svtData = new ArrayList<HPSSVTData>(); +
} /**
@@ -106,13 +121,29 @@
/** * */
- public void SetSamplesAboveThresh(int nSamplesAboveThresh)
+ public void setSamplesAboveThresh(int nSamplesAboveThresh)
{ this.nSamplesAboveThresh = nSamplesAboveThresh; } /** *
+ */ + public void setNoise(int noise) + { + this.noise = noise; + } + + /** + * + */ + public void setNoiseThreshold(int noiseThreshold) + { + this.noiseThreshold = noiseThreshold; + } + + /** + *
* */ public void addSample(Map<Long, Map<Integer, double[]>> sensorToDigitalMap)
@@ -166,42 +197,44 @@
/** * */
- public List<RawTrackerHit> findHits(int eventN)
+ public void findHits()
{
- short[] adc; - - List<RawTrackerHit> rawHits = new ArrayList<RawTrackerHit>();
+ short[] adc = new short[6];
+ // Clear the list of raw tracker hits + rawHits.clear(); + rawHitCuts.clear(); +
// Loop through all sensors and the corresponding blocks for(Map.Entry<Long, Map<Integer, List<Double>>> sensor : sensorToBlocksMap.entrySet()){ for(Map.Entry<Integer, List<Double>> block : sensor.getValue().entrySet()){ // Convert ADC value to a short
- adc = new short[block.getValue().size()]; - for(int index = 0; index < block.getValue().size(); index++){
+ for(int index = 0; index < adc.length; index++){
adc[index] = block.getValue().get(index).shortValue(); } // Check if a block has the appropriate number of blocks above // threshold
- if(samplesAboveThreshold(block.getValue()) >= nSamplesAboveThresh) continue;
+ if(samplesAboveThreshold(adc) >= nSamplesAboveThresh) continue;
// Apply the tail cut
- if(!(adc[3] > adc[2] || adc[4] > adc[3])) continue;
+ if(!tailCut(adc)) continue;
// Apply noise suppression cut
- if(adc[3] > noiseThreshold[3] || adc[4] > noiseThreshold[3]) continue;
+ if(!noiseSuppresionCut(adc)) continue;
// If all cuts are satisfied, create a RawTrackerHit rawHits.add(makeRawTrackerHit(block.getKey(), sensorMap.get(sensor.getKey()), adc));
+ + // Create an svtData packet + svtData.add(new HPSSVTData(sensorMap.get(sensor.getKey()), block.getKey(), adc));
block.getValue().clear(); } }
- - return rawHits;
} /**
@@ -235,52 +268,43 @@
return rawHit; }
- -
+
/** * Finds how many samples are above a given threshold * * @param samples * @return */
- private int samplesAboveThreshold(List<Double> samples)
+ private int samplesAboveThreshold(short[] adc)
{ // Number of samples above threshold int nSamplesAboveThreshold = 0;
- for(Double sample : samples ){ - - if(sample >= noiseThreshold[2]) nSamplesAboveThreshold++;
+ for(int sample = 0; sample < adc.length; sample++){ + if(adc[sample] >= noiseThreshold*noise) nSamplesAboveThreshold++;
} return nSamplesAboveThreshold; } /** *
+ * @param adc + * @return
*/
- private int[] createDataStream(short[] samples, short channel)
+ private boolean tailCut(short[] adc)
{
- int[] data = new int[4]; - short fpga = 0; // This will be extracted from the sensor number - - - /* - * Sample Data consists of the following: Z[xx:xx] = Zeros, O[xx:xx] = Ones - * Sample[0] = O[0], Z[0], Hybrid[1:0], Z[0], ApvChip[2:0], Z[0], Channel[6:0], FpgaAddress[15:0] - * Sample[1] = Z[1:0], Sample1[13:0]], Z[1:0], Sample0[13:0] - * Sample[2] = Z[1:0], Sample3[13:0]], Z[1:0], Sample2[13:0] - * Sample[3] = Z[1:0], Sample5[13:0]], Z[1:0], Sample4[13:0] - */ - - // Add the channel number - data[0] = ( ~(0xFFFF << 16) & data[0] ) | ( ( fpga & 0x7F ) << 16); - data[0] = ( ~(0x7F << 23) & data[0] ) | ( ( channel & 0x7F ) << 23); -// data[0] = ( ~(0x1 << 24) & data[0] ) | (( 0 & 0x1 ) << 24 ); - - - return data;
+ if(adc[3] > adc[2] || adc[4] > adc[3]) return true; + return false;
}
+ /** + * + */ + private boolean noiseSuppresionCut(short[] adc) + { + if(adc[3] > noiseThreshold*noise || adc[4] > noiseThreshold*noise) return true; + return false; + }
/** *
@@ -294,19 +318,13 @@
// If six samples have been collected process the data if(numberOfSamples == 6){
- - // find which blocks have a hit above threshold - raw_hits.addAll(findHits(event.getEventNumber()));
+ + // Find hits + findHits(); + event.put(RawTrackerHitsCollectionName, raw_hits, RawTrackerHit.class, flags);
// numberOfSamples = 0;
-
}
- - // Store the raw tracker hits in the event - if(raw_hits.size() > 0) - System.out.println(this.getClass().getName() + ": The number of raw hits found: " + raw_hits.size()); - event.put(RawTrackerHitsCollectionName, raw_hits, RawTrackerHit.class, flags); -
} }
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