lcsim/src/org/lcsim/contrib/Cassell
diff -N UIReconLoopTrack.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ UIReconLoopTrack.java 21 Oct 2008 21:31:43 -0000 1.1
@@ -0,0 +1,111 @@
+/*
+ * UIReconLoop.java
+ *
+ * Created on August 25, 2008, 11:15 AM
+ *
+ * Run the UI reconstruction, and output a slcio file
+ * with the results. First argument is the output path. If the second argument
+ * is not a slcio file, the contents of the file are used as input files.
+ * Otherwise, that argument and all subsequent arguments are assumed to be
+ * input file names.
+ *
+ * Ron Cassell
+ */
+
+package org.lcsim.contrib.Cassell;
+import java.io.File;
+import org.lcsim.util.Driver;
+import org.lcsim.util.loop.LCIODriver;
+import org.lcsim.util.loop.LCSimLoop;
+import org.freehep.record.loop.LoopSourceExhaustedException;
+import org.lcsim.contrib.Cassell.recon.UI.OutputUIReconTrack;
+import java.util.*;
+
+/**
+ *
+ * @author cassell
+ */
+public class UIReconLoopTrack
+{
+
+ public UIReconLoopTrack()
+ {
+ }
+ public static void main(String[] args) throws Exception
+ {
+ if (args.length<2)
+ {
+ //usage();
+ System.exit(1);
+ }
+ else
+ {
+ List<File> filelist = new ArrayList<File>();
+ String outpath = args[0];
+ String in = args[1];
+ String check = ".slcio";
+ if(in.endsWith(check))
+ {
+ for(int i=1;i<args.length;i++)
+ {
+ File infile = new File(args[i]);
+ if(infile.exists())
+ {
+ filelist.add(infile);
+ }
+ else
+ {
+ throw new RuntimeException("File "+args[i]+" does not exist");
+ }
+ }
+ }
+ else
+ {
+ File infile = new File(in);
+ File[] files = infile.listFiles();
+ if(files == null)
+ {
+ System.out.println("File list usage not yet implemented");
+ System.exit(1);
+ }
+ else
+ {
+ for(int i=0;i<files.length;i++)
+ {
+ if(files[i].getName().endsWith(check))
+ {
+ if(files[i].exists())
+ {
+ filelist.add(files[i]);
+ }
+ }
+ }
+ }
+ }
+
+ for(File inf:filelist)
+ {
+ LCSimLoop loop = new LCSimLoop();
+ loop.setLCIORecordSource(inf);
+ String inname = inf.getName();
+ String outname = inname.substring(0, inname.lastIndexOf("."));
+ outname += "_UIT"+check;
+ File output = new File(outpath,outname);
+ Driver myDriver = new OutputUIReconTrack(output);
+ loop.add(myDriver);
+ long nevts = 0;
+ try
+ {
+ nevts = loop.loop(-1);
+ }
+ catch (LoopSourceExhaustedException x)
+ {
+ nevts = loop.getTotalCountableSupplied();
+ }
+ loop.dispose();
+ System.out.println("Processed "+nevts+"events from file "+inname);
+ }
+ }
+ }
+
+}