Commit in lcsim/src/org/lcsim on MAIN
event/HitWithPosition.java+6added 1.1
     /CalorimeterHit.java+5-51.10 -> 1.11
     /SimTrackerHit.java+2-21.19 -> 1.20
event/base/BaseHitWithPosition.java+47added 1.1
          /BaseCalorimeterHit.java+15-161.6 -> 1.7
          /BaseHit.java+65-91.5 -> 1.6
          /BaseSimTrackerHit.java+6-11.7 -> 1.8
recon/vertexing/pixsim/SimPixelHit.java+13-61.1 -> 1.2
+159-39
2 added + 6 modified, total 8 files
improvements and refactoring of BaseHit; add BaseHitWithPosition, HitWithPosition, HasPosition

lcsim/src/org/lcsim/event
HitWithPosition.java added at 1.1
diff -N HitWithPosition.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HitWithPosition.java	17 Mar 2009 22:45:44 -0000	1.1
@@ -0,0 +1,6 @@
+package org.lcsim.event;
+
+import org.lcsim.detector.HasPosition;
+
+public interface HitWithPosition extends Hit, HasPosition 
+{}
\ No newline at end of file

lcsim/src/org/lcsim/event
CalorimeterHit.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- CalorimeterHit.java	23 May 2008 06:53:35 -0000	1.10
+++ CalorimeterHit.java	17 Mar 2009 22:45:44 -0000	1.11
@@ -1,17 +1,17 @@
 package org.lcsim.event;
 
-import org.lcsim.geometry.IDDecoder;
-import org.lcsim.geometry.Subdetector;
+import hep.physics.vec.Hep3Vector;
 
 /**
  * A hit in a calorimeter.
  * The super-interface gives access to subdetector, identifiers, iddecoder, etc.
  * @see org.lcsim.event.Hit
  * @author tonyj
- * @version $Id: CalorimeterHit.java,v 1.10 2008/05/23 06:53:35 jeremy Exp $
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: CalorimeterHit.java,v 1.11 2009/03/17 22:45:44 jeremy Exp $
  */
 public interface CalorimeterHit
-extends Hit
+extends HitWithPosition
 {
    /**
     * Raw energy deposited in calorimeter cell.
@@ -42,4 +42,4 @@
     * the hit position from the hit ID.
     */
    public double[] getPosition();
-}
+}
\ No newline at end of file

lcsim/src/org/lcsim/event
SimTrackerHit.java 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- SimTrackerHit.java	23 May 2008 06:53:35 -0000	1.19
+++ SimTrackerHit.java	17 Mar 2009 22:45:44 -0000	1.20
@@ -1,10 +1,10 @@
 package org.lcsim.event;
 
 /**
- * @version $Id: SimTrackerHit.java,v 1.19 2008/05/23 06:53:35 jeremy Exp $
+ * @version $Id: SimTrackerHit.java,v 1.20 2009/03/17 22:45:44 jeremy Exp $
  */
 public interface SimTrackerHit
-extends Hit
+extends HitWithPosition
 {
    /** Layer containing hit */
    public int getLayer();

lcsim/src/org/lcsim/event/base
BaseHitWithPosition.java added at 1.1
diff -N BaseHitWithPosition.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BaseHitWithPosition.java	17 Mar 2009 22:45:44 -0000	1.1
@@ -0,0 +1,47 @@
+package org.lcsim.event.base;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.event.HitWithPosition;
+
+public abstract class BaseHitWithPosition extends BaseHit implements HitWithPosition
+{
+	protected Hep3Vector positionVec;
+	
+    /**
+     * Get the position of this hit in mm as a {@see hep.physics.vec.Hep3Vector}.
+     * Depends on implementation of {@see #getPosition()}. 
+     * @return The vector position of the hit in mm.
+     */
+    public Hep3Vector getPositionVec()
+    {
+    	if (positionVec == null)
+    	{
+    		double[] p = getPosition();
+    		positionVec = new BasicHep3Vector(p[0],p[1],p[2]);
+    	}
+    	return positionVec;
+    }
+    
+    /**
+     * Override super's method in order to find the DetectorElement 
+     * if the hit has a position.
+     */
+    public IDetectorElement getDetectorElement()
+    {
+    	if (de == null)
+    	{
+    		de = getSubdetector().getDetectorElement().findDetectorElement(getPositionVec());
+    	}
+    	return de;
+    }
+    
+    /**
+     * Get the position of this hit in mm as a double array.
+     * Subclasses must implement this method.
+     * @return The position of this hit as a double array of size 3.
+     */
+    public abstract double[] getPosition(); 
+}

lcsim/src/org/lcsim/event/base
BaseCalorimeterHit.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- BaseCalorimeterHit.java	10 Sep 2008 21:24:41 -0000	1.6
+++ BaseCalorimeterHit.java	17 Mar 2009 22:45:44 -0000	1.7
@@ -1,25 +1,29 @@
 package org.lcsim.event.base;
 
+import hep.physics.vec.Hep3Vector;
+
 import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.detector.identifier.Identifier;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.util.SamplingFractionManager;
 import org.lcsim.geometry.IDDecoder;
 
 /**
+ * Base implementation of CalorimeterHit.
  * @author tonyj
+ * @author Jeremy McCormick <[log in to unmask]>
  */
-public abstract class BaseCalorimeterHit 
-extends BaseHit 
-implements CalorimeterHit 
-{       
-    protected double rawEnergy;
-    protected double corrEnergy = -1;
+public abstract class BaseCalorimeterHit extends BaseHitWithPosition implements CalorimeterHit 
+{   	
+    protected double rawEnergy;    
+    protected double corrEnergy = UNSET_CORRECTED_ENERGY;
     protected double[] position;
+    protected Hep3Vector positionVec;
     protected double time;
     protected long id;
     
+    private static final double UNSET_CORRECTED_ENERGY = -1;
+    
     public double getTime() 
     {
         return time;
@@ -41,7 +45,7 @@
 
     public double getCorrectedEnergy() 
     {
-        if (corrEnergy == -1)
+        if (corrEnergy == UNSET_CORRECTED_ENERGY)
         {
             calculateCorrectedEnergy();
         }
@@ -79,13 +83,8 @@
     
     public IIdentifier getIdentifier()
     {
-    	if (this.compactId == null)
-    		this.compactId = new Identifier(this.id);
-    	return this.compactId;
-    }
-    
-    public IIdentifierHelper getIdentifierHelper() 
-    {
-        return getSubdetector().getDetectorElement().getIdentifierHelper();
+    	if (compactId == null)
+    		compactId = new Identifier(id);
+    	return compactId;
     }
 }
\ No newline at end of file

lcsim/src/org/lcsim/event/base
BaseHit.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- BaseHit.java	20 Aug 2008 01:34:21 -0000	1.5
+++ BaseHit.java	17 Mar 2009 22:45:44 -0000	1.6
@@ -1,5 +1,7 @@
 package org.lcsim.event.base;
 
+import hep.physics.vec.Hep3Vector;
+
 import org.lcsim.detector.DetectorIdentifierHelper;
 import org.lcsim.detector.IDetectorElement;
 import org.lcsim.detector.identifier.IExpandedIdentifier;
@@ -10,6 +12,10 @@
 import org.lcsim.geometry.IDDecoder;
 import org.lcsim.geometry.Subdetector;
 
+/**
+ * A base class for hit-like objects.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
 public abstract class BaseHit
 implements Hit
 {
@@ -17,34 +23,68 @@
     protected IExpandedIdentifier expId;
     protected IIdentifier compactId;
     protected IDetectorElement de;
+    protected Hep3Vector positionVec;
 
+    /**
+     * Get the metadata associated with this hit.
+     * @return The hit's metadata.
+     */
     public LCMetaData getMetaData() 
     {
         return meta;
     }
 
+    /**
+     * Set the metadata associated with this hit.
+     * By default, this will not override an
+     * existing value.     
+     */
     public void setMetaData(LCMetaData meta) 
     {
-        // Don't allow meta to be reset!  
-    	// Override in subclass if you want to enable this.
-    	if (this.meta == null) this.meta = meta;
+    	if (this.meta == null)
+    	{
+    		this.meta = meta;
+    	}
     }
 	
+    /**
+     * Get the subdetector that this hit belongs to.
+     * @return The Subdetector of this hit.
+     */
     public Subdetector getSubdetector() 
     {
         return getIDDecoder().getSubdetector();
     }
 
+    /**
+     * Get the deepest {@see org.lcsim.detector.IDetectorElement} associated with this hit.
+     * If this is not set manually using {@see #setDetectorElement(IDetectorElement)}
+     * then the subdetector's DetectorElement is searched using the hit's position
+     * from {@see #getPositionVec()}.
+ 	 * @return The IDetectorElement for this hit.
+     */
     public IDetectorElement getDetectorElement() 
     {
         return de;
     }
-	
+    	
+    /**
+     * Set the @see org.lcsim.detector.IDetectorElement of this hit.
+     * By default, this will not override an existing value.
+     */
     public void setDetectorElement(IDetectorElement de)
     {
-        this.de = de;
+    	if (this.de == null)
+    	{
+    		this.de = de;
+    	}
     }
 
+    /**
+     * Get the {@see org.lcsim.detector.identifier.IExpandedIdentifier}
+     * of this hit.
+     * @return The <code>IExpandedIdentifier</code> of this hit.
+     */
     public IExpandedIdentifier getExpandedIdentifier() 
     {
         if (expId == null) 
@@ -54,23 +94,39 @@
         return expId;
     }
 
+    /**
+     * Get the identifier of this hit.
+     * @return The identifier of this hit.
+     */
     public IIdentifier getIdentifier() 
     {
         return compactId;
     }
 
+    /**
+     * Get the identifier helper of this hit.
+     * @return The hit's identifier helper.
+     */
     public IIdentifierHelper getIdentifierHelper() 
     {
-        return getDetectorElement().getIdentifierHelper();
+        return getSubdetector().getDetectorElement().getIdentifierHelper();
     }
     
+    /**
+     * Get the detector identifier helper of this hit.
+     * @return The hit's detector identifier helper.
+     */
     public DetectorIdentifierHelper getDetectorIdentifierHelper()
     {
-    	return (DetectorIdentifierHelper)getSubdetector().getDetectorElement().getIdentifierHelper();
+    	return (DetectorIdentifierHelper)getIdentifierHelper();
     }
 
-    public IDDecoder getIDDecoder() 
+    /**
+     * Get the {@see org.lcsim.geometryIDDecoder} of this hit.
+     * @return The hit's id decoder.
+     */
+    public IDDecoder getIDDecoder()
     {
         return meta.getIDDecoder();
     }
-}
\ No newline at end of file
+}	
\ No newline at end of file

lcsim/src/org/lcsim/event/base
BaseSimTrackerHit.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- BaseSimTrackerHit.java	7 Jul 2008 18:47:20 -0000	1.7
+++ BaseSimTrackerHit.java	17 Mar 2009 22:45:44 -0000	1.8
@@ -15,7 +15,7 @@
  * An concrete implementation of SimTrackerHit.
  * @author jeremym
  */
-public abstract class BaseSimTrackerHit extends BaseHit implements SimTrackerHit
+public abstract class BaseSimTrackerHit extends BaseHitWithPosition implements SimTrackerHit
 {
     protected double[] position = new double[3];
     protected double[] momentum = new double[3];
@@ -92,6 +92,11 @@
     {
         return position;
     }
+    
+    public double[] getPosition()
+    {
+    	return getPoint();
+    }
 
     public double getTime() 
     {

lcsim/src/org/lcsim/recon/vertexing/pixsim
SimPixelHit.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SimPixelHit.java	9 Dec 2008 23:36:34 -0000	1.1
+++ SimPixelHit.java	17 Mar 2009 22:45:44 -0000	1.2
@@ -1,18 +1,20 @@
 package org.lcsim.recon.vertexing.pixsim;
 
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.VecOp;
+
 import org.lcsim.detector.IDetectorElement;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.base.BaseHitWithPosition;
 import org.lcsim.geometry.IDDecoder;
 import org.lcsim.geometry.Subdetector;
-import org.lcsim.event.EventHeader.LCMetaData;
-import org.lcsim.event.base.*;
-import org.lcsim.event.*;
-import hep.physics.vec.*;
 
 /**
- * @version $Id: SimPixelHit.java,v 1.1 2008/12/09 23:36:34 jeremy Exp $
+ * @version $Id: SimPixelHit.java,v 1.2 2009/03/17 22:45:44 jeremy Exp $
  */
 
-public class SimPixelHit extends BaseHit implements SimTrackerHit
+public class SimPixelHit extends BaseHitWithPosition implements SimTrackerHit
 {
    SimTrackerHit _parent = null;
    SimHitParameters _param = null;
@@ -164,4 +166,9 @@
    {
     return new String(_param.s_p[0]+" "+_param.s_p[1]+" "+_param.s_p[2]);
    } 
+   
+   public double[] getPosition()
+   {
+	   return getPoint();
+   }
 }
\ No newline at end of file
CVSspam 0.2.8