View Javadoc

1   /*
2    * ClusFindZPlane1_Test.java
3    *
4    * Created on July 24, 2007, 11:09 PM
5    *
6    * $Id: ClusFindZPlane1_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 java.util.List;
12  import junit.framework.TestCase;
13  import org.lcsim.recon.tracking.trfbase.Cluster;
14  import org.lcsim.recon.tracking.trfbase.ETrack;
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 ClusFindZPlane1_Test extends TestCase
24  {
25      private boolean debug;
26      /** Creates a new instance of ClusFindZPlane1_Test */
27      public void testClusFindZPlane1()
28      {
29          String component = "ClusFindZPlane1";
30          String ok_prefix = component + " (I): ";
31          String error_prefix = component + " test (E): ";
32          
33          if(debug) System.out.println( ok_prefix
34                  + "-------- Testing component " + component
35                  + ". --------" );
36          
37          //********************************************************************
38          
39          if(debug) System.out.println( ok_prefix + "Test constructor." );
40          double zpos1 = 10.0;
41          ClusFindZPlane1 find1 = new ClusFindZPlane1(zpos1,0.01,0.02,10.0);
42          if(debug) System.out.println( find1 );
43          
44          //********************************************************************
45          
46          if(debug) System.out.println( ok_prefix + "Check the surface." );
47          SurfZPlane srf1 = new SurfZPlane(zpos1);
48          Assert.assertTrue( srf1.equals(find1.surface()) );
49          
50          //********************************************************************
51          
52          if(debug) System.out.println( ok_prefix + "Construct an axy finder." );
53          double zpos2 = 20.0;
54          double wx2 = 0.1;
55          double wy2 = 0.2;
56          ClusFindZPlane1 find2 = new ClusFindZPlane1(zpos2,wx2,wy2,10.0);
57          if(debug) System.out.println( find2 );
58          
59          //********************************************************************
60          
61          if(debug) System.out.println( ok_prefix + "Add axy clusters to finder." );
62          Cluster clu21 = new ClusZPlane1(zpos2,wx2,wy2,3.004,0.02);
63          Cluster clu22 = new ClusZPlane1(zpos2,wx2,wy2,3.071,0.02); //wrong
64          Cluster clu23 = new ClusZPlane1(zpos2,wx2,wy2,2.935,0.02);
65          Cluster clu24 = new ClusZPlane1(zpos2,wx2,wy2,2.929,0.02); //wrong
66          Cluster clu25 = new ClusZPlane1(zpos2,wx2,wy2,3.065,0.02);
67          find2.addCluster(clu21);
68          find2.addCluster(clu22);
69          find2.addCluster(clu23);
70          find2.addCluster(clu24);
71          int stat = find2.addCluster(clu25);
72          Assert.assertTrue( stat == 0 );
73          Assert.assertTrue( find2.clusters().size() == 5 );
74          
75          //********************************************************************
76          
77          if(debug) System.out.println( ok_prefix + "Find nearby axy clusters." );
78          SurfZPlane srf2 = new SurfZPlane(zpos2);
79          TrackVector vec = new TrackVector();
80          TrackError err = new TrackError();
81          err.set(SurfZPlane.IX,SurfZPlane.IX, 0.001);
82          err.set(SurfZPlane.IY,SurfZPlane.IY, 0.001);
83          err.set(SurfZPlane.IDXDZ,SurfZPlane.IDXDZ, 0.01);
84          err.set(SurfZPlane.IDYDZ,SurfZPlane.IDYDZ, 0.01);
85          err.set(SurfZPlane.IQP,SurfZPlane.IQP, 0.01);
86          vec.set(SurfZPlane.IY, 35.0);
87          vec.set(SurfZPlane.IX, (3.0 - wy2*vec.get(SurfZPlane.IY))/wx2);
88          ETrack tre2 = new ETrack(srf2.newPureSurface(),vec,err);
89          if(debug) System.out.println( tre2 );
90          
91          List nearby_clusters = find2.clusters(tre2);
92          Assert.assertTrue( nearby_clusters.size() == 3 );
93          if(debug) System.out.println( nearby_clusters.get(0) );
94          if(debug) System.out.println( nearby_clusters.get(nearby_clusters.size()-1) );
95          Assert.assertTrue( nearby_clusters.get(0).equals(clu23) );
96          Assert.assertTrue( nearby_clusters.get(nearby_clusters.size()-1).equals(clu25) );
97          
98          //********************************************************************
99          
100         if(debug) System.out.println( ok_prefix + "Drop clusters." );
101         find2.dropClusters();
102         Assert.assertTrue( find2.clusters().size() == 0 );
103         Assert.assertTrue( find2.clusters(tre2).size() == 0 );
104         
105         //********************************************************************
106         
107         if(debug) System.out.println( ok_prefix + "Find a single cluster." );
108         find2.addCluster(clu23);
109         Assert.assertTrue( find2.clusters().size() == 1 );
110         Assert.assertTrue( find2.clusters(tre2).size() == 1 );
111         
112         
113         //********************************************************************
114         
115         //********************************************************************
116         
117         if(debug) System.out.println( ok_prefix
118                 + "------------- All tests passed. -------------" );
119         
120         //********************************************************************
121         
122     }
123     
124 }