lcsim/src/org/lcsim/util/lcio
diff -u -r1.5 -r1.6
--- SIOSimCalorimeterHit.java 20 Jan 2006 23:45:23 -0000 1.5
+++ SIOSimCalorimeterHit.java 9 Feb 2006 21:15:06 -0000 1.6
@@ -14,17 +14,17 @@
/**
*
* @author Tony Johnson
- * @version $Id: SIOSimCalorimeterHit.java,v 1.5 2006/01/20 23:45:23 lima Exp $
+ * @version $Id: SIOSimCalorimeterHit.java,v 1.6 2006/02/09 21:15:06 lima Exp $
*/
public class SIOSimCalorimeterHit extends BaseCalorimeterHit implements SimCalorimeterHit
{
- protected int nContributions;
- protected Object[] particle;
- protected float[] energyContrib;
- protected float[] time;
- protected int[] pdg;
+ protected int nContributions;
+ protected Object[] particle;
+ protected float[] energyContrib;
+ protected float[] time;
+ protected int[] pdg;
- // useful constructor for new SimCalHits
+ // useful constructor for new SimCalHits
public SIOSimCalorimeterHit(long _id, double _rawE, double _time, Object[] mcparts, float[] energies, float[] times, int[] pdgs)
{
nContributions = mcparts.length;
@@ -40,6 +40,13 @@
super.position = null;
}
+ public void setPosition(double[] pos) {
+ if(position == null) position = new double[3];
+ position[0] = pos[0];
+ position[1] = pos[1];
+ position[2] = pos[2];
+ }
+
// constructor from LCIO data file
SIOSimCalorimeterHit(SIOInputStream in, int flags, int version, LCMetaData meta) throws IOException
{
@@ -52,7 +59,7 @@
id = ((long) cellid1)<<32 | cellid0;
rawEnergy = in.readFloat();
-
+
if (LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_LONG))
{
position = new double[3];
@@ -64,7 +71,7 @@
particle = new Object[nContributions];
energyContrib = new float[nContributions];
time = new float[nContributions];
-
+
boolean hasPDG = LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_PDG);
if (hasPDG) pdg = new int[nContributions];
for (int i = 0; i < nContributions; i++)
@@ -76,12 +83,12 @@
}
if ( version > 1000 ) in.readPTag(this);
}
-
+
public double getTime()
{
// Somewhat arbitrarily decide that the time of the hit
// is the earliest hit contribution time
-
+
if (time.length == 0) return 0;
double t = time[0];
for (int i=1; i<time.length; i++)
@@ -90,29 +97,29 @@
}
return t;
}
-
+
public MCParticle getMCParticle(int index)
{
Object p = particle[index];
if (p instanceof SIORef) p = ((SIORef) p).getObject();
return (MCParticle) p;
}
-
+
public double getContributedEnergy(int index)
{
return energyContrib[index];
}
-
+
public int getPDG(int index)
{
return pdg[index];
}
-
+
public double getContributedTime(int index)
{
return time[index];
}
-
+
public int getMCParticleCount()
{
return particle.length;
@@ -123,7 +130,7 @@
out.writeInt((int) cellID);
if (LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_ID1)) out.writeInt((int) (cellID>>32));
out.writeFloat((float) hit.getRawEnergy());
-
+
if ((flags & (1 << LCIOConstants.CHBIT_LONG)) != 0)
{
double[] pos = hit.getPosition();
@@ -131,7 +138,7 @@
out.writeFloat((float) pos[1]);
out.writeFloat((float) pos[2]);
}
-
+
boolean hasPDG = LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_PDG);
int n = hit.getMCParticleCount();
out.writeInt(n);