hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.1 -r1.2
--- TestRunEvioToLcio.java 12 Apr 2012 18:58:20 -0000 1.1
+++ TestRunEvioToLcio.java 13 Apr 2012 00:05:37 -0000 1.2
@@ -18,126 +18,134 @@
import org.lcsim.util.lcio.LCIOWriter;
/**
- * This class is for converting Test Run EVIO to LCIO events and performing an LCSim job
- * in the same session. The processed events are then written to disk using an LCIOWriter.
+ * This class is for converting Test Run EVIO to LCIO events and performing an
+ * LCSim job in the same session. The processed events are then written to disk
+ * using an LCIOWriter.
*
* To run this class from command line:
*
- * TestrunEvioToLcio -e [evioFile] -l [lcioFile] -d [detectorName] -x [lcsimXmlFile]
+ * TestRunEvioToLcio -e [evioFile] -l [lcioFile] -d [detectorName] -x [lcsimXmlFile]
*
* @author Jeremy McCormick <[log in to unmask]>
- *
*/
public class TestRunEvioToLcio {
- /**
- * Defines command line options for this program.
- * @return The command line options.
- */
- private static Options createCommandLineOptions() {
- Options options = new Options();
-
- Option evioFileOpt = new Option("e", true,
- "The input EVIO file containing Test Run data.");
- Option lcioFileOpt = new Option("l", true,
- "The name of the output LCIO file.");
- Option detectorNameOpt = new Option("d", true,
- "The name of the detector to use for LCSim conditions.");
- Option lcsimXmlOpt = new Option("x", true,
- "The LCSim XML file to process the LCIO events.");
-
- options.addOption(evioFileOpt);
- options.addOption(lcioFileOpt);
- options.addOption(detectorNameOpt);
- options.addOption(lcsimXmlOpt);
-
- return options;
- }
-
- /**
- * This method will execute the EVIO to LCIO conversion and perform an intermediate
- * LCSim job. Then the resultant LCIO events will be written to disk.
- * @param args The command line arguments.
- */
- public static void main(String[] args) {
-
- // Set up command line parsing.
- Options options = createCommandLineOptions();
- if (args.length == 0) {
- System.out.println("TestRunEvioToLcio [options]");
+ /**
+ * Defines command line options for this program.
+ *
+ * @return The command line options.
+ */
+ private static Options createCommandLineOptions() {
+ Options options = new Options();
+
+ Option evioFileOpt = new Option("e", true, "The input EVIO file containing Test Run data.");
+ Option lcioFileOpt = new Option("l", true, "The name of the output LCIO file.");
+ Option detectorNameOpt = new Option("d", true, "The name of the detector to use for LCSim conditions.");
+ Option lcsimXmlOpt = new Option("x", true, "The LCSim XML file to process the LCIO events.");
+
+ options.addOption(evioFileOpt);
+ options.addOption(lcioFileOpt);
+ options.addOption(detectorNameOpt);
+ options.addOption(lcsimXmlOpt);
+
+ return options;
+ }
+
+ /**
+ * This method will execute the EVIO to LCIO conversion and perform an
+ * intermediate LCSim job. Then the resultant LCIO events will be written to
+ * disk.
+ *
+ * @param args The command line arguments.
+ */
+ public static void main(String[] args) {
+
+ // Set up command line parsing.
+ Options options = createCommandLineOptions();
+ if (args.length == 0) {
+ System.out.println("TestRunEvioToLcio [options]");
HelpFormatter help = new HelpFormatter();
help.printHelp(" ", options);
System.exit(1);
}
- CommandLineParser parser = new PosixParser();
- CommandLine cl = null;
- try {
- cl = parser.parse(options, args);
- } catch (ParseException e) {
- throw new RuntimeException("Problem parsing command line options.", e);
- }
-
- // EVIO input file.
- String evioFileName = cl.getOptionValue("e");
- File evioFile = new File(evioFileName);
-
- // LCIO output file.
- String lcioFileName = cl.getOptionValue("l");
- File lcioFile = new File(lcioFileName);
-
- // Name of detector.
- String detectorName = cl.getOptionValue("d");
-
- // LCSim XML file to execute inline.
- String lcsimXmlName = cl.getOptionValue("x");
- File lcsimXmlFile = new File(lcsimXmlName);
-
- // EVIO reader.
- EvioReader reader = null;
- try {
- reader = new EvioReader(evioFile);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- // LCSim event builder from EVIO.
- LCSimEventBuilder eventBuilder = new LCSimTestRunEventBuilder();
- eventBuilder.setDetectorName(detectorName);
-
- // LCIO writer.
- LCIOWriter writer = null;
- try {
- writer = new LCIOWriter(lcioFile);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- // LCSim job manager.
- JobControlManager jobManager = new JobControlManager();
- jobManager.setup(lcsimXmlFile);
- jobManager.configure();
-
- // Loop over EVIO events and process them.
- while (true) {
- try {
- EvioEvent evioEvent = reader.parseNextEvent();
- EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent);
- jobManager.processEvent(lcioEvent);
- writer.write(lcioEvent);
- if (reader.getNumEventsRemaining() == 0) {
- break;
- }
- } catch (EvioException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- jobManager.finish();
- try {
- writer.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
+ CommandLineParser parser = new PosixParser();
+
+ // Parse command line arguments.
+ CommandLine cl = null;
+ try {
+ cl = parser.parse(options, args);
+ }
+ catch (ParseException e) {
+ throw new RuntimeException("Problem parsing command line options.", e);
+ }
+
+ // EVIO input file.
+ String evioFileName = cl.getOptionValue("e");
+ File evioFile = new File(evioFileName);
+
+ // LCIO output file.
+ String lcioFileName = cl.getOptionValue("l");
+ File lcioFile = new File(lcioFileName);
+
+ // Name of detector.
+ String detectorName = cl.getOptionValue("d");
+
+ // LCSim XML file to execute inline.
+ String lcsimXmlName = cl.getOptionValue("x");
+ File lcsimXmlFile = new File(lcsimXmlName);
+
+ // EVIO reader.
+ EvioReader reader = null;
+ try {
+ reader = new EvioReader(evioFile);
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ // LCIO writer.
+ LCIOWriter writer = null;
+ try {
+ writer = new LCIOWriter(lcioFile);
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ // LCSim job manager.
+ JobControlManager jobManager = new JobControlManager();
+ jobManager.setup(lcsimXmlFile);
+ jobManager.configure();
+
+ // LCSim event builder.
+ LCSimEventBuilder eventBuilder = new LCSimTestRunEventBuilder();
+ eventBuilder.setDetectorName(detectorName);
+
+ // Loop over EVIO events, build LCSim events, process them, and then
+ // write events to disk.
+ while (true) {
+ try {
+ EvioEvent evioEvent = reader.parseNextEvent();
+ EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent);
+ jobManager.processEvent(lcioEvent);
+ writer.write(lcioEvent);
+ if (reader.getNumEventsRemaining() == 0) {
+ break;
+ }
+ }
+ catch (EvioException e) {
+ throw new RuntimeException(e);
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ jobManager.finish();
+ try {
+ writer.close();
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
\ No newline at end of file