View Javadoc

1   package org.lcsim.recon.tracking.trfbase;
2   /**
3    *
4    * This class describes the crossing of a track with a surface.
5    * It is characterized by seven boolean variables and provide methods
6    * to fetch the state of each.
7    *
8    * The variables include:
9    *<pre>
10   *   Surface:
11   *     at - the track and surface have the same pure surface
12   *
13   *   Normal:
14   *     on - the track vector is on the surface
15   *     inside - the track vector is inside the surface
16   *     outside - the track vector is outside the surface
17   *
18   *   Boundary:
19   *     bounds_checked - boundaries have been checked
20   *     in_bounds - at surface and within boundaries
21   *     out_of_bounds - at surface and outside boundaries
22   *</pre>
23   * The vector state on is true if the track is with a distance
24   * PRECISION of the surface.  This value is nonzero to allow
25   * for roundoff errors.  If the track is not on, then it is either
26   * inside or outside--the surface defines the meaning of those.
27   * Exactly one of these states can be true.
28   *
29   * The state bounds_checked is true and the states in_bounds and
30   * out_of_bounds are defined only if the track is at the surface
31   * and the surface is bounded.  By definition, a bounded surface
32   * assigns each point in track parameter space as either in bounds
33   * or out of bounds.  The state in_bounds (out_of_bounds) is true
34   * if any in bounds (out of bounds) points are within distance
35   * PRECISION of the track volume.  The track volume is defined by
36   * expanding the error ellipsoid by NSIGMA.  Note that it is
37   * possible for both states to be true.
38   *
39   * Here are the allowed pure states and their names:
40   *<pre>
41   *  at  on in out
42   *   0   1  0  0      ON
43   *   0   0  1  0      INSIDE
44   *   0   0  0  1      OUTSIDE
45   *   1   1  0  0      AT
46   *</pre>
47   * Here are the allowed bound states (pure state must be AT):
48   *<pre>
49   *   0   0     UNDEFINED_BOUNDS
50   *   1   0     IN_BOUNDS
51   *   0   1     OUT_OF_BOUNDS
52   *   1   1     BOTH_BOUNDS
53   *</pre>
54   * The crossing status is constructed from
55   * <ol>
56   * <li> a pure state alone (leaving its bound state UNDEFINED_BOUNDS),
57   * <li> a bound state alone (pure state is set to AT), or
58   * <li> another crossing status (copy constructor).
59   *</ol>
60   * The state of the class is set by the constructor and cannot
61   * be modified.
62   *
63   * The methods get_precision() and get_nsigma() return the values
64   * to used for PRECISION and NSIGMA.  Programmers can inherit from
65   * this class to change these values.  If the base class is used,
66   * the values can also be obtained through the static methods
67   * get_static_precision() and get_static_nsigma().
68   *
69   *@author Norman A. Graf
70   *@version 1.0
71   */
72  public class CrossStat
73  {
74      
75      
76      // static attributes
77      
78      // precision
79      private static double _precision = 1.0e-14;
80      
81      // Magnification factor for error ellipsoid.
82      private static double _nsigma = 5.0;
83      
84      // static methods
85      
86      //
87      
88      /**
89       * Return the precision parameter for crossing.
90       *
91       * @return the precision parameter for crossing.
92       */
93      public static double staticPrecision()
94      { return _precision; }
95      
96      //
97      
98      /**
99       * Return sigma for error ellipsoid.
100      *
101      * @return  number of sigma with which to expand the track error ellipsoid.
102      */
103     public static double staticNSigma()
104     { return _nsigma; }
105     
106     // attributes
107     
108     // Pure state
109     private PureStat _pure;
110     
111     // Bound state
112     private BoundedStat _bound;
113     
114     // methods
115     
116     
117     
118     //
119     
120     /**
121      * Constructor from a pure state.
122      *
123      * @param  pure PureStat with which to construct.
124      */
125     public CrossStat(PureStat pure)
126     {
127         _pure = pure;
128         _bound = BoundedStat.UNDEFINED_BOUNDS;
129     }
130     
131     //
132     
133     /** Constructor from a bound state.
134      *
135      * @param bound BoundedStat from which to construct this CrossStat
136      */
137     public CrossStat(BoundedStat bound)
138     {
139         _pure = PureStat.AT;
140         _bound = bound;
141     }
142     
143     //
144     
145     /**
146      * Copy constructor.
147      *
148      * @param   xstat  CrossStat to copy.
149      */
150     public CrossStat(CrossStat xstat)
151     {
152         _pure = xstat._pure;
153         _bound = xstat._bound;
154     }
155     
156     //
157     
158     /**
159      * Is track at the surface?
160      *
161      * @return true if track is at surface.
162      */
163     public boolean at()
164     { return _pure==PureStat.AT; }
165     
166     //
167     
168     /**
169      * Is the the track position on the the surface?
170      *
171      * @return true if  track position is on the the surface.
172      */
173     public boolean on()
174     { return _pure==PureStat.ON || _pure==PureStat.AT; }
175     
176     //
177     
178     /**
179      * Is the track off the surface on the inside?
180      *
181      * @return  true if track is off the surface on the inside.
182      */
183     public boolean inside()
184     { return _pure==PureStat.INSIDE; }
185     
186     //
187     
188     /**
189      * Is the track off the surface on the outside?
190      *
191      * @return     true if track is off the surface on the outside.
192      */
193     public boolean outside()
194     { return _pure==PureStat.OUTSIDE; }
195     
196     // Have the bounds been checked?
197     
198     /**
199      * Have the bounds been checked?
200      *
201      * @return true if   the bounds have been checked.
202      */
203     public boolean boundsChecked()
204     { return _bound!=BoundedStat.UNDEFINED_BOUNDS; }
205     
206     //
207     
208     /**
209      * Is the track in bounds?
210      *
211      * @return true if the track is in bounds.
212      */
213     public boolean inBounds()
214     {
215         return _bound==BoundedStat.IN_BOUNDS || _bound==BoundedStat.BOTH_BOUNDS;
216     }
217     
218     //
219     
220     /**
221      * Is the track out of bounds?
222      *
223      * @return  true if the track is out of bounds.
224      */
225     public boolean outOfBounds()
226     {
227         return _bound==BoundedStat.OUT_OF_BOUNDS || _bound==BoundedStat.BOTH_BOUNDS;
228     }
229     
230     //
231     
232     /**
233      * Return the precision.
234      *
235      * @return precision of matching for track crossing.
236      */
237     public double precision()
238     { return staticPrecision(); }
239     
240     /**
241      * Return sigma for error ellipsoid.
242      *
243      * @return  number of sigma with which to expand the track error ellipsoid.
244      */
245     public double nSigma()
246     { return staticNSigma(); }
247     
248     // Output stream.
249     
250     /**
251      * String representation of CrossStat.
252      *
253      * @return     String representation of CrossStat.
254      */
255     public String toString()
256     {
257         String className = getClass().getName();
258         int lastDot = className.lastIndexOf('.');
259         if(lastDot!=-1)className = className.substring(lastDot+1);
260         
261         return className+" \n"
262                 +"\n at=            "+at()
263                 +"\n on=            "+on()
264                 +"\n inside=        "+inside()
265                 +"\n outside=       "+outside()
266                 +"\n in_bounds=     "+inBounds()
267                 +"\n out_of_bounds= "+outOfBounds();
268     }
269     
270 }