Print

Print


Commit in lcsim/src/org/lcsim on MAIN
contrib/NickSinev/event/base/BaseSimTrackerHit.java+12-631.4 -> 1.5
contrib/NickSinev/tracking/wmfitter/WeightMatrix.java+1-11.5 -> 1.6
event/SimTrackerHit.java+2-21.13 -> 1.14
event/base/BaseSimTrackerHit.java+143added 1.1
util/lcio/SIOSimTrackerHit.java+21-1391.12 -> 1.13
+179-205
1 added + 4 modified, total 5 files
JM: add BaseSimTrackerHit; refactor SIOSimTrackerHit to extend base class

lcsim/src/org/lcsim/contrib/NickSinev/event/base
BaseSimTrackerHit.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- BaseSimTrackerHit.java	10 May 2007 23:49:43 -0000	1.4
+++ BaseSimTrackerHit.java	15 May 2008 01:14:00 -0000	1.5
@@ -1,68 +1,17 @@
 package org.lcsim.contrib.NickSinev.event.base;
-import java.util.List;
-import java.util.ArrayList;
+
 import org.lcsim.event.*;
 import org.lcsim.event.base.*;
-import org.lcsim.geometry.IDDecoder;
-import org.lcsim.geometry.Subdetector;
-import org.lcsim.detector.DetectorElement;
-import org.lcsim.detector.IDetectorElement;
 
-public class BaseSimTrackerHit implements SimTrackerHit
+public class BaseSimTrackerHit extends org.lcsim.event.base.BaseSimTrackerHit
 {
-   double[] point = new double[3];
-   MCParticle mcparticle;
-   double time=0.;
-   double dedx=0.;
-   int cellID = 0;
-   int layer = 0;
-   double[] momentum;
-   double pathlength = 0.;
-   IDDecoder iddecoder;
-   Subdetector subdetector;    
-
-
-
-   public BaseSimTrackerHit(double[] pos,MCParticle mcp)
-   {
-    mcparticle = mcp;
-    for(int i=0; i<3; i++) point[i]=pos[i];    
-   }
-   
- 
-   public void setPoint(double[] pnt)
-   {
-      for(int i=0; i<3; i++)
-       point[i]=pnt[i];   
-   }
-
-   public void setMCParticle(MCParticle mcp) { mcparticle=mcp; }
-
-   public int getLayer() {return layer; }     
-
-   public double[] getPoint() { return point; }
-
-   public double getTime() { return time; }
-
-   public double getdEdx() { return dedx; }
-   
-   public MCParticle getMCParticle() { return mcparticle; }
-
-   public int getCellID() { return cellID; }
- 
-   public IDDecoder getIDDecoder() { return iddecoder; }
-
-   public Subdetector getSubdetector() { return subdetector; }
-
-   public double getPathLength() { return pathlength; }
-
-   public double[] getMomentum() { return momentum; } 
-   
-   public DetectorElement getDetectorElement() { return null; }
-   
-   public void setDetectorElement(IDetectorElement de) { };
-   
-   public double[] getStartPoint() { return null; }
-   
-   public double[] getEndPoint() { return null; }
-}
+    public BaseSimTrackerHit(double[] point, MCParticle particle)
+    {
+        for (int i=0, n=point.length; i < n; i++)
+        {
+            this.position[i] = point[0];
+        }
+        
+        this.mcparticle = particle;
+    }    
+}
\ No newline at end of file

lcsim/src/org/lcsim/contrib/NickSinev/tracking/wmfitter
WeightMatrix.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- WeightMatrix.java	17 Jan 2007 00:22:31 -0000	1.5
+++ WeightMatrix.java	15 May 2008 01:14:00 -0000	1.6
@@ -647,7 +647,7 @@
      double eftl = Math.abs(tz)/hr;
      if(doHist && (hitlrs[i] > 4)&&(hitlrs[i]<14))
       aida.cloud1D("WeightMatrix/ expected hit position in Z for layer "+hitlrs[i]).fill(tz);
-     SimTrackerHit simth = new BaseSimTrackerHit(pnt, mcp);
+     SimTrackerHit simth = new org.lcsim.contrib.NickSinev.event.base.BaseSimTrackerHit(pnt, mcp);
      List<SimTrackerHit> lst = new ArrayList();
      lst.add(simth);
      double hitrad = Math.sqrt(tx*tx+ty*ty);

lcsim/src/org/lcsim/event
SimTrackerHit.java 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- SimTrackerHit.java	24 May 2007 18:14:32 -0000	1.13
+++ SimTrackerHit.java	15 May 2008 01:14:00 -0000	1.14
@@ -8,10 +8,10 @@
 import org.lcsim.detector.identifier.IIdentifiable;
 
 /**
- * @version $Id: SimTrackerHit.java,v 1.13 2007/05/24 18:14:32 jeremy Exp $
+ * @version $Id: SimTrackerHit.java,v 1.14 2008/05/15 01:14:00 jeremy Exp $
  */
 public interface SimTrackerHit
-extends IDetectorElementMixin
+extends IDetectorElementMixin, IIdentifiable
 {
    /** Layer containing hit */
    public int getLayer();

lcsim/src/org/lcsim/event/base
BaseSimTrackerHit.java added at 1.1
diff -N BaseSimTrackerHit.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BaseSimTrackerHit.java	15 May 2008 01:14:00 -0000	1.1
@@ -0,0 +1,143 @@
+package org.lcsim.event.base;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.identifier.IExpandedIdentifier;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.SimTrackerHit;
+
+/**
+ * An abstract implementation of SimTrackerHit.
+ * @author jeremym
+ */
+public abstract class BaseSimTrackerHit implements SimTrackerHit
+{
+    protected double[] position = new double[3];
+    protected double[] momentum = new double[3];
+    protected MCParticle mcparticle;
+    protected double time;
+    protected double dEdx;
+    protected int cellID;
+    protected double pathLength;
+    protected LCMetaData meta;
+    private IDetectorElement de;
+    private IIdentifier compactId;
+    private IExpandedIdentifier expId;
+    private Hep3Vector startPoint, endPoint;
+
+    public int getLayer()
+    {
+        getIDDecoder().setID(getCellID());
+        return getIDDecoder().getValue("layer");
+    }
+    
+    public double[] getPoint() 
+    {
+        return position;
+    }
+
+    public double getTime() 
+    {
+        return time;
+    }
+
+    public double getdEdx() 
+    {
+        return dEdx;
+    }
+
+    public MCParticle getMCParticle() 
+    {
+        return mcparticle;
+    }
+
+    public int getCellID() 
+    {
+        return cellID;
+    }
+
+    public IDDecoder getIDDecoder() 
+    {
+        return meta.getIDDecoder();
+    }
+
+    public Subdetector getSubdetector() 
+    {
+        return getIDDecoder().getSubdetector();
+    }
+
+    public double getPathLength() 
+    {
+        return pathLength;
+    }
+
+    public double[] getMomentum() 
+    {
+        return momentum;
+    }    
+
+    public double[] getStartPoint() 
+    { 
+        if (startPoint == null)
+            computePoints();
+        return startPoint.v();
+    }
+
+    public double[] getEndPoint() 
+    {
+        if (endPoint == null)
+            computePoints();
+        return endPoint.v();
+    }
+    
+    private void computePoints()
+    {
+        Hep3Vector midpoint = new BasicHep3Vector(getPoint());
+        Hep3Vector direction = VecOp.unit(new BasicHep3Vector(getMomentum()));
+        Hep3Vector half_length = VecOp.mult(getPathLength()/2.0,direction);
+
+        startPoint = VecOp.add(midpoint,VecOp.mult(-1.0,half_length));
+        endPoint = VecOp.add(midpoint,half_length);
+    }            
+    
+    public IDetectorElement getDetectorElement() 
+    {
+        return de;
+    }
+
+    public void setDetectorElement(IDetectorElement de) 
+    {
+        this.de = de;
+    }            
+
+    public IIdentifierHelper getIdentifierHelper() 
+    {
+        return getSubdetector().getDetectorElement().getIdentifierHelper();
+    }
+
+    public IIdentifier getIdentifier() 
+    {
+        if (compactId == null) 
+        {
+            compactId = new Identifier(getCellID());
+        }
+        return compactId;
+    }
+
+    public IExpandedIdentifier getExpandedIdentifier() 
+    {
+        if (expId == null) 
+        {
+            expId = getIdentifierHelper().unpack(getIdentifier());
+        }
+        return expId;
+    }    
+}
\ No newline at end of file

lcsim/src/org/lcsim/util/lcio
SIOSimTrackerHit.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- SIOSimTrackerHit.java	17 Oct 2007 02:06:23 -0000	1.12
+++ SIOSimTrackerHit.java	15 May 2008 01:14:00 -0000	1.13
@@ -3,39 +3,21 @@
 import hep.io.sio.SIOInputStream;
 import hep.io.sio.SIOOutputStream;
 import hep.io.sio.SIORef;
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
 
 import java.io.IOException;
 
-import org.lcsim.detector.IDetectorElement;
+import org.lcsim.event.base.BaseSimTrackerHit;
 import org.lcsim.event.MCParticle;
 import org.lcsim.event.SimTrackerHit;
 import org.lcsim.event.EventHeader.LCMetaData;
-import org.lcsim.geometry.IDDecoder;
-import org.lcsim.geometry.Subdetector;
-
-//import org.lcsim.detector.identifier.*;
 
 /**
  * @author Tony Johnson
- * @version $Id: SIOSimTrackerHit.java,v 1.12 2007/10/17 02:06:23 tonyj Exp $
+ * @version $Id: SIOSimTrackerHit.java,v 1.13 2008/05/15 01:14:00 jeremy Exp $
  */
-class SIOSimTrackerHit implements SimTrackerHit
-{
-    private final int cellID;
-    private final double[] position = new double[3];
-    private final double[] momentum = new double[3];
-    private final float dEdx;
-    private final float time;
-    private Object particle;
-    private float pathLength;
-    LCMetaData meta;   
-    IDetectorElement detectorElement;
-    
-    Hep3Vector startPoint;
-    Hep3Vector endPoint;
+class SIOSimTrackerHit extends BaseSimTrackerHit
+{    
+    private Object particleref;
         
     SIOSimTrackerHit(SIOInputStream in, int flags, int version, LCMetaData meta) throws IOException
     {
@@ -46,7 +28,7 @@
         position[2] = in.readDouble();
         dEdx = in.readFloat();
         time = in.readFloat();
-        particle = in.readPntr();
+        particleref = in.readPntr();
         if (LCIOUtil.bitTest(flags, LCIOConstants.THBIT_MOMENTUM))
         {
             momentum[0] = in.readFloat();
@@ -58,45 +40,25 @@
 
         if (version > 1000)
             in.readPTag(this);
-    }
-
-    public double getdEdx()
-    {
-        return dEdx;
-    }
-
-    public double[] getPoint()
-    {
-        return position;
-    }
-
-    public double getTime()
-    {
-        return time;
-    }
+    }   
 
     public MCParticle getMCParticle()
     {
-        if (particle instanceof SIORef)
-            particle = ((SIORef) particle).getObject();
-        return (MCParticle) particle;
-    }
-
-    public int getCellID()
-    {
-        return cellID;
-    }
-
-    public double[] getMomentum()
-    {
-        return momentum;
-    }
-
-    public double getPathLength()
-    {
-        return pathLength;
+        if (mcparticle == null) 
+        {
+            if (particleref instanceof SIORef)
+            {
+                particleref = ((SIORef) particleref).getObject();
+                mcparticle = (MCParticle)particleref;
+            }
+            else 
+            {
+                throw new RuntimeException("Referenced object is not an MCParticle!");
+            }
+        }
+        return mcparticle;
     }
-
+    
     static void write(SimTrackerHit hit, SIOOutputStream out, int flags) throws IOException
     {
         out.writeInt(hit.getCellID());
@@ -118,84 +80,4 @@
         }
         out.writePTag(hit);
     }
-
-    public IDDecoder getIDDecoder()
-    {
-        return meta.getIDDecoder();
-    }
-
-    public Subdetector getSubdetector()
-    {
-        return meta.getIDDecoder().getSubdetector();
-    }
-    
-    public int getLayer()
-    {
-        getIDDecoder().setID(getCellID());
-        return getIDDecoder().getValue("layer");
-    }
-
-    public IDetectorElement getDetectorElement()
-    {
-        return detectorElement;
-    }
-
-    public void setDetectorElement(IDetectorElement detectorElement)
-    {
-        this.detectorElement = detectorElement;
-    }
-   
-    public double[] getStartPoint()
-    {
-        if ( startPoint == null )
-        {
-            computePoints();
-        }
-        return startPoint.v();
-    }
-    
-    public double[] getEndPoint()
-    {
-        if ( endPoint == null )
-        {
-            computePoints();
-        }
-        return endPoint.v();
-    }
-
-    private void computePoints()
-    {
-        Hep3Vector midpoint = new BasicHep3Vector(getPoint());
-        Hep3Vector direction = VecOp.unit(new BasicHep3Vector(getMomentum()));
-        Hep3Vector half_length = VecOp.mult(getPathLength()/2.0,direction);
-
-        startPoint = VecOp.add(midpoint,VecOp.mult(-1.0,half_length));
-        endPoint = VecOp.add(midpoint,half_length);
-    }
-    
-/*
-    public IIdentifierHelper getIdentifierHelper()
-    {
-        return getSubdetector().getDetectorElement().getIdentifierHelper();
-    }
-
-    public IIdentifier getIdentifier()
-    {
-        if ( compactId == null )
-        {
-            compactId = new Identifier( getCellID() );
-        }
-        return compactId;
-    }
-
-    public IExpandedIdentifier getExpandedIdentifier()
-    {
-        if ( expId == null )
-        {
-            expId = getIdentifierHelper().unpack( getIdentifier() );
-        }
-        return expId;
-    }
-*/
-
 }
CVSspam 0.2.8