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.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  
11  /**
12   * Describes a one dimensional xy measurement on a ZPlane.
13   * axy = wx*x + wy*y
14   *<p>
15   * This is a very simple hit.  It produces one prediction with fixed
16   * measurement which is simply the axy 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 HitZPlane1 extends Hit
24  {
25      
26      // Only ClusZPlane1 is allowed to construct HitZPlane1 objects.
27      // therefore package protection
28      
29      
30      //
31      /**
32       *Return a String representation of the class' type name.
33       *Included for completeness with the C++ version.
34       *
35       * @return   A String representation of the class' type name.
36       */
37      public static String typeName()
38      { return "HitZPlane1";
39      }
40      
41      //
42      
43      /**
44       *Return a String representation of the class' type name.
45       *Included for completeness with the C++ version.
46       *
47       * @return   A String representation of the class' type name.
48       */
49      public static String staticType()
50      { return typeName();
51      }
52      
53      
54      // prediction for axy
55      private double _axy_pre;
56      
57      // error matrix for axy
58      private double _eaxy_pre;
59      
60      
61      /**
62       * Test equality.
63       * Hits are equal if they have the same parent cluster.
64       *
65       * @param   hit The Hit to test against.
66       * @return true if the Hits are the same.
67       */
68      protected boolean equal( Hit hit)
69      {
70          Assert.assertTrue( type().equals(hit.type()) );
71          return cluster().equals(hit.cluster());
72      }
73      
74      // constructor (package access for ClusZPlane1)
75      HitZPlane1(double axy, double eaxy)
76      {
77          _axy_pre = axy;
78          _eaxy_pre = eaxy;
79      }
80      
81      //
82      
83      /**
84       *Construct an instance replicating the HitZPlane1 ( copy constructor ).
85       *
86       * @param   hit The Hit to replicate.
87       */
88      public HitZPlane1( HitZPlane1 hit)
89      {
90          super(hit);
91          _axy_pre = hit._axy_pre;
92          _eaxy_pre = hit._eaxy_pre;
93      }
94      
95      //
96      
97      /**
98       *Return a String representation of the class' type name.
99       *Included for completeness with the C++ version.
100      *
101      * @return   A String representation of the class' type name.
102      */
103     public String type()
104     { return staticType();
105     }
106     
107     //
108     
109     /**
110      *Return the dimension of an xy measurement on a z plane.
111      *axy = wx*x + wy*y
112      *The value is always one.
113      *
114      * @return The dimension of this hit (1).
115      */
116     public int size()
117     { return 1;
118     }
119     
120     //
121     
122     /**
123      *Return the measured hit vector.
124      *
125      * @return The HitVector for this hit.
126      */
127     public HitVector measuredVector()
128     {
129         return new HitVector( fullCluster().aXY() );
130     }
131     
132     //
133     
134     /**
135      *Return the measured hit error.
136      *
137      * @return The HitError for this hit.
138      */
139     public HitError measuredError()
140     {
141         double daxy = fullCluster().daXY();
142         return new HitError( daxy*daxy );
143     }
144     
145     //
146     
147     /**
148      *Return the predicted hit vector.
149      *
150      * @return The HitVector for the prediction.
151      */
152     public HitVector predictedVector()
153     {
154         return new HitVector( _axy_pre );
155     }
156     
157     //
158     
159     /**
160      *Return the predicted hit error.
161      *
162      * @return The HitError for the prediction.
163      */
164     public HitError predictedError()
165     {
166         return new HitError( _eaxy_pre );
167     }
168     
169     //
170     
171     /**
172      *Return the hit derivative with respect to a track on this surface.
173      *
174      * @return The HitDerivative for a track on this surface.
175      */
176     public HitDerivative dHitdTrack()
177     {
178         double values[] =
179         { 0.0, 0.0, 0.0, 0.0, 0.0 };
180         values[0] = fullCluster().wX();
181         values[1] = fullCluster().wY();
182         HitDerivative deriv = new HitDerivative(1,values);
183         return deriv;
184     }
185     
186     //
187     
188     /**
189      *Return the difference between prediction and measurement.
190      *
191      * @return The HitVector for the difference between the hit prediction and measurement.
192      */
193     public HitVector differenceVector()
194     {
195         return new HitVector( _axy_pre-fullCluster().aXY() );
196     }
197     
198     //
199     
200     /**
201      *Update the prediction (measurement and derivative do not change).
202      *
203      * @param   tre The ETrack for which to predict this hit measurement.
204      */
205     public void update(  ETrack tre)
206     {
207         
208         double x_track = tre.vector().get(SurfZPlane.IX);
209         double y_track = tre.vector().get(SurfZPlane.IY);
210         double exx_track = tre.error().get(SurfZPlane.IX,SurfZPlane.IX);
211         double exy_track = tre.error().get(SurfZPlane.IX,SurfZPlane.IY);
212         double eyy_track = tre.error().get(SurfZPlane.IY,SurfZPlane.IY);
213         
214         double cl_wx = fullCluster().wX();
215         double cl_wy = fullCluster().wY();
216         
217         _axy_pre = cl_wx*x_track + cl_wy*y_track;
218         _eaxy_pre =   exx_track*cl_wx*cl_wx +
219         2.*exy_track*cl_wx*cl_wy +
220         eyy_track*cl_wy*cl_wy;
221     }
222     
223     //
224     
225     /**
226      *Return a ClusZPlane1 reference to the cluster.
227      *
228      * @return The hit as a ClusZPlane1 object.
229      */
230     public ClusZPlane1 fullCluster()
231     {
232         return (ClusZPlane1) _pclus;
233     }
234     
235     
236     /**
237      *output stream
238      *
239      * @return  A String representation of this instance.
240      */
241     public String toString()
242     {
243         if( _pclus != null )
244         {
245             return "HitZPlane1 from " + _pclus;
246         }
247         else
248         {
249             return "HitZPlane1 with no parent clusters";
250         }
251     }
252 }