View Javadoc

1   package org.lcsim.recon.tracking.trfbase;
2   // SurfTest is a dummy concrete subclass for testing the abstract
3   // class Surface.
4   //
5   // It serves as a template for constructing pure and bound surface
6   // implementations.  Note however that the methods are chosen to
7   // simplify testing not to provide behavior characteristic of a real
8   // surface.  See trfcyl/SurfCylinder for a better example of a Surface
9   // subclass.
10  //
11  // SurfTest has two constructors: one from the x-coordinate and one
12  // the full SpacePath.
13  //
14  // We arbitrarily define the direction to be forward if x > 0.
15  
16  
17  import org.lcsim.recon.tracking.trfbase.CrossStat;
18  import org.lcsim.recon.tracking.trfbase.PureStat;
19  import org.lcsim.recon.tracking.trfbase.Surface;
20  import org.lcsim.recon.tracking.trfbase.TrackSurfaceDirection;
21  import org.lcsim.recon.tracking.trfbase.TrackVector;
22  import org.lcsim.recon.tracking.trfbase.VTrack;
23  import org.lcsim.recon.tracking.spacegeom.CartesianPath;
24  import org.lcsim.recon.tracking.spacegeom.SpacePath;
25  import org.lcsim.recon.tracking.spacegeom.SpacePoint;
26  
27  // Pure surface
28  
29  public class SurfTest extends Surface
30  {
31      
32      // attributes
33      
34      // Here the surface position and orientation are assumed to be
35      // characterized by a single number.  A more complicated surface
36      // might use more parameters or might define a space vector.
37      protected double _x;
38      
39      // SpacePath for testing SurfDCA.
40      protected SpacePath _spth;
41      
42      // methods
43      
44      public String toString()
45      {
46          return "Test surface with parameter " + _x + ".";
47          
48      }
49      
50      // equality comparing two pure surfaces
51      protected boolean safePureEqual(Surface srf)
52      { return _x == ((SurfTest) srf)._x;
53      }
54      
55      // ordering surfaces
56      protected boolean safePureLessThan(Surface srf)
57      { return _x < ((SurfTest) srf)._x;
58      }
59      
60      // static methods
61      
62      // Return the type name.
63      public static String typeName()
64      { return "SurfTest";
65      }
66      
67      // Return the type.
68      public static String staticType()
69      { return typeName();
70      }
71      
72      // methods
73      
74      // constructor
75      public SurfTest(double x)
76      {
77          _x = x;
78          _spth = new CartesianPath(_x,0,0,0,0,0);
79      }
80      
81      // constructor from a space path
82      public SurfTest(SpacePath spth)
83      {
84          _x = spth.x();
85          _spth = new SpacePath(spth);
86      }
87      
88      // copy constructor
89      public SurfTest(SurfTest st)
90      {
91          _x = st._x;
92          _spth = new SpacePath(st._spth);
93      }
94      
95      // Return the type.
96      public String type()
97      { return staticType();
98      }
99      
100     // Return the direction.
101     // The direction is defined if x > 0 and set forward.
102     // For x < 0 it is left undefined so the direction can
103     // be specified in VTrack.
104     public TrackSurfaceDirection direction( TrackVector vec)
105     {
106         if ( _x > 0.0 ) return TrackSurfaceDirection.TSD_FORWARD;
107         else return TrackSurfaceDirection.TSD_UNDEFINED;
108     }
109     
110     // return the pure type
111     public String pureType()
112     { return staticType();
113     }
114     
115     // clone the pure surface
116     public Surface newPureSurface( )
117     { return new SurfTest(_spth);
118     };
119     
120     // Return the parameter.
121     public double parameter(int ipar)
122     {
123         if( ipar != 0 ) throw new IllegalArgumentException("Wrong Parameter!");
124         return _x;
125     }
126     
127     // Return the space vector specifying the position and orientation
128     // of the surface.
129     public SpacePath get_space_vector()
130     { return new CartesianPath(_x, 0.0, 0.0, 1.0, 0.0, 0.0);
131     }
132     
133     // Return the crossing status for a track without error.
134     public CrossStat pureStatus( VTrack trv )
135     { return new CrossStat(PureStat.AT);
136     }
137     
138     // Return the difference between two track vectors.
139     public TrackVector vecDiff( TrackVector vec1,
140             TrackVector vec2 )
141     { return vec1.minus(vec2);
142     }
143     
144     // Return the space point for a track vector.
145     public SpacePoint spacePoint( TrackVector vec )
146     { return new SpacePoint();
147     }
148     
149     // Return the space vector for a track vector.
150     public SpacePath spacePath( TrackVector vec,
151             TrackSurfaceDirection dir)
152     { return _spth;
153     }
154     
155 }