Commit in lcsim on MAIN
src/org/lcsim/event/SimTrackerHit.java+13-11.5 -> 1.6
src/org/lcsim/util/lcio/SIOSimTrackerHit.java+112-911.5 -> 1.6
                       /SIOSimTrackerHitBlockHandler.java+24-121.4 -> 1.5
test/EventHeaderTest.java+91.4 -> 1.5
+158-104
4 modified files
JM: Add getSubdetector and getIDDecoder convenience methods to SimTrackerHit interface

lcsim/src/org/lcsim/event
SimTrackerHit.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- SimTrackerHit.java	23 Mar 2006 00:09:57 -0000	1.5
+++ SimTrackerHit.java	3 Apr 2006 22:40:20 -0000	1.6
@@ -1,11 +1,16 @@
 package org.lcsim.event;
 
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
+
 public interface SimTrackerHit
 {
    /** Layer containing hit */
-//   public int getLayer();
+   public int getLayer();
+
    /** x,y,z point of (center-of) hit */
    double[] getPoint();
+   
    /** returns dE/dx energy deposition */
    double getdEdx();
    
@@ -19,8 +24,15 @@
     * optional, only if bit LCIOConstants.THBIT_MOMENTUM is set.
     */
    double[] getMomentum();
+   
    /** The path length of the particle in the sensitive material that resulted in this hit.
     *  This is only stored together with momentum, i.e. if  LCIO::THBIT_MOMENTUM is set.
     */
    double getPathLength();
+   
+   /** Returns the IDDecoder associated with this hit */
+   IDDecoder getIDDecoder();
+   
+   /** Using the IDDecoder, returns the Subdetector associated with this hit */
+   Subdetector getSubdetector();
 }
\ No newline at end of file

lcsim/src/org/lcsim/util/lcio
SIOSimTrackerHit.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- SIOSimTrackerHit.java	23 Mar 2006 00:09:57 -0000	1.5
+++ SIOSimTrackerHit.java	3 Apr 2006 22:40:20 -0000	1.6
@@ -5,102 +5,123 @@
 import hep.lcd.io.sio.SIORef;
 
 import java.io.IOException;
+
 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;
 
 /**
- *
  * @author Tony Johnson
- * @version $Id: SIOSimTrackerHit.java,v 1.5 2006/03/23 00:09:57 tonyj Exp $
+ * @version $Id: SIOSimTrackerHit.java,v 1.6 2006/04/03 22:40:20 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;
-   
-   SIOSimTrackerHit(SIOInputStream in, int flags, int version) throws IOException
-   {
-      cellID = in.readInt();
-      position[0] = in.readDouble();
-      position[1] = in.readDouble();
-      position[2] = in.readDouble();
-      dEdx = in.readFloat();
-      time = in.readFloat();
-      particle = in.readPntr();
-      if ( LCIOUtil.bitTest(flags,LCIOConstants.THBIT_MOMENTUM) )
-      {
-        momentum[0] = in.readFloat();
-        momentum[1] = in.readFloat();
-        momentum[2] = in.readFloat();
-        if (version > 1006) pathLength = in.readFloat();
-      }      
-      
-      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;
-   }
-   
-   static void write(SimTrackerHit hit, SIOOutputStream out, int flags) throws IOException
-   {
-      out.writeInt(hit.getCellID());
-      
-      double[] pos = hit.getPoint();
-      out.writeDouble(pos[0]);
-      out.writeDouble(pos[1]);
-      out.writeDouble(pos[2]);
-      out.writeFloat((float) hit.getdEdx());
-      out.writeFloat((float) hit.getTime());
-      out.writePntr(hit.getMCParticle());
-      if ( LCIOUtil.bitTest(flags,LCIOConstants.THBIT_MOMENTUM) )
-      {
-        double[] p = hit.getMomentum() ;
-        out.writeFloat((float) p[0] ) ;
-        out.writeFloat((float) p[1] ) ;
-        out.writeFloat((float) p[2] ) ;
-        out.writeFloat((float) hit.getPathLength());
-      }      
-      out.writePTag(hit);
-   }
-
-
+{
+    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;
+
+    SIOSimTrackerHit(SIOInputStream in, int flags, int version, LCMetaData meta) throws IOException
+    {
+        this.meta = meta;
+        cellID = in.readInt();
+        position[0] = in.readDouble();
+        position[1] = in.readDouble();
+        position[2] = in.readDouble();
+        dEdx = in.readFloat();
+        time = in.readFloat();
+        particle = in.readPntr();
+        if (LCIOUtil.bitTest(flags, LCIOConstants.THBIT_MOMENTUM))
+        {
+            momentum[0] = in.readFloat();
+            momentum[1] = in.readFloat();
+            momentum[2] = in.readFloat();
+            if (version > 1006)
+                pathLength = in.readFloat();
+        }
+
+        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;
+    }
+
+    static void write(SimTrackerHit hit, SIOOutputStream out, int flags) throws IOException
+    {
+        out.writeInt(hit.getCellID());
+
+        double[] pos = hit.getPoint();
+        out.writeDouble(pos[0]);
+        out.writeDouble(pos[1]);
+        out.writeDouble(pos[2]);
+        out.writeFloat((float) hit.getdEdx());
+        out.writeFloat((float) hit.getTime());
+        out.writePntr(hit.getMCParticle());
+        if (LCIOUtil.bitTest(flags, LCIOConstants.THBIT_MOMENTUM))
+        {
+            double[] p = hit.getMomentum();
+            out.writeFloat((float) p[0]);
+            out.writeFloat((float) p[1]);
+            out.writeFloat((float) p[2]);
+            out.writeFloat((float) hit.getPathLength());
+        }
+        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");
+    }
 }

lcsim/src/org/lcsim/util/lcio
SIOSimTrackerHitBlockHandler.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- SIOSimTrackerHitBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.4
+++ SIOSimTrackerHitBlockHandler.java	3 Apr 2006 22:40:20 -0000	1.5
@@ -4,23 +4,35 @@
 import hep.lcd.io.sio.SIOOutputStream;
 
 import java.io.IOException;
+
 import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.EventHeader.LCMetaData;
 
 /**
- *
  * @author tonyj
  */
 class SIOSimTrackerHitBlockHandler extends AbstractBlockHandler
 {
-   public String getType() { return "SimTrackerHit"; }
-   public Class getClassForType() { return SimTrackerHit.class; }
-   void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
-   {
-      for (int i = 0; i < n; i++)
-         collection.add(new SIOSimTrackerHit(in, collection.getFlags(), version));
-   }
-   void writeCollectionElement(Object element, SIOOutputStream out, int flags) throws IOException
-   {
-      SIOSimTrackerHit.write((SimTrackerHit) element, out, flags);
-   }
+    public String getType()
+    {
+        return "SimTrackerHit";
+    }
+
+    public Class getClassForType()
+    {
+        return SimTrackerHit.class;
+    }
+
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version)
+            throws IOException
+    {
+        LCMetaData meta = event.getMetaData(collection);
+        for (int i = 0; i < n; i++)
+            collection.add(new SIOSimTrackerHit(in, collection.getFlags(), version, meta));
+    }
+
+    void writeCollectionElement(Object element, SIOOutputStream out, int flags) throws IOException
+    {
+        SIOSimTrackerHit.write((SimTrackerHit) element, out, flags);
+    }
 }

lcsim/test
EventHeaderTest.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- EventHeaderTest.java	4 Aug 2005 01:44:45 -0000	1.4
+++ EventHeaderTest.java	3 Apr 2006 22:40:20 -0000	1.5
@@ -20,6 +20,7 @@
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.EventHeader.LCMetaData;
 import org.lcsim.event.SimTrackerHit;
+import org.lcsim.geometry.Subdetector;
 
 /**
  *
@@ -92,6 +93,14 @@
                         //System.out.println("decoder = " + decoder);
                         assert(decoder.toString() != null);
                         assert(decoder.toString().length() > 0);
+                        
+                        IDDecoder hit_dc = hit.getIDDecoder();
+                        Subdetector hit_sd = hit.getSubdetector();
+                        
+                        // Check that the hit's IDDecoder and Subdetector match that
+                        // fetched from meta.
+                        assert(hit_dc == decoder);
+                        assert(hit_sd == decoder.getSubdetector());
                     }
                 }
             }
CVSspam 0.2.8