Author: [log in to unmask] Date: Sun Sep 20 17:27:43 2015 New Revision: 3649 Log: add some helper functions. Try to refactor to make things less confusing...not sure I accomplished that. Modified: java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java java/trunk/evio/src/main/java/org/hps/evio/SvtEvioUtils.java 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 Sun Sep 20 17:27:43 2015 @@ -250,7 +250,7 @@ // Extract multisample header if( SvtEvioUtils.isMultisampleHeader(samples) ) - multisampleHeaders[samplesN/4] = SvtEvioUtils.getMultisampleHeaderWord(samples); + multisampleHeaders[samplesN/4] = SvtEvioUtils.getMultisampleTailWord(samples); // If a set of samples is associated with an APV header or tail, skip it if (!this.isValidSampleSet(samples)) continue; 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 Sun Sep 20 17:27:43 2015 @@ -117,8 +117,8 @@ // + " Hybrid ID: " + SvtEvioUtils.getFebHybridID(data)); Pair<Integer, Integer> daqPair - = new Pair<Integer, Integer>(SvtEvioUtils.getFebID(data), - SvtEvioUtils.getFebHybridID(data)); + = new Pair<Integer, Integer>(SvtEvioUtils.getFebIDFromMultisample(data), + SvtEvioUtils.getFebHybridIDFromMultisample(data)); return daqPairToSensor.get(daqPair); } 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 Sun Sep 20 17:27:43 2015 @@ -71,34 +71,68 @@ /** * Extract and return the front end board (FEB) ID associated with the - * samples - * - * @param data : sample block of data + * multisample + * + * @param multisample : a header multisample * @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; - } + public static int getFebIDFromMultisample(int[] multisample) { + return getFebIDFromMultisampleTail(getMultisampleTailWord(multisample)); + } + + /** + * Extract and return the front end board (FEB) ID associated with the + * multisample tail + * + * @param data : a multisample header + * @return A FEB ID in the range 0-10 + */ + public static int getFebIDFromMultisampleTail(int multisampleTail) { + return (multisampleTail >>> 8) & FEB_MASK; + } + /** * Extract and return the front end board (FEB) hybrid ID associated with - * the samples + * the multisample * - * @param data : sample block of data + * @param multisample : a header multisample * @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; - } - - /** - * Extract and return the APV ID associated with the samples. - * - * @param data : sample block of data + public static int getFebHybridIDFromMultisample(int[] multisample) { + return getFebHybridIDFromMultisampleTail(getMultisampleTailWord(multisample)); + } + + /** + * Extract and return the front end board (FEB) hybrid ID associated with + * the multisample tail + * + * @param multisample : a multisample tail + * @return A FEB hybrid ID in the range 0-3 + */ + public static int getFebHybridIDFromMultisampleTail(int multisampleTail) { + return (multisampleTail >>> 26) & FEB_HYBRID_MASK; + } + + + /** + * Extract and return the APV ID associated with the multisample. + * + * @param multisample : a multisample of data * @return An APV ID in the range of 0-4 */ - public static int getApv(int[] data) { - return (data[ENG_RUN_SAMPLE_HEADER_INDEX] >>> 23) & ENG_RUN_APV_MASK; + public static int getApvFromMultiSample(int[] multisample) { + return getApvFromMultisampleTail(getMultisampleTailWord(multisample)); + } + + /** + * Extract and return the APV ID from the multisample tail. + * @param multisampleTail - tail word of a multisample + * @return the apv id in the range of 0-4 + */ + public static int getApvFromMultisampleTail(int multisampleTail) { + return (multisampleTail >>> 23) & ENG_RUN_APV_MASK; + } /** @@ -124,7 +158,7 @@ int channel = SvtEvioUtils.getChannelNumber(data); // Extract the APV ID from the data - int apv = SvtEvioUtils.getApv(data); + int apv = SvtEvioUtils.getApvFromMultiSample(data); // Get the physical channel number int physicalChannel = (APV25_PER_HYBRID - apv - 1) * CHANNELS_PER_APV25 + channel; @@ -149,13 +183,11 @@ } /** - * Get the multisample header word. - * @param multisample - block of data - * @return the header word - */ - public static int getMultisampleHeaderWord(int[] multisample) { - if( !isMultisampleHeader(multisample) ) - throw new RuntimeException("Need ApvHeader multisample in order to extract the header word."); + * Get the multisample tail word from a multisample. + * @param multisample - multisample of data + * @return the tail word + */ + public static int getMultisampleTailWord(int[] multisample) { return multisample[ENG_RUN_SAMPLE_HEADER_INDEX]; } @@ -212,7 +244,9 @@ * @return value of the error bit. This is non-zero if there is an error. */ public static int getMultisampleErrorBit(int[] multisample) { - return (getMultisampleHeaderWord(multisample) >>> 28) & ENG_RUN_ERROR_BIT_MASK; + if( !isMultisampleHeader(multisample) ) + throw new RuntimeException("Need ApvHeader multisample in order to extract the error bit from the tail word."); + return (getMultisampleTailWord(multisample) >>> 28) & ENG_RUN_ERROR_BIT_MASK; } /**