lcsim/src/org/lcsim/util/lcio
diff -u -r1.4 -r1.5
--- SIOReconstructedParticle.java 25 May 2007 00:16:14 -0000 1.4
+++ SIOReconstructedParticle.java 11 Sep 2007 21:01:29 -0000 1.5
@@ -6,59 +6,66 @@
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.BasicHepLorentzVector;
import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.HepLorentzVector;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.lcsim.event.Cluster;
import org.lcsim.event.ParticleID;
import org.lcsim.event.ReconstructedParticle;
import org.lcsim.event.Track;
+import org.lcsim.event.base.BaseReconstructedParticle;
/**
*
* @author Tony Johnson
- * @version $Id: SIOReconstructedParticle.java,v 1.4 2007/05/25 00:16:14 tonyj Exp $
+ * @version $Id: SIOReconstructedParticle.java,v 1.5 2007/09/11 21:01:29 tonyj Exp $
*/
-class SIOReconstructedParticle implements ReconstructedParticle
+class SIOReconstructedParticle extends BaseReconstructedParticle
{
+ private List<SIORef> tempParticles;
+ private List<SIORef> tempTracks;
+ private List<SIORef> tempClusters;
SIOReconstructedParticle(SIOInputStream in, int flags, int version) throws IOException
{
- type = in.readInt();
+ _type = in.readInt();
Hep3Vector momentum = new BasicHep3Vector(in.readFloat(),in.readFloat(),in.readFloat());
double energy = in.readFloat();
- fourVector = new BasicHepLorentzVector(energy,momentum);
- covMatrix = new double[10];
- for (int i=0; i<10; i++) covMatrix[i] = in.readFloat();
- mass = in.readFloat();
- charge = in.readFloat();
- referencePoint = new BasicHep3Vector(in.readFloat(),in.readFloat(),in.readFloat());
+ _fourVec = new BasicHepLorentzVector(energy,momentum);
+ _covMatrix = new double[10];
+ for (int i=0; i<10; i++) _covMatrix[i] = in.readFloat();
+ _mass = in.readFloat();
+ _charge = in.readFloat();
+ _referencePoint = new BasicHep3Vector(in.readFloat(),in.readFloat(),in.readFloat());
int nPid = in.readInt();
- this.particleIDs = new ArrayList(nPid);
+ _particleIds = new ArrayList(nPid);
for (int i=0; i<nPid; i++)
{
ParticleID id = new SIOParticleID(in,flags,version);
- particleIDs.add(id);
+ _particleIds.add(id);
in.readPTag(id);
}
- particleIDUsed = (ParticleID) in.readPntr().getObject();
- goodnessOfPID = in.readFloat();
+ _particleIdUsed = (ParticleID) in.readPntr().getObject();
+ _goodnessOfPid = in.readFloat();
int nReco = in.readInt();
tempParticles = new ArrayList(nReco);
+ _particles = null;
for (int i=0; i<nReco; i++)
{
tempParticles.add(in.readPntr());
}
int nTracks = in.readInt();
tempTracks = new ArrayList(nTracks);
+ _tracks = null;
for (int i=0; i<nTracks; i++)
{
tempTracks.add(in.readPntr());
}
int nClust = in.readInt();
tempClusters = new ArrayList(nClust);
+ _clusters = null;
for (int i=0; i<nClust; i++)
{
tempClusters.add(in.readPntr());
@@ -68,7 +75,7 @@
// Fixme: This is not currently accessible
SIORef startVertex = in.readPntr();
}
- in.readPTag(this);
+ in.readPTag(this);
}
static void write(ReconstructedParticle particle, SIOOutputStream out, int flags) throws IOException
@@ -103,125 +110,37 @@
for (Cluster cluster : clusters) out.writePntr(cluster);
out.writePTag(particle);
}
-
- public void addCluster(Cluster cluster)
- {
- }
-
- public void addParticle(ReconstructedParticle particle)
- {
- }
-
- public void addParticleID(ParticleID pid)
- {
- }
-
- public void addTrack(Track track)
- {
-
- }
-
- public HepLorentzVector asFourVector()
- {
- return fourVector;
- }
-
- public double getCharge()
- {
- return charge;
- }
-
+
public List<Cluster> getClusters()
{
- if (tempClusters != null)
+ if (tempClusters != null && _clusters == null)
{
- clusters = new ArrayList<Cluster>(tempClusters.size());
- for (SIORef ref : tempClusters) clusters.add((Cluster) ref.getObject());
+ _clusters = new ArrayList<Cluster>(tempClusters.size());
+ for (SIORef ref : tempClusters) _clusters.add((Cluster) ref.getObject());
tempClusters = null;
}
- return clusters;
- }
-
- public double[] getCovMatrix()
- {
- return covMatrix;
- }
-
- public double getEnergy()
- {
- return fourVector.t();
+ return _clusters == null ? Collections.<Cluster>emptyList() : _clusters;
}
-
- public double getGoodnessOfPID()
- {
- return goodnessOfPID;
- }
-
- public double getMass()
- {
- return mass;
- }
-
- public Hep3Vector getMomentum()
- {
- return fourVector.v3();
- }
-
- public ParticleID getParticleIDUsed()
- {
- return particleIDUsed;
- }
-
- public List<ParticleID> getParticleIDs()
- {
- return particleIDs;
- }
-
+
public List<ReconstructedParticle> getParticles()
{
- if (tempParticles != null)
+ if (tempParticles != null && _particles == null)
{
- particles = new ArrayList<ReconstructedParticle>(tempParticles.size());
- for (SIORef ref : tempParticles) particles.add((ReconstructedParticle) ref.getObject());
+ _particles = new ArrayList<ReconstructedParticle>(tempParticles.size());
+ for (SIORef ref : tempParticles) _particles.add((ReconstructedParticle) ref.getObject());
tempParticles = null;
}
- return particles;
+ return _particles == null ? Collections.<ReconstructedParticle>emptyList() : _particles;
}
-
- public Hep3Vector getReferencePoint()
- {
- return referencePoint;
- }
-
+
public List<Track> getTracks()
{
- if (tempTracks != null)
+ if (tempTracks != null && _tracks == null)
{
- tracks = new ArrayList<Track>(tempTracks.size());
- for (SIORef ref : tempTracks) tracks.add((Track) ref.getObject());
+ _tracks = new ArrayList<Track>(tempTracks.size());
+ for (SIORef ref : tempTracks) _tracks.add((Track) ref.getObject());
tempTracks = null;
}
- return tracks;
+ return _tracks == null ? Collections.<Track>emptyList() : _tracks;
}
-
- public int getType()
- {
- return type;
- }
-
- private List<SIORef> tempParticles;
- private List<SIORef> tempTracks;
- private List<SIORef> tempClusters;
- private int type;
- private List<Track> tracks;
- private Hep3Vector referencePoint;
- private List<ReconstructedParticle> particles;
- private List<ParticleID> particleIDs;
- private ParticleID particleIDUsed;
- private double[] covMatrix;
- private List<Cluster> clusters;
- private double charge;
- private HepLorentzVector fourVector;
- private double mass;
- private double goodnessOfPID;
}