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:

r3105 - /java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/EvioFileCrawler.java

From:

[log in to unmask]

Reply-To:

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

Date:

Sat, 6 Jun 2015 01:29:50 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (164 lines)

Author: [log in to unmask]
Date: Fri Jun  5 18:29:41 2015
New Revision: 3105

Log:
Add option for running extra EVIO processor classes.

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

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/EvioFileCrawler.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/EvioFileCrawler.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/EvioFileCrawler.java	Fri Jun  5 18:29:41 2015
@@ -6,9 +6,11 @@
 import java.nio.file.Files;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.EnumSet;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -18,6 +20,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
+import org.hps.record.evio.EvioEventProcessor;
 import org.lcsim.util.log.DefaultLogFormatter;
 import org.lcsim.util.log.LogUtil;
 
@@ -31,8 +34,9 @@
 // -database connections prop file
 // -writing Auger XML for crawl job (and don't actually execute job)
 // -writing out a summary EVIO file containing control events only (PRESTART, EPICS, scalars?, END)
-// -allow overwriting existing information in run table rather than inserting
 // -get supplementary information from run spreadsheet (including whether run was "JUNK" or not)
+// -allow running arbitrary EvioEventProcessor classes by giving fully qualified class names as args on command line
+//  e.g. -E org.hps.derp.MyEvioEventProcessor
 public final class EvioFileCrawler {
 
     /**
@@ -61,6 +65,7 @@
         OPTIONS.addOption("c", "cache-files", false, "automatically cache files from MSS (JLAB only)");
         OPTIONS.addOption("d", "directory", true, "root directory to start crawling (default is current dir)");
         OPTIONS.addOption("e", "epics", false, "process EPICS data found in EVIO files");
+        OPTIONS.addOption("E", "evio-processor", true, "class name of an additional EVIO processor to execute");
         OPTIONS.addOption("h", "help", false, "print help and exit");
         OPTIONS.addOption("m", "max-files", true, "max number of files to process per run (only for debugging)");
         OPTIONS.addOption("p", "print", true, "set event print interval during EVIO processing");
@@ -156,6 +161,8 @@
     private Long waitTime;
     
     private boolean allowUpdates = false;
+    
+    private List<EvioEventProcessor> processors = new ArrayList<EvioEventProcessor>();
 
     /**
      * Create the processor for a single run.
@@ -234,39 +241,46 @@
                 for (final String runString : cl.getOptionValues("a")) {
                     final Integer acceptRun = Integer.parseInt(runString);
                     this.acceptRuns.add(acceptRun);
-                    LOGGER.config("added accept run " + acceptRun);
+                    LOGGER.config("added run number filter " + acceptRun);
                 }
             }
 
             if (cl.hasOption("s")) {
+                LOGGER.config("print summary enabled");
                 this.printSummary = true;
             }
 
-            if (cl.hasOption("r")) {
+            if (cl.hasOption("r")) {                
                 this.updateRunLog = true;
-            }
-
-            if (cl.hasOption("e")) {
+                LOGGER.config("run db will be updated");
+            }
+
+            if (cl.hasOption("e")) {                
                 this.epics = true;
-            }
-
-            if (cl.hasOption("c")) {
+                LOGGER.config("EPICS processing enabled");
+            }
+
+            if (cl.hasOption("c")) {                
                 this.useFileCache = true;
+                LOGGER.config("using file cache");
             }
 
             if (cl.hasOption("w")) {
                 this.waitTime = Long.parseLong(cl.getOptionValue("w")) * MILLISECONDS;
                 if (this.waitTime > 0L) {
                     this.cacheManager.setWaitTime(this.waitTime);
+                    LOGGER.config("max wait time for caching set to " + this.waitTime);
                 }
             }
 
             if (cl.hasOption("m")) {
                 this.maxFiles = Integer.parseInt(cl.getOptionValue("m"));
+                LOGGER.config("max files set to " + this.maxFiles);
             }
 
             if (cl.hasOption("p")) {
                 this.eventPrintInterval = Integer.parseInt(cl.getOptionValue("p"));
+                LOGGER.config("event print interval set to " + this.eventPrintInterval);
             }
             
             if (cl.hasOption("u")) {
@@ -288,6 +302,18 @@
                 }
             }
             
+            
+            if (cl.hasOption("E")) {
+                String[] classNames = cl.getOptionValues("E");
+                for (String className : classNames) {
+                    try {
+                        processors.add(createEvioEventProcessor(className));
+                    } catch (Exception e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }
+            
         } catch (final ParseException e) {
             throw new RuntimeException("Error parsing options.", e);
         }
@@ -316,10 +342,15 @@
         this.cacheManager.clear();
 
         // Create a processor to process all the EVIO events in the run.
-        final RunProcessor processor = this.createRunProcessor(runSummary);
+        final RunProcessor runProcessor = this.createRunProcessor(runSummary);
+        
+        for (EvioEventProcessor processor : processors) {
+            runProcessor.addProcessor(processor);
+            LOGGER.config("added extra EVIO processor " + processor.getClass().getName());
+        }
 
         // Process all of the runs files.
-        processor.process();
+        runProcessor.process();
     }
 
     /**
@@ -398,4 +429,8 @@
         this.timestampFile.setLastModified(System.currentTimeMillis());
         LOGGER.info("set modified on timestamp file: " + new Date(this.timestampFile.lastModified()));
     }
+    
+    EvioEventProcessor createEvioEventProcessor(String className) throws Exception {
+        return EvioEventProcessor.class.cast(Class.forName(className).newInstance());
+    }
 }

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