View Javadoc

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