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  June 2015

HPS-SVN June 2015

Subject:

r3191 - /java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummary.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 24 Jun 2015 18:51:23 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (221 lines)

Author: [log in to unmask]
Date: Wed Jun 24 11:51:11 2015
New Revision: 3191

Log:
Add method for computing event rate and make get methods public.

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

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummary.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummary.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummary.java	Wed Jun 24 11:51:11 2015
@@ -2,8 +2,12 @@
 
 import java.io.File;
 import java.io.PrintStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.Map;
+import java.util.TimeZone;
 import java.util.logging.Logger;
 
 import org.hps.record.epics.EpicsData;
@@ -11,7 +15,8 @@
 import org.lcsim.util.log.LogUtil;
 
 /**
- * This class models the run summary information which is persisted as a row in the <i>run_log</i> table of the run database.
+ * This class models the run summary information which is persisted as a row in the <i>run_log</i>
+ * table of the run database.
  * <p>
  * This information includes:
  * <ul>
@@ -26,8 +31,16 @@
  *
  * @author Jeremy McCormick, SLAC
  */
-final class RunSummary {
-
+public final class RunSummary {
+
+    /**
+     * Set up date formatting to display EST (GMT-4).
+     */
+    private static final DateFormat DATE_DISPLAY = new SimpleDateFormat();
+    static {
+        DATE_DISPLAY.setCalendar(new GregorianCalendar(TimeZone.getTimeZone("America/New_York")));
+    }
+    
     /**
      * Setup logger.
      */
@@ -63,6 +76,9 @@
      */
     private final int run;
 
+    /**
+     * The scaler data from the last physics event in the run.
+     */
     private ScalerData scalerData;
 
     /**
@@ -103,7 +119,7 @@
      *
      * @return the date when the run ended
      */
-    Date getEndDate() {
+    public Date getEndDate() {
         return this.endDate;
     }
 
@@ -114,7 +130,7 @@
      *
      * @return the EPICS data summary
      */
-    EpicsData getEpicsData() {
+    public EpicsData getEpicsData() {
         return this.epics;
     }
 
@@ -123,7 +139,7 @@
      *
      * @return the counts of different event types
      */
-    Map<Object, Integer> getEventTypeCounts() {
+    public Map<Object, Integer> getEventTypeCounts() {
         return this.eventTypeCounts;
     }
 
@@ -132,20 +148,25 @@
      *
      * @return the list of EVIO files in this run
      */
-    EvioFileList getEvioFileList() {
+    public EvioFileList getEvioFileList() {
         return this.files;
     }
-
+    
     /**
      * Get the run number.
      *
      * @return the run number
      */
-    int getRun() {
+    public int getRun() {
         return this.run;
     }
 
-    ScalerData getScalerData() {
+    /**
+     * Get the scaler data of this run (last event only).
+     * 
+     * @return the scaler data of this run from the last event
+     */
+    public ScalerData getScalerData() {
         return this.scalerData;
     }
 
@@ -154,7 +175,7 @@
      *
      * @return the start date of the run
      */
-    Date getStartDate() {
+    public Date getStartDate() {
         return this.startDate;
     }
 
@@ -163,19 +184,47 @@
      *
      * @return the total events in the run
      */
-    int getTotalEvents() {
+    public int getTotalEvents() {
         if (this.totalEvents == -1) {
             this.totalEvents = this.files.getTotalEvents();
         }
         return this.totalEvents;
     }
+    
+    /**
+     * Get the number of seconds in the run which is the difference between the start and end times.
+     * 
+     * @return the total seconds in the run
+     */
+    public long getTotalSeconds() {
+        if (this.getStartDate() == null) {
+            throw new RuntimeException("missing start date");
+        }
+        if (this.getEndDate() == null) {
+            throw new RuntimeException("missing end date");
+        }
+        return (getEndDate().getTime() - getStartDate().getTime()) / 1000;
+    }
+    
+    /**
+     * Get the event rate (effectively the trigger rate) which is the total events divided by the number
+     * of seconds in the run.
+     * 
+     * @return the event rate
+     */
+    public double getEventRate() {
+        if (this.getTotalEvents() <= 0) {
+            throw new RuntimeException("Total events is zero or invalid.");
+        }
+        return (double) this.getTotalEvents() / (double) this.getTotalSeconds();
+    }
 
     /**
      * Return <code>true</code> if END event was found in the data.
      *
      * @return <code>true</code> if END event was in the data
      */
-    boolean isEndOkay() {
+    public boolean isEndOkay() {
         return this.endOkay;
     }
 
@@ -184,19 +233,21 @@
      *
      * @param ps the print stream for output
      */
-    void printRunSummary(final PrintStream ps) {
+    public void printRunSummary(final PrintStream ps) {
         ps.println("--------------------------------------------");
         ps.println("run: " + this.run);
         ps.println("first file: " + this.files.first());
         ps.println("last file: " + this.files.last());
-        ps.println("started: " + this.getStartDate());
-        ps.println("ended: " + this.getEndDate());
+        ps.println("started: " + DATE_DISPLAY.format(this.getStartDate()));
+        ps.println("ended: " + DATE_DISPLAY.format(this.getEndDate()));
         ps.println("total events: " + this.getTotalEvents());
+        ps.println("end OK: " + this.isEndOkay());
+        ps.println("event rate: " + this.getEventRate());
         ps.println("event types");
         for (final Object key : this.eventTypeCounts.keySet()) {
             ps.println("  " + key + ": " + this.eventTypeCounts.get(key));
         }
-        ps.println("files " + this.files.size());
+        ps.println(this.files.size() + " files");
         for (final File file : this.files) {
             ps.println("  " + file.getPath());
         }
@@ -258,6 +309,11 @@
         this.files.sort();
     }
 
+    /**
+     * Convert this object to a string.
+     * 
+     * @return this object converted to a string
+     */
     @Override
     public String toString() {
         return "RunSummary { run: " + this.run + ", started: " + this.getStartDate() + ", ended: " + this.getEndDate() + ", events: "

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