Commit in lcsim/src/org/lcsim/contrib/Cassell on MAIN
UIReconLoop.java+112added 1.1
"Production" type UI reconstruction loop

lcsim/src/org/lcsim/contrib/Cassell
UIReconLoop.java added at 1.1
diff -N UIReconLoop.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ UIReconLoop.java	25 Aug 2008 21:10:49 -0000	1.1
@@ -0,0 +1,112 @@
+/*
+ * 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.OutputUIRecon;
+import java.util.*;
+
+/**
+ *
+ * @author cassell
+ */
+public class UIReconLoop
+{
+    
+    /** Creates a new instance of PPRReconLoop */
+    public UIReconLoop()
+    {
+    }
+    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 += "_UI"+check;
+                File output = new File(outpath,outname);
+                Driver myDriver = new OutputUIRecon(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);
+            }
+        }
+    }
+    
+}
CVSspam 0.2.8