7 added files
lcsim/test/org/lcsim/recon/tracking/trffit
diff -N AddFitter_t.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AddFitter_t.java 25 Jul 2007 00:07:13 -0000 1.1
@@ -0,0 +1,63 @@
+/*
+ * AddFitter_t.java
+ *
+ * Created on July 24, 2007, 5:04 PM
+ *
+ * $Id: AddFitter_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ */
+
+package org.lcsim.recon.tracking.trffit;
+
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfbase.Cluster;
+import org.lcsim.recon.tracking.trfbase.ClusterTest;
+import org.lcsim.recon.tracking.trfbase.ETrack;
+import org.lcsim.recon.tracking.trfbase.Hit;
+import org.lcsim.recon.tracking.trfbase.SurfTest;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class AddFitter_t extends TestCase
+{
+ private boolean debug;
+ /** Creates a new instance of AddFitter_t */
+ public void testAddFitter()
+ {
+ String component = "AddFitter";
+ String ok_prefix = component + " (I): ";
+ String error_prefix = component + " test (E): ";
+
+ if(debug) System.out.println(ok_prefix
+ + "-------- Testing component " + component
+ + ". --------" );
+
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Define tracks and hit." );
+ SurfTest srf = new SurfTest(10);
+ ETrack tre = new ETrack( srf.newPureSurface() );
+ HTrack trh = new HTrack(tre);
+ Cluster pclu = new ClusterTest(srf,3);
+ Hit hit = (Hit)pclu.predict(tre,pclu).get(0);
+ if(debug) System.out.println(hit);
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Test constructor." );
+ AddFitterTest fit = new AddFitterTest(12);
+ if(debug) System.out.println(fit );
+ Assert.assertTrue( fit.addHit(trh,hit)!=0 );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix
+ + "------------- All tests passed. -------------" );
+
+ //********************************************************************
+ }
+
+}
lcsim/test/org/lcsim/recon/tracking/trffit
diff -N FullFitKalman_t.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FullFitKalman_t.java 25 Jul 2007 00:07:13 -0000 1.1
@@ -0,0 +1,140 @@
+/*
+ * FullFitKalman_t.java
+ *
+ * Created on July 24, 2007, 5:00 PM
+ *
+ * $Id: FullFitKalman_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ */
+
+package org.lcsim.recon.tracking.trffit;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfbase.Cluster;
+import org.lcsim.recon.tracking.trfbase.ETrack;
+import org.lcsim.recon.tracking.trfbase.Hit;
+import org.lcsim.recon.tracking.trfbase.Propagator;
+import org.lcsim.recon.tracking.trfbase.SurfTest;
+import org.lcsim.recon.tracking.trfbase.TrackError;
+import org.lcsim.recon.tracking.trfbase.TrackVector;
+import org.lcsim.recon.tracking.trflayer.PropTest;
+import org.lcsim.recon.tracking.trfutil.Assert;
+import org.lcsim.recon.tracking.trfutil.WAvg;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class FullFitKalman_t extends TestCase
+{
+ private boolean debug;
+ /** Creates a new instance of FullFitKalman_t */
+ public void testFullFitKalman()
+ {
+ String component = "FullFitKalman";
+ String ok_prefix = component + " (I): ";
+ String error_prefix = component + " test (E): ";
+
+ System.out.println(ok_prefix + "-------- Testing component " + component
+ + ". --------" );
+
+ //********************************************************************
+
+ // Create starting surface and track.
+
+ SurfTest stest = new SurfTest(1);
+ double tvec = 2.1;
+ double terr = 0.014;
+ TrackVector vec = new TrackVector();
+ TrackError err = new TrackError();
+ vec.set(0, tvec);
+ err.set(0,0, terr);
+ err.set(1,1, 0.000001);
+ err.set(2,2, 0.000001);
+ err.set(3,3, 0.000001);
+ err.set(4,4, 0.000001);
+ ETrack tre = new ETrack( stest.newPureSurface(), vec, err );
+ WAvg avg = new WAvg();
+ avg.addPair(tvec,terr);
+
+ //********************************************************************
+
+ System.out.println(ok_prefix + "Create clusters and generate prediction."
+ );
+ List clusters = new ArrayList();
+ int nmsmt = 5;
+ double msmt[] = { 2.00, 2.33, 1.94, 2.22, 1.87 };
+ double emsmt[] = { 0.01, 0.015, 0.016, 0.023, 0.012 };
+ int i;
+ for ( i=0; i<nmsmt; ++i )
+ {
+ clusters.add( new ClusTestFit1(stest,msmt[i],emsmt[i]) );
+ avg.addPair(msmt[i],emsmt[i]);
+ };
+ System.out.println("avg = "+avg );
+
+ //********************************************************************
+
+ // Create hits.
+ List hits = new ArrayList();
+
+ for( Iterator iclu=clusters.iterator(); iclu.hasNext(); )
+ {
+ Cluster clu = (Cluster)iclu.next();
+ List newhits = clu.predict(tre, clu);
+ hits.add( newhits.get(newhits.size()-1) );
+ }
+ // Check the list of Hits
+ if(debug)
+ {
+ for ( Iterator ihit=hits.iterator(); ihit.hasNext(); )
+ {
+ System.out.println("Hit= "+ihit.next());
+ }
+ }
+
+ //********************************************************************
+
+ // Put hit on an HTrack.
+ HTrack trh = new HTrack(tre);
+ for ( Iterator ihit=hits.iterator(); ihit.hasNext(); )
+ {
+ trh.addHit((Hit)ihit.next());
+ }
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Construct fitter." );
+ Propagator pprop = new PropTest();
+ FullFitKalman fitk = new FullFitKalman(pprop);
+ if(debug) System.out.println(fitk );
+
+ //********************************************************************
+ if(debug) System.out.println("tre= \n"+tre);
+ if(debug) System.out.println("trh= \n"+trh);
+ if(debug) System.out.println(ok_prefix + "Fit with all hits." );
+ Assert.assertTrue( ! trh.isFit() );
+ fitk.fit(trh);
+ if(debug) System.out.println( "trh= "+trh );
+ double small = 1.e-10;
+ Assert.assertTrue( trh.isFit() );
+ if(debug) System.out.println(Math.abs( trh.newTrack().vector().get(0) - avg.average()));
+ Assert.assertTrue( Math.abs( trh.newTrack().vector().get(0) - avg.average() )
+ < small );
+ Assert.assertTrue( Math.abs( trh.newTrack().error().get(0,0) - avg.error() )
+ < small );
+ if(debug) System.out.println("dchisq="+Math.abs( trh.chisquared() - avg.chiSquared() ) );
+ Assert.assertTrue( Math.abs( trh.chisquared() - avg.chiSquared() )
+ < small );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix
+ + "------------- All tests passed. -------------" );
+
+ //********************************************************************
+ }
+
+}
lcsim/test/org/lcsim/recon/tracking/trffit
diff -N HTrack_t.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HTrack_t.java 25 Jul 2007 00:07:13 -0000 1.1
@@ -0,0 +1,190 @@
+/*
+ * HTrack_t.java
+ *
+ * Created on July 24, 2007, 4:46 PM
+ *
+ * $Id: HTrack_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ */
+
+package org.lcsim.recon.tracking.trffit;
+
+import java.util.List;
+import java.util.ListIterator;
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfbase.Cluster;
+import org.lcsim.recon.tracking.trfbase.ClusterTest;
+import org.lcsim.recon.tracking.trfbase.ETrack;
+import org.lcsim.recon.tracking.trfbase.Hit;
+import org.lcsim.recon.tracking.trfbase.SurfTest;
+import org.lcsim.recon.tracking.trfbase.TrackError;
+import org.lcsim.recon.tracking.trfbase.TrackVector;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class HTrack_t extends TestCase
+{
+ private boolean debug;
+ /** Creates a new instance of HTrack_t */
+ public void testHTrack()
+ {
+ String component = "HTrack";
+ String ok_prefix = component + " (I): ";
+ String error_prefix = component + " test (E): ";
+
+ if(debug) System.out.println(ok_prefix + "-------- Testing component " + component
+ + ". --------" );
+
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Test constructors" );
+ ETrack tre = new ETrack( new SurfTest(5) );
+ if(debug) System.out.println(tre);
+ HTrack trh1 = new HTrack(tre);
+ if(debug) System.out.println(trh1 );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Test status" );
+ // Track with good fit and no hits is fit.
+ Assert.assertTrue( trh1.isFit() );
+ Assert.assertTrue( trh1.hits().size() == 0 );
+ trh1.unsetFit();
+ Assert.assertTrue( ! trh1.isFit() );
+ Assert.assertTrue( ! trh1.isFit() );
+ trh1.setFit(tre,0.0);
+ Assert.assertTrue( trh1.isFit() );
+ Assert.assertTrue( trh1.isFit() );
+ trh1.unsetFit();
+ Assert.assertTrue( ! trh1.isFit() );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Add hits." );
+ SurfTest srf1 = new SurfTest(10);
+ Cluster pclu = new ClusterTest(srf1,10);
+ ETrack tre1 = new ETrack( srf1.newPureSurface() );
+ List hits = pclu.predict(tre1,pclu);
+ Assert.assertTrue( hits.size() == 10 );
+
+
+ // ihit iterates over input hits
+
+ ListIterator ihit = hits.listIterator();
+ trh1.setFit(tre,0.0);
+ //0
+ trh1.addHit( (Hit)ihit.next() );
+ Assert.assertTrue( ! trh1.isFit() );
+ //1
+ trh1.addHit( (Hit)ihit.next() );
+ trh1.setFit(tre,0.0);
+ Assert.assertTrue( trh1.isFit() );
+ Assert.assertTrue( trh1.isFit() );
+ trh1.unsetFit();
+ Assert.assertTrue( ! trh1.isFit() );
+ Assert.assertTrue( ! trh1.isFit() );
+ // 2
+ trh1.addHit( (Hit)ihit.next() );
+ if(debug) System.out.println(trh1 );
+ // jhit iterates over output hits
+ Assert.assertTrue( trh1.hits().size() == 3 );
+
+ ihit = hits.listIterator(0);
+ ListIterator jhit = trh1.hits().listIterator();
+ Assert.assertTrue( ((Hit)ihit.next()).equals( (Hit)jhit.next()) );
+ // 1
+ Assert.assertTrue(((Hit)ihit.next()).equals( (Hit)jhit.next()));
+ // 2
+ Assert.assertTrue(((Hit)ihit.next()).equals( (Hit)jhit.next()));
+ Assert.assertTrue( trh1.hits().size() == 3 );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Drop a hit" );
+ trh1.setFit(tre,0.0);
+ ihit = hits.listIterator(0);
+ trh1.dropHit();
+ Assert.assertTrue( trh1.hits().size() == 2 );
+ Assert.assertTrue( ! trh1.isFit() );
+ jhit = trh1.hits().listIterator();
+ Assert.assertTrue( ((Hit)ihit.next()).equals( (Hit)jhit.next()) );
+ // 1
+ Assert.assertTrue( ((Hit)ihit.next()).equals( (Hit)jhit.next()) );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Set track and chi-square." );
+ TrackVector vec = new TrackVector();
+ int i,j;
+ for ( i=0; i<5; ++i ) vec.set(i,1.1*i);
+ TrackError err = new TrackError();
+ for ( i=0; i<5; ++i )
+ {
+ for ( j=0; j<=i; ++j )
+ {
+ double fac;
+ if ( i == j ) fac = 0.1;
+ else fac = 0.01;
+ err.set(i,j, ( i + 0.1*j ) * fac);
+ }
+ }
+
+ ETrack tre2 = new ETrack( srf1.newPureSurface(), vec, err );
+ double chisq = 12.345;
+ trh1.setFit(tre2,chisq);
+ if(debug) System.out.println(trh1 );
+ Assert.assertTrue( trh1.isFit() );
+ Assert.assertTrue( trh1.newTrack().equals(tre2) );
+ Assert.assertTrue( trh1.isFit() );
+ Assert.assertTrue( trh1.chisquared() == chisq );
+ Assert.assertTrue( trh1.isFit() );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Test copy constructor." );
+ HTrack trh2 = new HTrack(trh1);
+ if(debug) System.out.println(trh2 );
+ Assert.assertTrue( trh2.isFit() );
+ Assert.assertTrue( trh2.newTrack().equals(trh1.newTrack()) );
+ Assert.assertTrue( trh2.chisquared() == trh1.chisquared() );
+ Assert.assertTrue( trh2.hits().equals(trh1.hits()) );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Check equality." );
+ Assert.assertTrue( trh1.equals(trh1) );
+ Assert.assertTrue( ! (trh1.notEquals(trh1)) );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix + "Check Number of measurements." );
+ if(debug) System.out.println(trh1.numberOfMeasurements() );
+ Assert.assertTrue( trh1.numberOfMeasurements()==4 );
+
+ //********************************************************************
+
+ // HitTest does not set mcids currently.
+ if(debug) System.out.println(ok_prefix + "Check TrackMcHitInfo" );
+ if(debug) System.out.println(trh1.mcInfo().bestMcId() );
+ Assert.assertTrue( trh1.mcInfo().bestMcId()==0 );
+
+ //********************************************************************
+
+
+ if(debug) System.out.println(ok_prefix + "Drop all hits." );
+ Assert.assertTrue( trh1.isFit() );
+ Assert.assertTrue( trh1.hits().size() == 2 );
+ trh1.dropHits();
+ Assert.assertTrue( trh1.hits().size() == 0 );
+ Assert.assertTrue( ! trh1.isFit() );
+
+ //********************************************************************
+
+ if(debug) System.out.println(ok_prefix
+ + "------------- All tests passed. -------------" );
+ }
+
+}
lcsim/test/org/lcsim/recon/tracking/trffit
diff -N HTrackGenerator_t.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HTrackGenerator_t.java 25 Jul 2007 00:07:13 -0000 1.1
@@ -0,0 +1,116 @@
+/*
+ * HTrackGenerator_t.java
+ *
+ * Created on July 24, 2007, 4:57 PM
+ *
+ * $Id: HTrackGenerator_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ */
+
+package org.lcsim.recon.tracking.trffit;
+
+import java.util.ArrayList;
+import java.util.List;
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfbase.Cluster;
+import org.lcsim.recon.tracking.trfbase.ClusterTest;
+import org.lcsim.recon.tracking.trfbase.HitGenerator;
+import org.lcsim.recon.tracking.trfbase.SurfTest;
+import org.lcsim.recon.tracking.trfbase.Surface;
+import org.lcsim.recon.tracking.trfbase.TrackError;
+import org.lcsim.recon.tracking.trfbase.TrackVector;
+import org.lcsim.recon.tracking.trfbase.VTrack;
+import org.lcsim.recon.tracking.trflayer.PropTest;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class HTrackGenerator_t extends TestCase
+{
+ private boolean debug;
+ /** Creates a new instance of HTrackGenerator_t */
+ public void testHTrackGenerator()
+ {
+ //**********************************************************************
+
+
+ String component = "HTrackGenerator";
+ String ok_prefix = component + " (I): ";
+ String error_prefix = component + " test (E): ";
+
+ if(debug) System.out.println( ok_prefix
+ + "---------- Testing component " + component
+ + ". ----------" );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Test constructor." );
+ // construct VTrack generator
+ SurfTest stest = new SurfTest(1);
+ TrackVector vec = new TrackVector();
+ vec.set(0, 1.0);
+ vec.set(1, 2.0);
+ vec.set(2, 3.0);
+ vec.set(3, 4.0);
+ vec.set(4, 5.0);
+ VTrack trv = new VTrack( stest.newPureSurface(), vec );
+ // Construct list of Hit generators.
+ List hgens = new ArrayList();
+ hgens.add( new HitGeneratorTest(new SurfTest(2)) );
+ hgens.add( new HitGeneratorTest(new SurfTest(4)) );
+ hgens.add( new HitGeneratorTest(new SurfTest(6)) );
+ hgens.add( new HitGeneratorTest(new SurfTest(8)) );
+ // Construct track error matrix.
+ TrackError terr = new TrackError();
+ terr.set(0,0, 0.01);
+ terr.set(1,1, 0.02);
+ terr.set(2,2, 0.03);
+ terr.set(3,3, 0.04);
+ terr.set(4,4, 0.05);
+ // Construct propagator.
+ PropTest prop = new PropTest();
+ // construct generator
+ HTrackGenerator gen = new HTrackGenerator(hgens,prop,stest,terr);
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Generate tracks." );
+ HTrack trh = gen.newTrack(trv);
+ Assert.assertTrue( trh != null );
+ if(debug) System.out.println( trh );
+ Assert.assertTrue( trh.hits().size() == 4 );
+ Assert.assertTrue( trh.newTrack().surface().pureEqual(stest) );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix
+ + "------------- All tests passed. -------------" );
+
+
+ //********************************************************************
+ }
+
+}
+
+class HitGeneratorTest extends HitGenerator
+{
+
+ private SurfTest _srf;
+ private double _min;
+ private double _max;
+
+ public HitGeneratorTest( SurfTest srf)
+ {
+ _srf = new SurfTest(srf);
+ }
+ public Surface surface()
+ {
+ return _srf;
+ }
+ public Cluster newCluster( VTrack trv, int mcid)
+ {
+ int npred = (int)( flat(1.0,10.0) );
+ return new ClusterTest(_srf,npred);
+ }
+}
\ No newline at end of file
lcsim/test/org/lcsim/recon/tracking/trffit
diff -N TrackMcHitInfo_t.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TrackMcHitInfo_t.java 25 Jul 2007 00:07:13 -0000 1.1
@@ -0,0 +1,79 @@
+/*
+ * TrackMcHitInfo_t.java
+ *
+ * Created on July 24, 2007, 4:42 PM
+ *
+ * $Id: TrackMcHitInfo_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ */
+
+package org.lcsim.recon.tracking.trffit;
+
+import java.util.HashMap;
+import java.util.Map;
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class TrackMcHitInfo_t extends TestCase
+{
+ private boolean debug;
+ /** Creates a new instance of TrackMcHitInfo_t */
+ public void testTrackMcHitInfo()
+ {
+ String component = "TrackMcHitInfo";
+ String ok_prefix = component + " (I): ";
+ String error_prefix = component + " test (E): ";
+
+ if(debug) System.out.println("-------- Testing component " + component
+ + ". --------" );
+
+
+ //********************************************************************
+
+
+ // make some data
+
+ int nhits = 16;
+ Map idmap = new HashMap();
+ idmap.put(new Integer(2),new Integer(15));
+ idmap.put(new Integer(13),new Integer(11));
+ idmap.put(new Integer(137),new Integer(1));
+
+
+ if(debug) System.out.println("Test constructors" );
+
+ TrackMcHitInfo tmcinfo = new TrackMcHitInfo(nhits,idmap);
+
+ if(debug) System.out.println("Test best_id " + tmcinfo.bestMcId() );
+ Assert.assertTrue( tmcinfo.bestMcId() == 2 );
+
+ if(debug) System.out.println("Test purity " + tmcinfo.purity() );
+ Assert.assertTrue( tmcinfo.purity() == 15./16. );
+
+ if(debug) System.out.println("Test number of hits " + tmcinfo.numHits() );
+ Assert.assertTrue( tmcinfo.numHits() == 16 );
+
+ if(debug) System.out.println("Test full list of Mc Ids, there are " + tmcinfo.mc_idlist().size()+ " ids.");
+
+ Assert.assertTrue( tmcinfo.mc_idlist().size() == 3 );
+ for(int i = 0; i<tmcinfo.mc_idlist().size(); ++i)
+ {
+ if(debug) System.out.println("Mc Id " + i +" " + ((Integer)tmcinfo.mc_idlist().get(i)).intValue());
+ }
+
+ if(debug) System.out.println("Test McIdMap " + tmcinfo.mcHitNumber().size() );
+ Assert.assertTrue( tmcinfo.mcHitNumber().size() == 3 );
+
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix
+ + "------------- All tests passed. -------------" );
+
+ //********************************************************************
+ }
+
+}
lcsim/test/org/lcsim/recon/tracking/trffit
diff -N AddFitKalman_t.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AddFitKalman_t.java 25 Jul 2007 00:07:13 -0000 1.1
@@ -0,0 +1,112 @@
+/*
+ * AddFitKalman_t.java
+ *
+ * Created on July 24, 2007, 5:05 PM
+ *
+ * $Id: AddFitKalman_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ */
+
+package org.lcsim.recon.tracking.trffit;
+
+import java.util.List;
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfbase.Cluster;
+import org.lcsim.recon.tracking.trfbase.ETrack;
+import org.lcsim.recon.tracking.trfbase.Hit;
+import org.lcsim.recon.tracking.trfbase.SurfTest;
+import org.lcsim.recon.tracking.trfbase.TrackError;
+import org.lcsim.recon.tracking.trfbase.TrackVector;
+import org.lcsim.recon.tracking.trfutil.Assert;
+import org.lcsim.recon.tracking.trfutil.WAvg;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class AddFitKalman_t extends TestCase
+{
+ private boolean debug;
+ /** Creates a new instance of AddFitKalman_t */
+ public void testAddFitKalman()
+ {
+ String component = "AddFitKalman";
+ String ok_prefix = component + " (I): ";
+ String error_prefix = component + " test (E): ";
+
+ if(debug) System.out.println( ok_prefix
+ + "-------- Testing component " + component
+ + ". --------" + "\n");
+
+ //********************************************************************
+ if(debug) System.out.println( ok_prefix + "Test constructor." + "\n");
+ AddFitKalman fitk = new AddFitKalman();
+ if(debug) System.out.println( fitk + "\n");
+ Assert.assertTrue( fitk.type() == AddFitKalman.staticType() );
+ if(debug) System.out.println( fitk.typeName() + "\n");
+ Assert.assertTrue( fitk.typeName() == "AddFitKalman" );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Test fitting 1 hit." + "\n");
+ double small = 1.e-12;
+ WAvg avg = new WAvg();
+ SurfTest srf = new SurfTest(10);
+ TrackVector vec = new TrackVector();
+ TrackError err = new TrackError();
+ vec.set(0,2.9);
+ err.set(0,0,0.04);
+ err.set(1,1,0.0001);
+ err.set(2,2,0.0001);
+ err.set(3,3,0.0001);
+ err.set(4,4,0.0001);
+ avg.addPair(vec.get(0),err.get(0,0));
+
+ ETrack tre = new ETrack( srf.newPureSurface(), vec, err );
+ HTrack trh = new HTrack(tre);
+ Cluster clu1 = new ClusTestFit1(srf,3.0,0.01) ;
+ avg.addPair(3.0,0.01);
+
+ List hits = clu1.predict(tre,clu1);
+ if(debug) System.out.println( trh + "\n");
+ if(debug) System.out.println( hits.get(0) + "\n");
+ Assert.assertTrue( fitk.addHit(trh,(Hit)hits.get(0)) == 0 );
+ if(debug) System.out.println( trh + "\n");
+ if(debug) System.out.println( avg + "\n");
+ if(debug) System.out.println("trk= "+trh.newTrack().vector().get(0)+" "+avg.average());
+ Assert.assertTrue( Math.abs( trh.newTrack().vector().get(0) - avg.average() )
+ < small );
+ Assert.assertTrue( Math.abs( trh.newTrack().error().get(0,0) - avg.error() )
+ < small );
+ if(debug) System.out.println("trk chisq= "+trh.chisquared()+", avg chsq= "+ avg.chiSquared());
+ Assert.assertTrue( Math.abs( trh.chisquared() - avg.chiSquared() )
+ < small );
+ Assert.assertTrue( trh.hits().size() == 1 );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Test fitting 2 hits." + "\n");
+ Cluster clu2 = new ClusTestFit1(srf,3.3,0.02);
+ avg.addPair(3.3,0.02);
+ hits = clu2.predict(trh.newTrack(),clu2);
+ Assert.assertTrue( fitk.addHit( trh, (Hit)hits.get(0) ) == 0 );
+ if(debug) System.out.println( trh + "\n");
+ if(debug) System.out.println( avg + "\n");
+ Assert.assertTrue( Math.abs( trh.newTrack().vector().get(0) - avg.average() )
+ < small );
+ Assert.assertTrue( Math.abs( trh.newTrack().error().get(0,0) - avg.error() )
+ < small );
+ Assert.assertTrue( Math.abs( trh.chisquared() - avg.chiSquared() )
+ < small );
+ Assert.assertTrue( trh.hits().size() == 2 );
+
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix
+ + "------------- All tests passed. -------------" + "\n");
+
+
+ //********************************************************************
+ }
+
+}
lcsim/test/org/lcsim/recon/tracking/trffit
diff -N FullFitter_t.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FullFitter_t.java 25 Jul 2007 00:07:13 -0000 1.1
@@ -0,0 +1,57 @@
+/*
+ * FullFitter_t.java
+ *
+ * Created on July 24, 2007, 4:59 PM
+ *
+ * $Id: FullFitter_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ */
+
+package org.lcsim.recon.tracking.trffit;
+
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfbase.ETrack;
+import org.lcsim.recon.tracking.trfbase.SurfTest;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+/**
+ *
+ * @author Norman Graf
+ */
+public class FullFitter_t extends TestCase
+{
+ private boolean debug;
+ /** Creates a new instance of FullFitter_t */
+ public void testFullFitter()
+ {
+ String component = "FullFitter";
+ String ok_prefix = component + " (I): ";
+ String error_prefix = component + " test (E): ";
+
+ if(debug) System.out.println( ok_prefix
+ + "-------- Testing component " + component );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Define track." );
+ SurfTest srf = new SurfTest(10);
+ ETrack tre = new ETrack( srf.newPureSurface() );
+ HTrack trh = new HTrack(tre);
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Test constructor." );
+ int ival = 123;
+ FullFitterTest fit = new FullFitterTest(ival);
+ if(debug) System.out.println( fit );
+ Assert.assertTrue( fit.fit(trh) == ival );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix
+ + "------------- All tests passed. -------------" );
+
+
+ //********************************************************************
+ }
+
+}
CVSspam 0.2.8