View Javadoc

1   package org.lcsim.recon.tracking.trfzp;
2   
3   import org.lcsim.recon.tracking.trfutil.Assert;
4   
5   import  org.lcsim.recon.tracking.spacegeom.SpacePoint;
6   import  org.lcsim.recon.tracking.spacegeom.CartesianPoint;
7   import  org.lcsim.recon.tracking.spacegeom.SpacePath;
8   import  org.lcsim.recon.tracking.spacegeom.CartesianPath;
9   
10  import org.lcsim.recon.tracking.trfbase.Surface;
11  
12  import org.lcsim.recon.tracking.trfbase.VTrack;
13  import org.lcsim.recon.tracking.trfbase.ETrack;
14  import org.lcsim.recon.tracking.trfbase.CrossStat;
15  import org.lcsim.recon.tracking.trfbase.BoundedStat;
16  import org.lcsim.recon.tracking.trfbase.TrackVector;
17  import org.lcsim.recon.tracking.trfbase.TrackSurfaceDirection;
18  
19  /**
20   * BSurfZPlane is a ZPlane with rectangular boundaries in (x,y).
21   *
22   *@author Norman A. Graf
23   *@version 1.0
24   *
25   */
26  public class BSurfZPlane extends SurfZPlane
27  {
28      
29      // Static methods
30      
31      
32      /**
33       *Return a String representation of the class' type name.
34       *Included for completeness with the C++ version.
35       *
36       * @return   A String representation of the class' type name.
37       */
38      public static String typeName()
39      { return "BSurfZPlane";
40      }
41      
42      
43      
44      /**
45       *Return a String representation of the class' type name.
46       *Included for completeness with the C++ version.
47       *
48       * @return   A String representation of the class' type name.
49       */
50      public static String staticType()
51      { return typeName();
52      }
53      
54      // Attributes
55      
56      // lower x-limit
57      private double _xmin;
58      
59      // upper x-limit
60      private double _xmax;
61      
62      // lower y-limit
63      private double _ymin;
64      
65      // upper y-limit
66      private double _ymax;
67      
68      // Methods
69      
70      /** Equality */
71      protected boolean safeBoundEqual(Surface srf)
72      {
73          BSurfZPlane bxyp = (BSurfZPlane) srf;
74          return super.safePureEqual(srf) &&
75          _xmin == bxyp._xmin  && _xmax == bxyp._xmax &&
76          _ymin == bxyp._ymin  && _ymax == bxyp._ymax;
77      }
78      
79      // Calculate crossing status from VTrack and error in (x,y)_track
80      // This is used by both the public status methods.
81      private CrossStat status(VTrack trv, double dxtrk, double dytrk)
82      {
83          CrossStat xstat = super.pureStatus(trv);
84          // If track is not at surface exit with bounds flags undefined.
85          if ( !xstat.at() ) return xstat;
86          Assert.assertTrue( ! xstat.boundsChecked() );
87          // Calculate whether x track +/- nsigma is in and/or out of bounds.
88          double xtrk = trv.vector().get(SurfZPlane.IX);
89          double xtrk1 = xtrk - dxtrk;
90          double xtrk2 = xtrk + dxtrk;
91          
92          // Calculate whether y track +/- nsigma is in and/or out of bounds.
93          double ytrk = trv.vector().get(SurfZPlane.IY);
94          double ytrk1 = ytrk - dytrk;
95          double ytrk2 = ytrk + dytrk;
96          
97          // fully out of bounds
98          if( (xtrk2 < _xmin || xtrk1 > _xmax ) ||
99          (ytrk2 < _ymin || ytrk1 > _ymax ) )
100             return new CrossStat(BoundedStat.OUT_OF_BOUNDS);
101         // fully in bounds
102         if( (xtrk1 > _xmin  &&  xtrk2 < _xmax ) &&
103         (ytrk1 > _ymin  &&  ytrk2 < _ymax ) )
104             return new CrossStat(BoundedStat.IN_BOUNDS);
105         // must be both
106         return new CrossStat(BoundedStat.BOTH_BOUNDS);
107     }
108     
109     /**
110      *Construct an instance specifying the  z location of the plane and
111      *the bounds in x and y.
112      * @param zpos Z Position of ZPlane
113      * @param xmin Minimum x position of bound
114      * @param xmax Maximum x position of bound
115      * @param ymin Minimum y position of bound
116      * @param ymax Maximum y position of bound
117      */
118     public BSurfZPlane(double zpos,
119     double xmin, double xmax,
120     double ymin, double ymax)
121     {
122         super(zpos);
123         _xmin = xmin;
124         _xmax = xmax;
125         _ymin = ymin;
126         _ymax = ymax;
127         Assert.assertTrue( _ymax > _ymin );
128         Assert.assertTrue( _xmax > _xmin );
129     }
130     
131     /**
132      * Return the lower bound in x.
133      * @return The lower bound in x.
134      */
135     
136     public double xMin()
137     { return _xmin;
138     }
139     
140     /**
141      * Return the upper bound in x.
142      * @return The upper bound in x.
143      */
144     
145     public double xMax()
146     { return _xmax;
147     }
148     
149      /**
150      * Return the lower bound in y.
151      * @return The lower bound in y.
152      */
153     
154     public double yMin()
155     { return _ymin;
156     }
157     
158      /**
159      * Return the upper bound in y.
160      * @return The upper bound in y.
161      */
162     
163     public double yMax()
164     { return _ymax;
165     }
166     /**
167      *Return a String representation of the class' type name.
168      *Included for completeness with the C++ version.
169      *
170      * @return   A String representation of the class' type name.
171      */
172     public String type()
173     { return  staticType();
174     }
175     
176     /**
177      * Clone this BSurfZPlane.
178      * @return a clone of this BSurfZPlane.
179      */
180     
181     public Surface newSurface()
182     {
183         double zpos = parameter(SurfZPlane.ZPOS);
184         return new BSurfZPlane( zpos, _xmin, _xmax, _ymin, _ymax );
185     }
186     
187     /**
188      * Calculate the crossing status for a track without error.
189      * @param   trv The VTrack to test.
190      * @return The crossing status.
191      */
192     
193     public CrossStat status(VTrack trv)
194     {
195         double prec = CrossStat.staticPrecision();
196         double dxtrk = prec;
197         double dytrk = prec;
198         return status(trv,dxtrk,dytrk);
199     }
200     
201     /**
202      * Calculate the crossing status for a track with error.
203      * @param   tre The ETrack to test.
204      * @return The crossing status.
205      */
206     
207     public  CrossStat status(ETrack tre)
208     {
209         double nsigma = CrossStat.staticNSigma();
210         double prec = CrossStat.staticPrecision();
211         double dxtrk = nsigma*
212         Math.sqrt(tre.error().get(SurfZPlane.IX,SurfZPlane.IX)) + prec;
213         double dytrk = nsigma*
214         Math.sqrt(tre.error().get(SurfZPlane.IY,SurfZPlane.IY)) + prec;
215         return status(tre,dxtrk,dytrk);
216     }
217     
218     
219     /**
220      *output stream
221      *
222      * @return The String representation of this instance.
223      */
224     public String toString()
225     {
226         StringBuffer sb = new StringBuffer(super.toString());
227         sb.append(", xmin " + _xmin + " and xmax " + _xmax
228         + ", ymin " + _ymin + " and ymax " + _ymax);
229         return sb.toString();
230     }
231 }