LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  February 2016

HPS-SVN February 2016

Subject:

r4213 - /java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TIData.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Fri, 12 Feb 2016 15:30:54 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (322 lines)

Author: [log in to unmask]
Date: Fri Feb 12 07:30:52 2016
New Revision: 4213

Log: (empty)

Modified:
    java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TIData.java

Modified: java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TIData.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TIData.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TIData.java	Fri Feb 12 07:30:52 2016
@@ -4,19 +4,29 @@
 
 /**
  * Class <code>TIData</code> is an implementation of abstract class
- * <code>AbstractIntData</code> that represents a TI trigger bit bank.
- * It contains both a time window length and a set of flags that track
- * whether a trigger of a given type was registered with the event to
- * which this bank is attached.
+ * <code>AbstractIntData</code> that represents a TI trigger bit bank. It
+ * contains both a time window length and a set of flags that track whether a
+ * trigger of a given type was registered with the event to which this bank is
+ * attached.
  *
  * @author Nathan Baltzell <[log in to unmask]>
  */
 public class TIData extends AbstractIntData {
-	/** The EvIO bank header tag for TI data banks. */
+
+    /**
+     * The EvIO bank header tag for TI data banks.
+     */
     public static final int BANK_TAG = 0xe10a; // EvioEventConstants.TI_TRIGGER_BANK_TAG;
-    /** The expected number of entries in the data bank. */
-    public static final int BANK_SIZE = 4;
-    
+    /**
+     * The expected number of entries in the data bank for the 2015 data.
+     */
+    private static final int BANK_SIZE_2015 = 4;
+    /**
+     * The expected number of entries in the data bank for the 2016 data (after
+     * unprescaled trigger bits were added).
+     */
+    private static final int BANK_SIZE_2016 = 5;
+
     // Store the parsed data bank parameters.
     private long time = 0;
     private boolean singles0 = false;
@@ -25,36 +35,59 @@
     private boolean pairs1 = false;
     private boolean calib = false;
     private boolean pulser = false;
-    
-    /**
-     * Creates a <code>TIData</code> bank from a raw EvIO data bank.
-     * It is expected that the EvIO reader will verify that the bank
-     * tag is of the appropriate type.
+    private boolean hasUnprescaledTriggerBits = false;
+    private boolean singles0Unprescaled = false;
+    private boolean singles1Unprescaled = false;
+    private boolean pairs0Unprescaled = false;
+    private boolean pairs1Unprescaled = false;
+    private boolean calibUnprescaled = false;
+    private boolean pulserUnprescaled = false;
+
+    /**
+     * Creates a <code>TIData</code> bank from a raw EvIO data bank. It is
+     * expected that the EvIO reader will verify that the bank tag is of the
+     * appropriate type.
+     *
      * @param bank - The EvIO data bank.
      */
     public TIData(int[] bank) {
         super(bank);
         decodeData();
     }
-    
+
     /**
      * Creates a <code>TIData</code> object from an existing LCIO
      * <code>GenericObject</code>.
+     *
      * @param tiData - The source data bank object.
      */
     public TIData(GenericObject tiData) {
         super(tiData, BANK_TAG);
         decodeData();
     }
-    
+
     @Override
     protected final void decodeData() {
-    	// Check that the data bank is the expected size. If not, throw
-    	// and exception.
-        if(this.bank.length != BANK_SIZE) {
-            throw new RuntimeException("Invalid Data Length:  " + bank.length);
-        }
-        
+        // Check that the data bank is the expected size. If not, throw
+        // and exception.
+        switch (this.bank.length) {
+            case BANK_SIZE_2015:
+//                System.out.println("2015-style TI bank");
+                break;
+            case BANK_SIZE_2016:
+//                System.out.format("2016-style TI bank, first word %x, last word %x\n", bank[0], bank[4]);
+                hasUnprescaledTriggerBits = true;
+                singles0Unprescaled = ((bank[0]) & 1) == 1;
+                singles1Unprescaled = ((bank[0] >> 1) & 1) == 1;
+                pairs0Unprescaled = ((bank[0] >> 2) & 1) == 1;
+                pairs1Unprescaled = ((bank[0] >> 3) & 1) == 1;
+                calibUnprescaled = ((bank[0] >> 4) & 1) == 1;
+                pulserUnprescaled = ((bank[0] >> 5) & 1) == 1;
+                break;
+            default:
+                throw new RuntimeException("Invalid Data Length:  " + bank.length);
+        }
+
         // Check each trigger bit to see if it is active. A value of 
         // 1 indicates a trigger of that type occurred, and 0 that it
         // did not.
@@ -64,83 +97,184 @@
         pairs1 = ((bank[0] >> 27) & 1) == 1;
         calib = ((bank[0] >> 28) & 1) == 1;
         pulser = ((bank[0] >> 29) & 1) == 1;
-        
+
         // Get the unprocessed start and end times for the bank.
         long w1 = bank[2] & 0xffffffffL;
         long w2 = bank[3] & 0xffffffffL;
-        
+
         // Process the times into units of clock-cycles.
         final long timelo = w1;
         final long timehi = (w2 & 0xffff) << 32;
-        
+
         // Store the time difference in nanoseconds.
         time = 4 * (timelo + timehi);
     }
-    
+
     @Override
     public int getTag() {
         return BANK_TAG;
     }
-    
+
     /**
      * Gets the time window for the bank.
+     *
      * @return Returns the time window length in nanoseconds.
      */
     public long getTime() {
         return time;
     }
-    
+
     /**
      * Indicates whether a singles 0 trigger was registered.
+     *
      * @return Returns <code>true</code> if the trigger occurred, and
      * <code>false</code> otherwise.
      */
     public boolean isSingle0Trigger() {
         return singles0;
     }
-    
+
     /**
      * Indicates whether a singles 1 trigger was registered.
+     *
      * @return Returns <code>true</code> if the trigger occurred, and
      * <code>false</code> otherwise.
      */
     public boolean isSingle1Trigger() {
         return singles1;
     }
-    
+
     /**
      * Indicates whether a pair 0 trigger was registered.
+     *
      * @return Returns <code>true</code> if the trigger occurred, and
      * <code>false</code> otherwise.
      */
     public boolean isPair0Trigger() {
         return pairs0;
     }
-    
+
     /**
      * Indicates whether a pair 1 trigger was registered.
+     *
      * @return Returns <code>true</code> if the trigger occurred, and
      * <code>false</code> otherwise.
      */
     public boolean isPair1Trigger() {
         return pairs1;
     }
-    
+
     /**
      * Indicates whether a cosmic trigger was registered.
+     *
      * @return Returns <code>true</code> if the trigger occurred, and
      * <code>false</code> otherwise.
      */
     public boolean isCalibTrigger() {
         return calib;
     }
-    
+
     /**
      * Indicates whether a random/pulser trigger was registered.
+     *
      * @return Returns <code>true</code> if the trigger occurred, and
      * <code>false</code> otherwise.
      */
     public boolean isPulserTrigger() {
         return pulser;
     }
-}
+
+    /**
+     * Indicates whether this TI data has unprescaled trigger bits.
+     *
+     * @return Returns <code>true</code> if the TI data has a fifth int
+     * containing unprescaled trigger bits, and <code>false</code> otherwise.
+     */
+    public boolean hasUnprescaledTriggerBits() {
+        return hasUnprescaledTriggerBits;
+    }
+
+    /**
+     * Indicates whether a singles 0 (unprescaled) trigger was registered.
+     *
+     * @return Returns <code>true</code> if the trigger occurred, and
+     * <code>false</code> otherwise. Throws a RuntimeException if this data does
+     * not have unprescaled trigger bits.
+     */
+    public boolean isSingle0UnprescaledTrigger() {
+        if (!hasUnprescaledTriggerBits) {
+            throw new RuntimeException("This TI data does not have unprescaled trigger bits.");
+        }
+        return singles0Unprescaled;
+    }
+
+    /**
+     * Indicates whether a singles 1 (unprescaled) trigger was registered.
+     *
+     * @return Returns <code>true</code> if the trigger occurred, and
+     * <code>false</code> otherwise. Throws a RuntimeException if this data does
+     * not have unprescaled trigger bits.
+     */
+    public boolean isSingle1UnprescaledTrigger() {
+        if (!hasUnprescaledTriggerBits) {
+            throw new RuntimeException("This TI data does not have unprescaled trigger bits.");
+        }
+        return singles1Unprescaled;
+    }
+
+    /**
+     * Indicates whether a pairs 0 (unprescaled) trigger was registered.
+     *
+     * @return Returns <code>true</code> if the trigger occurred, and
+     * <code>false</code> otherwise. Throws a RuntimeException if this data does
+     * not have unprescaled trigger bits.
+     */
+    public boolean isPair0UnprescaledTrigger() {
+        if (!hasUnprescaledTriggerBits) {
+            throw new RuntimeException("This TI data does not have unprescaled trigger bits.");
+        }
+        return pairs0Unprescaled;
+    }
+
+    /**
+     * Indicates whether a pairs 1 (unprescaled) trigger was registered.
+     *
+     * @return Returns <code>true</code> if the trigger occurred, and
+     * <code>false</code> otherwise. Throws a RuntimeException if this data does
+     * not have unprescaled trigger bits.
+     */
+    public boolean isPair1UnprescaledTrigger() {
+        if (!hasUnprescaledTriggerBits) {
+            throw new RuntimeException("This TI data does not have unprescaled trigger bits.");
+        }
+        return pairs1Unprescaled;
+    }
+
+    /**
+     * Indicates whether a cosmic (unprescaled) trigger was registered.
+     *
+     * @return Returns <code>true</code> if the trigger occurred, and
+     * <code>false</code> otherwise. Throws a RuntimeException if this data does
+     * not have unprescaled trigger bits.
+     */
+    public boolean isCalibUnprescaledTrigger() {
+        if (!hasUnprescaledTriggerBits) {
+            throw new RuntimeException("This TI data does not have unprescaled trigger bits.");
+        }
+        return calibUnprescaled;
+    }
+
+    /**
+     * Indicates whether a random/pulser (unprescaled) trigger was registered.
+     *
+     * @return Returns <code>true</code> if the trigger occurred, and
+     * <code>false</code> otherwise. Throws a RuntimeException if this data does
+     * not have unprescaled trigger bits.
+     */
+    public boolean isPulserUnprescaledTrigger() {
+        if (!hasUnprescaledTriggerBits) {
+            throw new RuntimeException("This TI data does not have unprescaled trigger bits.");
+        }
+        return pulserUnprescaled;
+    }
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use