View Javadoc

1   package org.lcsim.recon.tracking.trfxyp;
2   import org.lcsim.recon.tracking.trfutil.Assert;
3   import org.lcsim.recon.tracking.trfutil.TRFMath;
4   
5   import org.lcsim.recon.tracking.spacegeom.SpacePoint;
6   import org.lcsim.recon.tracking.spacegeom.SpacePath;
7   import org.lcsim.recon.tracking.spacegeom.CartesianPoint;
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.TrackVector;
15  import org.lcsim.recon.tracking.trfbase.CrossStat;
16  import org.lcsim.recon.tracking.trfbase.PureStat;
17  import org.lcsim.recon.tracking.trfbase.BoundedStat;
18  import org.lcsim.recon.tracking.trfbase.TrackSurfaceDirection;
19  
20  
21  /**
22   * A bounded XYPlane with rectangular boundaries in (v,z).
23   *
24   *@author Norman A. Graf
25   *@version 1.0
26   *
27   */
28  public class BSurfXYPlane extends SurfXYPlane
29  {
30      /**
31       *Return a String representation of the class' type name.
32       *Included for completeness with the C++ version.
33       *
34       * @return   A String representation of the class' type name.
35       */
36      public static String typeName()
37      { return "BSurfXYPlane"; }
38      
39      /**
40       *Return a String representation of the class' type name.
41       *Included for completeness with the C++ version.
42       *
43       * @return   A String representation of the class' type name.
44       */
45      public static String staticType()
46      { return typeName(); }
47      
48      
49      
50      // lower v-limit
51      private double _vmin;
52      
53      // upper v-limit
54      private double _vmax;
55      
56      // lower z-limit
57      private double _zmin;
58      
59      // upper z-limit
60      private double _zmax;
61      
62      // bounded equality
63      protected boolean safeBoundEqual( Surface srf)
64      {
65          BSurfXYPlane bxyp = (BSurfXYPlane) srf;
66          return super.safePureEqual(srf) &&
67                  _vmin == bxyp._vmin  && _vmax == bxyp._vmax &&
68                  _zmin == bxyp._zmin  && _zmax == bxyp._zmax;
69      }
70      
71      // calculate crossing status from VTrack and error in (v,z)_track
72      // This is used by both the public status methods.
73      private CrossStat status(VTrack trv, double dvtrk, double dztrk)
74      {
75          CrossStat xstat = super.pureStatus(trv);
76          // If track is not at surface exit with bounds flags undefined.
77          if ( !xstat.at() ) return xstat;
78          Assert.assertTrue( ! xstat.boundsChecked() );
79          // Calculate whether v track +/- nsigma is in and/or out of bounds.
80          double vtrk = trv.vector().get(SurfXYPlane.IV);
81          double vtrk1 = vtrk - dvtrk;
82          double vtrk2 = vtrk + dvtrk;
83          
84          // Calculate whether z track +/- nsigma is in and/or out of bounds.
85          double ztrk = trv.vector().get(SurfXYPlane.IZ);
86          double ztrk1 = ztrk - dztrk;
87          double ztrk2 = ztrk + dztrk;
88          
89          // fully out of bounds
90          if( (vtrk2 < _vmin || vtrk1 > _vmax ) ||
91                  (ztrk2 < _zmin || ztrk1 > _zmax ) )
92              return new CrossStat(BoundedStat.OUT_OF_BOUNDS);
93          // fully in bounds
94          if( (vtrk1 > _vmin  &&  vtrk2 < _vmax ) &&
95                  (ztrk1 > _zmin  &&  ztrk2 < _zmax ) )
96              return new CrossStat(BoundedStat.IN_BOUNDS);
97          // must be both
98          return new CrossStat(BoundedStat.BOTH_BOUNDS);
99      }
100     
101     /**
102      * Construct an instace from the shortest distance to the plane from the z axis
103      * and the phi angle of the normal to the plane.
104      * @param dist The shortest distance to the plane from the z axis.
105      * @param phi The angle of the normal to the plane with respect to the x axis.
106      * @param vmin The lower bound in v.
107      * @param vmax The upper bound in v.
108      * @param zmin The lower bound in z.
109      * @param zmax The upper bound in z.
110      */
111     public BSurfXYPlane(double dist, double phi,
112             double vmin, double vmax,
113             double zmin, double zmax)
114     {
115         super(dist,phi);
116         _vmin =  vmin;
117         _vmax =  vmax;
118         _zmin =  zmin;
119         _zmax =  zmax;
120         Assert.assertTrue  (  _zmax > _zmin );
121         Assert.assertTrue  (   _vmax > _vmin );
122     }
123     
124     /**
125      * Return the lower bound in v.
126      * @return The lower bound in v.
127      */
128     public double vMin()
129     { return _vmin; }
130     
131     /**
132      * Return the upper bound in v.
133      * @return The upper bound in v.
134      */
135     public double vMax()
136     { return _vmax; }
137     
138     /**
139      * Return the lower bound in z.
140      * @return The lower bound in z.
141      */
142     public double zMin()
143     { return _zmin; }
144     
145     /**
146      * Return the upper bound in v.
147      * @return The upper bound in v.
148      */
149     public double zMax()
150     { return _zmax; }
151     
152     /**
153      *Return a String representation of the class' type name.
154      *Included for completeness with the C++ version.
155      *
156      * @return   A String representation of the class' type name.
157      */
158     public String type()
159     { return  staticType(); };
160     
161     /**
162      * Clone this BSurfZPlane.
163      * @return a clone of this BSurfZPlane.
164      */
165     public Surface newSurface()
166     {
167         
168         double phi = parameter(SurfXYPlane.NORMPHI);
169         double dist = parameter(SurfXYPlane.DISTNORM);
170         return new BSurfXYPlane( dist, phi, _vmin, _vmax, _zmin, _zmax );
171     }
172     
173     /**
174      * Calculate the crossing status for a track without error.
175      * @param   trv The VTrack to test.
176      * @return The crossing status.
177      */
178     public CrossStat status(VTrack trv)
179     {
180         double prec = CrossStat.staticPrecision();
181         double dvtrk = prec;
182         double dztrk = prec;
183         return status(trv,dvtrk,dztrk);
184     }
185     
186     /**
187      * Calculate the crossing status for a track with error.
188      * @param   tre The ETrack to test.
189      * @return The crossing status.
190      */
191     public CrossStat status(ETrack tre)
192     {
193         double nsigma = CrossStat.staticNSigma();
194         double prec = CrossStat.staticPrecision();
195         double dvtrk = nsigma*
196                 Math.sqrt(tre.error().get(SurfXYPlane.IV,SurfXYPlane.IV)) + prec;
197         double dztrk = nsigma*
198                 Math.sqrt(tre.error().get(SurfXYPlane.IZ,SurfXYPlane.IZ)) + prec;
199         return status(tre,dvtrk,dztrk);
200     }
201     
202     /**
203      *output stream
204      *
205      * @return The String representation of this instance.
206      */
207     public String toString()
208     {
209         return super.toString() + ", vmin " + _vmin + " and vmax " + _vmax
210                 + ", zmin " + _zmin + " and zmax " + _zmax;
211     }
212 }