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