lcsim/src/org/lcsim/mc/fast/reconstructedparticle
diff -N MCFastReconstructedParticle.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MCFastReconstructedParticle.java 1 Jul 2005 23:50:55 -0000 1.1
@@ -0,0 +1,202 @@
+package org.lcsim.mc.fast.reconstructedparticle;
+
+import hep.physics.vec.BasicHepLorentzVector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.HepLorentzVector;
+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 static java.lang.Math.sqrt;
+import org.lcsim.spacegeom.CartesianPoint;
+import org.lcsim.spacegeom.SpacePoint;
+
+/**
+ *
+ * @author ngraf
+ */
+public class MCFastReconstructedParticle implements ReconstructedParticle
+{
+ // ReconstructedParticle attributes
+ private int _type;
+ private Hep3Vector _momentum;
+ private double _energy;
+ private double[] _covMatrix;
+ private double _mass;
+ private double _charge;
+ private Hep3Vector _referencePoint;
+ private List<ParticleID> _particleIds = new ArrayList<ParticleID>();
+ private ParticleID _particleIdUsed;
+ private double _goodnessOfPid;
+ 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();
+
+
+ public MCFastReconstructedParticle(Track t, double mass)
+ {
+ _mass = mass;
+ 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());
+ }
+
+ public MCFastReconstructedParticle(Cluster c, double mass)
+ {
+ _mass = mass;
+ addCluster(c);
+ double e = c.getEnergy();
+ double p = sqrt(e*e-_mass*_mass);
+ // get direction from position of cluster and assume it comes from the origin
+ double[] point = c.getPosition();
+ SpacePoint pos = new CartesianPoint(point[0], point[1], point[2]);
+ double px = p*pos.cosPhi()*pos.cosTheta();
+ double py = p*pos.sinPhi()*pos.cosTheta();
+ double pz = p*pos.cosTheta();
+ _fourVec.setV3(e, px, py, pz);
+ }
+
+ // ReconstructedParticle interface
+
+ /** Type of reconstructed particle.
+ */
+ public int getType()
+ {
+ return _type;
+ }
+
+ /** The magnitude of the reconstructed particle's momentum
+ */
+ public Hep3Vector getMomentum()
+ {
+ return _momentum;
+ }
+
+ /** Energy of the reconstructed particle
+ */
+ public double getEnergy()
+ {
+ return _energy;
+ }
+
+ /** Covariance matrix of the reconstructed particle's 4vector (10 parameters).
+ * Stored as lower triangle matrix of the four momentum (px,py,pz,E), i.e.
+ * cov(px,px), cov(py,px), cov( py,py ) , ....
+ */
+ public double[] getCovMatrix()
+ {
+ return _covMatrix;
+ }
+
+ /** Mass of the reconstructed particle, set independently from four vector quantities
+ */
+ public double getMass()
+ {
+ return _mass;
+ }
+
+ /** Charge of the reconstructed particle.
+ */
+ public double getCharge()
+ {
+ return _charge;
+ }
+
+ /** Reference point of the reconstructedParticle parameters.
+ */
+ public Hep3Vector getReferencePoint()
+ {
+ return _referencePoint;
+ }
+
+ /** The particle Id's sorted by their likelihood.
+ * @see ParticleID
+ */
+ public List<ParticleID> getParticleIDs()
+ {
+ return _particleIds;
+ }
+
+ /** The particle Id used for the kinematics of this particle.
+ * @see ParticleID
+ */
+ public ParticleID getParticleIDUsed()
+ {
+ return _particleIdUsed;
+ }
+
+ /** The overall goodness of the PID on a scale of [0;1].
+ */
+ public double getGoodnessOfPID()
+ {
+ return _goodnessOfPid;
+ }
+
+ /** The reconstructed particles that have been combined to this particle.
+ */
+ public List<ReconstructedParticle> getParticles()
+ {
+ return _particles;
+ }
+
+ /** The clusters that have been used for this particle.
+ */
+ public List<Cluster> getClusters()
+ {
+ return _clusters;
+ }
+
+ /** The tracks that have been used for this particle.
+ */
+ public List<Track> getTracks()
+ {
+ return _tracks;
+ }
+
+ /**Add a ParticleID object.
+ * @see ParticleID
+ */
+ public void addParticleID(ParticleID pid)
+ {
+ _particleIds.add(pid);
+ }
+
+ /**Add a particle that has been used to create this particle.
+ */
+ public void addParticle(ReconstructedParticle particle)
+ {
+ _particles.add(particle);
+ }
+
+ /**Add a cluster that has been used to create this particle.
+ */
+ public void addCluster(Cluster cluster)
+ {
+ _clusters.add(cluster);
+ }
+
+ /**Add a track that has been used to create this particle.
+ */
+ public void addTrack(Track track)
+ {
+ _tracks.add(track);
+ }
+
+ /**Returns this particles momentum and energy as a four vector
+ */
+ public HepLorentzVector asFourVector()
+ {
+ return _fourVec;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("MCFastReconstructedParticle: \n");
+ sb.append("E: "+getEnergy());
+ return sb.toString();
+ }
+}
lcsim/src/org/lcsim/mc/fast/reconstructedparticle
diff -N MCFastReconstructedParticleDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MCFastReconstructedParticleDriver.java 1 Jul 2005 23:50:55 -0000 1.1
@@ -0,0 +1,59 @@
+/*
+ * MCFastReconstructedParticleDriver.java
+ *
+ * Created on July 1, 2005, 2:55 PM
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+
+package org.lcsim.mc.fast.reconstructedparticle;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
+import org.lcsim.util.Driver;
+
+/**
+ *
+ * @author ngraf
+ */
+public class MCFastReconstructedParticleDriver extends Driver
+{
+
+ /** Creates a new instance of MCFastReconstructedParticleDriver */
+ public MCFastReconstructedParticleDriver()
+ {
+ }
+
+ public void process(EventHeader event)
+ {
+ List<ReconstructedParticle> rpList = new ArrayList<ReconstructedParticle>();
+ // start with the smeared tracks...
+ List<Track> tracks = event.getTracks();
+ for(Track t : tracks)
+ {
+ double mass = 140.;
+// System.out.println(t);
+ MCFastReconstructedParticle rp = new MCFastReconstructedParticle(t, mass);
+ rpList.add(rp);
+ }
+
+ // loop over clusters...
+ List<Cluster> clusters = event.getClusters();
+ for(Cluster c : clusters)
+ {
+// System.out.println(c);
+ double mass = 939.;
+ MCFastReconstructedParticle rp = new MCFastReconstructedParticle(c, mass);
+ rpList.add(rp);
+ }
+
+// System.out.println(tracks.size()+ " tracks, "+clusters.size()+" clusters, "+rpList.size()+" reconstructedParticles");
+ }
+
+}