hps-java/src/main/resources/org/lcsim/hps/steering
diff -N TestRunCnv.lcsim
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestRunCnv.lcsim 12 Apr 2012 18:58:20 -0000 1.1
@@ -0,0 +1,17 @@
+<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
+ <execute>
+ <driver name="EventMarkerDriver"/>
+ <driver name="SVTSetupDriver"/>
+ <driver name="HPSSVTDAQMaps"/>
+ <driver name="SVTDataToRawTrackerHitDriver"/>
+ </execute>
+ <drivers>
+ <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
+ <eventInterval>1</eventInterval>
+ </driver>
+ <driver name="SVTSetupDriver" type="org.lcsim.hps.recon.tracking.HPSSVTSensorSetup"/>
+ <driver name="HPSSVTDAQMaps" type="org.lcsim.hps.recon.tracking.HPSSVTDAQMaps"/>
+ <driver name="SVTDataToRawTrackerHitDriver" type="org.lcsim.hps.recon.tracking.SVTDataToRawTrackerHitDriver"/>
+ </drivers>
+</lcsim>
hps-java/src/main/java/org/lcsim/hps/evio
diff -N TestRunEvioToLcio.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestRunEvioToLcio.java 12 Apr 2012 18:58:20 -0000 1.1
@@ -0,0 +1,143 @@
+package org.lcsim.hps.evio;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.EvioException;
+import org.jlab.coda.jevio.EvioReader;
+import org.lcsim.event.EventHeader;
+import org.lcsim.job.JobControlManager;
+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.
+ *
+ * To run this class from command line:
+ *
+ * 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]");
+ 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);
+ }
+ }
+}
\ No newline at end of file