1 /* 2 * PropJoinCyl_Test.java 3 * 4 * Created on July 24, 2007, 8:29 PM 5 * 6 * $Id: PropJoinCyl_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $ 7 */ 8 9 package org.lcsim.recon.tracking.trfcyl; 10 11 import junit.framework.TestCase; 12 import org.lcsim.recon.tracking.trfbase.ETrack; 13 import org.lcsim.recon.tracking.trfbase.PropDir; 14 import org.lcsim.recon.tracking.trfbase.PropDirectedTest; 15 import org.lcsim.recon.tracking.trfbase.PropStat; 16 import org.lcsim.recon.tracking.trfbase.Propagator; 17 import org.lcsim.recon.tracking.trfbase.SurfTest; 18 import org.lcsim.recon.tracking.trfbase.Surface; 19 import org.lcsim.recon.tracking.trfbase.TrackError; 20 import org.lcsim.recon.tracking.trfbase.TrackVector; 21 import org.lcsim.recon.tracking.trfbase.VTrack; 22 import org.lcsim.recon.tracking.trfutil.Assert; 23 24 /** 25 * 26 * @author Norman Graf 27 */ 28 public class PropJoinCyl_Test extends TestCase 29 { 30 private boolean debug; 31 /** Creates a new instance of PropJoinCyl_Test */ 32 public void testPropJoinCyl() 33 { 34 String ok_prefix = "PropJoinCyl (I): "; 35 String error_prefix = "PropJoinCyl test (E): "; 36 37 if(debug) System.out.println( ok_prefix 38 + "-------- Testing component PropJoinCyl. --------" ); 39 40 if(debug) System.out.println( ok_prefix + "Test constructor." ); 41 Propagator ptest = new PropDirectedTest(); 42 PropJoinCyl prop = new PropJoinCyl(0.1,1.0,ptest,ptest); 43 if(debug) System.out.println( prop ); 44 45 //******************************************************************** 46 47 if(debug) System.out.println( ok_prefix + "Propagate a VTrack." ); 48 { 49 Surface srf1 = new SurfTest(1); 50 Surface srf2 = new SurfTest(2); 51 TrackVector vec = new TrackVector(); 52 VTrack trv = new VTrack(srf1,vec); 53 PropStat pstat = prop.vecDirProp(trv,srf2,PropDir.FORWARD); 54 if(debug) System.out.println( trv ); 55 56 Assert.assertTrue( pstat.success() ); 57 // Two propagations ==> vec(1) = 2. 58 Assert.assertTrue( trv.vector().get(1) == 2.0 ); 59 60 } 61 62 //******************************************************************** 63 64 if(debug) System.out.println( ok_prefix + "Propagate an ETrack." ); 65 { 66 Surface srf1 = new SurfTest(1); 67 Surface srf2 = new SurfTest(2); 68 TrackVector vec = new TrackVector(); 69 vec.set(1, 3.0); 70 TrackError err = new TrackError(); 71 err.set(0,0, 0.01); 72 err.set(1,1, 0.02); 73 err.set(2,2, 0.03); 74 err.set(3,3, 0.04); 75 err.set(4,4, 0.05); 76 ETrack tre = new ETrack(srf1,vec,err); 77 tre.setForward(); 78 if(debug) System.out.println( "track before propagation\n"+tre ); 79 PropStat pstat = prop.errDirProp(tre,srf2,PropDir.BACKWARD); 80 if(debug) System.out.println( "track after propagation\n"+tre ); 81 Assert.assertTrue( pstat.success() ); 82 // Two propagations ==> vec(1) = 3 + 1 - 1 = 3. 83 Assert.assertTrue( tre.vector().get(1) == 3.0 ); 84 } 85 86 //******************************************************************** 87 88 89 //******************************************************************** 90 91 if(debug) System.out.println( ok_prefix 92 + "------------- All tests passed. -------------" ); 93 94 95 //******************************************************************** 96 97 } 98 99 }