lcsim/src/org/lcsim/event/base
diff -u -r1.1 -r1.2
--- BaseCalorimeterHit.java 23 May 2008 03:12:09 -0000 1.1
+++ BaseCalorimeterHit.java 23 May 2008 03:36:09 -0000 1.2
@@ -64,11 +64,12 @@
}
private void calculatePosition()
- {
+ {
+ position = new double[3];
+
if (getMetaData() != null)
{
- IDDecoder decoder = getIDDecoder();
- position = new double[3];
+ IDDecoder decoder = getIDDecoder();
decoder.setID(id);
position[0] = decoder.getX();
position[1] = decoder.getY();
lcsim/src/org/lcsim/event/base
diff -u -r1.1 -r1.2
--- BaseSimCalorimeterHit.java 23 May 2008 03:12:09 -0000 1.1
+++ BaseSimCalorimeterHit.java 23 May 2008 03:36:09 -0000 1.2
@@ -1,7 +1,5 @@
package org.lcsim.event.base;
-import hep.io.sio.SIORef;
-
import org.lcsim.event.MCParticle;
import org.lcsim.event.SimCalorimeterHit;
@@ -36,15 +34,17 @@
super.rawEnergy = rawEnergy;
super.time = time;
super.position = null;
- }
+ }
public double getTime()
{
- if (times.length == 0) return 0;
+ // First check for explicit value that has been set.
if (super.time != 0) return super.time;
- // Somewhat arbitrarily decide that the time of the hit
- // is the earliest hit contribution time
+ // If the times array is empty, then there is no valid time to find.
+ if (times.length == 0) return 0;
+
+ // Find the earliest time from the array.
double t = times[0];
for (int i=1; i<times.length; i++)
{
@@ -57,11 +57,12 @@
return t;
}
+ // FIXME: This is included so that this class can be instantiated and so that
+ // it has no dependency on the SIO package. But it is actually implemented
+ // elsewhere (e.g. SIOSimCalorimeterHit).
public MCParticle getMCParticle(int index)
{
- Object p = particle[index];
- if (p instanceof SIORef) p = ((SIORef) p).getObject();
- return (MCParticle) p;
+ throw new UnsupportedOperationException("This should be implemented elsewhere!");
}
public double getContributedEnergy(int index)
lcsim/src/org/lcsim/util/lcio
diff -u -r1.8 -r1.9
--- SIOSimCalorimeterHit.java 23 May 2008 03:12:10 -0000 1.8
+++ SIOSimCalorimeterHit.java 23 May 2008 03:36:09 -0000 1.9
@@ -2,9 +2,11 @@
import hep.io.sio.SIOInputStream;
import hep.io.sio.SIOOutputStream;
+import hep.io.sio.SIORef;
import java.io.IOException;
+import org.lcsim.event.MCParticle;
import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.base.BaseSimCalorimeterHit;
@@ -12,7 +14,7 @@
/**
*
* @author Tony Johnson
- * @version $Id: SIOSimCalorimeterHit.java,v 1.8 2008/05/23 03:12:10 jeremy Exp $
+ * @version $Id: SIOSimCalorimeterHit.java,v 1.9 2008/05/23 03:36:09 jeremy Exp $
*/
public class SIOSimCalorimeterHit extends BaseSimCalorimeterHit
{
@@ -80,4 +82,11 @@
}
out.writePTag(hit);
}
-}
+
+ public MCParticle getMCParticle(int index)
+ {
+ Object p = particle[index];
+ if (p instanceof SIORef) p = ((SIORef) p).getObject();
+ return (MCParticle) p;
+ }
+}
\ No newline at end of file