lcsim/src/org/lcsim/event/base
diff -N BaseMCParticle.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ BaseMCParticle.java 30 Mar 2006 18:33:13 -0000 1.1
@@ -0,0 +1,109 @@
+/*
+ * BaseMCParticle.java
+ *
+ * Created on March 30, 2006, 8:58 AM
+ *
+ * $Id: BaseMCParticle.java,v 1.1 2006/03/30 18:33:13 ngraf Exp $
+ */
+
+package org.lcsim.event.base;
+
+import hep.physics.particle.BasicParticle;
+import hep.physics.particle.properties.ParticleType;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.HepLorentzVector;
+import java.util.ArrayList;
+import java.util.List;
+import org.lcsim.event.MCParticle;
+
+/**
+ * A base class implementatin of the MCParticle interface.
+ * Extends BasicParticle to fulfill the Particle interface.
+ * @author Norman Graf
+ */
+public class BaseMCParticle extends BasicParticle implements MCParticle
+{
+ // TODO resolve whether this should be handled by BasicParticle
+ protected List<MCParticle> _parents = new ArrayList<MCParticle>();
+ protected List<MCParticle> _daughters = new ArrayList<MCParticle>();;
+
+ protected Hep3Vector _endPoint = new BasicHep3Vector(0., 0., 0.);
+
+ protected SimulatorStatus _status;
+
+ /**
+ * Creates a new instance of BaseMCParticle
+ * @param origin The (x,y,z) point of origin for this particle in mm.
+ * @param p The four momentum of this particle in GeV.
+ * @param ptype The particle type.
+ * @param status the integer status of this particle.
+ * @param time the time of creation of this particle in ns.
+ */
+ public BaseMCParticle(Hep3Vector origin,HepLorentzVector p,ParticleType ptype,int status, double time)
+ {
+ super(origin, p, ptype, status, time);
+ }
+
+ /**
+ * If this point has interacted, set its end point.
+ * @param p The (x,y,z) end point in mm.
+ */
+ public void setEndPoint(Hep3Vector p)
+ {
+ _endPoint = p;
+ }
+
+ public String toString()
+ {
+ // TODO fix this to call super.toString() when BasicParticle implements toString()
+ String className = getClass().getName();
+ int lastDot = className.lastIndexOf('.');
+ if(lastDot!=-1)className = className.substring(lastDot+1);
+ StringBuffer sb = new StringBuffer(className+": "+getType().getName()+"\n");
+ sb.append("pdgId: "+getPDGID()+"\n");
+ sb.append("(x,y,z): ("+getOriginX()+", "+getOriginY()+", "+getOriginZ()+")\n");
+ sb.append("(px,py,pz): ("+getPX()+", "+getPY()+", "+getPZ()+")\n");
+ return sb.toString();
+ }
+
+// MCParticle interface
+
+ /**
+ * The list of parents of this particle
+ * @return list of parent MCParticles.
+ */
+ public List<MCParticle> getParents()
+ {
+ return _parents;
+ }
+ /**
+ * The list of daughters of this particle
+ * @return list of daughter MCParticles.
+ */
+ public List<MCParticle> getDaughters()
+ {
+ return _daughters;
+ }
+ /**
+ * If this event has been simulated by Geant4 this method will return
+ * the simulation status
+ * @return
+ */
+ public SimulatorStatus getSimulatorStatus()
+ {
+ return _status;
+ }
+ /**
+ * The endpoint of the simulated track. Note this may not always be available,
+ * in which case this method may throw an exception.
+ * @return
+ */
+ public Hep3Vector getEndPoint()
+ {
+ return _endPoint;
+ }
+
+
+
+}
lcsim/src/org/lcsim/event/base
diff -u -r1.3 -r1.4
--- BaseTrackerHit.java 28 Mar 2006 19:51:37 -0000 1.3
+++ BaseTrackerHit.java 30 Mar 2006 18:33:13 -0000 1.4
@@ -3,7 +3,7 @@
*
* Created on March 24, 2006, 9:22 AM
*
- * $Id: BaseTrackerHit.java,v 1.3 2006/03/28 19:51:37 ngraf Exp $
+ * $Id: BaseTrackerHit.java,v 1.4 2006/03/30 18:33:13 ngraf Exp $
*/
package org.lcsim.event.base;
@@ -13,7 +13,8 @@
import org.lcsim.event.*;
/**
- *
+ * // TODO add methods to add hits to this object.
+ * // TODO decide what these hits should be.
* @author Norman Graf
*/
public class BaseTrackerHit implements TrackerHit
lcsim/src/org/lcsim/event/base
diff -u -r1.2 -r1.3
--- BaseTrackerHitMC.java 28 Mar 2006 19:51:37 -0000 1.2
+++ BaseTrackerHitMC.java 30 Mar 2006 18:33:13 -0000 1.3
@@ -3,7 +3,7 @@
*
* Created on March 24, 2006, 9:46 AM
*
- * $Id: BaseTrackerHitMC.java,v 1.2 2006/03/28 19:51:37 ngraf Exp $
+ * $Id: BaseTrackerHitMC.java,v 1.3 2006/03/30 18:33:13 ngraf Exp $
*/
package org.lcsim.event.base;
@@ -11,14 +11,33 @@
import java.util.ArrayList;
import java.util.List;
import org.lcsim.event.MCParticle;
+import org.lcsim.event.SimTrackerHit;
/**
- * A BaseTrackerHit which includes information about the Monte carlo particles contributing to it.
+ * A BaseTrackerHit which includes information about the Monte Carlo particles contributing to it.
* @author Norman Graf
*/
public class BaseTrackerHitMC extends BaseTrackerHit
{
+ // TODO should this be a Set so we have no duplicates?
protected List<MCParticle> _mcparticles = new ArrayList<MCParticle>();
+ protected List<SimTrackerHit> _simHits = new ArrayList<SimTrackerHit>();
+
+ /**
+ * fully qualified constructor
+ * @param pos the position of this hit (x,y,z) in mm
+ * @param cov the covariance matrix for the position measurement, packed as 6 elements.
+ * @param t the time for this measurement in ns
+ * @param e the energy deposit associated with this measurement, in GeV
+ * @param type the type of this measurement. not yet defined.
+ * @param mcparticle The monte carlo particle contributing to this measurement.
+ */
+ public BaseTrackerHitMC(double[] pos, double[] cov, double t, double e, int type, MCParticle mcparticle)
+ {
+ super(pos, cov, t, e, type);
+ _mcparticles.add(mcparticle);
+ }
+
/**
* fully qualified constructor
* @param pos the position of this hit (x,y,z) in mm
@@ -26,15 +45,28 @@
* @param t the time for this measurement in ns
* @param e the energy deposit associated with this measurement, in GeV
* @param type the type of this measurement. not yet defined.
- * @param mcparticles The list of monte carlo particles contributing to this measurement.
+ * @param simHits The list of SimTrackerHit(s) contributing to this measurement.
*/
- public BaseTrackerHitMC(double[] pos, double[] cov, double t, double e, int type, List<MCParticle> mcparticles)
+ public BaseTrackerHitMC(double[] pos, double[] cov, double t, double e, int type, List<SimTrackerHit> simHits)
{
super(pos, cov, t, e, type);
- _mcparticles = mcparticles;
+ for(SimTrackerHit hit : simHits)
+ {
+ MCParticle mcp = hit.getMCParticle();
+ if(!_mcparticles.contains(mcp)) _mcparticles.add(mcp);
+ if(!_simHits.contains(hit)) _simHits.add(hit);
+ }
}
/**
+ * Add an MCParticle which contributed to this hit.
+ * @param mcp The MCParticle to associate with this hit.
+ */
+ public void addMCParticle(MCParticle mcp)
+ {
+ if(!_mcparticles.contains(mcp)) _mcparticles.add(mcp);
+ }
+ /**
* The list of monte carlo particles contributing to this measurement.
* @return The list of monte carlo particles contributing to this measurement.
*/
@@ -43,11 +75,23 @@
return _mcparticles;
}
+ /**
+ * The MC tracker hits contributing to this hit.
+ * @return the list of SimTrackerHit which contribute to this hit.
+ */
+ public List<SimTrackerHit> getSimHits()
+ {
+ return _simHits;
+ }
+
public String toString()
{
StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" with "+_mcparticles.size()+" MCParticle"+(_mcparticles.size()==1?"":"s"));
- // TODO decide how to handle listing of MCParticles.
+ sb.append(" with "+_mcparticles.size()+" MCParticle"+(_mcparticles.size()==1?"":"s")+"\n");
+ for(MCParticle mcp : _mcparticles)
+ {
+ sb.append(mcp+"\n");
+ }
return sb.toString();
}