lcsim/src/org/lcsim/recon/cheater
diff -N CheatReconstructedParticle.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CheatReconstructedParticle.java 26 Sep 2005 22:47:04 -0000 1.1
@@ -0,0 +1,222 @@
+/* CheatReconstructedParticle.java
+ *
+ * A reconstructed particle found by ReconCheater.
+ *
+ * Author: M.Ronan 23 Sep. 2005
+ *
+ */
+
+package org.lcsim.recon.cheater;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.BasicHepLorentzVector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.HepLorentzVector;
+import hep.physics.particle.Particle;
+import hep.physics.particle.properties.ParticleType;
+import java.util.ArrayList;
+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.MCParticle;
+import org.lcsim.recon.ztracking.cheater.CheatTrack;
+import org.lcsim.recon.cluster.cheat.CheatCluster;
+
+import static java.lang.Math.sqrt;
+import static java.lang.Math.pow;
+
+
+/**
+ * A reconstructed particle found by ReconCheater.
+ * @author M.Ronan
+ */
+public class CheatReconstructedParticle implements ReconstructedParticle
+{
+ // ReconstructedParticle attributes
+ private double[] _covMatrix = new double[10];
+ private double _mass;
+ private double _charge;
+ private Hep3Vector _referencePoint;
+ private List<ParticleID> _particleIds = new ArrayList<ParticleID>();
+ private ParticleID _particleIdUsed;
+ private double _goodnessOfPid;
+ private MCParticle _mcp;
+ private List<ReconstructedParticle> _particles = new ArrayList<ReconstructedParticle>();
+ private List<Cluster> _clusters = new ArrayList<Cluster>();
+ private List<Track> _tracks = new ArrayList<Track>();
+ private BasicHepLorentzVector _fourVec = new BasicHepLorentzVector();
+
+ static boolean warnElessthanM = true;
+
+ public CheatReconstructedParticle(MCParticle mcp)
+ {
+ _mcp = mcp;
+ _mass = 0.;
+ try { _mass = mcp.getType().getMass(); }
+ catch (hep.physics.particle.properties.UnknownParticleIDException ex)
+ { System.err.println(" CheatReconstructedParticle:: Particle "+mcp.getPDGID()+" is unknown!"); }
+ double e = mcp.getEnergy();
+ _fourVec.setV3(e, mcp.getPX(), mcp.getPY(), mcp.getPZ());
+ _charge = mcp.getCharge();
+
+ // Fixme: ...
+ _referencePoint = new BasicHep3Vector(0., 0., 0.);
+
+ addParticleID(new CheatParticleID(mcp.getType()));
+ }
+
+ public CheatReconstructedParticle(Track t, Particle p)
+ {
+ _mcp = ((CheatTrack) t).getMCParticle();
+
+ _mass = p.getType().getMass();
+ addTrack(t);
+ double e = sqrt(t.getPX()*t.getPX()+t.getPY()*t.getPY()+t.getPZ()*t.getPZ() + _mass*_mass);
+ _fourVec.setV3(e, t.getPX(), t.getPY(), t.getPZ());
+ _charge = t.getCharge();
+
+ // Fixme: Probably wrong, this is not a point on the track, nor should we assume that the track
+ // reference point is at the POCA.
+ _referencePoint = new BasicHep3Vector(t.getReferencePointX(), t.getReferencePointY(), t.getReferencePointZ());
+
+ addParticleID(new CheatParticleID(p.getType()));
+ }
+
+ public CheatReconstructedParticle(Cluster c, double e, Particle p)
+ {
+ _mcp = ((CheatCluster) c).getMCParticle();
+
+ _mass = p.getType().getMass();
+ addCluster(c);
+ //double e = c.getEnergy();
+ if (e<_mass) {
+ if (warnElessthanM) System.err.println(" CheatReconstructedParticle: "+p.getType().getName()+" w/ E<mass = "+e+" < "+_mass);
+ e = _mass;
+ warnElessthanM = false;
+ }
+
+ double pm = sqrt(e*e-_mass*_mass);
+ // get direction from position of cluster and assume it comes from the origin
+ double[] point = c.getPosition();
+ double len = sqrt(point[0]*point[0] + point[1]*point[1] + point[2]*point[2]);
+
+ _referencePoint = new BasicHep3Vector(0, 0, 0);
+ double px=0., py=0., pz=0.;
+ if (len!=0.) {
+ px = (pm/len)*(point[0]);
+ py = (pm/len)*(point[1]);
+ pz = (pm/len)*(point[2]);
+ }
+ _fourVec.setV3(e, px, py, pz);
+ _charge = 0.;
+
+ addParticleID(new CheatParticleID(p.getType()));
+ }
+
+ // ReconstructedParticle interface
+
+ public MCParticle getMCParticle()
+ {
+ return _mcp;
+ }
+
+ public int getType()
+ {
+ return _particleIdUsed.getType();
+ }
+
+ public Hep3Vector getMomentum()
+ {
+ return _fourVec.v3();
+ }
+
+ public double getEnergy()
+ {
+ return _fourVec.t();
+ }
+
+ public double[] getCovMatrix()
+ {
+ return _covMatrix;
+ }
+
+ public double getMass()
+ {
+ return _mass;
+ }
+
+ public double getCharge()
+ {
+ return _charge;
+ }
+
+ public Hep3Vector getReferencePoint()
+ {
+ return _referencePoint;
+ }
+
+ public List<ParticleID> getParticleIDs()
+ {
+ return _particleIds;
+ }
+
+ public ParticleID getParticleIDUsed()
+ {
+ return _particleIdUsed;
+ }
+
+ public double getGoodnessOfPID()
+ {
+ return _goodnessOfPid;
+ }
+
+ public List<ReconstructedParticle> getParticles()
+ {
+ return _particles;
+ }
+
+ public List<Cluster> getClusters()
+ {
+ return _clusters;
+ }
+
+ public List<Track> getTracks()
+ {
+ return _tracks;
+ }
+
+ public void addParticleID(ParticleID pid)
+ {
+ _particleIds.add(pid);
+ _particleIdUsed = pid;
+ }
+
+ public void addParticle(ReconstructedParticle particle)
+ {
+ _particles.add(particle);
+ }
+
+ public void addCluster(Cluster cluster)
+ {
+ _clusters.add(cluster);
+ }
+
+ public void addTrack(Track track)
+ {
+ _tracks.add(track);
+ }
+
+ public HepLorentzVector asFourVector()
+ {
+ return _fourVec;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("CheatReconstructedParticle: \n");
+ sb.append("E: "+getEnergy());
+ return sb.toString();
+ }
+}