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

HPS-SVN December 2014

Subject:

r1728 - /java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java

From:

[log in to unmask]

Reply-To:

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

Date:

Sun, 14 Dec 2014 21:35:27 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (142 lines)

Author: [log in to unmask]
Date: Sun Dec 14 13:35:23 2014
New Revision: 1728

Log:
Add command line argument for giving a text file with list of EVIO file paths.  Extra args are now optional but at least one EVIO file must be supplied with either method.  (They can be used together.)

Modified:
    java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.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	Sun Dec 14 13:35:23 2014
@@ -5,7 +5,13 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
+import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -71,15 +77,16 @@
     protected EvioToLcio() {
         logger.config("initializing EVIO to LCIO converter");
         options = new Options();
-        options.addOption(new Option("l", true, "The name of the output LCIO file"));
-        options.addOption(new Option("d", true, "The name of the detector to use for LCSim conditions"));
-        options.addOption(new Option("R", true, "A run number which will override those found in the input files"));
-        options.addOption(new Option("x", true, "The XML steeering file to process the LCIO events"));
-        options.addOption(new Option("n", true, "Maximum number of events to process per input file"));
-        options.addOption(new Option("D", true, "Pass a variable to the steering file with format -Dname=value"));
-        options.addOption(new Option("r", false, "Interpret steering from -x argument as a resource instead of a file"));
-        options.addOption(new Option("L", true, "Set the log level (INFO, FINE, FINEST, etc.)"));
-        options.addOption(new Option("b", false, "Enable headless mode which will suppress showing of AIDA plots"));
+        options.addOption(new Option("f", true, "path to a text file containing a list of EVIO files to process"));
+        options.addOption(new Option("L", true, "log level (INFO, FINE, FINEST, etc.)"));
+        options.addOption(new Option("x", true, "XML steeering file for processing LCIO events"));
+        options.addOption(new Option("r", false, "interpret steering from -x argument as a resource instead of a file"));
+        options.addOption(new Option("D", true, "pass a variable to the steering file with format -Dname=value"));
+        options.addOption(new Option("l", true, "path of output LCIO file"));
+        options.addOption(new Option("d", true, "name of the detector to use for LCSim conditions"));
+        options.addOption(new Option("R", true, "fixed run number which will override run numbers of input files"));        
+        options.addOption(new Option("n", true, "maximum number of events to process in the job"));                      
+        options.addOption(new Option("b", false, "enable headless mode which will not show plots OR allow writing them to graphics files"));        
         logger.setLevel(Level.FINE);
     }
 
@@ -116,21 +123,47 @@
         } catch (ParseException e) {
             throw new RuntimeException("Problem parsing command line options.", e);
         }
-
-        // Is the extra argument list empty?
-        if (cl.getArgs().length == 0) {
-            logger.severe("No EVIO file names were given on the command line.");
-            // User didn't supply any EVIO files so exit.
-            printUsage();
-        }
-
+       
         // Set log level.
         if (cl.hasOption("L")) {
             Level level = Level.parse(cl.getOptionValue("L").toUpperCase());
             logger.config("setting log level to " + level);
             logger.setLevel(level);
         }
-
+        
+        // Add all extra arguments to the EVIO file list.
+        List<String> evioFileList = new ArrayList<String>(Arrays.asList(cl.getArgs()));
+        
+        if (cl.hasOption("f")) {
+            // Add additional EVIO files to process from text file.
+            File file = new File(cl.getOptionValue("f"));
+            if (!file.exists()) {
+                throw new RuntimeException("The file " + file.getPath() + " does not exist.");
+            }
+            Path filePath = file.toPath();
+            List<String> lines = null;
+            try {
+                lines = Files.readAllLines(filePath, Charset.defaultCharset());
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            for (String line : lines) {
+                File evioFile = new File(line);
+                if (evioFile.exists()) {
+                    evioFileList.add(evioFile.getPath());
+                } else {
+                    throw new RuntimeException("The EVIO file " + line + " does not exist.");
+                }
+            }
+        }
+         
+        // Is the EVIO file list empty?
+        if (evioFileList.isEmpty()) {  
+            // There weren't any EVIO files provided on the command line so exit.
+            logger.severe("No EVIO files were provided with command line arguments or -f option.");
+            printUsage();
+        }
+        
         String lcioFileName = null;
         LCIOWriter writer = null;
         InputStream steeringStream = null;
@@ -242,16 +275,26 @@
             logger.config("Conditions system will be frozen to use specified run number and detector!");
             conditionsManager.freeze();
         }
-
+               
+        // Print out the EVIO file list before the job starts.
+        StringBuffer buff = new StringBuffer();
+        buff.append("The job will include the following EVIO files ...");
+        buff.append('\n');
+        for (String evioFileName : evioFileList) {
+            buff.append(evioFileName);
+            buff.append('\n');
+        }        
+        logger.config(buff.toString());
+                
         // Loop over the input EVIO files.
-        for (String evioFileName : cl.getArgs()) {
+        for (String evioFileName : evioFileList) {
             
             // Get the next EVIO input file.
             File evioFile = new File(evioFileName);
             if (!evioFile.exists()) {
                 throw new RuntimeException("EVIO file " + evioFile.getPath() + " does not exist.");
             }
-            logger.info("Opening EVIO file " + evioFileName + " for reading.");
+            logger.info("Opening EVIO file " + evioFileName + " ...");
 
             // Open the EVIO reader.
             EvioReader reader = 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