Print

Print


Author: [log in to unmask]
Date: Mon May 11 12:26:13 2015
New Revision: 2947

Log:
Add enums for EVIO event tag values and masks.

Added:
    java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagBitMask.java
    java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagConstant.java

Added: java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagBitMask.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagBitMask.java	(added)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagBitMask.java	Mon May 11 12:26:13 2015
@@ -0,0 +1,88 @@
+package org.hps.record.evio;
+
+import org.jlab.coda.jevio.EvioEvent;
+
+/**
+ * Encapsulates bit mask values for different types of physics events as described at <a
+ * href="https://confluence.slac.stanford.edu/display/hpsg/EVIO+Data+Format#EVIODataFormat-EVIOEventtypes-2015DataSet"
+ * >EVIO Event types</a>.
+ *
+ * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
+ */
+public enum EventTagBitMask {
+
+    /** LED or Cosmic trigger. */
+    LED_COSMIC(4),
+    /** Pair 0 trigger. */
+    PAIRS0(2),
+    /** Pair 1 trigger. */
+    PAIRS1(3),
+    /** Physics event. */
+    PHYSICS(7),
+    /** Pulser triggered event. */
+    PULSER(5),
+    /** Single 0 trigger. */
+    SINGLE0(0),
+    /** Single 1 trigger. */
+    SINGLE1(1),
+    /** Physics sync event. */
+    SYNC(6);
+
+    /**
+     * The bit number.
+     */
+    private int bit;
+
+    /**
+     * The bit mask.
+     */
+    int bitMask;
+
+    /**
+     * Constructor with bit number.
+     *
+     * @param bit the bit number
+     */
+    private EventTagBitMask(final int bit) {
+        this.bit = bit;
+        this.bitMask = 1 >> this.bit;
+    }
+
+    /**
+     * Get the bit number.
+     *
+     * @return the bit number
+     */
+    public int getBit() {
+        return this.bit;
+    }
+
+    /**
+     * Get the bit mask.
+     *
+     * @return the bit mask
+     */
+    public int getBitMask() {
+        return this.bitMask;
+    }
+
+    /**
+     * Return <code>true</code> if the event's tag matches this one.
+     *
+     * @param event an <code>EvioEvent</code> to check
+     * @return <code>true</code> if the event's tag matches this one
+     */
+    public boolean isEventTag(final EvioEvent event) {
+        return isEventTag(event.getHeader().getTag());
+    }
+
+    /**
+     * Return <code>true</code> if the tag matches this one.
+     *
+     * @param eventTag the event's tag from the header bank
+     * @return <code>true</code> if the tag matches this one
+     */
+    public boolean isEventTag(final int eventTag) {
+        return (eventTag & this.bitMask) == 1;
+    }
+}

Added: java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagConstant.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagConstant.java	(added)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagConstant.java	Mon May 11 12:26:13 2015
@@ -0,0 +1,61 @@
+package org.hps.record.evio;
+
+import org.jlab.coda.jevio.EvioEvent;
+
+/**
+ * Encapsulates event tag constants for EVIO events as described at <a
+ * href="https://confluence.slac.stanford.edu/display/hpsg/EVIO+Data+Format#EVIODataFormat-EVIOEventtypes-2015DataSet"
+ * >EVIO Event types</a>.
+ *
+ * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
+ */
+public enum EventTagConstant {
+
+    /** CODA END event inserted at end of run. */
+    END(20),
+    /** EPICS event containing variable values. */
+    EPICS(31),
+    /** CODA GO event indicating event stream is starting. */
+    GO(18),
+    /** CODA PAUSE event indicating the pause button was pressed in the GUI. */
+    PAUSE(19),
+    /** The old physics event tag by HPS convention. */
+    PHYSICS_OLD(1),
+    /** CODA PRESTART event when run initializes. */
+    PRESTART(17),
+    /** CODA SYNC event. */
+    SYNC(16);
+
+    /**
+     * The tag value.
+     */
+    private final int tag;
+
+    /**
+     * Constructor with tag value.
+     * 
+     * @param tag the tag value
+     */
+    private EventTagConstant(final int tag) {
+        this.tag = tag;
+    }
+
+    /**
+     * Return <code>true</code> if the event tag matches this one.
+     * 
+     * @param event the <code>EvioEvent</code> to check
+     * @return <code>true</code> if the event's tag matches this one
+     */
+    public boolean isEventTag(final EvioEvent event) {
+        return event.getHeader().getTag() == this.tag;
+    }
+
+    /**
+     * Get the tag value.
+     * 
+     * @return the tag value
+     */
+    public int tag() {
+        return this.tag;
+    }
+}