View Javadoc

1   package org.lcsim.recon.tracking.trfcyl;
2   import org.lcsim.recon.tracking.trfutil.Assert;
3   import org.lcsim.recon.tracking.trfutil.TRFMath;
4   import org.lcsim.recon.tracking.trfbase.ETrack;
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.TrackVector;
10  import org.lcsim.recon.tracking.trfbase.TrackError;
11  
12  /**
13   * Describes a measurement of both phi and z on a cylinder.
14   *<p>
15   * This hit produces a two-dimensional prediction of phi and z of the track.
16   *<p>
17   *Only ClusCylPhiZ2D objects are allowed to construct HitCylPhiZ2D objects.
18   *
19   *
20   *@author Norman A. Graf
21   *@version 1.0
22   *
23   */
24  //**********************************************************************
25  //cng changed to public for component tests
26  public class HitCylPhiZ2D extends Hit
27  {
28      
29      // Only ClusCylPhiZ2D is allowed to construct HitCylPhiZ2D objects.
30      
31      // static methods
32      
33      //
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 "HitCylPhiZ2D"; }
43      
44      //
45      /**
46       *Return a String representation of the class' type name.
47       *Included for completeness with the C++ version.
48       *
49       * @return   A String representation of the class' type name.
50       */
51      public static String staticType()
52      { return typeName(); }
53      
54      // prediction for phi
55      private double _phi_pre;
56      
57      // prediction for z
58      private double _z_pre;
59      
60      // error matrix for prediction
61      private double _ephi_pre;
62      private double _ez_pre;
63      private double _ephiz_pre;
64      
65      // store the HitDerivative
66      private static double values[] =
67      { 1.0, 0.0, 0.0, 0.0, 0.0,
68                0.0, 1.0, 0.0, 0.0, 0.0 };
69                private static HitDerivative _deriv = new HitDerivative(2,values);
70                
71                
72                //
73                
74                /**
75                 * Test equality.
76                 * Hits are equal if they have the same parent cluster.
77                 *
78                 * @param   hit The Hit to test against.
79                 * @return true if the Hits are the same.
80                 */
81                public boolean equal(Hit hit)
82                {
83                    Assert.assertTrue( type().equals(hit.type()) );
84                    return cluster().equals(hit.cluster());
85                }
86                
87                // constructor
88                HitCylPhiZ2D(double phi, double ephi, double z, double ez, double ephiz)
89                {
90                    _phi_pre = phi;
91                    _ephi_pre = ephi;
92                    _z_pre = z;
93                    _ez_pre = ez;
94                    _ephiz_pre = ephiz;
95                }
96                
97                //
98                
99                /**
100                *Construct an instance replicating the HitCylPhiZ2D ( copy constructor ).
101                *
102                * @param   hcpz The Hit to replicate.
103                */
104               public HitCylPhiZ2D(HitCylPhiZ2D hcpz)
105               {
106                   super(hcpz);
107                   _phi_pre = hcpz._phi_pre;
108                   _ephi_pre = hcpz._ephi_pre;
109                   _z_pre = hcpz._z_pre;
110                   _ez_pre = hcpz._ez_pre;
111                   _ephiz_pre = hcpz._ephiz_pre;
112               }
113               
114               //
115               
116               /**
117                *Return a String representation of the class' type name.
118                *Included for completeness with the C++ version.
119                *
120                * @return   A String representation of the class' type name.
121                */
122               public String type()
123               { return staticType(); }
124               
125               //
126               
127               /**
128                *Return the dimension of a phi, z measurement on a cylinder.
129                *The value is always two.
130                *
131                * @return The dimension of this hit (2).
132                */
133               public int size()
134               { return 2; }
135               
136               //
137               
138               /**
139                *Return the measured hit vector.
140                *
141                * @return The HitVector for this hit.
142                */
143               public HitVector measuredVector()
144               {
145                   return new HitVector( fullCluster().phi(), fullCluster().z() );
146               }
147               
148               //
149               
150               /**
151                *Return the measured hit error.
152                *
153                * @return The HitError for this hit.
154                */
155               public HitError measuredError()
156               {
157                   double dphi = fullCluster().dPhi();
158                   double dz = fullCluster().dZ();
159                   double dphidz = fullCluster().dPhidZ();;
160                   return new HitError( dphi*dphi, dphidz, dz*dz );
161               }
162               
163               //
164               
165               /**
166                *Return the predicted hit vector.
167                *
168                * @return The HitVector for the prediction.
169                */
170               public HitVector predictedVector()
171               {
172                   return new HitVector( _phi_pre, _z_pre );
173               }
174               
175               //
176               
177               /**
178                *Return the predicted hit error.
179                *
180                * @return The HitError for the prediction.
181                */
182               public HitError predictedError()
183               {
184                   return new HitError( _ephi_pre, _ephiz_pre, _ez_pre );
185               }
186               
187               //
188               
189               /**
190                *Return the hit derivative with respect to a track on this surface.
191                *
192                * @return The HitDerivative for a track on this surface.
193                */
194               public HitDerivative dHitdTrack()
195               {
196                   return _deriv;
197               }
198               
199               //
200               
201               /**
202                *Return the difference between prediction and measurement.
203                *
204                * @return The HitVector for the difference between the hit prediction and measurement.
205                */
206               public HitVector differenceVector()
207               {
208                   return new HitVector(
209                           TRFMath.fmod2(_phi_pre-fullCluster().phi(), TRFMath.TWOPI),
210                           _z_pre-fullCluster().z() );
211               }
212               
213               //
214               
215               /**
216                *Update the prediction (measurement and derivative do not change).
217                *
218                * @param   tre The ETrack for which to predict this hit measurement.
219                */
220               public void update( ETrack tre)
221               {
222                   TrackVector vec =   tre.vector();
223                   TrackError err =  tre.error() ;
224                   
225                   _phi_pre = vec.get(SurfCylinder.IPHI);
226                   _ephi_pre = err.get(SurfCylinder.IPHI,SurfCylinder.IPHI);
227                   
228                   _z_pre = vec.get(SurfCylinder.IZ);
229                   _ez_pre = err.get(SurfCylinder.IZ,SurfCylinder.IZ);
230                   
231                   _ephiz_pre = err.get(SurfCylinder.IPHI,SurfCylinder.IZ);
232                   
233               }
234               
235               //
236               
237               /**
238                *Return a ClusCylPhiZ2D reference to the hit.
239                *
240                * @return The hit as a ClusCylPhiZ2D object.
241                */
242               public ClusCylPhiZ2D fullCluster()
243               { return (ClusCylPhiZ2D) _pclus; };
244               
245               
246               /**
247                *output stream
248                *
249                * @return A String representation of this instance.
250                */
251               public String toString()
252               {
253                   return "hit from "+_pclus;
254               }
255 }