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

HPS-SVN August 2015

Subject:

r3427 - in /java/trunk/record-util/src/main/java/org/hps/record: evio/crawler/ triggerbank/

From:

[log in to unmask]

Reply-To:

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

Date:

Fri, 28 Aug 2015 01:40:36 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (299 lines)

Author: [log in to unmask]
Date: Thu Aug 27 18:40:34 2015
New Revision: 3427

Log:
More updates and changes for run db work.

Added:
    java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfig.java
      - copied, changed from r3424, java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigInt.java
Removed:
    java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigInt.java
Modified:
    java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/Crawler.java
    java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java
    java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TiTimeOffsetEvioProcessor.java
    java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigVariable.java

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/Crawler.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/Crawler.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/Crawler.java	Thu Aug 27 18:40:34 2015
@@ -21,8 +21,8 @@
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
 import org.hps.conditions.database.ConnectionParameters;
+import org.hps.rundb.RunDatabaseDaoFactory;
 import org.hps.rundb.RunSummary;
-import org.hps.rundb.RunSummaryDaoImpl;
 import org.hps.rundb.RunSummaryImpl;
 import org.lcsim.util.log.DefaultLogFormatter;
 import org.lcsim.util.log.LogUtil;
@@ -65,7 +65,8 @@
         OPTIONS.addOption("r", "run", true, "add a run number to accept (when used others will be excluded)");
         OPTIONS.addOption("t", "timestamp-file", true, "existing or new timestamp file name");
         OPTIONS.addOption("w", "max-cache-wait", true, "total time to allow for file caching (seconds)");
-        OPTIONS.addOption("u", "update", false, "allow replacement of existing data in the run db (not allowed by default)");
+        OPTIONS.addOption("u", "update", false,
+                "allow replacement of existing data in the run db (not allowed by default)");
         OPTIONS.addOption("x", "max-depth", true, "max depth to crawl in the directory tree");
     }
 
@@ -79,6 +80,34 @@
             new Crawler().parse(args).run();
         } catch (final Exception e) {
             throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Process all the runs that were found.
+     *
+     * @param runs the run log containing the list of run summaries
+     * @throws Exception if there is an error processing one of the runs
+     */
+    static void processRuns(final JCacheManager cacheManager, final RunSummaryMap runs, final boolean useFileCache)
+            throws Exception {
+
+        // Process all of the runs that were found.
+        for (final RunSummary runSummary : runs.getRunSummaries()) {
+
+            // Clear the cache manager.
+            if (useFileCache) {
+                LOGGER.info("clearing file cache");
+                cacheManager.clear();
+            }
+
+            // Create a processor to process all the EVIO events in the run.
+            LOGGER.info("creating run processor for " + runSummary.getRun());
+            final RunProcessor runProcessor = new RunProcessor(cacheManager, (RunSummaryImpl) runSummary, useFileCache);
+
+            // Process all of the files from the run.
+            LOGGER.info("processing run " + runSummary.getRun());
+            runProcessor.processRun();
         }
     }
 
@@ -304,7 +333,7 @@
 
         // Execute the run database update.
         LOGGER.info("updating run database");
-        this.updateRunDatabase(runs);       
+        this.updateRunDatabase(runs);
         LOGGER.getHandlers()[0].flush();
 
         // Update the timestamp output file.
@@ -330,8 +359,10 @@
             // Open a DB connection.
             final Connection connection = config.connectionParameters().createConnection();
 
-            // Insert all run summaries into the database.            
-            new RunSummaryDaoImpl(connection).insertFullRunSummaries(new ArrayList<RunSummary>(runs.getRunSummaries()),
+            final RunDatabaseDaoFactory dbFactory = new RunDatabaseDaoFactory(connection);
+
+            // Insert all run summaries into the database.
+            dbFactory.createRunSummaryDao().insertFullRunSummaries(new ArrayList<RunSummary>(runs.getRunSummaries()),
                     config.allowUpdates());
 
             // Close the DB connection.
@@ -393,33 +424,5 @@
             throw new RuntimeException("Error while walking the directory tree.", e);
         }
     }
-    
-    /**
-     * Process all the runs that were found.
-     *
-     * @param runs the run log containing the list of run summaries
-     * @throws Exception if there is an error processing one of the runs
-     */
-    static void processRuns(JCacheManager cacheManager, final RunSummaryMap runs, boolean useFileCache) 
-            throws Exception {
-
-        // Process all of the runs that were found.
-        for (final RunSummary runSummary : runs.getRunSummaries()) {
-
-            // Clear the cache manager.
-            if (useFileCache) {
-                LOGGER.info("clearing file cache");
-                cacheManager.clear();
-            }
-
-            // Create a processor to process all the EVIO events in the run.
-            LOGGER.info("creating run processor for " + runSummary.getRun());
-            final RunProcessor runProcessor = new RunProcessor(cacheManager, (RunSummaryImpl) runSummary, useFileCache);
-
-            // Process all of the files from the run.
-            LOGGER.info("processing run " + runSummary.getRun());
-            runProcessor.processRun();
-        }
-    }
-    
+
 }

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java	Thu Aug 27 18:40:34 2015
@@ -13,7 +13,7 @@
 import org.hps.record.evio.EvioLoop;
 import org.hps.record.scalers.ScalersEvioProcessor;
 import org.hps.record.triggerbank.TiTimeOffsetEvioProcessor;
-import org.hps.record.triggerbank.TriggerConfigInt;
+import org.hps.record.triggerbank.TriggerConfig;
 import org.hps.record.triggerbank.TriggerConfigVariable;
 import org.hps.rundb.RunSummaryImpl;
 import org.lcsim.util.log.DefaultLogFormatter;
@@ -225,7 +225,7 @@
 
         // Add trigger config from the trigger time processor.
         LOGGER.info("updating trigger config");
-        TriggerConfigInt triggerConfig = new TriggerConfigInt();
+        TriggerConfig triggerConfig = new TriggerConfig();
         this.triggerTimeProcessor.updateTriggerConfig(triggerConfig);
         LOGGER.info("tiTimeOffset: " + triggerConfig.get(TriggerConfigVariable.TI_TIME_OFFSET.name()));
         System.out.println("tiTimeOffset: " + triggerConfig.get(TriggerConfigVariable.TI_TIME_OFFSET.name()));

Modified: java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TiTimeOffsetEvioProcessor.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TiTimeOffsetEvioProcessor.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TiTimeOffsetEvioProcessor.java	Thu Aug 27 18:40:34 2015
@@ -13,31 +13,31 @@
 public class TiTimeOffsetEvioProcessor extends EvioEventProcessor {
 
     private final IntBankDefinition headBankDefinition;
+    private long maxOffset = 0;
+
+    private final int maxOutliers = 10;
+    private final double maxRange = 1.1e9;
+    private long minOffset = 0;
+
+    private final double minRange = 0.99e9;
+    private int nOutliers = 0;
     private final IntBankDefinition tiBankDefinition;
 
-    private final double minRange = 0.99e9;
-    private final double maxRange = 1.1e9;
-    private final int maxOutliers = 10;
-
-    private long minOffset = 0;
-    private long maxOffset = 0;
-    private int nOutliers = 0;
-
     public TiTimeOffsetEvioProcessor() {
-        headBankDefinition = new IntBankDefinition(HeadBankData.class, new int[]{0x2e, 0xe10f});
-        tiBankDefinition = new IntBankDefinition(TIData.class, new int[]{0x2e, 0xe10a});
+        headBankDefinition = new IntBankDefinition(HeadBankData.class, new int[] {0x2e, 0xe10f});
+        tiBankDefinition = new IntBankDefinition(TIData.class, new int[] {0x2e, 0xe10a});
     }
 
     @Override
     public void process(final EvioEvent evioEvent) {
-        BaseStructure headBank = headBankDefinition.findBank(evioEvent);
-        BaseStructure tiBank = tiBankDefinition.findBank(evioEvent);
+        final BaseStructure headBank = headBankDefinition.findBank(evioEvent);
+        final BaseStructure tiBank = tiBankDefinition.findBank(evioEvent);
         if (headBank != null && tiBank != null) {
-            int[] headData = headBank.getIntData();
-            int thisTimestamp = headData[3];
-            TIData tiData = new TIData(tiBank.getIntData());
+            final int[] headData = headBank.getIntData();
+            final int thisTimestamp = headData[3];
+            final TIData tiData = new TIData(tiBank.getIntData());
             if (thisTimestamp != 0) {
-                long offset = thisTimestamp * 1000000000L - tiData.getTime();
+                final long offset = thisTimestamp * 1000000000L - tiData.getTime();
                 if (minOffset == 0 || minOffset > offset) {
                     if (maxOffset - offset < maxRange) {
                         minOffset = offset;
@@ -56,12 +56,12 @@
         }
     }
 
-    public void updateTriggerConfig(TriggerConfigInt triggerConfig) {
-        long offsetRange = maxOffset - minOffset;
+    public void updateTriggerConfig(final TriggerConfig triggerConfig) {
+        final long offsetRange = maxOffset - minOffset;
         if (offsetRange > minRange && nOutliers < maxOutliers) {
-            triggerConfig.put(TriggerConfigVariable.TI_TIME_OFFSET.name(), minOffset);
+            triggerConfig.put(TriggerConfigVariable.TI_TIME_OFFSET, minOffset);
         } else {
-            triggerConfig.put(TriggerConfigVariable.TI_TIME_OFFSET.name(), 0L);
+            triggerConfig.put(TriggerConfigVariable.TI_TIME_OFFSET, 0L);
         }
     }
 }

Copied: java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfig.java (from r3424, java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigInt.java)
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigInt.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfig.java	Thu Aug 27 18:40:34 2015
@@ -3,23 +3,22 @@
 import java.util.HashMap;
 
 /**
- * Trigger config information in the form of string keys and long values.
+ * Trigger config information in the form of variables with <code>long</code> values.
  * <p>
- * This is not the "standard" interface using in LCSim to access trigger configuration.  
- * It is used as a simplistic representation for the run database.
- * 
+ * This is not the "standard" interface using in LCSim to access trigger configuration. It is used as a simplistic
+ * representation for the run database.
+ *
  * @author Jeremy McCormick, SLAC
  */
 @SuppressWarnings("serial")
-public class TriggerConfigInt extends HashMap<String, Long> {
-    
+public class TriggerConfig extends HashMap<TriggerConfigVariable, Long> {
+
     /**
-     * Get a particular trigger config variable's value.
-     * 
-     * @param variable the variable enum
-     * @return the variable's value
+     * Get the TI time offset.
+     *
+     * @return the TI time offset
      */
-    Long getValue(TriggerConfigVariable variable) {
-        return this.get(variable.name());
+    public Long getTiTimeOffset() {
+        return this.get(TriggerConfigVariable.TI_TIME_OFFSET);
     }
 }

Modified: java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigVariable.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigVariable.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/triggerbank/TriggerConfigVariable.java	Thu Aug 27 18:40:34 2015
@@ -2,12 +2,22 @@
 
 /**
  * Enum for trigger config variables.
- * 
+ *
  * @author Jeremy McCormick, SLAC
  */
 public enum TriggerConfigVariable {
+
     /**
-     * TI time offset
+     * TI time offset variable.
      */
-    TI_TIME_OFFSET
+    TI_TIME_OFFSET;
+
+    /**
+     * Get the column name in the run database for the config variable (convenience method).
+     *
+     * @return the column name
+     */
+    public String getColumnName() {
+        return this.name().toLowerCase();
+    }
 }

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