View Javadoc

1   /*
2    * ZSegmentFit.java
3    *
4    * Created on August 1, 2007, 9:46 AM
5    *
6    */
7   
8   package org.lcsim.fit.zsegment;
9   
10  import java.util.List;
11  import hep.physics.matrix.SymmetricMatrix;
12  
13  /**
14   * Encapsulates the constraints in the z0 - tan(lambda) track parameters
15   * due to a track passing through a set of detectors segmented in z.
16   * @author Richard Partridge
17   * @version 1.0
18   */
19  public class ZSegmentFit {
20      
21      private List<double[]> _polygon;
22      private double[] _centroid;
23      private SymmetricMatrix _covariance;
24      
25      /**
26       * Create a new instance of ZSegmentFit
27       * @param polygon List of vertices of the polygon describing the allowed region in the z0 - tan(lambda) plane.
28       * Each vertex is a double[2] with the first element being the z0 coordinate and the second
29       * the tan(lambda) coordinate.
30       * @param centroid Centroid of the polygon, where centroid[0] is the z0 coordinate, centroid[1] is the tan(lambda) coordinate
31       * @param covariance Covariance matrix calculated assuming equal probability for all points in the polygonal allowed region
32       */
33      public ZSegmentFit(List<double[]> polygon, double[] centroid, SymmetricMatrix covariance) {
34          _polygon = polygon;
35          _centroid = centroid;
36          _covariance = covariance;
37      }
38      
39      /**
40       * Return the polygon that specifies the allowed region in z0 - tan(lambda) space
41       * @return List of vertices for the polygon.  Each vertex is returned as a double[2] with the first element
42       * giving the z0 coordinate and the second element the tan(lambda) coordinate
43       */
44      public List<double[]> getPolygon() {
45          return _polygon;
46      }
47      
48      /**
49       * Return the centroid (i.e., center of gravity) of the allowed region in the z0-tan(lambda) plane
50       * @return Centroid of the polygon, with the first element giving the z0 coordinate and the second element
51       * giving the tan(lambda) coordinate
52       */
53      public double[] getCentroid() {
54          return _centroid;
55      }
56      
57      /**
58       * Return the covariance matrix for the allowed region in the z0 - tan(lambda) plane
59       * @return Covariance matrix
60       */
61      public SymmetricMatrix getCovariance() {
62          return _covariance;
63      }
64      
65      /**
66       * Return a string containing properties of this ZSegmentFit
67       * @return String containing ZSegmentFit properties
68       */
69      public String toString() {
70          String nl = System.getProperty("line.separator");
71          StringBuffer output = new StringBuffer("ZSegmentFit: Centroid (z0, tan(lambda)) = ("+_centroid[0]+", "+_centroid[1]+")"+nl);
72          output.append("             Covariance matrix ("+_covariance.e(0,0)+", "+_covariance.e(1,0)+", "+_covariance.e(1,1)+")"+nl);
73          output.append("             Allowed region is a "+_polygon.size()+" sided polygon with vertices:"+nl);
74          for (double[] vert : _polygon) {
75              output.append("                 ("+vert[0]+", "+vert[1]+")"+nl);
76          }
77          return new String(output);
78      }
79      
80  }