1 /* 2 * ThickCylMs_Test.java 3 * 4 * Created on July 24, 2007, 7:56 PM 5 * 6 * $Id: ThickCylMs_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.Surface; 14 import org.lcsim.recon.tracking.trfbase.TrackError; 15 import org.lcsim.recon.tracking.trfbase.TrackVector; 16 import org.lcsim.recon.tracking.trfutil.Assert; 17 18 /** 19 * 20 * @author Norman Graf 21 */ 22 public class ThickCylMs_Test extends TestCase 23 { 24 private boolean debug; 25 /** Creates a new instance of ThickCylMs_Test */ 26 public void testThickCylMs() 27 { 28 String component = "ThickCylMS"; 29 String ok_prefix = component + " (I): "; 30 String error_prefix = component + " test (E): "; 31 32 if(debug) System.out.println( ok_prefix 33 + "---------- Testing component " + component 34 + ". ----------" ); 35 36 37 //******************************************************************** 38 39 ThickCylMs scatterIt = new ThickCylMs(1.0, 1.0); 40 41 TrackError initialError = new TrackError(); 42 initialError.set(0,0, 0.0); 43 initialError.set(1,1, 0.0); 44 initialError.set(2,2, 0.0); 45 initialError.set(3,3, 0.0); 46 initialError.set(4,4, 0.0); 47 48 initialError.set(0,2, 0.0); 49 initialError.set(1,3, 0.0); 50 initialError.set(3,1, 0.0); 51 initialError.set(4,3, 0.0); 52 initialError.set(3,4, 0.0); 53 54 TrackVector trv = new TrackVector(); 55 trv.set(0, 1.0); // phi 56 trv.set(1, 1.0); // z 57 trv.set(2, 1.0); // alpha 58 trv.set(3, 1.0); // tan lambda 59 trv.set(4, 0.01); // q/pt 60 61 Surface srf = new SurfCylinder( 100.0 ); 62 63 ETrack tmpTrack = new ETrack( srf, trv, initialError ); 64 65 tmpTrack.setError( initialError ); 66 scatterIt.interact( tmpTrack ); 67 68 //if(debug) System.out.println(endl+"Returned track: "+tmpTrack+endl+endl; 69 70 71 TrackError finalError = tmpTrack.error(); 72 73 double path_length = 1.0; 74 double rad_length = 1.0; 75 //actually 1 over track momentum: 76 double trackMomentum = Math.abs(trv.get(4)*Math.cos(Math.atan( trv.get(3) ))); 77 double tlamSqr = trv.get(3)*trv.get(3); 78 double ThetaSqr = (0.0136)*trackMomentum*Math.sqrt(path_length/rad_length)* 79 (1 + 0.038*Math.log(path_length/rad_length)); 80 81 ThetaSqr *= ThetaSqr; 82 83 double correl = Math.sqrt(3.0)/2; 84 85 double phiphi = ThetaSqr/(3*10000); 86 double zz = ThetaSqr*(1 + tlamSqr)/3; 87 double alfalf = ThetaSqr*( (1 + tlamSqr) + 1/(3*10000) 88 - 2*correl*((1 + tlamSqr)*1/(3*10000)) ); 89 double tlamtlam = ThetaSqr*(1 + tlamSqr)*(1 + tlamSqr); 90 double ptpt = ThetaSqr*trv.get(4)*trv.get(4)*tlamSqr; 91 double pttlam = ThetaSqr*trv.get(3)*trv.get(3)*(1.0+tlamSqr); 92 93 if(debug) System.out.println("Calulated Errors:"+" \n phiphi: "+phiphi+"\n zz: "+zz+"\n alfalf: "+alfalf+"\n tlamtlam: "+tlamtlam+"\n ptpt: "+ptpt); 94 95 if(debug) System.out.println("ThetaSqr: "+ThetaSqr+ " trackMomentum: "+trackMomentum); 96 97 if(debug) System.out.println("Track Errors \nphiphi: "+finalError.get(0,0)+"\n zz: "+finalError.get(1,1)+"\n alfalf: "+finalError.get(2,2)+"\n tlamtlam: "+finalError.get(3,3)+"\n ptpt: "+finalError.get(4,4)); 98 99 100 101 Assert.assertTrue(scatterIt.radLength() == 1.0); 102 Assert.assertTrue(scatterIt.pathLength() == 1.0); 103 Assert.assertTrue(Math.abs((finalError.get(0,0)-phiphi))<0.000001); 104 Assert.assertTrue(Math.abs((finalError.get(1,1)-zz))<0.000001); 105 Assert.assertTrue(Math.abs((finalError.get(2,2)-alfalf))<0.000001); 106 Assert.assertTrue(Math.abs((finalError.get(3,3)-tlamtlam))<0.000001); 107 Assert.assertTrue(Math.abs((finalError.get(4,4)-ptpt))<0.000001); 108 109 // Assert.assertTrue(Math.abs((finalError.get(0,2)-correl))<0.000001); 110 // Assert.assertTrue(Math.abs((finalError.get(2,0)-correl))<0.000001); 111 // Assert.assertTrue(Math.abs((finalError.get(1,3)-correl))<0.000001); 112 // Assert.assertTrue(Math.abs((finalError.get(3,1)-correl))<0.000001); 113 // Assert.assertTrue(Math.abs((finalError.get(3,4)-ptpt))<0.000001); 114 // Assert.assertTrue(Math.abs((finalError.get(4,3)-pttlam))<0.000001); 115 116 //******************************************************************** 117 118 119 //******************************************************************** 120 121 if(debug) System.out.println( ok_prefix 122 + "------------- All tests passed. -------------" ); 123 124 125 //******************************************************************** 126 127 } 128 129 }