1 /* 2 * BSurfXYPlane_Test.java 3 * 4 * Created on July 24, 2007, 10:34 PM 5 * 6 * $Id: BSurfXYPlane_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $ 7 */ 8 9 package org.lcsim.recon.tracking.trfxyp; 10 11 import junit.framework.TestCase; 12 import org.lcsim.recon.tracking.trfbase.CrossStat; 13 import org.lcsim.recon.tracking.trfbase.ETrack; 14 import org.lcsim.recon.tracking.trfbase.Surface; 15 import org.lcsim.recon.tracking.trfbase.TrackError; 16 import org.lcsim.recon.tracking.trfbase.TrackVector; 17 import org.lcsim.recon.tracking.trfutil.Assert; 18 19 /** 20 * 21 * @author Norman Graf 22 */ 23 public class BSurfXYPlane_Test extends TestCase 24 { 25 private boolean debug; 26 /** Creates a new instance of BSurfXYPlane_Test */ 27 public void testBSurfXYPlane() 28 { 29 String ok_prefix = "BSurfXYPlane test (I): "; 30 String error_prefix = "BSurfXYPlane test (E): "; 31 32 if(debug) System.out.println( ok_prefix 33 + "------ Testing component BSurfXYPlane. ------" ); 34 35 //******************************************************************** 36 37 if(debug) System.out.println( ok_prefix + "Test constructor and get routines." ); 38 BSurfXYPlane bxyp = new BSurfXYPlane( 10.0, Math.PI/3., -20.0, 30.0, -120.0, 130.0 ); 39 if(debug) System.out.println( bxyp ); 40 Assert.assertTrue( bxyp.parameter(SurfXYPlane.DISTNORM) == 10.0 ); 41 Assert.assertTrue( bxyp.parameter(SurfXYPlane.NORMPHI) == Math.PI/3. ); 42 Assert.assertTrue( bxyp.vMin() == -20.0 ); 43 Assert.assertTrue( bxyp.vMax() == 30.0 ); 44 Assert.assertTrue( bxyp.zMin() == -120.0 ); 45 Assert.assertTrue( bxyp.zMax() == 130.0 ); 46 47 //******************************************************************** 48 49 if(debug) System.out.println( ok_prefix + "Equality tests varying parameters." ); 50 BSurfXYPlane bxyp1 = new BSurfXYPlane( 10.0, Math.PI/3., -20.0, 30.0, -120.0, 130.0 ); 51 BSurfXYPlane bxyp2 = new BSurfXYPlane( 10.0, Math.PI/3., 20.0, 30.0, -120.0, 130.0 ); 52 BSurfXYPlane bxyp3 = new BSurfXYPlane( 10.0, Math.PI/3., -20.0, 20.0, -120.0, 130.0 ); 53 BSurfXYPlane bxyp4 = new BSurfXYPlane( 20.0, Math.PI/3., -20.0, 30.0, -120.0, 130.0 ); 54 BSurfXYPlane bxyp5 = new BSurfXYPlane( 10.0, Math.PI/5., -20.0, 30.0, -120.0, 130.0 ); 55 BSurfXYPlane bxyp6 = new BSurfXYPlane( 10.0, Math.PI/3., -20.0, 30.0, 121.0, 130.0 ); 56 BSurfXYPlane bxyp7 = new BSurfXYPlane( 10.0, Math.PI/3., -20.0, 30.0, -120.0, 131.0 ); 57 Assert.assertTrue( bxyp.boundEqual(bxyp) ); 58 Assert.assertTrue( bxyp.boundEqual(bxyp1) ); 59 Assert.assertTrue( ! bxyp.boundEqual(bxyp2) ); 60 Assert.assertTrue( ! bxyp.boundEqual(bxyp3) ); 61 Assert.assertTrue( ! bxyp.boundEqual(bxyp4) ); 62 Assert.assertTrue( ! bxyp.boundEqual(bxyp5) ); 63 Assert.assertTrue( ! bxyp.boundEqual(bxyp6) ); 64 Assert.assertTrue( ! bxyp.boundEqual(bxyp7) ); 65 66 //******************************************************************** 67 68 if(debug) System.out.println( ok_prefix + "Equality tests using base class." ); 69 SurfXYPlane sxyp = new SurfXYPlane(10.0, Math.PI/3.); 70 SurfXYPlane psxyp = bxyp; 71 Assert.assertTrue( bxyp.boundEqual(psxyp) ); 72 Assert.assertTrue( psxyp.boundEqual(bxyp) ); 73 Assert.assertTrue( ! psxyp.boundEqual(bxyp2) ); 74 Assert.assertTrue( ! bxyp.boundEqual(sxyp) ); 75 Assert.assertTrue( bxyp.pureEqual(sxyp) ); 76 Assert.assertTrue( sxyp.pureEqual(bxyp) ); 77 78 //******************************************************************** 79 80 if(debug) System.out.println( ok_prefix + "Test type." ); 81 Assert.assertTrue( bxyp.type() != null ); 82 Assert.assertTrue( !bxyp.type().equals(sxyp.type()) ); 83 Assert.assertTrue( bxyp.type().equals(BSurfXYPlane.staticType()) ); 84 85 //******************************************************************** 86 87 if(debug) System.out.println( ok_prefix + "Test purity." ); 88 Assert.assertTrue( ! bxyp.isPure() ); 89 Assert.assertTrue( sxyp.isPure() ); 90 Assert.assertTrue( ! psxyp.isPure() ); 91 92 //******************************************************************** 93 94 if(debug) System.out.println( ok_prefix + "Test crossing status." ); 95 if(debug) System.out.println( bxyp ); 96 TrackVector tvec = new TrackVector(); 97 TrackError terr = new TrackError(); 98 terr.set(SurfXYPlane.IV,SurfXYPlane.IV, 4.0); 99 terr.set(SurfXYPlane.IZ,SurfXYPlane.IZ, 4.0); 100 101 // Checking V component 102 103 tvec.set(SurfXYPlane.IZ, 0.0); 104 105 // completely inside 106 tvec.set(SurfXYPlane.IV, 15.0); 107 ETrack trk1= new ETrack(bxyp.newPureSurface(),tvec,terr); 108 if(debug) System.out.println( trk1 ); 109 CrossStat xs = bxyp.status(trk1); 110 if(debug) System.out.println( xs ); 111 Assert.assertTrue( xs.inBounds() ); 112 Assert.assertTrue( !xs.outOfBounds() ); 113 // inside overlapping out 114 tvec.set(SurfXYPlane.IV, 25.0); 115 ETrack trk2= new ETrack(bxyp.newPureSurface(),tvec,terr); 116 xs = bxyp.status(trk2); 117 if(debug) System.out.println( trk2 ); 118 if(debug) System.out.println( xs ); 119 Assert.assertTrue( xs.inBounds()); 120 Assert.assertTrue( xs.outOfBounds()); 121 // outside overlapping in 122 tvec.set(SurfXYPlane.IV, 35.0); 123 ETrack trk3= new ETrack(bxyp.newPureSurface(),tvec,terr); 124 if(debug) System.out.println( trk3 ); 125 xs = bxyp.status(trk3); 126 if(debug) System.out.println( xs ); 127 Assert.assertTrue( xs.inBounds()); 128 Assert.assertTrue( xs.outOfBounds()); 129 // way outside 130 tvec.set(SurfXYPlane.IV, 45.0); 131 ETrack trk4= new ETrack(bxyp.newPureSurface(),tvec,terr); 132 if(debug) System.out.println( trk4 ); 133 xs = bxyp.status(trk4); 134 if(debug) System.out.println( xs ); 135 Assert.assertTrue( !xs.inBounds()); 136 Assert.assertTrue( xs.outOfBounds()); 137 // inside overlapping out 138 tvec.set(SurfXYPlane.IV, -15.0); 139 ETrack trk5= new ETrack(bxyp.newPureSurface(),tvec,terr); 140 if(debug) System.out.println( trk5 ); 141 xs = bxyp.status(trk5); 142 if(debug) System.out.println( xs ); 143 Assert.assertTrue( xs.inBounds()); 144 Assert.assertTrue( xs.outOfBounds()); 145 // outside overlapping in 146 tvec.set(SurfXYPlane.IV, -25.0); 147 ETrack trk6= new ETrack(bxyp.newPureSurface(),tvec,terr); 148 if(debug) System.out.println( trk6 ); 149 xs = bxyp.status(trk6); 150 if(debug) System.out.println( xs ); 151 Assert.assertTrue( xs.inBounds() ); 152 Assert.assertTrue( xs.outOfBounds() ); 153 // way outside 154 tvec.set(SurfXYPlane.IV, -35.0); 155 ETrack trk7= new ETrack(bxyp.newPureSurface(),tvec,terr); 156 if(debug) System.out.println( trk7 ); 157 xs = bxyp.status(trk7); 158 if(debug) System.out.println( xs ); 159 Assert.assertTrue( !xs.inBounds() ); 160 Assert.assertTrue( xs.outOfBounds() ); 161 162 163 // Checking Z component 164 165 tvec.set(SurfXYPlane.IV, 0.0); 166 167 // completely inside 168 tvec.set(SurfXYPlane.IZ, 115.0); 169 ETrack trk11= new ETrack(bxyp.newPureSurface(),tvec,terr); 170 if(debug) System.out.println( trk11 ); 171 xs = bxyp.status(trk11); 172 if(debug) System.out.println( xs ); 173 Assert.assertTrue( xs.inBounds()); 174 Assert.assertTrue( !xs.outOfBounds()); 175 // inside overlapping out 176 tvec.set(SurfXYPlane.IZ, 125.0); 177 ETrack trk12= new ETrack(bxyp.newPureSurface(),tvec,terr); 178 xs = bxyp.status(trk12); 179 if(debug) System.out.println( trk12 ); 180 if(debug) System.out.println( xs ); 181 Assert.assertTrue( xs.inBounds() ); 182 Assert.assertTrue( xs.outOfBounds()); 183 // outside overlapping in 184 tvec.set(SurfXYPlane.IZ, 135.0); 185 ETrack trk13= new ETrack(bxyp.newPureSurface(),tvec,terr); 186 if(debug) System.out.println( trk13 ); 187 xs = bxyp.status(trk13); 188 if(debug) System.out.println( xs ); 189 Assert.assertTrue( xs.inBounds() ); 190 Assert.assertTrue( xs.outOfBounds() ); 191 // way outside 192 tvec.set(SurfXYPlane.IZ, 145.0); 193 ETrack trk14= new ETrack(bxyp.newPureSurface(),tvec,terr); 194 if(debug) System.out.println( trk14 ); 195 xs = bxyp.status(trk14); 196 if(debug) System.out.println( xs ); 197 Assert.assertTrue( !xs.inBounds() ); 198 Assert.assertTrue( xs.outOfBounds() ); 199 // inside overlapping out 200 tvec.set(SurfXYPlane.IZ, -115.0); 201 ETrack trk15= new ETrack(bxyp.newPureSurface(),tvec,terr); 202 if(debug) System.out.println( trk15 ); 203 xs = bxyp.status(trk15); 204 if(debug) System.out.println( xs ); 205 Assert.assertTrue( xs.inBounds() ); 206 Assert.assertTrue( xs.outOfBounds() ); 207 // outside overlapping in 208 tvec.set(SurfXYPlane.IZ, -125.0); 209 ETrack trk16= new ETrack(bxyp.newPureSurface(),tvec,terr); 210 if(debug) System.out.println( trk16 ); 211 xs = bxyp.status(trk16); 212 if(debug) System.out.println( xs ); 213 Assert.assertTrue( xs.inBounds() ); 214 Assert.assertTrue( xs.outOfBounds() ); 215 // way outside 216 tvec.set(SurfXYPlane.IZ, -135.0); 217 ETrack trk17= new ETrack(bxyp.newPureSurface(),tvec,terr); 218 if(debug) System.out.println( trk17 ); 219 xs = bxyp.status(trk17); 220 if(debug) System.out.println( xs ); 221 Assert.assertTrue( !xs.inBounds() ); 222 Assert.assertTrue( xs.outOfBounds() ); 223 224 //******************************************************************** 225 226 if(debug) System.out.println( ok_prefix + "Check cloning." ); 227 Surface psrf = bxyp.newSurface(); 228 Assert.assertTrue( psrf.type().equals(BSurfXYPlane.staticType()) ); 229 230 //******************************************************************** 231 if(debug) System.out.println( ok_prefix 232 + "------------- All tests passed. -------------" ); 233 234 //******************************************************************** 235 236 } 237 238 }