View Javadoc

1   package org.lcsim.recon.tracking.trfbase;
2   import java.util.*;
3   import org.lcsim.recon.tracking.trfutil.Assert;
4   
5   /**Abstract interface for hits.
6    *
7   
8    * A hit provides a measurement vector and error matrix, a predicted
9    * vector and error matrix and the derivative of the prediction with
10   * respect to the input track.  If the hit is N-dimensional, then the
11   * error matrix is NxN symmetric and the derivative is Nx5.
12   *<p>
13   * The hit also maintains a reference-counting pointer to its parent hit.
14   * This must be supplied when generating the list of predictions.
15   *<p>
16   * The hit prediction has one non-const method update which takes a
17   * track as input.  This track is used to recalculate the data.  The
18   * data should remain the same if the track is the same as that used
19   * to generate the hit prediction.  If the track vector or its error
20   * change, then any of the data may change.
21   *
22   * @author Norman A. Graf
23   * @version 1.0
24   */
25  
26  public abstract class Hit
27  {
28      
29      // static methods
30      
31      //
32      
33      /**
34       *Return the type name.
35       *
36       * @return  String representation of the type
37       * Included for completeness with C++ version
38       */
39      public static String typeName()
40      { return "Hit"; }
41      
42      //
43      
44      /**
45       *Return the type.
46       *
47       * @return  String representation of the type
48       * Included for completeness with C++ version
49       */
50      public static String staticType()
51      { return typeName(); }
52      
53      // pointer to the parent cluster
54      protected Cluster _pclus;
55      
56      
57      // equality
58      // Return true if and only if the two predictions would return the same
59      // parameters for any input track.
60      // The current track (and thus the current sets of parameters) do
61      // not have to be the same.
62      // It has already been verified that this and hp are of the same type
63      // and have equal clusters.
64      protected abstract boolean equal( Hit hp);
65      
66      //
67      
68      /**
69       *constructor
70       *
71       */
72      public Hit()
73      {
74      }
75      
76      //
77      
78      /**
79       * copy constructor
80       *
81       * @param   hp  Hit to replicate
82       */
83      public Hit(Hit hp)
84      {
85      }
86      
87      //
88      
89      /**
90       *Return the generic type.
91       *
92       * @return  String representation of the type
93       * Included for completeness with C++ version
94       *
95       */
96      public String genericType()
97      { return staticType(); }
98      
99      /**
100      *Return the type.
101      *
102      * @return  String representation of the type
103      * Included for completeness with C++ version
104      */
105     public String type()
106     { return staticType(); }
107     
108     //
109     
110     /**
111      * Register the parent cluster.
112      * This should only be called once.
113      *
114      * @param   clus The Cluster which creates this Hit
115      */
116     public void setParentPointer( Cluster clus)
117     {
118         Assert.assertTrue(_pclus == null || _pclus == clus);
119         _pclus = clus;
120     }
121     
122     //
123     
124     /**
125      *return the parent cluster
126      *
127      * @return the Cluster which created this Hit
128      */
129     public Cluster cluster()
130     {return _pclus; }
131     
132     //
133     
134     /**
135      *Return the parent cluster surface.
136      *
137      * @return the Surface at which this Hit's originating Cluster is defined
138      */
139     public Surface surface()
140     {
141         return cluster().surface();
142     }
143     
144     //
145     
146     /**
147      *return the dimension of the hit vector
148      *
149      * @return the dimensionality of this Hit
150      */
151     public abstract int size();
152     
153     //
154     
155     /**
156      *return the measured hit vector
157      *
158      * @return the measured HitVector
159      */
160     public abstract HitVector measuredVector();
161     
162     //
163     
164     /**
165      *return the measured hit error
166      *
167      * @return the measurement HitError
168      */
169     public abstract HitError measuredError();
170     
171     //
172     
173     /**
174      *return the predicted hit vector
175      *
176      * @return the predicted Hit
177      */
178     public abstract HitVector predictedVector();
179     
180     //
181     
182     /**
183      *return the predicted hit error
184      *
185      * @return the predicted Hit error
186      */
187     public abstract HitError predictedError();
188     
189     //
190     
191     /**
192      *return the Nx5 derivative dhit_dtrack.
193      *
194      * @return the erivative for this Hit
195      */
196     public abstract HitDerivative dHitdTrack();
197     
198     //
199     
200     /**
201      *return the difference between the prediction and the measurement
202      * this is not trivial because of circular variables (e.g. angles)
203      *
204      * @return the difference between the prediction and measurement
205      */
206     public abstract HitVector differenceVector();
207     
208     //
209     
210     /**
211      *Update the measurement and prediction using new track parameters.
212      * If update is called with the same track, then the measurement,
213      * prediction and derivative should not change.
214      *
215      * @param   tre the ETrack to use for updating 
216      */
217     public abstract void update( ETrack tre);
218     
219     //
220     
221     /**
222      *Return the ID's of MC tracks contributing to the parent cluster.
223      *
224      * @return a List of MC Id's of tracks contributing to the parent cluster
225      */
226     public List mcIds()
227     { return _pclus.mcIds(); }
228     
229     //
230     
231     /**
232      *equality
233      * false if the hits are of different type
234      * otherwise compare with virtual function equal
235      *
236      * @param   hit Hit to compare
237      * @return false if the hits are of different type
238      * otherwise compare with virtual function equal
239      */
240     public boolean equals( Hit hit)
241     {
242         if( !type().equals(hit.type()) ) return false;
243         if( cluster() != hit.cluster() ) return false;
244         return equal(hit);
245     }
246     
247     //
248     
249     /**
250      *inequality
251      *
252      * @param   hit Hit to compare
253      * @return true if Hits are not equal
254      */
255     public boolean notEquals( Hit hit)
256     { return ! equals(hit); }
257     
258 }