Print

Print


Author: [log in to unmask]
Date: Wed Jan 14 12:17:14 2015
New Revision: 1925

Log:
Add method to get head bank if it exists.

Modified:
    java/trunk/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java	Wed Jan 14 12:17:14 2015
@@ -6,8 +6,8 @@
 import static org.hps.record.evio.EvioEventConstants.PHYSICS_EVENT_TAG;
 import static org.hps.record.evio.EvioEventConstants.PRESTART_EVENT_TAG;
 import static org.hps.record.evio.EvioEventConstants.SYNC_EVENT_TAG;
+
 import org.jlab.coda.jevio.BaseStructure;
-
 import org.jlab.coda.jevio.EvioEvent;
 
 /**
@@ -114,4 +114,25 @@
             return null; //we didn't find the bank; give up
         }
     }
-}
+    
+    /**
+     * Get the head bank with event header that includes run number.
+     * This is a nested bank.
+     * @param evioEvent The EVIO event.
+     * @return The head bank or null if does not exist in this event.
+     */
+    public static BaseStructure getHeadBank(EvioEvent evioEvent) {
+        if (evioEvent.getChildCount() > 0) {
+            for (BaseStructure topBank : evioEvent.getChildren()) {
+                if (topBank.getChildren() != null) {
+                    for (BaseStructure nestedBank : topBank.getChildren()) {
+                        if (nestedBank.getHeader().getTag() == EvioEventConstants.HEAD_BANK_TAG) {
+                            return nestedBank;
+                        }
+                    }
+                }
+            }
+        }
+        return null;        
+    }
+}