View Javadoc

1   package  org.lcsim.recon.tracking.trfzp;
2   
3   
4   import org.lcsim.recon.tracking.trfutil.Assert;
5   
6   import org.lcsim.recon.tracking.trfbase.Hit;
7   import org.lcsim.recon.tracking.trfbase.HitVector;
8   import org.lcsim.recon.tracking.trfbase.HitError;
9   import org.lcsim.recon.tracking.trfbase.HitDerivative;
10  import org.lcsim.recon.tracking.trfbase.ETrack;
11  import org.lcsim.recon.tracking.trfbase.TrackVector;
12  import org.lcsim.recon.tracking.trfbase.TrackError;
13  
14  /**
15   * Describes a two dimensional (x,y) measurement on a ZPlane.
16   *<p>
17   * This is a very simple hit.  It produces one prediction with fixed
18   * measurement which is simply the (x,y) of the track.
19   *
20   *@author Norman A. Graf
21   *@version 1.0
22   *
23   */
24  
25  //cng changed to public for component tests
26  public class HitZPlane2 extends Hit
27  {
28      
29      // Only ClusZPlane2 is allowed to construct HitZPlane2 objects.
30      // therefore package level protection
31      
32      // store the derivative
33      static double values[] =
34      { 1.0, 0.0, 0.0, 0.0, 0.0,
35        0.0, 1.0, 0.0, 0.0, 0.0 };
36        static HitDerivative _deriv = new HitDerivative(2,values);
37        
38        //
39        
40        /**
41         *Return a String representation of the class' type name.
42         *Included for completeness with the C++ version.
43         *
44         * @return   A String representation of the class' type name.
45         */
46        public static String typeName()
47        { return "HitZPlane2"; }
48        
49        //
50        
51        /**
52         *Return a String representation of the class' type name.
53         *Included for completeness with the C++ version.
54         *
55         * @return   A String representation of the class' type name.
56         */
57        public static String staticType()
58        { return typeName(); }
59        
60        
61        // prediction for hm
62        private double _x;
63        private double _y;
64        
65        // error matrix for hm
66        private double _dx2;
67        private double _dy2;
68        private double _dxdy;
69        
70        // equality
71        // Hits are equal if they have the same parent cluster.
72        
73        protected boolean equal( Hit hit)
74        {
75            Assert.assertTrue( type().equals(hit.type()) );
76            return cluster().equals(hit.cluster());
77        }
78        
79        // constructor (package access for ClusZPlane2)
80        HitZPlane2(double x, double y, double dx2, double dy2, double dxdy)
81        {
82            _x = x;
83            _y = y;
84            _dx2 = dx2;
85            _dy2 = dy2;
86            _dxdy = dxdy;
87        }
88        
89        //
90        
91        /**
92         *Construct an instance replicating the HitZPlane2 ( copy constructor ).
93         *
94         * @param   hit The Hit to replicate.
95         */
96        public HitZPlane2( HitZPlane2 hit)
97        {
98            super(hit);
99            _x = hit._x;
100           _y = hit._y;
101           _dx2 = hit._dx2;
102           _dy2 = hit._dy2;
103           _dxdy = hit._dxdy;
104       }
105       
106       //
107       
108       /**
109        *Return a String representation of the class' type name.
110        *Included for completeness with the C++ version.
111        *
112        * @return   A String representation of the class' type name.
113        */
114       public String type()
115       { return staticType();  }
116       
117       //
118       
119       /**
120        *Return the dimension of an (x,y) measurement on a z plane.
121        *The value is always two.
122        *
123        * @return The dimension of this hit (2).
124        */
125       public int size()
126       { return 2; }
127       
128       //
129       
130       /**
131        *Return the measured hit vector.
132        *
133        * @return The HitVector for this hit.
134        */
135       public HitVector measuredVector()
136       {
137           ClusZPlane2 clu =  fullCluster();
138           return new HitVector( clu.x(), clu.y() );
139       }
140       
141       //
142       
143       /**
144        *Return the measured hit error.
145        *
146        * @return The HitError for this hit.
147        */
148       public HitError measuredError()
149       {
150           ClusZPlane2 clu =  fullCluster();
151           return new HitError(clu.dX2(),clu.dXdY(), clu.dY2()   );
152       }
153       
154       //
155       
156       /**
157        *Return the predicted hit vector.
158        *
159        * @return The HitVector for the prediction.
160        */
161       public HitVector predictedVector()
162       {
163           return new HitVector( _x , _y );
164       }
165       
166       //
167       
168       /**
169        *Return the predicted hit error.
170        *
171        * @return The HitError for the prediction.
172        */
173       public HitError predictedError()
174       {
175           return new HitError( _dx2,_dxdy, _dy2 );
176       }
177       
178       //
179       
180       /**
181        *Return the hit derivative with respect to a track on this surface.
182        *
183        * @return The HitDerivative for a track on this surface.
184        */
185       public HitDerivative dHitdTrack()
186       {
187           return _deriv;
188       }
189       
190       //
191       
192       /**
193        *Return the difference between prediction and measurement.
194        *
195        * @return The HitVector for the difference between the hit prediction and measurement.
196        */
197       public HitVector differenceVector()
198       {
199           
200           ClusZPlane2 clu =  fullCluster();
201           
202           double diff_x = _x - clu.x();
203           double diff_y = _y - clu.y();
204           return new HitVector( diff_x, diff_y );
205       }
206       
207       //
208       
209       /**
210        *Update the prediction (measurement and derivative do not change).
211        *
212        * @param   tre The ETrack for which to predict this hit measurement.
213        */
214       public void update(  ETrack tre)
215       {
216           
217           TrackVector vec =   tre.vector();
218           
219           _x = vec.get(SurfZPlane.IX);
220           _y = vec.get(SurfZPlane.IY);
221           
222           TrackError err =  tre.error() ;
223           
224           _dx2 = err.get(SurfZPlane.IX,SurfZPlane.IX);
225           _dxdy = err.get(SurfZPlane.IX,SurfZPlane.IY);
226           _dy2 = err.get(SurfZPlane.IY,SurfZPlane.IY);
227       }
228       
229       
230       /**
231        * Return the measured x position of the hit.
232        *
233        * @return The measured x position of the hit.
234        */
235       public double x()
236       { return _x; }
237       
238       /**
239        * Return the measured y position of the hit.
240        *
241        * @return The measured y position of the hit.
242        */
243       public double y()
244       { return _y; }
245       
246       /**
247        * Return the error matrix term for x.
248        *
249        * @return The error matrix term for x.
250        */
251       public double dX2()
252       { return _dx2; }
253       
254       /**
255        *  Return the error matrix term for y.
256        *
257        * @return The error matrix term for y.
258        */
259       public double dY2()
260       { return _dy2; }
261       
262       /**
263        * Return the error matrix covariance term.
264        *
265        * @return The error matrix covariance term.
266        */
267       public double dXdY()
268       { return _dxdy; }
269       
270       //
271       
272       /**
273        *Return a ClusZPlane2 reference to the cluster.
274        *
275        * @return The hit as a ClusZPlane2 object.
276        */
277       public  ClusZPlane2 fullCluster()
278       { return ( ClusZPlane2) _pclus; }
279       
280       
281       /**
282        *output stream
283        *
284        * @return  A String representation of this instance.
285        */
286       public String toString()
287       {
288           if( _pclus != null )
289           {
290               return "HitZPlane2 from " + _pclus;
291           }
292           else
293           {
294               return "HitZPlane2 with no parent clusters";
295           }
296       }
297       
298 }