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  November 2014

HPS-SVN November 2014

Subject:

r1601 - in /java/trunk: evio/src/main/java/org/hps/evio/EvioToLcio.java evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java

From:

[log in to unmask]

Reply-To:

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

Date:

Thu, 27 Nov 2014 01:49:59 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (261 lines)

Author: [log in to unmask]
Date: Wed Nov 26 17:49:54 2014
New Revision: 1601

Log:
handle new control event structure

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

Modified: java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java	Wed Nov 26 17:49:54 2014
@@ -301,7 +301,7 @@
                     if (EvioEventUtilities.isPreStartEvent(evioEvent)) {
                                                 
                         // Get the pre start event's int data bank.
-                        int[] data = evioEvent.getIntData();
+                        int[] data = EvioEventUtilities.getControlEventData(evioEvent);
                         
                         // Does the int data bank actually exist?
                         if (data != null) {
@@ -327,7 +327,7 @@
                     eventBuilder.readEvioEvent(evioEvent);
 
                     if (EvioEventUtilities.isEndEvent(evioEvent)) {
-                        int[] data = evioEvent.getIntData();
+                        int[] data = EvioEventUtilities.getControlEventData(evioEvent);
                         int seconds = data[0];
                         int totalEvents = data[2];
                         logger.info("got EVIO end event with " + totalEvents + " events and " + seconds + " seconds");

Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java	Wed Nov 26 17:49:54 2014
@@ -26,14 +26,14 @@
  */
 public class LCSimTestRunEventBuilder implements LCSimEventBuilder, ConditionsListener {
 
-	String detectorName = null;
+    String detectorName = null;
     ECalEvioReader ecalReader = null;
     SVTEvioReader svtReader = null;
     protected int run = 0; //current run number, taken from prestart and end events
     protected long time = 0; //most recent event time (ns), taken from prestart and end events, and trigger banks (if any)
     protected int sspCrateBankTag = 0x1; //bank ID of the crate containing the SSP
     protected int sspBankTag = 0xe106; //SSP bank's tag
-    protected static Logger logger = LogUtil.create(LCSimTestRunEventBuilder.class); 
+    protected static Logger logger = LogUtil.create(LCSimTestRunEventBuilder.class);
 
     public LCSimTestRunEventBuilder() {
         ecalReader = new ECalEvioReader(0x1, 0x2);
@@ -43,7 +43,7 @@
 
     @Override
     public void setDetectorName(String detectorName) {
-    	this.detectorName = detectorName;
+        this.detectorName = detectorName;
     }
 
     public void setEcalHitCollectionName(String ecalHitCollectionName) {
@@ -53,11 +53,11 @@
     @Override
     public void readEvioEvent(EvioEvent evioEvent) {
         if (EvioEventUtilities.isSyncEvent(evioEvent)) {
-            int[] data = evioEvent.getIntData();
+            int[] data = EvioEventUtilities.getControlEventData(evioEvent);
             int seconds = data[0];
             logger.info("Sync event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count since last sync " + data[1] + ", event count so far " + data[2] + ", status " + data[3]);
         } else if (EvioEventUtilities.isPreStartEvent(evioEvent)) {
-            int[] data = evioEvent.getIntData();
+            int[] data = EvioEventUtilities.getControlEventData(evioEvent);
             if (data != null) {
                 int seconds = data[0];
                 time = ((long) seconds) * 1000000000;
@@ -65,19 +65,19 @@
                 logger.info("Prestart event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", run " + run + ", run type " + data[2]);
             }
         } else if (EvioEventUtilities.isGoEvent(evioEvent)) {
-            int[] data = evioEvent.getIntData();
+            int[] data = EvioEventUtilities.getControlEventData(evioEvent);
             if (data != null) {
                 int seconds = data[0];
                 time = ((long) seconds) * 1000000000;
                 logger.info("Go event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count so far " + data[2]);
             }
         } else if (EvioEventUtilities.isPauseEvent(evioEvent)) {
-            int[] data = evioEvent.getIntData();
+            int[] data = EvioEventUtilities.getControlEventData(evioEvent);
             int seconds = data[0];
             time = ((long) seconds) * 1000000000;
             logger.info("Pause event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count so far " + data[2]);
         } else if (EvioEventUtilities.isEndEvent(evioEvent)) {
-            int[] data = evioEvent.getIntData();
+            int[] data = EvioEventUtilities.getControlEventData(evioEvent);
             int seconds = data[0];
             time = ((long) seconds) * 1000000000;
             run = 0;
@@ -128,7 +128,7 @@
         if (eventID == null) {
             logger.warning("No event ID bank found");
             eventID = new int[3];
-        } else {            
+        } else {
             logger.finest("Read EVIO event number " + eventID[0]);
             if (eventID[1] != 1) {
                 logger.warning("Trigger code is usually 1; got " + eventID[1]);
@@ -146,7 +146,7 @@
 
         // Create a new LCSimEvent.
         EventHeader lcsimEvent = new BaseLCSimEvent(run, eventID[0], detectorName, time);
-        
+
         lcsimEvent.put("TriggerBank", triggerList, TriggerData.class, 0);
         return lcsimEvent;
     }
@@ -177,8 +177,8 @@
         return triggerData;
     }
 
-	@Override
-	public void conditionsChanged(ConditionsEvent conditionsEvent) {
-		ecalReader.initialize();
-	}
+    @Override
+    public void conditionsChanged(ConditionsEvent conditionsEvent) {
+        ecalReader.initialize();
+    }
 }

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 Nov 26 17:49:54 2014
@@ -6,21 +6,25 @@
 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;
 
 /**
- * This is a set of basic static utility methods on <code>EvioEvent</code> objects.  
+ * This is a set of basic static utility methods on <code>EvioEvent</code>
+ * objects.
+ *
  * @author Jeremy McCormick <[log in to unmask]>
  */
 public final class EvioEventUtilities {
-    
-    private EvioEventUtilities() {        
+
+    private EvioEventUtilities() {
     }
-        
+
     /**
-     * Check if the EVIO event is a PRE START event indicating
-     * the beginning of a run.
+     * Check if the EVIO event is a PRE START event indicating the beginning of
+     * a run.
+     *
      * @param event The EvioEvent.
      * @return True if the event is a pre start event.
      */
@@ -30,6 +34,7 @@
 
     /**
      * Check if the EVIO event is a GO event.
+     *
      * @param event The EvioEvent.
      * @return True if the event is a go event.
      */
@@ -39,6 +44,7 @@
 
     /**
      * Check if the EVIO event is a PAUSE event.
+     *
      * @param event The EvioEvent.
      * @return True if the event is a pause event.
      */
@@ -48,28 +54,71 @@
 
     /**
      * Check if this event is an END event.
+     *
      * @param event The EvioEvent.
      * @return True if this event is an end event.
      */
     public static boolean isEndEvent(EvioEvent event) {
         return event.getHeader().getTag() == END_EVENT_TAG;
     }
-    
+
     /**
      * Check if this event has physics data.
+     *
      * @param event The EvioEvent.
      * @return True if this event is a physics event.
      */
     public static boolean isPhysicsEvent(EvioEvent event) {
         return event.getHeader().getTag() == PHYSICS_EVENT_TAG;
     }
-    
+
     /**
      * Check if this event is a SYNC event.
+     *
      * @param event The EvioEvent.
      * @return True if this event is a SYNC event.
      */
     public static boolean isSyncEvent(EvioEvent event) {
         return event.getHeader().getTag() == SYNC_EVENT_TAG;
     }
+
+    /**
+     * Extract the CODA run data stored in a control event.
+     *
+     * @param event The EvioEvent.
+     * @return The int data for the control event. Null if the event is not a
+     * control event, or the int bank for the control event is not found.
+     */
+    public static int[] getControlEventData(EvioEvent event) {
+        int eventTag = event.getHeader().getTag();
+        System.out.format("event tag %d\n", eventTag);
+        switch (eventTag) {
+            case PRESTART_EVENT_TAG:
+            case PAUSE_EVENT_TAG:
+            case END_EVENT_TAG:
+            case SYNC_EVENT_TAG:
+            case GO_EVENT_TAG:
+                break;
+            default:
+                return null;
+        }
+
+        int[] data = event.getIntData();
+        if (data != null) {
+            System.out.format("got data\n");
+
+            return data;
+        } else {
+            System.out.format("didn't get data\n");
+
+            for (BaseStructure bank : event.getChildren()) {
+                System.out.format("got bank with tag %d\n", bank.getHeader().getTag());
+                if (bank.getHeader().getTag() == eventTag) {
+                    System.out.format("got data from bank\n");
+                    return bank.getIntData();
+                }
+            }
+            return null;
+        }
+    }
 }

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