lcsim/test/org/lcsim/recon/tracking/trfcyl
diff -u -r1.1 -r1.2
--- HitCylPhiGenerator_t.java 25 Jul 2007 17:22:24 -0000 1.1
+++ HitCylPhiGenerator_t.java 9 Aug 2007 18:21:03 -0000 1.2
@@ -3,7 +3,7 @@
*
* Created on July 24, 2007, 8:44 PM
*
- * $Id: HitCylPhiGenerator_t.java,v 1.1 2007/07/25 17:22:24 ngraf Exp $
+ * $Id: HitCylPhiGenerator_t.java,v 1.2 2007/08/09 18:21:03 jeremy Exp $
*/
package org.lcsim.recon.tracking.trfcyl;
@@ -30,150 +30,150 @@
*/
public class HitCylPhiGenerator_t extends TestCase
{
- private boolean debug;
- /** Creates a new instance of HitCylPhiGenerator_t */
- public void testHitCylPhiGenerator()
- {
- String component = "HitCylPhiGenerator";
- 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." );
- double radius = 25.0;
- double dphi = 0.01;
- TestSurfCylinder tcy = new TestSurfCylinder(radius);
- if(debug) System.out.println(tcy);
- HitCylPhiGenerator gen = new HitCylPhiGenerator(tcy,dphi);
- if(debug) System.out.println( gen );
-
- //********************************************************************
-
- if(debug) System.out.println( ok_prefix + "Generate a list of hits." );
- double phi0 = 1.2345;
- Surface srf = new SurfCylinder(radius);
- TrackVector vec = new TrackVector();
- vec.set(SurfCylinder.IPHI, phi0);
- TrackError err = new TrackError();
- VTrack trv = new VTrack(srf,vec);
- ETrack tre = new ETrack(trv,err);
- List clusters = new ArrayList();
- int nclus = 20;
- for ( int i=0; i<nclus; ++i )
- {
- Cluster clu = gen.newCluster(trv);
- Assert.assertTrue( clu != null );
- clusters.add( clu );
- }
- // Verify and display the list.
- List hits = new ArrayList();
- for ( Iterator iclu=clusters.iterator(); iclu.hasNext(); )
- {
- Cluster clu = (Cluster) iclu.next();
- Assert.assertTrue( clu != null );
- List newhits = clu.predict(tre,clu);
- Assert.assertTrue( newhits.size() == 1 );
- hits.add( newhits.get(0) );
- }
- Assert.assertTrue( hits.size() == nclus );
-
- //********************************************************************
-
- if(debug) System.out.println( ok_prefix + "Generate list of measured values." );
- double avg = 0.0;
- double sdev = 0.0;
- for ( Iterator ihit=hits.iterator(); ihit.hasNext(); )
- {
- Hit hit = (Hit) ihit.next();
- Assert.assertTrue( hit != null );
- double mval = hit.measuredVector().get(0);
- double merr = hit.measuredError().get(0,0);
- double pval = hit.predictedVector().get(0);
- double perr = hit.predictedError().get(0,0);
- Assert.assertTrue( TRFMath.isEqual(pval,phi0) );
- Assert.assertTrue( TRFMath.isEqual(merr,dphi*dphi) );
- if(debug) System.out.println( mval );
- avg += mval;
- sdev += (mval-pval)*(mval-pval);
- }
- avg /= nclus;
- sdev = Math.sqrt(sdev/nclus);
- if(debug) System.out.println( " Avg: " + avg );
- if(debug) System.out.println( "Sdev: " + sdev );
- Assert.assertTrue( Math.abs( avg - phi0 ) < dphi );
- Assert.assertTrue( Math.abs( sdev - dphi ) < dphi );
-
- //********************************************************************
-
- if(debug) System.out.println( ok_prefix + "Generate a hit out-of-bounds." );
- vec.set(SurfCylinder.IZ, 200.0);
- trv.setVector(vec);
- Assert.assertTrue( gen.newCluster(trv) == null );
-
- //********************************************************************
-
- if(debug) System.out.println( ok_prefix + "Print final generator state." );
- if(debug) System.out.println( gen );
-
- //********************************************************************
-
- if(debug) System.out.println( ok_prefix
- + "------------- All tests passed. -------------" );
-
- //********************************************************************
-
- }
-
-}
+ private boolean debug;
+ /** Creates a new instance of HitCylPhiGenerator_t */
+ public void testHitCylPhiGenerator()
+ {
+ String component = "HitCylPhiGenerator";
+ 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." );
+ double radius = 25.0;
+ double dphi = 0.01;
+ TestSurfCylinder tcy = new TestSurfCylinder(radius);
+ if(debug) System.out.println(tcy);
+ HitCylPhiGenerator gen = new HitCylPhiGenerator(tcy,dphi);
+ if(debug) System.out.println( gen );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Generate a list of hits." );
+ double phi0 = 1.2345;
+ Surface srf = new SurfCylinder(radius);
+ TrackVector vec = new TrackVector();
+ vec.set(SurfCylinder.IPHI, phi0);
+ TrackError err = new TrackError();
+ VTrack trv = new VTrack(srf,vec);
+ ETrack tre = new ETrack(trv,err);
+ List clusters = new ArrayList();
+ int nclus = 20;
+ for ( int i=0; i<nclus; ++i )
+ {
+ Cluster clu = gen.newCluster(trv);
+ Assert.assertTrue( clu != null );
+ clusters.add( clu );
+ }
+ // Verify and display the list.
+ List hits = new ArrayList();
+ for ( Iterator iclu=clusters.iterator(); iclu.hasNext(); )
+ {
+ Cluster clu = (Cluster) iclu.next();
+ Assert.assertTrue( clu != null );
+ List newhits = clu.predict(tre,clu);
+ Assert.assertTrue( newhits.size() == 1 );
+ hits.add( newhits.get(0) );
+ }
+ Assert.assertTrue( hits.size() == nclus );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Generate list of measured values." );
+ double avg = 0.0;
+ double sdev = 0.0;
+ for ( Iterator ihit=hits.iterator(); ihit.hasNext(); )
+ {
+ Hit hit = (Hit) ihit.next();
+ Assert.assertTrue( hit != null );
+ double mval = hit.measuredVector().get(0);
+ double merr = hit.measuredError().get(0,0);
+ double pval = hit.predictedVector().get(0);
+ double perr = hit.predictedError().get(0,0);
+ Assert.assertTrue( TRFMath.isEqual(pval,phi0) );
+ Assert.assertTrue( TRFMath.isEqual(merr,dphi*dphi) );
+ if(debug) System.out.println( mval );
+ avg += mval;
+ sdev += (mval-pval)*(mval-pval);
+ }
+ avg /= nclus;
+ sdev = Math.sqrt(sdev/nclus);
+ if(debug) System.out.println( " Avg: " + avg );
+ if(debug) System.out.println( "Sdev: " + sdev );
+ Assert.assertTrue( Math.abs( avg - phi0 ) < dphi );
+ Assert.assertTrue( Math.abs( sdev - dphi ) < dphi );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Generate a hit out-of-bounds." );
+ vec.set(SurfCylinder.IZ, 200.0);
+ trv.setVector(vec);
+ Assert.assertTrue( gen.newCluster(trv) == null );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix + "Print final generator state." );
+ if(debug) System.out.println( gen );
+
+ //********************************************************************
+
+ if(debug) System.out.println( ok_prefix
+ + "------------- All tests passed. -------------" );
+
+ //********************************************************************
+
+ }
+
+ // SurfCylinder subclass for testing.
+ // z > 100 is considered out of bounds.
+ static class TestSurfCylinder extends SurfCylinder
+ {
+ // static methods
+ // Return the type name.
+ public static String typeName()
+ { return "TestSurfCylinder"; }
+ // Return the type.
+ public static String staticType()
+ { return typeName(); }
+ public double _zmax;
+
+
+ public TestSurfCylinder(double radius)
+ {
+ super(radius);
+ }
+
+ public CrossStat status( ETrack tre)
+ {
+ return status( (VTrack) tre );
+ }
+
+ // Return the type.
+ public String type()
+ { return staticType(); }
+
+ public CrossStat status( VTrack trv )
+ {
+ CrossStat xstat = pureStatus(trv);
+ if ( ! xstat.at() ) return xstat;
+ double z = trv.vector(SurfCylinder.IZ);
+ if ( z > 100.0 ) return new CrossStat(BoundedStat.OUT_OF_BOUNDS);
+ return new CrossStat(BoundedStat.IN_BOUNDS);
+ }
+ public Surface newSurface()
+ {
+ return new TestSurfCylinder(radius());
+ }
+
+ public String toString()
+ {
+ return "TestSurfCylinder with radius "+_radius;
+ }
+ }
-// SurfCylinder subclass for testing.
-// z > 100 is considered out of bounds.
-class TestSurfCylinder extends SurfCylinder
-{
- // static methods
- // Return the type name.
- public static String typeName()
- { return "TestSurfCylinder"; }
- // Return the type.
- public static String staticType()
- { return typeName(); }
- public double _zmax;
-
-
- public TestSurfCylinder(double radius)
- {
- super(radius);
- }
-
- public CrossStat status( ETrack tre)
- {
- return status( (VTrack) tre );
- }
-
- // Return the type.
- public String type()
- { return staticType(); }
-
- public CrossStat status( VTrack trv )
- {
- CrossStat xstat = pureStatus(trv);
- if ( ! xstat.at() ) return xstat;
- double z = trv.vector(SurfCylinder.IZ);
- if ( z > 100.0 ) return new CrossStat(BoundedStat.OUT_OF_BOUNDS);
- return new CrossStat(BoundedStat.IN_BOUNDS);
- }
- public Surface newSurface()
- {
- return new TestSurfCylinder(radius());
- }
-
- public String toString()
- {
- return "TestSurfCylinder with radius "+_radius;
- }
}
lcsim/test/org/lcsim/recon/tracking/trffit
diff -u -r1.1 -r1.2
--- HTrackGenerator_t.java 25 Jul 2007 00:07:13 -0000 1.1
+++ HTrackGenerator_t.java 9 Aug 2007 18:21:04 -0000 1.2
@@ -3,7 +3,7 @@
*
* Created on July 24, 2007, 4:57 PM
*
- * $Id: HTrackGenerator_t.java,v 1.1 2007/07/25 00:07:13 ngraf Exp $
+ * $Id: HTrackGenerator_t.java,v 1.2 2007/08/09 18:21:04 jeremy Exp $
*/
package org.lcsim.recon.tracking.trffit;
@@ -28,89 +28,89 @@
*/
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. -------------" );
-
-
- //********************************************************************
- }
-
-}
+ private boolean debug;
+ /** Creates a new instance of HTrackGenerator_t */
+ public void testHTrackGenerator()
+ {
+ //**********************************************************************
-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);
- }
+
+ 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. -------------" );
+
+
+ //********************************************************************
+ }
+
+ public static 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/trfutil
diff -u -r1.1 -r1.2
--- RootFindLinear_t.java 24 Jul 2007 22:03:09 -0000 1.1
+++ RootFindLinear_t.java 9 Aug 2007 18:21:04 -0000 1.2
@@ -3,7 +3,7 @@
*
* Created on July 24, 2007, 11:30 AM
*
- * $Id: RootFindLinear_t.java,v 1.1 2007/07/24 22:03:09 ngraf Exp $
+ * $Id: RootFindLinear_t.java,v 1.2 2007/08/09 18:21:04 jeremy Exp $
*/
package org.lcsim.recon.tracking.trfutil;
@@ -51,19 +51,20 @@
//*******************************************
}
-}
-
-class RootFindSin extends RootFindLinear
-{
- private double _val;
-
- public RootFindSin(double val)
- {
- _val = val;
- }
-
- public StatusDouble evaluate(double x)
+ static class RootFindSin extends RootFindLinear
{
- return new StatusDouble(0,Math.sin(x)-_val);
- }
+ private double _val;
+
+ public RootFindSin(double val)
+ {
+ _val = val;
+ }
+
+ public StatusDouble evaluate(double x)
+ {
+ return new StatusDouble(0,Math.sin(x)-_val);
+ }
+ }
}
+
+