Commit in lcsim/src/org/lcsim/mc/fast/frontend on MAIN | |||
Main.java | +49 | -42 | 1.1 -> 1.2 |
minor changes
diff -u -r1.1 -r1.2 --- Main.java 5 Feb 2013 23:15:09 -0000 1.1 +++ Main.java 6 Feb 2013 01:47:06 -0000 1.2 @@ -18,10 +18,9 @@
import org.lcsim.util.loop.LCSimLoop; /**
- * This is a reworked class from an old main program provided by Tim and Norman. - * The jet and vertex reconstruction was removed, so this now only runs the Fast MC - * and writes the output LCIO file. Analysis and reconstruction would be performed - * in a subsequent lcsim XML job.
+ * This is a reworked class from an old main program provided by Tim and Norman. The jet and vertex + * reconstruction was removed, so this now only runs the Fast MC and writes the output LCIO file. Analysis and + * reconstruction would be performed in a subsequent lcsim XML job.
* * @author Norman A. Graf * @author Jeremy McCormick
@@ -37,7 +36,7 @@
private static final boolean defaultSimple = true; private static final int defaultSeed = (new Random()).nextInt(); private static final boolean defaultDebug = false;
-
+
String inputFileName; String outputFileName; String detector;
@@ -48,41 +47,45 @@
boolean beamSpotConstraint; boolean simple; boolean debug;
-
+
private static Options options = null;
- - private Main() {
+ + private Main() + {
createOptions(); }
- - Options getOptions() {
+ + Options getOptions() + {
return options; }
- - void parse(String[] args) throws ParseException { -
+ + void parse(String[] args) + { +
// Create the parser and parse command line options. PosixParser parser = new PosixParser();
-
+
CommandLine cmd = null; try {
- cmd = parser.parse(options, args);
+ cmd = parser.parse(options, args);
} catch (ParseException x) { System.out.println("Parsing failed: " + x.getMessage()); usage(); }
-
+
// Set the parameters from the parsed command line.
- setParameters(cmd); -
+ setParameters(cmd); +
// Print out the parameters to System.out. printParameters(); }
- - private void setParameters(CommandLine cmd) {
+ + private void setParameters(CommandLine cmd) + {
inputFileName = cmd.getOptionValue("i"); if (inputFileName == null)
- usage();
+ usage();
outputFileName = cmd.getOptionValue("o", defaultOutputFileName); detector = cmd.getOptionValue("d", defaultDetector); numToProcess = Integer.valueOf(cmd.getOptionValue("r", String.valueOf(defaultNumProcess)));
@@ -90,11 +93,12 @@
seed = Integer.valueOf(cmd.getOptionValue("m", String.valueOf(defaultSeed))); refPoint000 = Boolean.valueOf(cmd.getOptionValue("p", String.valueOf(defaultRefPoint000))); beamSpotConstraint = Boolean.valueOf(cmd.getOptionValue("b", String.valueOf(defaultBeamSpotConstraint)));
- simple = Boolean.valueOf(cmd.getOptionValue("S", String.valueOf(defaultSimple)));
+ simple = Boolean.valueOf(cmd.getOptionValue("S", String.valueOf(defaultSimple)));
debug = Boolean.valueOf(cmd.getOptionValue("d", String.valueOf(defaultDebug))); }
- - private void printParameters() {
+ + private void printParameters() + {
System.out.println("Received the following command line parameters:"); System.out.println('\t' + "inputFileName = " + inputFileName); System.out.println('\t' + "outputFileName = " + outputFileName);
@@ -107,9 +111,10 @@
System.out.println('\t' + "simple mode = " + simple); System.out.println('\t' + "debug mode = " + debug); }
- - private void createOptions() { - options = new Options();
+ + private void createOptions() + { + options = new Options();
options.addOption("h", false, "print usage information"); options.addOption("i", true, "input file"); options.addOption("o", true, "output file name");
@@ -119,26 +124,26 @@
options.addOption("m", true, "random seed"); options.addOption("p", false, "use default ref point"); options.addOption("b", false, "use beam spot constraint");
- options.addOption("S", false, "use simple");
+ options.addOption("S", false, "use simple");
options.addOption("d", false, "print debug info"); }
-
+
private void usage()
- {
+ {
HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(getClass().getCanonicalName(), options); System.exit(1); }
-
+
private void error(String message) { System.out.println(message); System.exit(1); }
- - private void run() throws IOException, NoSuchRecordException { - - // Check existence of detector.
+ + private void run() throws IOException, NoSuchRecordException + { + // Check existence of detector.
Detector det = DetectorLocator.findDetector(detector); if (det == null) { error("Unknown detector: " + detector);
@@ -153,10 +158,9 @@
// Setup the LCIO output driver. LCIODriver writer = null; File output = new File(outputFileName);
- if(output.exists()) - {
+ if (output.exists()) {
throw new RuntimeException("Output file already exists!");
- }
+ }
writer = new LCIODriver(output); // Initialize Fast MC driver.
@@ -187,12 +191,15 @@
loop.dispose(); System.out.println(getClass().getSimpleName() + ": processed " + loop.getTotalSupplied() + " events"); }
- - - public static void main(String[] args) throws Exception
+ + public static void main(String[] args)
{ Main main = new Main(); main.parse(args);
- main.run();
+ try { + main.run(); + } catch (Exception 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