1 /* 2 * ThinZPlaneMsSim_Test.java 3 * 4 * Created on July 24, 2007, 10:58 PM 5 * 6 * $Id: ThinZPlaneMsSim_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $ 7 */ 8 9 package org.lcsim.recon.tracking.trfzp; 10 11 import junit.framework.TestCase; 12 import org.lcsim.recon.tracking.trfbase.SimInteractor; 13 import org.lcsim.recon.tracking.trfbase.TrackVector; 14 import org.lcsim.recon.tracking.trfbase.VTrack; 15 import org.lcsim.recon.tracking.trfutil.Assert; 16 17 /** 18 * 19 * @author Norman Graf 20 */ 21 public class ThinZPlaneMsSim_Test extends TestCase 22 { 23 private boolean debug; 24 private static final int IX = SurfZPlane.IX; 25 private static final int IY = SurfZPlane.IY; 26 private static final int IDXDZ = SurfZPlane.IDXDZ; 27 private static final int IDYDZ = SurfZPlane.IDYDZ; 28 private static final int IQP = SurfZPlane.IQP; 29 //********************************************************************** 30 31 /** Creates a new instance of ThinZPlaneMsSim_Test */ 32 public void testThinZPlaneMsSim() 33 { 34 String component = "ThinZPlaneMsSim"; 35 String ok_prefix = component + " (I): "; 36 String error_prefix = component + " test (E): "; 37 38 if(debug) System.out.println( ok_prefix 39 + "---------- Testing component " + component 40 + ". ----------" ); 41 42 43 //******************************************************************** 44 45 ThinZPlaneMsSim scatterIt = new ThinZPlaneMsSim(0.001); 46 if(debug) System.out.println( scatterIt); 47 48 Assert.assertTrue(scatterIt.radLength() == 0.001); 49 50 VTrack vtrk = new VTrack(); 51 // Give the track 1GeV 52 TrackVector trv = new TrackVector( ); 53 trv.set(IDXDZ, 0.001); 54 trv.set(IQP, 1.0); 55 vtrk.setVector( trv ); 56 scatterIt.interact( vtrk ); 57 TrackVector scattered = new TrackVector( vtrk.vector() ); 58 Assert.assertTrue( scattered.get(IX) == trv.get(IX) ); 59 Assert.assertTrue( scattered.get(IY) == trv.get(IY) ); 60 Assert.assertTrue( scattered.get(IDXDZ) != trv.get(IDXDZ) ); 61 Assert.assertTrue( scattered.get(IDYDZ) != trv.get(IDYDZ) ); 62 Assert.assertTrue( scattered.get(IQP) != trv.get(IQP) ); 63 if(debug) System.out.println( "before interaction " + trv ); 64 if(debug) System.out.println( "after interaction " + scattered ); 65 66 //cng 67 TrackVector tvec = new TrackVector(); 68 tvec.set(IX, 1.0); 69 tvec.set(IY, 2.0); 70 tvec.set(IDXDZ, 3.0); 71 tvec.set(IDYDZ, 4.0); 72 tvec.set(IQP, 5.0); 73 SurfZPlane szp = new SurfZPlane(6.0); 74 VTrack t = new VTrack(szp.newPureSurface(),tvec); 75 if(debug) System.out.println( "Track before interacting... " + tvec ); 76 scatterIt.interact( t ); 77 TrackVector trv1 = t.vector() ; 78 if(debug) System.out.println( "Track after interacting... " + trv1 ); 79 //cng 80 81 82 tvec.set(IX, 7.25001); 83 tvec.set(IY, 83.571); 84 tvec.set(IDXDZ, 0.0220818); 85 tvec.set(IDYDZ, 0.586898); 86 tvec.set(IQP, -0.0116488); 87 88 89 SurfZPlane szp2 = new SurfZPlane(35.0); 90 VTrack t2 = new VTrack(szp2.newPureSurface(),tvec); 91 if(debug) System.out.println( "Track before interacting... " + tvec ); 92 scatterIt.interact( t2 ); 93 TrackVector trv2 = t2.vector(); 94 if(debug) System.out.println( "Track after interacting... " + trv2 ); 95 96 //******************************************************************** 97 if(debug) System.out.println(ok_prefix + "Testing clone"); 98 VTrack t3 = new VTrack(t2); 99 t3.setForward(); 100 VTrack t4 = new VTrack(t2); 101 t4.setForward(); 102 Assert.assertTrue(t3.equals(t4)); 103 // clone 104 SimInteractor scatterIt2 = scatterIt.newCopy(); 105 // assert they are not the same object 106 Assert.assertTrue( scatterIt2!=scatterIt ); 107 // scatter both tracks 108 scatterIt2.interact(t4); 109 scatterIt.interact(t3); 110 // assert that the newly scattered tracks are not equal 111 // since scattering is stochastic and we have different random 112 // number generators 113 Assert.assertTrue( t3.notEquals(t4) ); 114 // assert they're different from the original track 115 Assert.assertTrue( t3.notEquals(t2) ); 116 Assert.assertTrue( t4.notEquals(t2) ); 117 118 //******************************************************************** 119 120 if(debug) System.out.println( ok_prefix 121 + "------------- All tests passed. -------------" ); 122 123 //******************************************************************** 124 125 } 126 127 }