View Javadoc

1   /*
2    * BaseTrackerHit.java
3    *
4    * Created on March 24, 2006, 9:22 AM
5    *
6    * $Id: BaseTrackerHit.java,v 1.7 2011/08/24 18:51:17 jeremy Exp $
7    */
8   
9   package org.lcsim.event.base;
10  
11  import java.util.ArrayList;
12  import java.util.List;
13  import org.lcsim.event.RawTrackerHit;
14  import org.lcsim.event.TrackerHit;
15  
16  /**
17   * // TODO add methods to add hits to this object. // TODO decide what these hits should be.
18   * 
19   * @author Norman Graf
20   */
21  public class BaseTrackerHit implements TrackerHit {
22      protected double[] _pos = new double[3];
23      protected double[] _covMatrix = new double[6];
24      protected double _time;
25      protected double _dedx;
26      // TODO set up an enumeration to replace the integer type
27      protected int _type;
28      // TODO decide what this is a list of
29      // TODO decide whether this should be a Set
30      protected List _rawHits = new ArrayList();
31      protected long id;
32  
33      /** Creates a new instance of BaseTrackerHit */
34      public BaseTrackerHit() {
35      }
36  
37      /**
38       * fully qualified constructor
39       * 
40       * @param pos
41       *            the position of this hit (x,y,z) in mm
42       * @param cov
43       *            the covariance matrix for the position measurement, packed as 6 elements.
44       * @param t
45       *            the time for this measurement in ns
46       * @param e
47       *            the energy deposit associated with this measurement, in GeV
48       * @param type
49       *            the type of this measurement. not yet defined.
50       */
51      public BaseTrackerHit(double[] pos, double[] cov, double t, double e, int type) {
52          _pos = pos;
53          _covMatrix = cov;
54          _time = t;
55          _dedx = e;
56          _type = type;
57      }
58  
59      // include these setters since I don't know what the final inheriting classes will
60      // look like.
61      /**
62       * The (x,y,z) position of this measurement.
63       * 
64       * @param pos
65       *            the position of this hit (x,y,z) in mm
66       */
67      public void setPosition(double[] pos) {
68          _pos = pos;
69      }
70  
71      /**
72       * The covariance matrix for the position measurement.
73       * 
74       * @param cov
75       *            Packed array representing the symmetric covariance matrix (6 elements).
76       */
77      public void setCovarianceMatrix(double[] cov) {
78          _covMatrix = cov;
79      }
80  
81      /**
82       * The time at which this measurement was made.
83       * 
84       * @param t
85       *            the time in ns.
86       */
87      public void setTime(double t) {
88          _time = t;
89      }
90  
91      /**
92       * The energy deposit associated with this measurement.
93       * 
94       * @param e
95       *            The energy in GeV.
96       */
97      public void setEnergy(double e) {
98          _dedx = e;
99      }
100 
101     /**
102      * The type of this measurement.
103      * 
104      * @param type
105      *            Not yet defined.
106      */
107     public void setType(int type) {
108         _type = type;
109     }
110 
111     /**
112      * Add the RawTrackerHit from which this TrackerHit originates
113      * 
114      * @param hit
115      */
116     public void addRawTrackerHit(RawTrackerHit hit) {
117         _rawHits.add(hit);
118     }
119 
120     /**
121      * Add the list of RawTrackerHits from which this TrackerHit originates
122      * 
123      * @param hits
124      */
125     public void addRawTrackerHits(List<RawTrackerHit> hits) {
126         _rawHits.addAll(hits);
127     }
128 
129     // TODO consider customizing based on hit type.
130     public String toString() {
131         String className = getClass().getName();
132         int lastDot = className.lastIndexOf('.');
133         if (lastDot != -1)
134             className = className.substring(lastDot + 1);
135         StringBuffer sb = new StringBuffer(className + ": Type: " + _type + "\n");
136         sb.append("(x,y,z): " + _pos[0] + " " + _pos[1] + " " + _pos[2] + "\n");
137         // TODO add in covariance matrix
138         sb.append("dEdx: " + _dedx + " t: " + _time + "\n");
139         return sb.toString();
140     }
141 
142     // TODO add convenience methods which extend the base interface.
143     // TODO return position as SpacePoint
144     // TODO return covariance matrix as Matrix
145 
146     // TrackerHit interface
147     /**
148      * The (x,y,z) hit position in [mm].
149      * 
150      * @return the cartesian position of this point.
151      */
152     public double[] getPosition() {
153         return _pos;
154     }
155 
156     /**
157      * Covariance of the position (x,y,z) as a 6 element array.
158      * 
159      * @return the packed covariance matrix
160      */
161     public double[] getCovMatrix() {
162         return _covMatrix;
163     }
164 
165     /**
166      * The energy deposited by this hit in [GeV].
167      * 
168      * @return the energy deposit associated with this hit.
169      */
170     public double getdEdx() {
171         return _dedx;
172     }
173 
174     /**
175      * The time of the hit in [ns]. By convention, the earliest time of energy deposition is used if this is a composite hit.
176      * 
177      * @return the time of this hit.
178      */
179     public double getTime() {
180         return _time;
181     }
182 
183     public double getEdepError() {
184         return 0.;
185     }
186 
187     public int getQuality() {
188         return 0;
189     }
190 
191     /**
192      * Type of hit. Mapping of integer types to type names through collection parameters "TrackerHitTypeNames" and "TrackerHitTypeValues".
193      * 
194      * @return the integer type of this hit.
195      */
196     // TODO define what this type is.
197     public int getType() {
198         return _type;
199     }
200 
201     // TODO fix the covariant return type.
202     /**
203      * The raw data hits. Check getType() to get actual data type.
204      * 
205      * @return the list of raw hits which contribute to this hit.
206      */
207     public List getRawHits() {
208         return _rawHits;
209     }
210 
211     public long getCellID() {
212         return id;
213     }
214 }