Print

Print


Commit in GeomConverter/src/org/lcsim/detector on MAIN
DetectorElement.java+12-121.21 -> 1.22
DetectorFactory.java+2-21.5 -> 1.6
IDetectorElement.java+2-21.16 -> 1.17
IDetectorFactory.java+1-11.8 -> 1.9
IReadout.java+31-41.3 -> 1.4
Readout.java+20-251.2 -> 1.3
+68-46
6 modified files
JM: Support readout of DetectorElement with multiple types for hits.

GeomConverter/src/org/lcsim/detector
DetectorElement.java 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- DetectorElement.java	6 May 2007 09:51:25 -0000	1.21
+++ DetectorElement.java	7 May 2007 22:32:48 -0000	1.22
@@ -14,10 +14,10 @@
 implements IDetectorElement
 {
     private IDetectorElementContainer children = new DetectorElementContainer(); 
-    private IGeometryInfo geometry = null;
-    private IDetectorElement parent = null;
-    private IIdentifier id = null;
-    private IIdentifierHelper helper = null;
+    private IGeometryInfo geometry;
+    private IDetectorElement parent;
+    private IIdentifier id;
+    private IIdentifierHelper helper;
     private IParameters parameters = new Parameters();
     private IReadout readout;
 
@@ -281,23 +281,23 @@
         return srch;                       
     }    
     
-    public <T> IReadout<T> getReadout()
+    public IReadout getReadout()
     {
-	if ( readout == null ) 
-	{
-	    readout = new Readout<T>();
-	}
+    	if ( readout == null ) 
+    	{
+    		readout = createReadout();
+    	}
         return readout;
     }    
     
-    public <T> void setReadout(IReadout<T> readout)
+    public void setReadout(IReadout readout)
     {
         this.readout = readout;        
     }
 
-    public <T> void createReadout( Class<T> klass )
+    public IReadout createReadout()
     {
-	this.readout = new Readout<T>();
+    	return new Readout();
     }
 
     public boolean hasReadout()

GeomConverter/src/org/lcsim/detector
DetectorFactory.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- DetectorFactory.java	2 May 2007 01:58:18 -0000	1.5
+++ DetectorFactory.java	7 May 2007 22:32:48 -0000	1.6
@@ -139,8 +139,8 @@
 				zHalfLength);
 	}
     
-    public <T> IReadout<T> createReadout()
+    public IReadout createReadout()
     {
-        return new Readout<T>();
+        return new Readout();
     }    
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/detector
IDetectorElement.java 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- IDetectorElement.java	4 May 2007 10:23:37 -0000	1.16
+++ IDetectorElement.java	7 May 2007 22:32:48 -0000	1.17
@@ -26,7 +26,7 @@
  * 
  * @author jeremym
  * @author tknelson
- * @version $Id: IDetectorElement.java,v 1.16 2007/05/04 10:23:37 jeremy Exp $
+ * @version $Id: IDetectorElement.java,v 1.17 2007/05/07 22:32:48 jeremy Exp $
  */
 public interface IDetectorElement 
 extends IIdentifiable, INamed
@@ -128,7 +128,7 @@
      * @return Associated IReadout object or <code>null</code> if
      *         Readout has been assigned to this DetectorElement.
      */
-    public <T> IReadout<T> getReadout();
+    public IReadout getReadout();
 
     /**
      * True if this DetectorElement has an {@link IReadout}; 

GeomConverter/src/org/lcsim/detector
IDetectorFactory.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- IDetectorFactory.java	2 May 2007 01:58:19 -0000	1.8
+++ IDetectorFactory.java	7 May 2007 22:32:48 -0000	1.9
@@ -73,5 +73,5 @@
 			double outerRadius, 
 			double zHalfLength);	
     
-    public <T> IReadout<T> createReadout();    
+    public IReadout createReadout();    
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/detector
IReadout.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- IReadout.java	27 Apr 2007 12:33:39 -0000	1.3
+++ IReadout.java	7 May 2007 22:32:48 -0000	1.4
@@ -2,8 +2,35 @@
 
 import java.util.List;
 
-public interface IReadout<T>
+/**
+ * The {@link IReadout} provides access to hit objects
+ * from {@link IDetectorElement} objects.  Since there
+ * is no generic class for digits or hits, this class
+ * provides access to readout based on template parameters.
+ * 
+ * @author jeremym
+ * @version $Id: IReadout.java,v 1.4 2007/05/07 22:32:48 jeremy Exp $
+ */
+public interface IReadout
 {
-    public List<T> getHits();
-    public void clear();
-}
+	/**
+	 * Get a reference to the list storing hits of type T.
+	 * 
+	 * @param  klass The class of the list to return.
+	 * @return A {@link List} containing the hits or containing
+	 *         nothing if no hits have been added.
+	 */
+	public <T> List<T> getHits(Class<T> klass);
+	
+	/**
+	 * Add a hit of type T.
+	 * 
+	 * @param hit The hit to add.
+	 */
+	public <T> void addHit(T hit);
+	
+	/**
+	 * Clear the state of this {@link IReadout}.
+	 */
+	public void clear();
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector
Readout.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- Readout.java	27 Apr 2007 12:33:39 -0000	1.2
+++ Readout.java	7 May 2007 22:32:48 -0000	1.3
@@ -1,43 +1,38 @@
 package org.lcsim.detector;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
- * Simple readout implementation that is able
- * to store a list of hits of one type.
+ * Simple implementation that of {@link IReadout}
+ * that stores lists of hits by type.
+ * 
+ * @see IReadout
+ * 
  */
-public class Readout<T>
+public class Readout
 implements IReadout
 {
-    List<T> hits;
-    
-    public Readout()
-    {
-        this.hits = new ArrayList<T>();
-    }
-    
-    public Readout(List<T> hits)
-    {
-        this.hits = hits;
-    }
+	Map<Class,List> hits = new HashMap<Class,List>();
 
-    public List<T> getHits()
+    public <T> List<T> getHits(Class<T> klass)
     {
-        return hits;
+    	if ( !hits.containsKey(klass) )
+    	{
+    		hits.put( klass, new ArrayList<T>() );
+    	}
+    	return (List<T>)hits.get( klass );
     }
     
-    public void addHit(T hit)
-    {
-        hits.add(hit);
-    }
-
-    public void setHits(List<T> hits)
+    public <T> void addHit(T hit)
     {
-	this.hits = hits;
+    	List<T> addList = (List<T>)getHits(hit.getClass());
+    	addList.add(hit);
     }
 
     public void clear()
     {
-	hits.clear(); 
+    	hits.clear(); 
     }
-}
+}
\ No newline at end of file
CVSspam 0.2.8