Commit in hps-java/src/main/java/org/lcsim/hps/evio on MAIN | |||
TestRunEvioToLcio.java | +42 | -40 | 1.4 -> 1.5 |
loop over any number of input arguments
diff -u -r1.4 -r1.5 --- TestRunEvioToLcio.java 29 Apr 2012 23:05:26 -0000 1.4 +++ TestRunEvioToLcio.java 29 Apr 2012 23:46:55 -0000 1.5 @@ -23,7 +23,7 @@
* * To run this class from command line: *
- * TestRunEvioToLcio -e [evioFile] -l [lcioFile] -d [detectorName] -x
+ * TestRunEvioToLcio [evioFile] -l [lcioFile] -d [detectorName] -x
* [lcsimXmlFile] * * @author Jeremy McCormick <[log in to unmask]>
@@ -84,6 +84,7 @@
} String lcioFileName = null;
+ LCIOWriter writer = null;
String detectorName = defaultDetectorName; InputStream steeringStream = null; int sleepTime = -1;
@@ -119,11 +120,10 @@
// Sleep time. if (cl.hasOption("s")) {
- sleepTime = Integer.getInteger(cl.getOptionValue("s"));
+ sleepTime = Integer.valueOf(cl.getOptionValue("s"));
} // LCIO writer.
- LCIOWriter writer = null;
if (lcioFileName != null) { try { writer = new LCIOWriter(new File(lcioFileName));
@@ -141,50 +141,52 @@
LCSimEventBuilder eventBuilder = new LCSimTestRunEventBuilder(); eventBuilder.setDetectorName(detectorName);
- // EVIO input file. - File evioFile = new File(cl.getArgs()[0]); - - // EVIO reader. - EvioReader reader = null; - try { - reader = new EvioReader(evioFile); - } catch (IOException e) { - throw new RuntimeException(e); - }
+ for (String evioFileName : cl.getArgs()) { + // EVIO input file. + File evioFile = new File(evioFileName);
- // Loop over EVIO events, build LCSim events, process them, and then - // write events to disk. - while (true) { - EvioEvent evioEvent = null;
+ // EVIO reader. + EvioReader reader = null;
try {
- do { - try { - evioEvent = reader.parseNextEvent(); - } catch (NullPointerException e) { - evioEvent = null; - e.printStackTrace(); - } - } while (evioEvent == null || !eventBuilder.isPhysicsEvent(evioEvent)); - - EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent); - jobManager.processEvent(lcioEvent); - if (writer != null) { - writer.write(lcioEvent); - writer.flush(); - } - if (reader.getNumEventsRemaining() == 0) { - break; - } - } catch (EvioException e) { - throw new RuntimeException(e);
+ reader = new EvioReader(evioFile);
} catch (IOException e) { throw new RuntimeException(e); }
- if (sleepTime > 0) {
+ + // Loop over EVIO events, build LCSim events, process them, and then + // write events to disk. + while (true) { + EvioEvent evioEvent = null;
try {
- Thread.sleep(sleepTime); - } catch (InterruptedException e) {
+ do { + try { + evioEvent = reader.parseNextEvent(); + } catch (NullPointerException e) { + evioEvent = null; + e.printStackTrace(); + } + } while (evioEvent == null || !eventBuilder.isPhysicsEvent(evioEvent)); + + EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent); + jobManager.processEvent(lcioEvent); + if (writer != null) { + writer.write(lcioEvent); + writer.flush(); + } + if (reader.getNumEventsRemaining() == 0) { + break; + } + } catch (EvioException e) {
throw new RuntimeException(e);
+ } catch (IOException e) { + throw new RuntimeException(e); + } + if (sleepTime > 0) { + try { + Thread.sleep(sleepTime); + } catch (InterruptedException e) { + throw new RuntimeException(e); + }
} } }
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1