Commit in lcsim/test/org/lcsim/event/base on MAIN
BaseTrackerHitMCTest.java+79added 1.1
BaseMCParticleTest.java+56added 1.1
+135
2 added files
New tests.

lcsim/test/org/lcsim/event/base
BaseTrackerHitMCTest.java added at 1.1
diff -N BaseTrackerHitMCTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BaseTrackerHitMCTest.java	30 Mar 2006 18:37:08 -0000	1.1
@@ -0,0 +1,79 @@
+/*
+ * BaseTrackerHitMCTest.java
+ *
+ * Created on March 30, 2006, 8:47 AM
+ *
+ * $Id: BaseTrackerHitMCTest.java,v 1.1 2006/03/30 18:37:08 ngraf Exp $
+ */
+
+package org.lcsim.event.base;
+
+import hep.physics.particle.properties.ParticlePropertyManager;
+import hep.physics.particle.properties.ParticlePropertyProvider;
+import hep.physics.particle.properties.ParticleType;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.BasicHepLorentzVector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.HepLorentzVector;
+import junit.framework.TestCase;
+import org.lcsim.event.MCParticle;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class BaseTrackerHitMCTest extends TestCase
+{
+   ParticlePropertyProvider ppp = ParticlePropertyManager.getParticlePropertyProvider();
+   
+    /** Creates a new instance of BaseTrackerHitMCTest */
+    public void testBaseTrackerHitMC()
+    {
+       double[] mcPos = {0., 0., 0.};
+       double[] mcMom = {10., 0., 0.};
+       int mcPdgId = 13;
+       MCParticle mcp = makeMCParticle(mcPos, mcMom, mcPdgId);
+       
+        double[] pos = {1., 2., 3.};
+        double[] cov = {1., 2., 3., 4., 5., 6. };
+        double time = 137.;
+        double e = .001;
+        int type = 11;
+        
+        BaseTrackerHitMC hit = new BaseTrackerHitMC(pos, cov, time, e, type, mcp);
+//        System.out.println(hit);        
+        assertEquals(hit.getTime(),time);
+        assertEquals(hit.getdEdx(), e);
+        assertEquals(hit.getType(), type);
+        
+        assertEquals(hit.getSimHits().size(), 0);
+        assertEquals(hit.mcParticles().size(), 1);
+        
+        // should not count the same MCParticle twice...
+        hit.addMCParticle(mcp);
+        assertEquals(hit.mcParticles().size(), 1);
+        
+        // Should update
+        // TODO fix equality checks on MCParticle!
+        hit.addMCParticle(makeMCParticle(mcPos, mcMom, mcPdgId));
+        // In the future, this test should fail, since it is the same MCParticle
+        // even if they are different objects
+        assertEquals(hit.mcParticles().size(), 2);
+          
+    }
+    
+    MCParticle makeMCParticle(double[] x, double[] p, int pdgId)
+    {
+        // boiler plate to get going...
+        
+        Hep3Vector pos = new BasicHep3Vector(x);
+        ParticleType type = ppp.get(pdgId);
+        int status = 0;
+        double time = 137.;
+        Hep3Vector mom = new BasicHep3Vector(p);
+        HepLorentzVector fourmom = new BasicHepLorentzVector(type.getMass(),mom);
+        
+        return new BaseMCParticle(pos, fourmom, type, status, time);        
+    }
+    
+}

lcsim/test/org/lcsim/event/base
BaseMCParticleTest.java added at 1.1
diff -N BaseMCParticleTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BaseMCParticleTest.java	30 Mar 2006 18:37:08 -0000	1.1
@@ -0,0 +1,56 @@
+/*
+ * BaseMCParticleTest.java
+ *
+ * Created on March 30, 2006, 9:14 AM
+ *
+ * $Id: BaseMCParticleTest.java,v 1.1 2006/03/30 18:37:08 ngraf Exp $
+ */
+
+package org.lcsim.event.base;
+
+import hep.physics.particle.properties.ParticlePropertyManager;
+import hep.physics.particle.properties.ParticlePropertyProvider;
+import hep.physics.particle.properties.ParticleType;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.BasicHepLorentzVector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.HepLorentzVector;
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class BaseMCParticleTest extends TestCase
+{
+    
+    /** Creates a new instance of BaseMCParticleTest */
+    public void  testBaseMCParticle()
+    {
+        // boiler plate to get going...
+        ParticlePropertyProvider ppp = ParticlePropertyManager.getParticlePropertyProvider();
+        
+        Hep3Vector pos = new BasicHep3Vector(0., 0., 0.);
+        int pdgId = 13;
+        ParticleType type = ppp.get(pdgId);
+        int status = 0;
+        double time = 137.;
+        Hep3Vector mom = new BasicHep3Vector(10., 0., 0.);
+        double e = Math.sqrt(type.getMass()*type.getMass()+mom.magnitudeSquared());
+        HepLorentzVector fourmom = new BasicHepLorentzVector(e,mom);
+        
+        BaseMCParticle mcp = new BaseMCParticle(pos, fourmom, type, status, time);
+        
+//        System.out.println(mcp);
+        
+        assertEquals(mcp.getParents().size(),0);
+        assertEquals(mcp.getDaughters().size(),0);
+        assertNull(mcp.getSimulatorStatus());
+        
+        assertEquals(mcp.getEndPoint().x(), 0.);
+        mcp.setEndPoint(new BasicHep3Vector(1., 2., 3.));
+        assertEquals(mcp.getEndPoint().x(), 1.);
+        
+    }
+    
+}
CVSspam 0.2.8