View Javadoc

1   package  org.lcsim.recon.tracking.trfzp;
2   
3   import java.util.List;
4   import java.util.ArrayList;
5   
6   import org.lcsim.recon.tracking.trfutil.Assert;
7   
8   import org.lcsim.recon.tracking.trfbase.McCluster;
9   import org.lcsim.recon.tracking.trfbase.ETrack;
10  import org.lcsim.recon.tracking.trfbase.TrackVector;
11  import org.lcsim.recon.tracking.trfbase.TrackError;
12  import org.lcsim.recon.tracking.trfbase.Cluster;
13  import org.lcsim.recon.tracking.trfbase.Surface;
14  import org.lcsim.recon.tracking.trfbase.Hit;
15  import org.lcsim.recon.tracking.trfbase.HitVector;
16  import org.lcsim.recon.tracking.trfbase.HitError;
17  
18  /**
19   * Describes a cluster which measures (x,y) on a ZPlane.
20   *
21   *
22   *@author Norman A. Graf
23   *@version 1.0
24   *
25   */
26  public class ClusZPlane2 extends McCluster
27  {
28      
29      // static methods
30      
31      //
32      
33      /**
34       *Return a String representation of the class' type name.
35       *Included for completeness with the C++ version.
36       *
37       * @return   A String representation of the class' type name.
38       *
39       */
40      public static String typeName()
41      { return "ClusZPlane2";
42      }
43      
44      //
45      
46      /**
47       *Return a String representation of the class' type name.
48       *Included for completeness with the C++ version.
49       *
50       * @return   A String representation of the class' type name.
51       *
52       */
53      public static String staticType()
54      { return typeName();
55      }
56      
57      
58      // cluster parameter indices
59      
60      public static final int IX=0;
61      public static final int IY=1;
62      
63      // attributes
64      
65      // the surface
66      private SurfZPlane _szp;
67      
68      // measurement
69      private double _x,_y;
70      
71      // the error matrix for the measurement
72      private double _dx2;
73      private double _dy2;
74      private double _dxdy;
75      
76      // methods
77      
78      //
79      
80      /**
81       * Test equality.
82       *
83       * @param   clus The Cluster to test against.
84       * @return true if the Clusters are the same.
85       */
86      public boolean equal( Cluster clus)
87      {
88          Assert.assertTrue( type().equals(clus.type()) );
89          ClusZPlane2 ccp = (ClusZPlane2) clus;
90          return ( _x == ccp._x ) &&
91                  ( _y == ccp._y ) &&
92                  ( _dx2 == ccp._dx2 ) &&
93                  ( _dy2 == ccp._dy2 ) &&
94                  ( _dxdy == ccp._dxdy ) &&
95                  ( _szp.equals(ccp._szp) );
96      }
97      
98      //
99      
100     /**
101      *Generate the first (and only) track prediction.
102      *
103      * @param   tre The ETrack for which to generate the prediction.
104      * @return A list of hits for this Track.
105      */
106     public  List predict( ETrack tre)
107     {
108         List hits = new ArrayList();
109         
110         TrackVector  vec = tre.vector();
111         TrackError  err = tre.error();
112         
113         hits.add(  new
114                 HitZPlane2( vec.get(SurfZPlane.IX),vec.get(SurfZPlane.IY),
115                 err.get(SurfZPlane.IX,SurfZPlane.IX),
116                 err.get(SurfZPlane.IY,SurfZPlane.IY),
117                 err.get(SurfZPlane.IX,SurfZPlane.IY)
118                 ) );
119         
120         return hits;
121     }
122     
123     // methods
124     //
125     
126     
127     /**
128      *Construct an instance from the z plane position, the hit measurement,
129      *and the hit measurement uncertainty.
130      *
131      * @param   zpos The z position of the plane.
132      * @param   hm   The two dimensional HitVector representing the x,y measurement and its correlation.
133      * @param   dhm  The two dimensional HitError representing the x,y measurement uncertainty and its correlation.
134      */
135     public ClusZPlane2(double zpos,
136             HitVector hm,
137             HitError dhm )
138     {
139         
140         _szp = new SurfZPlane(zpos);
141         // check that determinant of _dhm is positive
142         
143         _x = hm.get(IX);
144         _y = hm.get(IY);
145         _dx2 = dhm.get(IX,IX);
146         _dy2 = dhm.get(IY,IY);
147         _dxdy = dhm.get(IX,IY);
148         
149         Assert.assertTrue( _dx2 >= 0.0 && _dy2 >=0. );
150         
151         // check that determinant of _dhm is positive
152         Assert.assertTrue( _dx2*_dy2 - _dxdy*_dxdy >= 0.0);
153         
154     }
155     
156     
157     /**
158      *Construct an instance from the z plane position, the x and y measurements,
159      *and the hit measurement uncertainty.
160      *
161      * @param   zpos The z position of the plane.
162      * @param   x The x measurement.
163      * @param   y The y measurement.
164      * @param   dhm  The two dimensional HitError representing the x,y measurement uncertainty and its correlation.
165      */
166     public ClusZPlane2(double zpos,
167             double x, double y,
168             HitError dhm )
169     {
170         _szp = new SurfZPlane(zpos);
171         _x = x;
172         _y = y;
173         _dx2 = dhm.get(IX,IX);
174         _dy2 = dhm.get(IY,IY);
175         _dxdy = dhm.get(IX,IY);
176         
177         Assert.assertTrue( _dx2 >= 0.0 && _dy2 >=0. );
178         
179         // check that determinant of _dhm is positive
180         Assert.assertTrue( _dx2*_dy2 - _dxdy*_dxdy >= 0.0);
181     }
182     
183     
184     //
185     
186     
187     /**
188      *Construct an instance from the z plane position, the x and y measurements,
189      *and the hit measurement uncertainty.
190      *
191      * @param   zpos The z position of the plane.
192      * @param   x The x measurement.
193      * @param   y The y measurement.
194      * @param   dx2 The (squared) error on the x measurement.
195      * @param   dy2 The (squared) error on the y measurement.
196      * @param   dxdy The xy covariance term.
197      */
198     public  ClusZPlane2(double zpos, double x, double y, double dx2, double dy2, double dxdy)
199     {
200         _szp = new SurfZPlane(zpos);
201         _x = x;
202         _y = y;
203         _dx2 = dx2;
204         _dy2 = dy2;
205         _dxdy = dxdy;
206         
207         Assert.assertTrue( _dx2 >= 0.0 && _dy2 >=0. );
208         
209         // check that determinant of _dhm is positive
210         Assert.assertTrue( _dx2*_dy2 - _dxdy*_dxdy >= 0.0);
211     }
212     
213     //Constructor from single MC Id
214     
215     /**
216      *Construct an instance from the z plane position, the x and y measurements,
217      *the hit measurement uncertainty and the MC ID associated with this cluster.
218      *
219      * @param   zpos The z position of the plane.
220      * @param   x The x measurement.
221      * @param   y The y measurement.
222      * @param   dx2 The (squared) error on the x measurement.
223      * @param   dy2 The (squared) error on the y measurement.
224      * @param   dxdy The xy covariance term.
225      * @param   mcid The MC ID for the track creating this cluster.
226      */
227     public  ClusZPlane2(double zpos, double x, double y, double dx2, double dy2, double dxdy, int mcid)
228     {
229         super(mcid);
230         _szp = new SurfZPlane(zpos);
231         _x = x;
232         _y = y;
233         _dx2 = dx2;
234         _dy2 = dy2;
235         _dxdy = dxdy;
236         
237         Assert.assertTrue( _dx2 >= 0.0 && _dy2 >=0. );
238         
239         // check that determinant of _dhm is positive
240         Assert.assertTrue( _dx2*_dy2 - _dxdy*_dxdy >= 0.0);
241     }
242     
243     //
244     
245     /**
246      *Construct an instance from the z plane position, the x and y measurements,
247      *the hit measurement uncertainty and the MC ID associated with this cluster.
248      *
249      * @param   zpos The z position of the plane.
250      * @param   x The x measurement.
251      * @param   y The y measurement.
252      * @param   dx2 The (squared) error on the x measurement.
253      * @param   dy2 The (squared) error on the y measurement.
254      * @param   dxdy The xy covariance term.
255      * @param   mcids The list of MC IDs for the tracks contributing to this cluster.
256      */
257     public  ClusZPlane2(double zpos, double x, double y, double dx2, double dy2, double dxdy, List mcids)
258     {
259         super(mcids);
260         _szp = new SurfZPlane(zpos);
261         _x = x;
262         _y = y;
263         _dx2 = dx2;
264         _dy2 = dy2;
265         _dxdy = dxdy;
266         
267         Assert.assertTrue( _dx2 >= 0.0 && _dy2 >=0. );
268         
269         // check that determinant of _dhm is positive
270         Assert.assertTrue( _dx2*_dy2 - _dxdy*_dxdy >= 0.0);
271     }
272     
273     //
274     
275     /**
276      *Construct an instance replicating the ClusZPlane2 ( copy constructor ).
277      *
278      * @param   clus The Cluster to replicate.
279      */
280     public  ClusZPlane2( ClusZPlane2 clus)
281     {
282         super(clus);
283         _szp = new SurfZPlane(clus._szp);
284         _x = clus._x;
285         _y = clus._y;
286         _dx2 = clus._dx2;
287         _dy2 = clus._dy2;
288         _dxdy = clus._dxdy;
289     }
290     
291     //
292     
293     /**
294      *Return a String representation of the class' type name.
295      *Included for completeness with the C++ version.
296      *
297      * @return   A String representation of the class' type name.
298      *
299      */
300     public  String type()
301     {
302         return staticType();
303     }
304     
305     //
306     
307     /**
308      *Return the surface at which this cluster is measured.
309      *
310      * @return The surface of this cluster.
311      */
312     public  Surface surface()
313     {
314         return _szp;
315     }
316     
317     //
318     
319     /**
320      *There are no more predictions.
321      *
322      * @return null.
323      */
324     public  Hit newNextPrediction()
325     {
326         return null;
327     }
328     
329     
330     /**
331      * Return the measured x position.
332      *
333      * @return The measured x position.
334      */
335     public double x()
336     {
337         return _x;
338     }
339     
340     /**
341      * Return the measured y position.
342      *
343      * @return The measured y position.
344      */
345     public double y()
346     {
347         return _y;
348     }
349     
350     /**
351      * Return the error matrix element for x.
352      * This is the square of the uncertainty on the x measurement.
353      *
354      * @return The square of the uncertainty on the x measurement.
355      */
356     public double dX2()
357     {
358         return _dx2;
359     }
360     
361     /**
362      * Return the error matrix element for y.
363      * This is the square of the uncertainty on the y measurement.
364      *
365      * @return The square of the uncertainty on the y measurement.
366      */
367     public double dY2()
368     {
369         return _dy2;
370     }
371     
372     /**
373      *Return the error matrix covariance element for xy.
374      *
375      * @return The error matrix covariance element for xy.
376      */
377     public double dXdY()
378     {
379         return _dxdy;
380     }
381     
382     
383     /**
384      *output stream
385      *
386      * @return A String representation of this instance.
387      */
388     public String toString()
389     {
390         return " z " + _szp.z()
391         + ": xy =  [" + _x + " , " + _y + " ] +/- " +
392                 "[ " + _dx2 + " , " + _dy2 +" , " + _dxdy + " ] ";
393     }
394     
395 }
396