View Javadoc

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