Print

Print


Commit in lcio/src/java/hep/lcio/implementation on MAIN
event/ISimTrackerHit.java+36-281.9 -> 1.10
sio/SIOSimTrackerHit.java+34-291.13 -> 1.14
+70-57
2 modified files
Add support for pathLength to Java version of SimTrackerHit

lcio/src/java/hep/lcio/implementation/event
ISimTrackerHit.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- ISimTrackerHit.java	8 Mar 2006 09:57:28 -0000	1.9
+++ ISimTrackerHit.java	20 Mar 2006 20:05:46 -0000	1.10
@@ -7,7 +7,7 @@
 /**
  * A default implementation of SimTrackerHit
  * @author Tony Johnson
- * @version $Id: ISimTrackerHit.java,v 1.9 2006/03/08 09:57:28 gaede Exp $
+ * @version $Id: ISimTrackerHit.java,v 1.10 2006/03/20 20:05:46 tonyj Exp $
  */
 public class ISimTrackerHit extends ILCObject implements SimTrackerHit
 {
@@ -17,29 +17,30 @@
    protected float time;
    protected int cellID;
    protected float[] momentum = new float[3] ;
-
+   protected float pathLength;
+   
    public void setCellID(int cellID)
    {
       checkAccess();
       this.cellID = cellID;
    }
-
+   
    public int getCellID()
    {
       return cellID;
    }
-
+   
    public void setMCParticle(MCParticle mc)
    {
       checkAccess();
       particle = mc;
    }
-
+   
    public MCParticle getMCParticle()
    {
       return (MCParticle) particle;
    }
-
+   
    public void setPosition(double[] pos)
    {
       checkAccess();
@@ -47,49 +48,56 @@
          throw new IllegalArgumentException();
       position = pos;
    }
-
+   
    public double[] getPosition()
    {
       return position;
    }
-
-
+   
+   
    public void setTime(float time)
    {
       checkAccess();
       this.time = time;
    }
-
+   
    public float getTime()
    {
       return time;
    }
-
+   
    public float getdEdx()
    {
       return dEdx;
    }
-
+   
    public void setdEdx(float dEdx)
    {
       checkAccess();
       this.dEdx = dEdx;
    }
+   
+   public float[] getMomentum()
+   {
+      return momentum;
+   }
+   
+   public void setMomentum(float[] fs)
+   {
+      checkAccess() ;
+      if (fs.length != 3) throw new IllegalArgumentException();
+      momentum = fs;
+   }
+   
+   public float getPathLength()
+   {
+      return pathLength;
+   }
+   
+   public void setPathLength(float length)
+   {
+      this.pathLength = length;
+   }
 
-public float[] getMomentum() {
-	return momentum;
-}
-
-public float getPathLength() {
-    //FIXME: return attribute - just to compile java
-	return (float) 0. ;
-}
-
-public void setMomentum(float[] fs) {
-	checkAccess() ;
-	if (fs.length != 3)
-		throw new IllegalArgumentException();
- 	momentum = fs;
-}
-
+   
 }

lcio/src/java/hep/lcio/implementation/sio
SIOSimTrackerHit.java 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- SIOSimTrackerHit.java	19 Sep 2005 15:40:28 -0000	1.13
+++ SIOSimTrackerHit.java	20 Mar 2006 20:05:46 -0000	1.14
@@ -17,7 +17,7 @@
 /**
  *
  * @author Tony Johnson
- * @version $Id: SIOSimTrackerHit.java,v 1.13 2005/09/19 15:40:28 gaede Exp $
+ * @version $Id: SIOSimTrackerHit.java,v 1.14 2006/03/20 20:05:46 tonyj Exp $
  */
 class SIOSimTrackerHit extends ISimTrackerHit
 {
@@ -32,25 +32,28 @@
       time = in.readFloat();
       particle = in.readPntr();
       
-	if ((flags & (1 << LCIO.THBIT_MOMENTUM)) != 0)
-	  {
-		momentum[0] = in.readFloat();
-		momentum[1] = in.readFloat();
-		momentum[2] = in.readFloat();
-	  }
+      int version = SIOVersion.encode(major,minor); 
+      
+      if ((flags & (1 << LCIO.THBIT_MOMENTUM)) != 0)
+      {
+         momentum[0] = in.readFloat();
+         momentum[1] = in.readFloat();
+         momentum[2] = in.readFloat();
+         
+         if (version > SIOVersion.encode(1,6)) pathLength = in.readFloat();
+      }
+      
 
-      double version  = (double) major + ( (double) minor ) /  10. ;
-      if( version > 1.0 )
-        in.readPTag(this);
+      if( version > SIOVersion.encode(1,0)) in.readPTag(this);
    }
-
+   
    public MCParticle getMCParticle()
    {
       if (particle instanceof SIORef)
          particle = ((SIORef) particle).getObject();
       return (MCParticle) particle;
    }
-
+   
    static void write(SimTrackerHit hit, SIOOutputStream out, int flags) throws IOException
    {
       if (hit instanceof SIOSimTrackerHit)
@@ -58,7 +61,7 @@
       else
       {
          out.writeInt(hit.getCellID());
-
+         
          double[] pos = hit.getPosition();
          out.writeDouble(pos[0]);
          out.writeDouble(pos[1]);
@@ -66,18 +69,19 @@
          out.writeFloat(hit.getdEdx());
          out.writeFloat(hit.getTime());
          out.writePntr(hit.getMCParticle());
- 		if ((flags & (1 << LCIO.THBIT_MOMENTUM)) != 0)
-		  {
-			float[] p = hit.getMomentum() ;
-			out.writeFloat(p[0] ) ;
-			out.writeFloat(p[1] ) ;
-			out.writeFloat(p[2] ) ;
-		  }
-
+         if ((flags & (1 << LCIO.THBIT_MOMENTUM)) != 0)
+         {
+            float[] p = hit.getMomentum() ;
+            out.writeFloat(p[0] ) ;
+            out.writeFloat(p[1] ) ;
+            out.writeFloat(p[2] ) ;
+            out.writeFloat(hit.getPathLength());
+         }
+         
          out.writePTag(hit);
       }
    }
-
+   
    private void write(SIOOutputStream out,int flags) throws IOException
    {
       out.writeInt(cellID);
@@ -87,12 +91,13 @@
       out.writeFloat(dEdx);
       out.writeFloat(time);
       out.writePntr(getMCParticle());
-	if ((flags & (1 << LCIO.THBIT_MOMENTUM)) != 0)
-	  {
-		out.writeFloat(momentum[0] ) ;
-		out.writeFloat(momentum[1] ) ;
-		out.writeFloat(momentum[2] ) ;
-	  }
-     out.writePTag(this);
+      if ((flags & (1 << LCIO.THBIT_MOMENTUM)) != 0)
+      {
+         out.writeFloat(momentum[0] ) ;
+         out.writeFloat(momentum[1] ) ;
+         out.writeFloat(momentum[2] ) ;
+         out.writeFloat(pathLength);
+      }
+      out.writePTag(this);
    }
 }
CVSspam 0.2.8