Author: [log in to unmask]
Date: Wed Sep 30 17:12:31 2015
New Revision: 3744
Log:
add SVT data integrity checks.
Modified:
java/trunk/evio/pom.xml
java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java
java/trunk/evio/src/main/java/org/hps/evio/AugmentedSvtEvioReader.java
java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java
java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java
java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java
java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java
Modified: java/trunk/evio/pom.xml
=============================================================================
--- java/trunk/evio/pom.xml (original)
+++ java/trunk/evio/pom.xml Wed Sep 30 17:12:31 2015
@@ -18,15 +18,15 @@
<dependencies>
<dependency>
<groupId>org.hps</groupId>
- <artifactId>hps-tracking</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hps</groupId>
<artifactId>hps-record-util</artifactId>
</dependency>
<dependency>
<groupId>org.hps</groupId>
<artifactId>hps-run-database</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hps</groupId>
+ <artifactId>hps-tracking</artifactId>
</dependency>
</dependencies>
<build>
Modified: java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java
=============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java (original)
+++ java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java Wed Sep 30 17:12:31 2015
@@ -7,7 +7,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.hps.readout.svt.SvtHeaderDataInfo;
+import org.hps.record.svt.SvtHeaderDataInfo;
+import org.hps.util.BasicLogFormatter;
import org.hps.util.Pair;
import org.jlab.coda.jevio.BaseStructure;
import org.jlab.coda.jevio.DataType;
@@ -40,8 +41,7 @@
// Initialize the logger
- protected static Logger logger = LogUtil.create(AbstractSvtEvioReader.class.getName(),
- new DefaultLogFormatter(), Level.INFO);
+ protected static Logger logger = LogUtil.create(AbstractSvtEvioReader.class.getName(), new BasicLogFormatter(), Level.INFO);
// A Map from DAQ pair (FPGA/Hybrid or FEB ID/FEB Hybrid ID) to the
// corresponding sensor
@@ -233,9 +233,6 @@
// extract header and tail information
SvtHeaderDataInfo headerData = this.extractSvtHeader(dataBank.getHeader().getNumber(), data);
- // Check the integrity of the SVT header data
- this.checkSvtHeaderData(headerData);
-
// Check that the multisample count is consistent
this.checkSvtSampleCount(sampleCount, headerData);
@@ -243,17 +240,36 @@
headers.add(headerData);
- // create array for the apv headers of known length
- int multisampleHeaders[] = new int[sampleCount/4];
+ // Create array for the apv headers of known length
+ //int multisampleHeaderTails[] = new int[sampleCount/4];
+
+ // Store the multisample headers
+ // Note that the length is not known but can't be longer than the multisample count
+ // in other words the data can be only header multisamples for example.
+ int multisampleHeaderData[] = new int[sampleCount];
+ int multisampleHeaderIndex = 0;
+
+ logger.fine("sampleCount " + sampleCount);
// Loop through all of the samples and make hits
for (int samplesN = 0; samplesN < sampleCount; samplesN += 4) {
-
+
int[] samples = new int[4];
System.arraycopy(data, this.getDataHeaderLength() + samplesN, samples, 0, samples.length);
- // Extract multisample header
- this.extractMultisampleTail(samples, samplesN/4, multisampleHeaders);
+ logger.fine("samplesN " + samplesN + " multisampleHeaderCount " + multisampleHeaderIndex);
+ if(SvtEvioUtils.isMultisampleHeader(samples))
+ logger.fine("this is a header multisample for apv " + SvtEvioUtils.getApvFromMultiSample(samples) + " ch " + SvtEvioUtils.getChannelNumber(samples));
+ else
+ logger.fine("this is a data multisample for apv " + SvtEvioUtils.getApvFromMultiSample(samples) + " ch " + SvtEvioUtils.getChannelNumber(samples));
+
+
+ // Extract tail word in multisample header
+ //this.extractMultisampleHeaderTail(samples, samplesN/4, multisampleHeaderTails);
+
+ // Extract data words from multisample header
+ multisampleHeaderIndex += this.extractMultisampleHeaderData(samples, multisampleHeaderIndex, multisampleHeaderData);
+
//if( SvtEvioUtils.isMultisampleHeader(samples) )
// multisampleHeaders[samplesN/4] = SvtEvioUtils.getMultisampleTailWord(samples);
@@ -262,9 +278,13 @@
rawHits.add(this.makeHit(samples));
}
- // add multisample headers to header data object
- this.setMultiSampleHeaders(headerData, multisampleHeaders);
+ logger.fine("got " + multisampleHeaderIndex + " multisampleHeaderIndex for " + sampleCount + " sampleCount");
+
+ // add multisample header tails to header data object
+ this.setMultiSampleHeaders(headerData, multisampleHeaderIndex, multisampleHeaderData);
//headerData.setMultisampleHeaders(multisampleHeaders);
+
+ //this.checkSvtHeaders(headers);
}
}
@@ -275,6 +295,10 @@
// Add the collection of raw hits to the LCSim event
lcsimEvent.put(SVT_HIT_COLLECTION_NAME, rawHits, RawTrackerHit.class, flag, READOUT_NAME);
+
+ // Check that the SVT header data is valid
+ this.checkSvtHeaders(headers);
+
// Add SVT header data to the event
this.addSvtHeadersToEvents(headers, lcsimEvent);
@@ -283,12 +307,12 @@
return true;
}
- protected abstract void setMultiSampleHeaders(SvtHeaderDataInfo headerData, int[] multisampleHeaders);
-
- protected abstract void extractMultisampleTail(int[] multisample, int index, int[] multisampleHeaders);
-
-
-
+
+
+ protected abstract void checkSvtHeaders(List<SvtHeaderDataInfo> headers) throws SvtEvioHeaderException;
+ protected abstract int extractMultisampleHeaderData(int[] samples, int i, int[] multisampleHeaderData);
+ protected abstract void setMultiSampleHeaders(SvtHeaderDataInfo headerData, int max, int[] multisampleHeaders);
+ protected abstract void extractMultisampleHeaderTail(int[] multisample, int index, int[] multisampleHeaders);
protected abstract void checkSvtSampleCount(int sampleCount, SvtHeaderDataInfo headerData) throws SvtEvioHeaderException;
/**
Modified: java/trunk/evio/src/main/java/org/hps/evio/AugmentedSvtEvioReader.java
=============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/AugmentedSvtEvioReader.java (original)
+++ java/trunk/evio/src/main/java/org/hps/evio/AugmentedSvtEvioReader.java Wed Sep 30 17:12:31 2015
@@ -3,9 +3,11 @@
*/
package org.hps.evio;
+import java.util.Arrays;
import java.util.List;
-
-import org.hps.readout.svt.SvtHeaderDataInfo;
+import java.util.logging.Level;
+
+import org.hps.record.svt.SvtHeaderDataInfo;
import org.lcsim.event.EventHeader;
import org.lcsim.lcio.LCIOUtil;
@@ -38,15 +40,22 @@
@Override
protected void checkSvtHeaderData(SvtHeaderDataInfo header) throws SvtEvioHeaderException {
int tail = header.getTail();
+ if(logger.getLevel().intValue() >= Level.FINE.intValue()) {
+ logger.fine("checkSvtHeaderData tail " + tail + "( " + Integer.toHexString(tail) + " )");
+ logger.fine("checkSvtHeaderData errorbit " + Integer.toHexString(SvtEvioUtils.getSvtTailSyncErrorBit(tail)));
+ logger.fine("checkSvtHeaderData OFerrorbit " + Integer.toHexString(SvtEvioUtils.getSvtTailOFErrorBit(tail)));
+ logger.fine("checkSvtHeaderData skipcount " + Integer.toHexString(SvtEvioUtils.getSvtTailMultisampleSkipCount(tail)));
+ }
if( SvtEvioUtils.getSvtTailSyncErrorBit(tail) != 0) {
- throw new SvtEvioHeaderException("This header had a SyncError");
+ throw new SvtEvioHeaderApvBufferAddressException("This SVT header had a SyncError");
}
else if( SvtEvioUtils.getSvtTailOFErrorBit(tail) != 0) {
- throw new SvtEvioHeaderException("This header had a OverFlowError");
+ throw new SvtEvioHeaderOFErrorException("This header had a OverFlowError");
}
else if( SvtEvioUtils.getSvtTailMultisampleSkipCount(tail) != 0) {
- throw new SvtEvioHeaderException("This header had a skipCount " + SvtEvioUtils.getSvtTailMultisampleSkipCount(tail));
- }
+ throw new SvtEvioHeaderSkipCountException("This header had a skipCount " + SvtEvioUtils.getSvtTailMultisampleSkipCount(tail) + " error");
+ }
+ logger.fine("checkSvtHeaderData passed all I guess");
}
@Override
@@ -65,15 +74,156 @@
}
@Override
- protected void setMultiSampleHeaders(SvtHeaderDataInfo headerData, int[] multisampleHeaders) {
- headerData.setMultisampleHeaders(multisampleHeaders);
- }
-
- @Override
- protected void extractMultisampleTail(int[] multisample, int index, int[] multisampleHeaders) {
- if( SvtEvioUtils.isMultisampleHeader(multisample) )
+ protected void setMultiSampleHeaders(SvtHeaderDataInfo headerData, int n, int[] multisampleHeaders) {
+ //copy out the headers that are non-zero
+ int[] vals = new int[n];
+ System.arraycopy(multisampleHeaders, 0, vals, 0, n);
+ //logger.info("setMultiSampleHeaders: adding " + vals.length + " multisample headers");
+ headerData.setMultisampleHeaders(vals);
+ }
+
+ @Override
+ protected void extractMultisampleHeaderTail(int[] multisample, int index, int[] multisampleHeaders) {
+ //logger.fine("extractMultisampleHeaderTail: index " + index);
+ if( SvtEvioUtils.isMultisampleHeader(multisample) && !SvtEvioUtils.isMultisampleTail(multisample))
multisampleHeaders[index] = SvtEvioUtils.getMultisampleTailWord(multisample);
- }
-
+ //else
+ // logger.fine("extractMultisampleHeaderTail: this is a NOT multisample header at index " + index);
+
+ }
+
+ @Override
+ protected int extractMultisampleHeaderData(int[] samples, int index, int[] multisampleHeaderData) {
+ logger.fine("extractMultisampleHeaderData: index " + index);
+ if( SvtEvioUtils.isMultisampleHeader(samples) && !SvtEvioUtils.isMultisampleTail(samples) ) {
+ logger.fine("extractMultisampleHeaderData: this is a multisample header so add the words to index " + index);
+ System.arraycopy(samples, 0, multisampleHeaderData, index, samples.length);
+ return samples.length;
+ } else {
+ logger.fine("extractMultisampleHeaderData: this is a NOT multisample header ");
+ return 0;
+ }
+ }
+
+ @Override
+ protected void checkSvtHeaders(List<SvtHeaderDataInfo> headers) throws SvtEvioHeaderException {
+ logger.fine("check " + headers.size() + " headers ");
+ int[] bufferAddresses = new int[6];
+ int[] firstFrameCounts = new int[6];
+ boolean firstHeader = true;
+ int[] multisampleHeader;
+ int[] bufAddresses;
+ int[] frameCounts;
+ int[] readError;
+ int count;
+ int multisampleHeaderTailerrorBit;
+ for( SvtHeaderDataInfo headerDataInfo : headers ) {
+ logger.fine("checking header: " + headerDataInfo.toString());
+
+
+ // Check the header data
+ this.checkSvtHeaderData(headerDataInfo);
+
+ int nMultisampleHeaders = headerDataInfo.getNumberOfMultisampleHeaders();
+ for(int iMultisampleHeader = 0; iMultisampleHeader < nMultisampleHeaders; iMultisampleHeader++) {
+ logger.fine("iMultisampleHeader " + iMultisampleHeader);
+
+ multisampleHeader = SvtHeaderDataInfo.getMultisampleHeader(iMultisampleHeader, headerDataInfo);
+
+ // get multisample tail error bit and check it
+ multisampleHeaderTailerrorBit = SvtEvioUtils.getErrorBitFromMultisampleHeader(SvtEvioUtils.getMultisampleTailWord(multisampleHeader));
+ logger.fine("multisampleHeaderTailerrorBit " + multisampleHeaderTailerrorBit + " from multisampleHeaderTail " + SvtEvioUtils.getMultisampleTailWord(multisampleHeader) + " ( " + Integer.toHexString( SvtEvioUtils.getMultisampleTailWord(multisampleHeader) ) + " )");
+ if( multisampleHeaderTailerrorBit != 0)
+ throw new SvtEvioHeaderMultisampleErrorBitException("This multisampleheader had the error bit set.");
+
+
+ // get buffer addresses
+ bufAddresses = SvtEvioUtils.getApvBufferAddresses(multisampleHeader);
+
+ // get frame counts
+ frameCounts = SvtEvioUtils.getApvFrameCount(multisampleHeader);
+
+
+ if( bufAddresses.length != 6)
+ throw new SvtEvioHeaderApvBufferAddressException("Invalid number of APV buffer addresses.");
+
+ if( frameCounts.length != 6)
+ throw new SvtEvioHeaderApvFrameCountException("Invalid number of APV frame counts.");
+
+ if(logger.getLevel().intValue() >= Level.FINE.intValue()) {
+ for (int i=0; i<bufAddresses.length; ++i) {
+ logger.fine("buffer address " + i + " " + bufAddresses[i] + " ( " + Integer.toHexString( bufAddresses[i]) + " )");
+ }
+ for (int i=0; i<frameCounts.length; ++i) {
+ logger.fine("frame count " + i + " " + frameCounts[i] + " ( " + Integer.toHexString( frameCounts[i]) + " )");
+ }
+ }
+
+ // Get a reference for comparison
+ if(firstHeader) {
+
+ System.arraycopy(bufAddresses, 0, bufferAddresses, 0, bufAddresses.length);
+
+ System.arraycopy(frameCounts, 0, firstFrameCounts, 0, frameCounts.length);
+
+ firstHeader = false;
+ }
+ else {
+
+ // Check that apv buffer addresses match
+ if( !Arrays.equals(bufferAddresses, bufAddresses)) {
+ for (int i=0; i<bufAddresses.length; ++i) {
+ logger.info("buffer address " + i + " " + bufAddresses[i] + " ( " + Integer.toHexString( bufAddresses[i]) + " )");
+ }
+ for (int i=0; i<bufferAddresses.length; ++i) {
+ logger.info("ref buffer address " + i + " " + bufferAddresses[i] + " ( " + Integer.toHexString( bufferAddresses[i]) + " )");
+ }
+ throw new SvtEvioHeaderApvBufferAddressException("The APV buffer addresses in this event do not match!");
+ }
+
+ // Check that apv frame count match
+ if( !Arrays.equals(firstFrameCounts, frameCounts)) {
+ for (int i=0; i<frameCounts.length; ++i) {
+ logger.info("frame count " + i + " " + frameCounts[i] + " ( " + Integer.toHexString( frameCounts[i]) + " )");
+ }
+ for (int i=0; i<firstFrameCounts.length; ++i) {
+ logger.info("ref frame count " + i + " " + firstFrameCounts[i] + " ( " + Integer.toHexString( firstFrameCounts[i]) + " )");
+ }
+ throw new SvtEvioHeaderApvFrameCountException("The APV frame counts in this event do not match!");
+ }
+ }
+
+ // Check that the APV frame counts are incrementing
+ // remember to take into account the 2-bit rollover (duh!)
+
+ count = -1;
+ for (int i=0; i<frameCounts.length; ++i) {
+ logger.fine("frame count " + i + " " + frameCounts[i] + " ( " + Integer.toHexString( frameCounts[i]) + " )");
+
+ if( frameCounts[i] > 15 )
+ throw new SvtEvioHeaderApvFrameCountException("Frame count " + frameCounts[i] + " is larger than 2-bit number?");
+
+ if( (count < 15 && frameCounts[i] < count) || ( count == 15 && frameCounts[i] != 0 ) ) {
+ //logger.severe("Frame count " + frameCounts[i] + " was not increasing compared to previous " + count + " for APV " + i);
+ throw new SvtEvioHeaderApvFrameCountException("Frame count " + frameCounts[i] + " was not increasing compared to previous " + count + " for index " + i + " ( tailword: " + Integer.toHexString( SvtEvioUtils.getMultisampleTailWord(multisampleHeader) ) + " )");
+ }
+ count = frameCounts[i];
+ }
+
+
+ // check if there was any read errors
+ readError = SvtEvioUtils.getApvReadErrors(multisampleHeader);
+
+ for (int i=0; i<readError.length; ++i) {
+ logger.fine("i " + i + " " + readError[i] + " ( " + Integer.toHexString( readError[i]) + " )");
+ if( readError[i] != 1) // active low
+ throw new SvtEvioHeaderApvReadErrorException("Read error for apv " + i);
+ }
+
+
+ } // multisampleheaders
+ }
+
+ }
}
Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java
=============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java (original)
+++ java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java Wed Sep 30 17:12:31 2015
@@ -145,16 +145,34 @@
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, "Error making ECal hits.", e);
}
-
+
// Make SVT RawTrackerHits.
try {
svtReader.makeHits(evioEvent, lcsimEvent);
+ } catch (final SvtEvioHeaderMultisampleErrorBitException e) {
+ LOGGER.log(Level.SEVERE, "Error reading header information from the SVT. Stop!", e);
+ throw new RuntimeException(e);
+ } catch (final SvtEvioHeaderSkipCountException e) {
+ LOGGER.log(Level.SEVERE, "Error reading header information from the SVT. Stop!", e);
+ throw new RuntimeException(e);
+ } catch (final SvtEvioHeaderOFErrorException e) {
+ LOGGER.log(Level.SEVERE, "Error reading header information from the SVT. Stop!", e);
+ throw new RuntimeException(e);
+ } catch (final SvtEvioHeaderApvBufferAddressException e) {
+ LOGGER.log(Level.SEVERE, "Error reading header information from the SVT. Stop!", e);
+ throw new RuntimeException(e);
+ } catch (final SvtEvioHeaderApvFrameCountException e) {
+ LOGGER.log(Level.SEVERE, "Error reading header information from the SVT. Stop!", e);
+ throw new RuntimeException(e);
+ } catch (final SvtEvioHeaderApvReadErrorException e) {
+ LOGGER.log(Level.SEVERE, "Error reading header information from the SVT. Stop!", e);
+ throw new RuntimeException(e);
} catch (final SvtEvioHeaderException e) {
- LOGGER.log(Level.SEVERE, "Error reading header information from the SVT.", e);
+ LOGGER.log(Level.SEVERE, "General error reading header information from the SVT. Don't stop", e);
} catch (final SvtEvioReaderException e) {
LOGGER.log(Level.SEVERE, "Error making SVT hits.", e);
} catch (final Exception e) {
- LOGGER.log(Level.SEVERE, "Error making SVT hits. Don't think I should be able to get here?", e);
+ LOGGER.log(Level.SEVERE, "General error making SVT hits. I should handle this exception in some way", e);
}
// Write the current EPICS data into this event.
Modified: java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java
=============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java (original)
+++ java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java Wed Sep 30 17:12:31 2015
@@ -2,7 +2,7 @@
import java.util.List;
-import org.hps.readout.svt.SvtHeaderDataInfo;
+import org.hps.record.svt.SvtHeaderDataInfo;
import org.hps.util.Pair;
import org.jlab.coda.jevio.BaseStructure;
import org.jlab.coda.jevio.EvioEvent;
@@ -231,14 +231,27 @@
@Override
protected void setMultiSampleHeaders(SvtHeaderDataInfo headerData,
+ int max, int[] multisampleHeaders) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void extractMultisampleHeaderTail(int[] multisample, int index,
int[] multisampleHeaders) {
// TODO Auto-generated method stub
}
@Override
- protected void extractMultisampleTail(int[] multisample, int index,
- int[] multisampleHeaders) {
+ protected int extractMultisampleHeaderData(int[] samples, int i,
+ int[] multisampleHeaderData) {
+ return 0;
+
+ }
+
+ @Override
+ protected void checkSvtHeaders(List<SvtHeaderDataInfo> headers) throws SvtEvioHeaderException {
// TODO Auto-generated method stub
}
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 Sep 30 17:12:31 2015
@@ -15,6 +15,12 @@
private static final int TOTAL_SAMPLES = 6;
public static final int SAMPLE_MASK = 0xFFFF;
+ private static final int APV_HEADER_DATA_READ_ERROR_MASK = 0x1; //[0:0]
+ private static final int APV_HEADER_BUFFER_ADDRESS_MASK = 0xFF; //[8:1]
+ private static final int APV_HEADER_DATA_FRAME_COUNT_MASK = 0xF; //[12:9]
+ private static final int APV_HEADER_DATA_APV_NR_MASK = 0x3; //[15:13]
+
+
// TODO: Move these to constants class
public static final int APV25_PER_HYBRID = 5;
@@ -287,6 +293,93 @@
throw new RuntimeException("Invalid sample number! Valid range of values for n are from 0 - 5");
}
}
+
+
+ /**
+ * Extract and return the nth SVT APV buffer address.
+ *
+ * @param sampleN : The apv address of interest. Valid values are 0 to 5?
+ * @param data : a multisample header
+ * @throws RuntimeException if the apv address number is out of range
+ * @return address of the nth apv
+ *
+ */
+ public static int getApvBufferAddress(int sampleN, int[] data) {
+
+ switch (sampleN) {
+ case 0:
+ return (data[0] >>> 1) & APV_HEADER_BUFFER_ADDRESS_MASK;
+ case 1:
+ return (data[0] >>> 17) & APV_HEADER_BUFFER_ADDRESS_MASK;
+ case 2:
+ return (data[1] >>> 1) & APV_HEADER_BUFFER_ADDRESS_MASK;
+ case 3:
+ return (data[1] >>> 17) & APV_HEADER_BUFFER_ADDRESS_MASK;
+ case 4:
+ return (data[2] >>> 1) & APV_HEADER_BUFFER_ADDRESS_MASK;
+ case 5:
+ return (data[2] >>> 17) & APV_HEADER_BUFFER_ADDRESS_MASK;
+ default:
+ throw new RuntimeException("Invalid address number! Valid range of values for n are from 0 - 5");
+ }
+ }
+
+ /**
+ * Extract and return the nth SVT APV read error.
+ *
+ * @param sampleN : The apv read error of interest. Valid values are 0 to 5.
+ * @param data : a multisample header
+ * @throws RuntimeException if the apv number is out of range
+ * @return read error of the nth apv
+ *
+ */
+ public static int getApvReadErrors(int sampleN, int[] data) {
+ switch (sampleN) {
+ case 0:
+ return data[0] & APV_HEADER_DATA_READ_ERROR_MASK;
+ case 1:
+ return (data[0] >>> 16) & APV_HEADER_DATA_READ_ERROR_MASK;
+ case 2:
+ return data[1] & APV_HEADER_DATA_READ_ERROR_MASK;
+ case 3:
+ return (data[1] >>> 16) & APV_HEADER_DATA_READ_ERROR_MASK;
+ case 4:
+ return data[2] & APV_HEADER_DATA_READ_ERROR_MASK;
+ case 5:
+ return (data[2] >>> 16) & APV_HEADER_DATA_READ_ERROR_MASK;
+ default:
+ throw new RuntimeException("Invalid address number! Valid range of values for n are from 0 - 5");
+ }
+ }
+
+ /**
+ * Extract and return the nth SVT APV read error.
+ *
+ * @param sampleN : The apv read error of interest. Valid values are 0 to 5.
+ * @param data : a multisample header
+ * @throws RuntimeException if the apv number is out of range
+ * @return read error of the nth apv
+ *
+ */
+ public static int getApvFrameCount(int sampleN, int[] data) {
+ switch (sampleN) {
+ case 0:
+ return (data[0] >>> 9) & APV_HEADER_DATA_FRAME_COUNT_MASK;
+ case 1:
+ return (data[0] >>> 25) & APV_HEADER_DATA_FRAME_COUNT_MASK;
+ case 2:
+ return (data[1] >>> 9) & APV_HEADER_DATA_FRAME_COUNT_MASK;
+ case 3:
+ return (data[1] >>> 25) & APV_HEADER_DATA_FRAME_COUNT_MASK;
+ case 4:
+ return (data[2] >>> 9) & APV_HEADER_DATA_FRAME_COUNT_MASK;
+ case 5:
+ return (data[2] >>> 25) & APV_HEADER_DATA_FRAME_COUNT_MASK;
+ default:
+ throw new RuntimeException("Invalid address number! Valid range of values for n are from 0 - 5");
+ }
+ }
+
/**
* Extract and return all SVT samples as an array
@@ -302,6 +395,52 @@
}
return samples;
}
+
+ /**
+ * Extract and return all SVT APV buffer addresses as an array
+ *
+ * @param multisampleHeader : multisample header
+ * @return An array containing all SVT APV buffer addresses
+ */
+ public static int[] getApvBufferAddresses(int[] multisampleHeader) {
+ int[] samples = new int[TOTAL_SAMPLES];
+ // Get all SVT Samples
+ for (int sampleN = 0; sampleN < TOTAL_SAMPLES; sampleN++) {
+ samples[sampleN] = getApvBufferAddress(sampleN, multisampleHeader);
+ }
+ return samples;
+ }
+
+ /**
+ * Extract and return all SVT APV read errorsas an array
+ *
+ * @param multisampleHeader : multisample header
+ * @return An array containing all SVT APV read errors
+ */
+ public static int[] getApvReadErrors(int[] multisampleHeader) {
+ int[] samples = new int[TOTAL_SAMPLES];
+ // Get all SVT Samples
+ for (int sampleN = 0; sampleN < TOTAL_SAMPLES; sampleN++) {
+ samples[sampleN] = getApvReadErrors(sampleN, multisampleHeader);
+ }
+ return samples;
+ }
+
+ /**
+ * Extract and return all SVT APV read errorsas an array
+ *
+ * @param multisampleHeader : multisample header
+ * @return An array containing all SVT APV read errors
+ */
+ public static int[] getApvFrameCount(int[] multisampleHeader) {
+ int[] samples = new int[TOTAL_SAMPLES];
+ // Get all SVT Samples
+ for (int sampleN = 0; sampleN < TOTAL_SAMPLES; sampleN++) {
+ samples[sampleN] = getApvFrameCount(sampleN, multisampleHeader);
+ }
+ return samples;
+ }
+
/**
* Private constructor to prevent the class from being instantiated.
Modified: java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java
=============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java (original)
+++ java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java Wed Sep 30 17:12:31 2015
@@ -2,7 +2,7 @@
import java.util.List;
-import org.hps.readout.svt.SvtHeaderDataInfo;
+import org.hps.record.svt.SvtHeaderDataInfo;
import org.hps.util.Pair;
import org.jlab.coda.jevio.BaseStructure;
import org.lcsim.detector.tracker.silicon.HpsSiSensor;
@@ -194,14 +194,27 @@
@Override
protected void setMultiSampleHeaders(SvtHeaderDataInfo headerData,
+ int max, int[] multisampleHeaders) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void extractMultisampleHeaderTail(int[] multisample, int index,
int[] multisampleHeaders) {
// TODO Auto-generated method stub
}
@Override
- protected void extractMultisampleTail(int[] multisample, int index,
- int[] multisampleHeaders) {
+ protected int extractMultisampleHeaderData(int[] samples, int i,
+ int[] multisampleHeaderData) {
+ return 0;
+
+ }
+
+ @Override
+ protected void checkSvtHeaders(List<SvtHeaderDataInfo> headers) {
// TODO Auto-generated method stub
}
|