Print

Print


Commit in SlicDiagnostics on MAIN
RunnerTest.properties+14added 1.1
SlicDiagnosticsDriverTest.properties+14added 1.1
project.xml+2-21.8 -> 1.9
src/org/lcsim/slic/diagnostics/CleanupDriver.java+23added 1.1
                              /LayerInfoDriver.java+127added 1.1
                              /CalorimeterHitPlots.java+114-131.30 -> 1.31
                              /CommandLineProcessor.java+35-261.6 -> 1.7
                              /GenericHitPlots.java+26-451.36 -> 1.37
                              /Main.java+2-61.11 -> 1.12
                              /Runner.java+7-81.7 -> 1.8
                              /SlicDiagnosticsDriver.java+25-71.18 -> 1.19
                              /UserOptions.java+57-31.1 -> 1.2
test/org/lcsim/slic/diagnostics/RunnerTest.java+3-41.3 -> 1.4
                               /SlicDiagnosticsDriverTest.java+18-141.4 -> 1.5
+467-128
4 added + 10 modified, total 14 files
JM: Miscellaneous updates to SlicDiagnostics.

SlicDiagnostics
RunnerTest.properties added at 1.1
diff -N RunnerTest.properties
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ RunnerTest.properties	13 Oct 2006 07:07:16 -0000	1.1
@@ -0,0 +1,14 @@
+# Properties file for SlicDiagnostics
+genParticles: true
+simParticles: true
+cheatClusters: true
+clusterPlots: true
+particlePlots: true
+genericHitPlots: true
+trackerHitPlots: true
+calorimeterHitPlots: true
+eventNoticeInterval: 0
+maxEvents: 1
+verbosity: 1
+outputFile: RunnerTest
+enableAutoname: false

SlicDiagnostics
SlicDiagnosticsDriverTest.properties added at 1.1
diff -N SlicDiagnosticsDriverTest.properties
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SlicDiagnosticsDriverTest.properties	13 Oct 2006 07:07:16 -0000	1.1
@@ -0,0 +1,14 @@
+# Properties file for SlicDiagnostics
+genParticles: true
+simParticles: true
+cheatClusters: true
+clusterPlots: true
+particlePlots: true
+genericHitPlots: true
+trackerHitPlots: true
+calorimeterHitPlots: true
+eventNoticeInterval: 1
+maxEvents: 1
+verbosity: 4
+enableAutoname: true
+#outputFile: SlicDiagnosticsDriverTestPlots

SlicDiagnostics
project.xml 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- project.xml	1 Mar 2006 00:31:07 -0000	1.8
+++ project.xml	13 Oct 2006 07:07:15 -0000	1.9
@@ -23,7 +23,7 @@
     <dependency>
       <groupId>lcsim</groupId>
       <artifactId>lcsim</artifactId>
-      <version>1.0</version>
+      <version>1.1</version>
       <url>http://www.lcsim.org</url>
     </dependency>
     <dependency>
@@ -113,7 +113,7 @@
     <dependency>
       <groupId>lcsim</groupId>
       <artifactId>GeomConverter</artifactId>
-      <version>1.0</version>
+      <version>1.1</version>
       <url>http://www.lcsim.org</url>
       <properties>
 	<jas3.bundle>true</jas3.bundle>

SlicDiagnostics/src/org/lcsim/slic/diagnostics
CleanupDriver.java added at 1.1
diff -N CleanupDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CleanupDriver.java	13 Oct 2006 07:07:25 -0000	1.1
@@ -0,0 +1,23 @@
+package org.lcsim.slic.diagnostics;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+
+/**
+ * Driver to be called last in event/run processing
+ * to cleanup and reset SlicDiagnostics data.
+ *  
+ * @author jeremym
+ */
+public class CleanupDriver extends Driver
+{
+	protected void process(EventHeader event)
+	{
+		LayerInfoDriver.resetEvent();
+	}
+		
+    protected void endEvents(int nevents)
+    {
+    	LayerInfoDriver.resetEndData();
+    }
+}
\ No newline at end of file

SlicDiagnostics/src/org/lcsim/slic/diagnostics
LayerInfoDriver.java added at 1.1
diff -N LayerInfoDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ LayerInfoDriver.java	13 Oct 2006 07:07:25 -0000	1.1
@@ -0,0 +1,127 @@
+package org.lcsim.slic.diagnostics;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.Layered;
+import org.lcsim.geometry.Subdetector;
+import org.lcsim.geometry.layer.Layer;
+import org.lcsim.util.Driver;
+
+public class LayerInfoDriver extends Driver
+{
+	// Map of layer number to LayerInfo
+	private static Map<Subdetector,Map<Integer, LayerInfo>> subdetLayerMap = null;
+	Detector detector = null;
+	
+	LayerInfoDriver()
+	{
+		//System.out.println("LayerInfoDriver");
+	}
+
+	protected void process(EventHeader event)
+	{
+		// If first time processing or new detector.
+		if (detector == null || event.getDetector() != detector)
+		{
+			//System.out.println("building layerinfo...");
+			
+			detector = event.getDetector();
+			
+			subdetLayerMap = new HashMap<Subdetector,Map<Integer, LayerInfo>>();
+			
+			Detector detector = event.getDetector();
+			
+			for (Subdetector subdet : detector.getSubdetectors().values())
+			{
+				if (subdet.isCalorimeter() || subdet.isTracker())
+				{
+					makeLayerInfo(subdet);
+				}
+			}
+		}
+	}
+	
+	private void makeLayerInfo(Subdetector subdet)
+	{
+		//System.out.println(subdet.getName() + " building layerinfo...");
+		Layered l = (Layered) subdet;
+		int nlayers = l.getLayering().getNumberOfLayers();
+		Map<Integer,LayerInfo> layerMap = new LinkedHashMap<Integer,LayerInfo>();
+		for (int i = 0; i < nlayers; i++)
+		{
+			//System.out.println("layer " + i);
+			
+			LayerInfo info = new LayerInfo(i);
+
+			Layer layer = l.getLayering().getLayer(i);
+			int sens = layer.indexOfFirstSensor();
+
+			//System.out.println("sesn " + sens);
+			
+			if (sens >= 0)
+			{
+				double sensThick = layer.getSlice(sens).getThickness();
+				double tosens = layer.getThicknessToSensitive();
+				double offset = l.getLayering().getDistanceToLayer(i);
+				double ir = offset + tosens;
+				double or = ir + sensThick;
+
+				info.setSensorInnerRadius(ir);
+				info.setSensorOuterRadius(or);
+			
+				layerMap.put(Integer.valueOf(i),info);
+			}
+		}				
+		
+		if (layerMap.values().size() != 0)
+		{
+			subdetLayerMap.put(subdet,layerMap);
+		}
+		//else {
+		//	System.out.println(subdet.getName() + " failed to build layerMap");
+		//}
+	}
+
+	static Map<Subdetector, Map<Integer,LayerInfo>> getSubdetectorLayerInfoMap()
+	{
+		return subdetLayerMap;
+	}
+	
+	static Map<Integer,LayerInfo> getLayerMap(Subdetector subdet)
+	{
+		return subdetLayerMap.get(subdet);
+	}
+	
+    /** 
+     * Reset the LayerInfo objects after event processing 
+     */
+    static void resetEvent()
+    {
+    	for ( Map<Integer,LayerInfo> layerMap : subdetLayerMap.values())
+    	{
+    		for (LayerInfo layerInfo : layerMap.values())
+    		{
+    			layerInfo.resetEvent();
+    		}
+    	}
+    }
+    
+    /**
+     * Reset the LayerInfo objects after done with this set of files.
+     */
+    static void resetEndData()
+    {
+    	for ( Map<Integer,LayerInfo> layerMap : subdetLayerMap.values())
+    	{
+    		for (LayerInfo layerInfo : layerMap.values())
+    		{
+    			layerInfo.resetEndData();
+    		}
+    	}
+    	
+    }
+}
\ No newline at end of file

SlicDiagnostics/src/org/lcsim/slic/diagnostics
CalorimeterHitPlots.java 1.30 -> 1.31
diff -u -r1.30 -r1.31
--- CalorimeterHitPlots.java	6 Jul 2006 01:09:22 -0000	1.30
+++ CalorimeterHitPlots.java	13 Oct 2006 07:07:19 -0000	1.31
@@ -1,19 +1,18 @@
 package org.lcsim.slic.diagnostics;
 
+import static java.lang.Math.log10;
 import hep.aida.ICloud1D;
 import hep.aida.ICloud2D;
 
 import java.util.List;
 
-import static java.lang.Math.log10;
-
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.MCParticle;
 import org.lcsim.event.SimCalorimeterHit;
 import org.lcsim.event.EventHeader.LCMetaData;
-import org.lcsim.geometry.CalorimeterIDDecoder;
 import org.lcsim.geometry.IDDecoder;
 import org.lcsim.geometry.Subdetector;
+import org.lcsim.geometry.compact.Segmentation;
 import org.lcsim.geometry.segmentation.GridXYZ;
 import org.lcsim.geometry.segmentation.NonprojectiveCylinder;
 import org.lcsim.geometry.segmentation.ProjectiveCylinder;
@@ -27,7 +26,7 @@
  * collections of SimCalorimeterHits are done by GenericHitPlots.
  * 
  * @author jeremym
- * @version $Id: CalorimeterHitPlots.java,v 1.30 2006/07/06 01:09:22 jeremy Exp $
+ * @version $Id: CalorimeterHitPlots.java,v 1.31 2006/10/13 07:07:19 jeremy Exp $
  */
 class CalorimeterHitPlots extends AbstractPlots
 {
@@ -178,8 +177,7 @@
 
         if (hits.size() > 0)
         {
-            CalorimeterIDDecoder segmentation = (CalorimeterIDDecoder) getEventHeader().getMetaData(hits)
-                    .getIDDecoder();
+            Segmentation segmentation = (Segmentation) getEventHeader().getMetaData(hits).getIDDecoder();
             int mcpMissingCount = 0;
             for (SimCalorimeterHit hit : hits)
             {
@@ -191,7 +189,7 @@
                     mcpMissingCount += 1;
                 }
 
-                // Plot the segmentation plots
+                // Plot the segmentation plots.
                 if (_segmentationPlots != null)
                 {
                     _segmentationPlots.fill(segmentation);
@@ -248,7 +246,12 @@
             this.plots = plots;
         }
 
-        abstract public void fill(CalorimeterIDDecoder segmentation);
+        protected LayerInfo getLayerInfo(IDDecoder id)
+        {
+        	return LayerInfoDriver.getLayerMap(id.getSubdetector()).get(id.getLayer()); 
+        }
+        
+        abstract public void fill(Segmentation segmentation);
     }
 
     public class ProjectivePlots extends SegmentationPlots
@@ -258,7 +261,7 @@
             super(plots);
         }
 
-        public void fill(CalorimeterIDDecoder segmentation)
+        public void fill(Segmentation segmentation)
         {
             cd();
 
@@ -271,6 +274,34 @@
 
             // Plot phi bin vs theta bin
             aida().cloud2D("Hit: Phi Bin vs Theta Bin").fill((double) segmentation.getValue("phi"),
+                    (double) segmentation.getValue("theta"));                       
+
+            //
+            // === Layer Plots ===
+            //
+
+            // Get layering information for this hit.            
+            LayerInfo layerInfo = getLayerInfo(segmentation);
+            
+            // Change into layer plots directory.
+            cd(layerInfo.getDirName());
+            
+            // Get name of layer for plots.
+            String layerName = layerInfo.getTitleName();
+
+            // Phi Bin vs Theta Bin for this layer.
+            aida().cloud2D(layerName + ": Hit: Phi Bin vs Theta Bin").fill((double) segmentation.getValue("phi"),
+                    (double) segmentation.getValue("theta"));
+            
+            // Plot phi vs phi bin for this layer.
+            aida().cloud2D(layerName + ": Hit: Phi vs Phi Bin").fill(segmentation.getPhi(), (double) segmentation.getValue("phi"));
+
+            // Plot theta vs theta bin  for this layer.
+            aida().cloud2D(layerName + ": Hit: Theta vs Theta Bin").fill(segmentation.getTheta(),
+                    (double) segmentation.getValue("theta"));
+
+            // Plot phi bin vs theta bin for this layer.
+            aida().cloud2D(layerName + ": Hit: Phi Bin vs Theta Bin").fill((double) segmentation.getValue("phi"),
                     (double) segmentation.getValue("theta"));
         }
     }
@@ -282,9 +313,8 @@
             super(plots);
         }
 
-        public void fill(CalorimeterIDDecoder segmentation)
+        public void fill(Segmentation segmentation)
         {
-
             // Plot phi vs phi bin
             aida().cloud2D("Hit: Phi vs Phi Bin").fill(segmentation.getPhi(), (double) segmentation.getValue("phi"));
 
@@ -294,6 +324,30 @@
             // Plot phi bin vs Z bin
             aida().cloud2D("Hit: Phi Bin vs Z Bin").fill((double) segmentation.getValue("phi"),
                     (double) segmentation.getValue("z"));
+            
+            //
+            // === Layer Plots ===
+            //
+
+            // Get layering information for this hit.            
+            LayerInfo layerInfo = getLayerInfo(segmentation);
+            
+            // Change into layer plots directory.
+            cd(layerInfo.getDirName());
+            
+            // Get name of layer for plots.
+            String layerName = layerInfo.getTitleName();
+            
+            // Plot phi vs phi bin
+            aida().cloud2D(layerName + ": Hit: Phi vs Phi Bin").fill(segmentation.getPhi(), (double) segmentation.getValue("phi"));
+
+            // Plot Z vs Z bin
+            aida().cloud2D(layerName + ": Hit: Z vs Z Bin").fill(segmentation.getZ(), (double) segmentation.getValue("z"));
+
+            // Plot phi bin vs Z bin
+            aida().cloud2D(layerName + ": Hit: Phi Bin vs Z Bin").fill((double) segmentation.getValue("phi"),
+                    (double) segmentation.getValue("z"));
+            
         }
     }
 
@@ -304,7 +358,7 @@
             super(plots);
         }
 
-        public void fill(CalorimeterIDDecoder segmentation)
+        public void fill(Segmentation segmentation)
         {
             // Plot X vs X bin
             aida().cloud2D("Hit: X vs X Bin").fill(segmentation.getX(), (double) segmentation.getValue("x"));
@@ -315,6 +369,30 @@
             // Plot X bin vs Y bin
             aida().cloud2D("Hit: X Bin vs Y Bin").fill((double) segmentation.getValue("x"),
                     (double) segmentation.getValue("y"));
+            
+            //
+            // === Layer Plots ===
+            //
+
+            // Get layering information for this hit.            
+            LayerInfo layerInfo = getLayerInfo(segmentation);
+            
+            // Change into layer plots directory.
+            cd(layerInfo.getDirName());
+            
+            // Get name of layer for plots.
+            String layerName = layerInfo.getTitleName();
+            
+            // Plot X vs X bin
+            aida().cloud2D(layerName + ": Hit: X vs X Bin").fill(segmentation.getX(), (double) segmentation.getValue("x"));
+
+            // Plot Y vs Y bin
+            aida().cloud2D(layerName + ": Hit: Y vs Y Bin").fill(segmentation.getZ(), (double) segmentation.getValue("y"));
+
+            // Plot X bin vs Y bin
+            aida().cloud2D(layerName + ": Hit: X Bin vs Y Bin").fill((double) segmentation.getValue("x"),
+                    (double) segmentation.getValue("y"));
+            
         }
     }
 
@@ -325,7 +403,7 @@
             super(plots);
         }
 
-        public void fill(CalorimeterIDDecoder segmentation)
+        public void fill(Segmentation segmentation)
         {
             // Plot X vs X bin
             aida().cloud2D("Hit: X vs X Bin").fill(segmentation.getX(), (double) segmentation.getValue("x"));
@@ -336,6 +414,29 @@
             // Plot X bin vs Z bin
             aida().cloud2D("Hit: X Bin vs Z Bin").fill((double) segmentation.getValue("x"),
                     (double) segmentation.getValue("z"));
+            
+            //
+            // === Layer Plots ===
+            //
+
+            // Get layering information for this hit.            
+            LayerInfo layerInfo = getLayerInfo(segmentation);
+            
+            // Change into layer plots directory.
+            cd(layerInfo.getDirName());
+            
+            // Get name of layer for plots.
+            String layerName = layerInfo.getTitleName();
+            
+            // Plot X vs X bin
+            aida().cloud2D(layerName + ": Hit: X vs X Bin").fill(segmentation.getX(), (double) segmentation.getValue("x"));
+
+            // Plot Z vs Z bin
+            aida().cloud2D(layerName + ": Hit: Z vs Z Bin").fill(segmentation.getZ(), (double) segmentation.getValue("z"));
+
+            // Plot X bin vs Z bin
+            aida().cloud2D(layerName + ": Hit: X Bin vs Z Bin").fill((double) segmentation.getValue("x"),
+                    (double) segmentation.getValue("z"));                     
         }
     }
 }

SlicDiagnostics/src/org/lcsim/slic/diagnostics
CommandLineProcessor.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- CommandLineProcessor.java	30 Mar 2006 01:09:44 -0000	1.6
+++ CommandLineProcessor.java	13 Oct 2006 07:07:19 -0000	1.7
@@ -28,7 +28,7 @@
  * Main.
  * 
  * @author Jeremy McCormick
- * @version $Id: CommandLineProcessor.java,v 1.6 2006/03/30 01:09:44 jeremy Exp $
+ * @version $Id: CommandLineProcessor.java,v 1.7 2006/10/13 07:07:19 jeremy Exp $
  */
 public class CommandLineProcessor
 {
@@ -37,7 +37,7 @@
     private Properties _properties = new Properties();
     private UserOptions _userOptions = null;
     private List<File> _infiles = new ArrayList<File>();
-    private File _outfile = null;
+    //private File _outfile = null;
     int _verbosity = 0;
 
     /** Create a CommandLineProcessor where parse will be called later. */
@@ -82,6 +82,9 @@
         opt = new Option("o", false, "set the output file name");
         opt.setArgs(1);
         _options.addOption(opt);
+        
+        opt = new Option("O", false, "automatically name output files");
+        _options.addOption(opt);
 
         opt = new Option("h", false, "print usage");
         _options.addOption(opt);
@@ -121,19 +124,11 @@
         {            
             String propFilename = cl.getOptionValue("p");
             
-            FileInputStream propFile = null;
-            try {
-                propFile = new FileInputStream(propFilename);
-                _properties.load(propFile);
-            }
-            catch (Exception e)
-            {
-                throw new RuntimeException("An error occured processing the properties file " + propFilename + ".", e);
-            }
-            
-            _userOptions = new UserOptions(_properties);            
+            // Create the UserOptions from input properties file.
+            _userOptions  = new UserOptions(propFilename);
         }
         else {
+        	// Create default UserOptions.
             _userOptions = new UserOptions();
         }
         
@@ -276,21 +271,35 @@
             printUsage(true);
         }
 
-        // Name the output file
+        // === Name the output file ==
+                
+        // Output file from command-line.
         if (cl.hasOption("o"))
         {
-            _outfile = new File(cl.getOptionValue("o"));
-        }
-        // Or autoname the output file
-        else
-        {
-            String outfile = _infiles.get(0).toString().replace(".slcio", "");
-            _outfile = new File(outfile);
+        	System.out.println("filename from command line");
+        	
+        	// Override possible UserOption setting.
+        	_userOptions.setStringOption("outputFile",cl.getOptionValue("o"));
+        }        
+        // Output file is autonamed.
+        else 
+        {
+        	if (cl.hasOption("-O") || _userOptions.getBooleanOption("enableAutoname"))
+        	{
+        		System.out.println("filename from autoname");
+        		
+        		// Override possible UserOption setting.
+        		_userOptions.setStringOption("outputFile", _infiles.get(0).toString().replace(".slcio", ""));
+        	}
         }
+        
+        // If neither of above 2 are selected for output filename,
+        // the user's outputFile option is kept or the default,
+        // e.g. hard-coded, filename is used.
 
         if (_verbosity > 0)
         {
-            System.out.println("outputFile=" + _outfile.getAbsoluteFile());
+            System.out.println("outputFile=" + _userOptions.getStringOption("outputFile"));
             
             for (File file : _infiles)
             {
@@ -306,10 +315,10 @@
     }
 
     /** Get the output file name. */
-    public File getOutputFile()
-    {
-        return _outfile;
-    }
+    //public File getOutputFile()
+    //{
+    //    return _outfile;
+    //}
 
     /** Get the verbosity. */
     public int verbosity()

SlicDiagnostics/src/org/lcsim/slic/diagnostics
GenericHitPlots.java 1.36 -> 1.37
diff -u -r1.36 -r1.37
--- GenericHitPlots.java	11 Apr 2006 21:53:05 -0000	1.36
+++ GenericHitPlots.java	13 Oct 2006 07:07:20 -0000	1.37
@@ -24,7 +24,7 @@
  * creates a set of plots for each layer in the subdetector.
  * 
  * @author jeremym
- * @version $Id: GenericHitPlots.java,v 1.36 2006/04/11 21:53:05 jeremy Exp $
+ * @version $Id: GenericHitPlots.java,v 1.37 2006/10/13 07:07:20 jeremy Exp $
  */
 class GenericHitPlots extends AbstractPlots
 {
@@ -88,6 +88,8 @@
 
     Subdetector _detector;
 
+    Map<Integer,LayerInfo> layerMap = null;
+    
     protected void definePlots()
     {
         super.definePlots();
@@ -319,30 +321,23 @@
         _maxTime.annotation().addItem("yAxisLabel", "Number of Events");
     }
 
-    private void makeLayers()
-    {
-        Layered l = (Layered) _detector;
+    private void setupLayerPlots()
+    {    	
+    	this.layerMap = LayerInfoDriver.getLayerMap(_detector);
+    	
+    	if (layerMap == null)
+    	{
+    		throw new RuntimeException(_detector.getName() + "'s layerMap is null!");
+    	}
+    	
         for (int i = 0; i < _nlayers; i++)
         {
-            LayerInfo info = new LayerInfo(i);
-
-            Layer layer = l.getLayering().getLayer(i);
-            int sens = layer.findIndexOfFirstSensitiveSlice();
-            double sensThick = layer.getSlice(sens).getThickness();
-            double tosens = layer.getThicknessToSensitive();
-            double offset = l.getLayering().getDistanceToLayer(i);
-            double ir = offset + tosens;
-            double or = ir + sensThick;
-
-            info.setSensorInnerRadius(ir);
-            info.setSensorOuterRadius(or);
-
-            _layers.put(i, info);
+        	LayerInfo info = layerMap.get(Integer.valueOf(i));        	       
 
             String layerName = info.getTitleName();
             String dirName = info.getDirName();
 
-            // Make directory for layer plots.
+            // Make directory for GenericHit layer plots.
             cd();
             try
             {
@@ -418,7 +413,7 @@
     List<GenericHit> _hits;
 
     // Map of layer number to LayerInfo
-    Map<Integer, LayerInfo> _layers = new LinkedHashMap<Integer, LayerInfo>();
+    //Map<Integer, LayerInfo> _layers = new LinkedHashMap<Integer, LayerInfo>();
 
     // Type of hits, i.e. SimCalorimeterHit or SimTrackerHit
     GenericHit.HitType _hitType = null;
@@ -450,7 +445,7 @@
         _nlayers = ((Layered) _detector).getLayering().getLayerCount();
 
         // Make a LayerInfo for each layer and do layer plot definitions
-        makeLayers();
+        setupLayerPlots();
 
         // Define the plots
         definePlots();
@@ -517,8 +512,8 @@
             double sphR = hit.getSphericalRadius();
 
             // Lookup the LayerInfo from this hit's layer number
-            LayerInfo layerInfo = _layers.get(layern);
-
+            LayerInfo layerInfo = layerMap.get(Integer.valueOf(layern));
+            
             // Fill hit depth
             _hitDepth.fill(cylR - layerInfo.getSensorInnerRadius());
 
@@ -582,7 +577,7 @@
             aida().cloud1D(layerName + ": Hit Time").fill(time);
 
             // Fill log10 layer time
-            aida().cloud1D(layerName + ": log10(Hit Time)").fill(log10(time));
+            aida().cloud1D(layerName + ": log10(Hit Time)").fill(log10(time));                        
 
             // Leave layer dir
             cd();
@@ -747,9 +742,9 @@
 
         // Cumulative layer E
         double cume = 0;
-
+        
         // Loop over the layers after hits are processed
-        for (LayerInfo layerInfo : _layers.values())
+        for (LayerInfo layerInfo : layerMap.values())
         {
             // Layer info into local vars
             String layerName = layerInfo.getTitleName();
@@ -885,18 +880,6 @@
 
         // Increment total energy
         _totalAvgEnergy += eventTotE;
-
-        // Reset layer event data
-        resetLayers();
-    }
-
-    /** Reset the LayerInfo objects after event processing */
-    private void resetLayers()
-    {
-        for (LayerInfo layerInfo : _layers.values())
-        {
-            layerInfo.resetEvent();
-        }
     }
 
     /** Do end of events processing */
@@ -910,20 +893,18 @@
 
         // Scale cum N hits
         _layerCumNHits.scale(scale);
-
-        // Make layer plots
+        
+        // Make layer plots for end run.
         for (int i = 0; i < _nlayers; i++)
         {
-            LayerInfo layer = _layers.get(i);
+        	// Get the LayerInfo for this layer.
+            LayerInfo layer = layerMap.get(Integer.valueOf(i));
 
             // Fill average total energy in the layer for nevents
             _layerAvgTotE.fill(i, layer.getAverageTotalEnergy(nevents));
 
             // Fill average n hits in the layer for nevents
             _layerAvgTotNHits.fill(i, layer.getAverageTotalNHits(nevents));
-
-            // Reset LayerInfo objects after all events
-            layer.resetEndData();
         }
     }
-}
+}
\ No newline at end of file

SlicDiagnostics/src/org/lcsim/slic/diagnostics
Main.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- Main.java	16 Mar 2006 02:36:45 -0000	1.11
+++ Main.java	13 Oct 2006 07:07:21 -0000	1.12
@@ -5,7 +5,7 @@
  * SlicDiagnostics command-line job.
  * 
  * @author jeremym
- * @version $Id: Main.java,v 1.11 2006/03/16 02:36:45 jeremy Exp $
+ * @version $Id: Main.java,v 1.12 2006/10/13 07:07:21 jeremy Exp $
  */
 public class Main
 {
@@ -19,11 +19,7 @@
         try
         {
             CommandLineProcessor cl = new CommandLineProcessor(args);                       
-            Runner.run(
-                    cl.getInputFileList(), 
-                    cl.getOutputFile(),
-                    cl.getUserOptions()
-                    );
+            Runner.run(cl.getInputFileList(), cl.getUserOptions());
         }
         catch (Exception e)
         {

SlicDiagnostics/src/org/lcsim/slic/diagnostics
Runner.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- Runner.java	16 Mar 2006 02:34:01 -0000	1.7
+++ Runner.java	13 Oct 2006 07:07:23 -0000	1.8
@@ -10,25 +10,24 @@
  * by using LCIOEventSource and LCSimLoop.
  *
  * @author jeremym
- * @version $Id: Runner.java,v 1.7 2006/03/16 02:34:01 jeremy Exp $
+ * @version $Id: Runner.java,v 1.8 2006/10/13 07:07:23 jeremy Exp $
  */
 public class Runner
 {    
     /** Run on list of files with defaults for other args. */
     public static void run(List<File> files) throws Exception
     {        
-        String outfile = files.get(0).toString().replace(".slcio","");
-        run(files, new File(outfile), new UserOptions());
+        run(files, new UserOptions());
     }
     
     /** Run on list files with all args. */
-    public static void run(List<File> files, File outfile, UserOptions options) throws Exception
+    public static void run(List<File> files, UserOptions options) throws Exception
     {           
         // New driver
         SlicDiagnosticsDriver driver = new SlicDiagnosticsDriver(options);
               
-        // Set name of output AIDA file
-        driver.setAidaFileName(outfile.toString());
+        // Set name of output AIDA file.
+        driver.setAidaFileName(options.getStringOption("outputFile").toString());
                                         
         // Create a new record source with the list of files
         LCIOEventSource src = new LCIOEventSource("SlicDiagnostics", files);               
@@ -51,12 +50,12 @@
                 
         try
         {
-            // Set the max number of events in the event loop
+            // Set the max number of events in the event loop.
             loop.loop(maxevents);     
         }
         catch (org.freehep.record.loop.NoLoopRecordException nlre)
         {
-            // Ignore this exception 
+        	// Ignore this exception. 
         }
         catch (Exception e)
         {

SlicDiagnostics/src/org/lcsim/slic/diagnostics
SlicDiagnosticsDriver.java 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- SlicDiagnosticsDriver.java	16 Mar 2006 02:34:01 -0000	1.18
+++ SlicDiagnosticsDriver.java	13 Oct 2006 07:07:24 -0000	1.19
@@ -1,10 +1,10 @@
 package org.lcsim.slic.diagnostics;
 
 import hep.aida.IPlotter;
-import hep.aida.ITree;
+//import hep.aida.ITree;
 
 import java.io.File;
-import java.util.Properties;
+//import java.util.Properties;
 
 import org.freehep.application.Application;
 import org.freehep.application.studio.Studio;
@@ -27,9 +27,9 @@
 {
     private UserOptions _options = null;
     private static AIDA _aida = AIDA.defaultInstance();
-    private static ITree _tree = _aida.tree();
+    //private static ITree _tree = _aida.tree();
     private String _fileName = null;    
-    private static final String _defaultFileName = "SlicDiagnostics";    
+    private static final String _defaultFileName = "SlicDiagnosticsPlots";    
     private EventHeader _currentEvent = null;    
     private int _verbosity = 0;
     private int _evtCnt = 0;
@@ -58,7 +58,18 @@
                 
         // Set event notice interval
         setEventNoticeInterval(_options.getIntegerOption("eventNoticeInterval"));        
-    }
+        
+        // Set name of output file if found in options and autonaming is disabled.
+        if (_options.getBooleanOption("enableAutoname") == false)
+        {
+        	if (_options.getStringOption("outputFile") != null)
+        	{
+        		_fileName = _options.getStringOption("outputFile");
+        	}
+        }
+     }
+    
+    //_infiles.get(0).toString().replace(".slcio", "")
 
     private void addDefaultSubdrivers()
     {
@@ -66,6 +77,9 @@
         {
             message(this.getClass().getSimpleName() + " is loaded.");
         }
+
+        // Always add the layer info driver.
+        add(new LayerInfoDriver());
         
         // Create gen FS particle list.
         if (_options.getBooleanOption("genParticles"))
@@ -115,10 +129,12 @@
             add(new ClusterPlotsDriver(this));
         }
         
-        if (drivers().size() == 0)
+        if (drivers().size() <= 1)
         {
-            System.err.println("WARNING: SlicDiagnosticsDriver was not initialized with any subdrivers.");
+            System.err.println("WARNING: SlicDiagnosticsDriver was not initialized with any plotting subdrivers.");
         }        
+        
+        add(new CleanupDriver());
     }
 
     protected void process(EventHeader event)
@@ -198,6 +214,8 @@
                             s = s.substring(slashPos);
                         }
 
+                        System.out.println("autoname studio");
+                        
                         setAidaFileName(s);
                     }
                 }

SlicDiagnostics/src/org/lcsim/slic/diagnostics
UserOptions.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- UserOptions.java	16 Mar 2006 02:34:01 -0000	1.1
+++ UserOptions.java	13 Oct 2006 07:07:25 -0000	1.2
@@ -1,5 +1,6 @@
 package org.lcsim.slic.diagnostics;
 
+import java.io.FileInputStream;
 import java.util.Properties;
 import java.util.Map;
 import java.util.HashMap;
@@ -9,15 +10,17 @@
  * Represents simple options set from properties file or command-line.
  * 
  * @author Jeremy McCormick
- * @version $Id: UserOptions.java,v 1.1 2006/03/16 02:34:01 jeremy Exp $
+ * @version $Id: UserOptions.java,v 1.2 2006/10/13 07:07:25 jeremy Exp $
  */
 public final class UserOptions
 {    
     Map<String, Boolean> _booleanOptions = new HashMap<String, Boolean>();
     Map<String, Integer> _integerOptions = new HashMap<String, Integer>();    
+    Map<String, String> _stringOptions = new HashMap<String, String>();
     
-    Properties _properties = null;
+    Properties _properties = new Properties();
 
+    // Set from loaded properties object.
     UserOptions(Properties prop)
     {
         _properties = prop;
@@ -25,12 +28,34 @@
         parse(prop);
     }
     
+    // Can be used to set options manually.
     UserOptions()
     {
-        _properties = new Properties();
         setDefaultOptions();
     }
     
+    // Set options from file.
+    UserOptions(String filename)
+    {
+    	System.out.println("useroptions from file " + filename);
+    	
+    	_properties = new Properties();
+    	
+    	setDefaultOptions();
+    	
+        FileInputStream propFile = null;
+        try {
+            propFile = new FileInputStream(filename);
+            _properties.load(propFile);
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("An error occured processing the properties file " + filename + ".", e);
+        }
+        
+        parse(_properties);
+    }        
+    
     public boolean getBooleanOption(String k)
     {
         return _booleanOptions.get(k);
@@ -41,6 +66,11 @@
         return _integerOptions.get(k);
     }
     
+    public String getStringOption(String k)
+    {
+    	return _stringOptions.get(k);
+    }
+    
     public void setBooleanOption(String k, boolean b)
     {        
         _booleanOptions.put(k, b);
@@ -50,6 +80,11 @@
     {        
         _integerOptions.put(k, i);
     }
+    
+    public void setStringOption(String k, String s)
+    {
+    	_stringOptions.put(k, s);
+    }
         
     private void setDefaultOptions()
     {
@@ -64,10 +99,15 @@
         setBooleanOption("genericHitPlots", true);
         setBooleanOption("eventPlots", true);
         
+        setBooleanOption("enableAutoname", true);
+        
         // int options
         setIntegerOption("eventNoticeInterval", 100);
         setIntegerOption("verbosity", 0);
         setIntegerOption("maxEvents", -1);
+        
+        // String options
+        setStringOption("outputFile","SlicDiagPlots");
     }
     
     private void parse(Properties prop)
@@ -82,11 +122,16 @@
         parseBooleanOption("calorimeterHitPlots");
         parseBooleanOption("genericHitPlots");
         parseBooleanOption("eventPlots");
+     
+        parseBooleanOption("enableAutoname");
         
         // int options
         parseIntegerOption("eventNoticeInterval");
         parseIntegerOption("verbosity");
         parseIntegerOption("maxEvents");
+        
+        // String options.
+        parseStringOption("outputFile");
     }
 
     private void parseBooleanOption(String k)
@@ -107,6 +152,15 @@
         }
     }
     
+    private void parseStringOption(String k)
+    {
+        String s = _properties.getProperty(k);        
+        if (s != null)
+        {            
+            setStringOption(k, s);
+        }
+    }
+    
     public String toString()
     {
         StringBuffer sb = new StringBuffer();

SlicDiagnostics/test/org/lcsim/slic/diagnostics
RunnerTest.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- RunnerTest.java	17 Feb 2006 01:26:34 -0000	1.3
+++ RunnerTest.java	13 Oct 2006 07:07:41 -0000	1.4
@@ -42,9 +42,8 @@
         ArrayList<File> files = new ArrayList<File>();
         files.add(file);
         
-        Runner runner = new Runner();
-        //runner.addFile(file.toString());
-        runner.run(files);  
-        runner = null;
+        UserOptions options = new UserOptions("RunnerTest.properties");
+        System.out.println("RunnerTest - outputFile " + options.getStringOption("outputFile"));
+        Runner.run(files,new UserOptions("RunnerTest.properties"));
     }
 }
\ No newline at end of file

SlicDiagnostics/test/org/lcsim/slic/diagnostics
SlicDiagnosticsDriverTest.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- SlicDiagnosticsDriverTest.java	29 Sep 2005 21:08:31 -0000	1.4
+++ SlicDiagnosticsDriverTest.java	13 Oct 2006 07:07:42 -0000	1.5
@@ -1,8 +1,9 @@
 package org.lcsim.slic.diagnostics;
 
+import org.lcsim.recon.cluster.nn.NearestNeighborClusterDriver;
+
 import java.io.File;
 import java.net.URL;
-import org.lcsim.event.EventHeader;
 import org.lcsim.util.cache.FileCache;
 import org.lcsim.util.loop.LCSimLoop;
 
@@ -12,34 +13,37 @@
 
 /**
  *
+ * Test the SlicDiagnosticsDriver.
+ *
  * @author jeremym
  */
 public class SlicDiagnosticsDriverTest extends TestCase
-{
-    private int recordCount = 0;
-        
+{        
     private void runTestFile(String s) throws Exception
     {
         System.out.println("Running SlicDiagnosticsTest on file: " + s);
         
+        // Get a test file from lcsim.org website.
         URL url = new URL(s);
         FileCache cache = new FileCache();
         File file = cache.getCachedFile(url);
-        
-        recordCount = 0;
+       
+        // Setup the record loop.
         LCSimLoop loop = new LCSimLoop();
-        loop.setLCIORecordSource(file);
+        loop.setLCIORecordSource(file);       
         
-        SlicDiagnosticsDriver slicDiag = new SlicDiagnosticsDriver();
-        slicDiag.setAidaFileName("SlicDiagnosticsDriverTest");
+        // Set UserOptions from test.properties options file.
+        UserOptions options = new UserOptions("SlicDiagnosticsDriverTest.properties");
+
+        // Add some clusters to the event.
+        loop.add(new NearestNeighborClusterDriver(5));
         
-        slicDiag.add(new CalorimeterHitPlotsDriver(slicDiag));
-        slicDiag.add(new EventSummaryPlotsDriver(slicDiag));
-        slicDiag.add(new MCParticlePlotsDriver(slicDiag));
-        slicDiag.add(new GenericHitPlotsDriver(slicDiag));                
+        // Setup SlicDiagnostics driver with options.
+        SlicDiagnosticsDriver slicDiag = new SlicDiagnosticsDriver(options);
         
+        // Run the test.
         loop.add(slicDiag);
-        loop.loop(-1);
+        loop.loop(1);
         loop.dispose();
     }
     
CVSspam 0.2.8