Author: [log in to unmask]
Date: Wed Apr 15 14:21:43 2015
New Revision: 2714
Log:
Add static method to extract the error bit from a set of APV samples.
Modified:
java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java
Modified: java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java
=============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java (original)
+++ java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java Wed Apr 15 14:21:43 2015
@@ -1,26 +1,26 @@
package org.hps.evio;
/**
- * A set of static utility methods used to decode SVT data.
+ * A set of static utility methods used to decode SVT data.
*
- * @author Omar Moreno <[log in to unmask]>
- * @date November 20, 2014
+ * @author Omar Moreno <[log in to unmask]>
+ * @date November 20, 2014
*/
public class SvtEvioUtils {
- //-----------------//
- //--- Constants ---//
- //-----------------//
-
- private static final int TOTAL_SAMPLES = 6;
+ //-----------------//
+ //--- Constants ---//
+ //-----------------//
+
+ private static final int TOTAL_SAMPLES = 6;
public static final int SAMPLE_MASK = 0xFFFF;
// TODO: Move these to constants class
public static final int APV25_PER_HYBRID = 5;
public static final int CHANNELS_PER_APV25 = 128;
-
- //--- Test Run ---//
- private static final int TEST_RUN_SAMPLE_HEADER_INDEX = 0;
+
+ //--- Test Run ---//
+ private static final int TEST_RUN_SAMPLE_HEADER_INDEX = 0;
public static final int FPGA_MASK = 0xFFFF;
public static final int HYBRID_MASK = 0x3;
public static final int TEST_RUN_CHANNEL_MASK = 0x7F;
@@ -33,60 +33,61 @@
private static final int ENG_RUN_CHANNEL_MASK = 0x7F;
private static final int ENG_RUN_APV_HEADER_MASK = 0x1;
private static final int ENG_RUN_APV_TAIL_MASK = 0x1;
-
- /**
- * Extract and return the FPGA ID associated with the samples.
- * Note: This method should only be used when looking at test run data.
- *
- * @param data - sample block of data
- * @return An FPGA ID in the range 0-7
- */
- public static int getFpgaID(int[] data) {
- return data[TEST_RUN_SAMPLE_HEADER_INDEX] & FPGA_MASK;
- }
-
- /**
- * Extract and return the hybrid ID associated with the samples
- * Note: This method should only be used when looking at test run data.
- *
- * @param data : sample block of data
- * @return A hybrid number in the range 0-2
+ private static final int ENG_RUN_ERROR_BIT_MASK = 0x1;
+
+ /**
+ * Extract and return the FPGA ID associated with the samples.
+ * Note: This method should only be used when looking at test run data.
+ *
+ * @param data - sample block of data
+ * @return An FPGA ID in the range 0-7
+ */
+ public static int getFpgaID(int[] data) {
+ return data[TEST_RUN_SAMPLE_HEADER_INDEX] & FPGA_MASK;
+ }
+
+ /**
+ * Extract and return the hybrid ID associated with the samples
+ * Note: This method should only be used when looking at test run data.
+ *
+ * @param data : sample block of data
+ * @return A hybrid number in the range 0-2
*/
public static int getHybridID(int[] data) {
return (data[TEST_RUN_SAMPLE_HEADER_INDEX] >>> 28) & HYBRID_MASK;
}
-
- /**
- * Extract and return the channel number associated with the samples
- * Note: This method should only be used when looking at test run data.
- *
- * @param data : sample block of data
- * @return A channel number in the range 0-127
+
+ /**
+ * Extract and return the channel number associated with the samples
+ * Note: This method should only be used when looking at test run data.
+ *
+ * @param data : sample block of data
+ * @return A channel number in the range 0-127
*/
public static int getTestRunChannelNumber(int[] data) {
return (data[TEST_RUN_SAMPLE_HEADER_INDEX] >>> 16) & TEST_RUN_CHANNEL_MASK;
}
/**
- * Extract and return the front end board (FEB) ID associated with the
- * samples
- *
- * @param data : sample block of data
- * @return A FEB ID in the range 0-10
+ * Extract and return the front end board (FEB) ID associated with the
+ * samples
+ *
+ * @param data : sample block of data
+ * @return A FEB ID in the range 0-10
*/
public static int getFebID(int[] data) {
- return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 8) & FEB_MASK;
- }
-
- /**
- * Extract and return the front end board (FEB) hybrid ID associated with
- * the samples
- *
- * @param data : sample block of data
- * @return A FEB hybrid ID in the range 0-3
+ return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 8) & FEB_MASK;
+ }
+
+ /**
+ * Extract and return the front end board (FEB) hybrid ID associated with
+ * the samples
+ *
+ * @param data : sample block of data
+ * @return A FEB hybrid ID in the range 0-3
*/
public static int getFebHybridID(int[] data) {
- return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 26) & FEB_HYBRID_MASK;
+ return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 26) & FEB_HYBRID_MASK;
}
/**
@@ -100,10 +101,10 @@
}
/**
- * Extract and return the channel number associated with the samples
- *
- * @param data : sample block of data
- * @return A channel number in the range 0-127
+ * Extract and return the channel number associated with the samples
+ *
+ * @param data : sample block of data
+ * @return A channel number in the range 0-127
*/
public static int getChannelNumber(int[] data) {
return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 16) & ENG_RUN_CHANNEL_MASK;
@@ -114,7 +115,7 @@
*
* @param data : sample block of data
* @return A channel number in the range 0-639
- * @throws RuntimeException if the physical channel number is out of range
+ * @throws RuntimeException if the physical channel number is out of range
*/
public static int getPhysicalChannelNumber(int[] data) {
@@ -157,14 +158,24 @@
if (((data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 29) & ENG_RUN_APV_TAIL_MASK) == 1) return true;
return false;
}
-
- /**
- * Extract and return the nth SVT sample.
- *
- * @param sampleN : The sample number of interest. Valid values are 0 to 5
- * @param data : sample block of data
- * @throws RuntimeException if the sample number is out of range
- * @return ADC value of the nth sample
+
+ /**
+ * Extract the error bit of the samples.
+ *
+ * @param data : sample block of data
+ * @return value of the error bit. This is non-zero if there is an error.
+ */
+ public static int getErrorBit(int[] data) {
+ return (data[3] >>> 28) & ENG_RUN_ERROR_BIT_MASK;
+ }
+
+ /**
+ * Extract and return the nth SVT sample.
+ *
+ * @param sampleN : The sample number of interest. Valid values are 0 to 5
+ * @param data : sample block of data
+ * @throws RuntimeException if the sample number is out of range
+ * @return ADC value of the nth sample
*
*/
public static int getSample(int sampleN, int[] data) {
@@ -188,10 +199,10 @@
}
/**
- * Extract and return all SVT samples as an array
- *
- * @param data : sample block of data
- * @return An array containing all SVT Shaper signal samples
+ * Extract and return all SVT samples as an array
+ *
+ * @param data : sample block of data
+ * @return An array containing all SVT Shaper signal samples
*/
public static short[] getSamples(int[] data) {
short[] samples = new short[TOTAL_SAMPLES];
@@ -203,7 +214,7 @@
}
/**
- * Private constructor to prevent the class from being instantiated.
+ * Private constructor to prevent the class from being instantiated.
*/
private SvtEvioUtils(){};
}
|