View Javadoc

1   package org.lcsim.recon.tracking.vsegment.hit.base;
2   
3   import hep.physics.matrix.SymmetricMatrix;
4   import hep.physics.vec.Hep3Vector;
5   
6   import org.lcsim.spacegeom.SpacePoint;
7   import org.lcsim.spacegeom.SpacePointVector;
8   
9   import org.lcsim.recon.tracking.vsegment.geom.Sensor;
10  import org.lcsim.recon.tracking.vsegment.hit.TrackerCluster;
11  import org.lcsim.recon.tracking.vsegment.hit.TrackerHit;
12  
13  /**
14   * Implementation of {@link TrackerHit} suitable for representing point-like hits.
15   * Position and covariance matrix can be supplied to the constructor in either
16   * global reference frame or <tt>Sensor</tt> local frame. Conversion will only be
17   * done if needed, and the results will be cached.
18   *
19   * @author D.Onoprienko
20   * @version $Id: TrackerHitPoint.java,v 1.1 2008/12/06 21:53:44 onoprien Exp $
21   */
22  public class TrackerHitPoint extends TrackerHitAdapter {
23    
24  // -- Constructors :  ----------------------------------------------------------
25    
26    /**
27     * Construct a new TrackerHit.
28     * Vector and matrix supplied to the constructor will be owned by the created hit.
29     * Signal and time associated with this hit will be set to those of the <tt>TrackerCluster</tt>.
30     *
31     * @param cluster    {@link TrackerCluster} from which this hit was created.
32     * @param position   Position of the hit.
33     * @param covMatrix  Covariance matrix
34     * @param isLocal    <tt>true</tt> if position and covariance matrix are given
35     *                   in the <tt>Sensor</tt> local reference frame, <tt>false</tt>
36     *                   if they are given in the global frame.
37     */
38    public TrackerHitPoint(TrackerCluster cluster, Hep3Vector position, SymmetricMatrix covMatrix, boolean isLocal) {
39      super(cluster);
40      if (isLocal) {
41        _posLocal = position;
42        _covLocal = covMatrix;
43      } else {
44        _posGlobal = position;
45        _covGlobal = covMatrix;      
46      }
47    }
48    
49    /**
50     * Construct a new TrackerHit.
51     * Vector and matrix supplied to the constructor will be owned by the created hit.
52     *
53     * @param cluster    {@link TrackerCluster} from which this hit was created.
54     * @param position   Position of the hit.
55     * @param covMatrix  Covariance matrix
56     * @param isLocal    <tt>true</tt> if position and covariance matrix are given
57     *                   in the <tt>Sensor</tt> local reference frame, <tt>false</tt>
58     *                   if they are given in the global frame.
59     * @param signal     Signal amplitude to be associated with this hit.
60     * @param time       Time to be associated with this hit.
61     */
62    public TrackerHitPoint(TrackerCluster cluster, Hep3Vector position, SymmetricMatrix covMatrix, boolean isLocal,
63                           double signal, double time) {
64      super(cluster, signal, time);
65      if (isLocal) {
66        _posLocal = position;
67        _covLocal = covMatrix;
68      } else {
69        _posGlobal = position;
70        _covGlobal = covMatrix;      
71      }
72    }
73    
74  // -- Position and covariance matrix in local coordinates :  -------------------
75    
76    /** 
77     * Returns position of the hit in local reference frame of the {@link Sensor}.
78     */
79    public Hep3Vector getLocalPosition() {
80      if (_posLocal == null) _posLocal = super.getLocalPosition();
81      return _posLocal;
82    }
83    
84    /** 
85     * Returns covariance matrix in local frame. 
86     */
87    public SymmetricMatrix getLocalCovMatrix() {
88      if (_covLocal == null) _covLocal = super.getLocalCovMatrix();
89      return _covLocal;
90    }
91    
92    /** 
93     * Returns <tt>SpacePointVector</tt> pointing from start to end of the segment 
94     * defining the hit in the local reference frame.
95     */
96    public SpacePointVector getLocalSegment() {
97      if (_posLocal == null) _posLocal = super.getLocalPosition();
98      SpacePoint loc = new SpacePoint(_posLocal);
99      return new SpacePointVector(loc, loc);
100   }
101   
102 // -- Position and covariance matrix in global coordinates :  ------------------
103   
104   /**
105    * 
106    * Returns position of the hit in global reference frame.
107    */
108   public Hep3Vector getPosition() {
109     if (_posGlobal == null) _posGlobal = super.getPosition();
110     return _posGlobal;
111   }
112   
113   /** 
114    * Returns covariance matrix of the hit in global reference frame. 
115    */
116   public SymmetricMatrix getCovMatrix() {
117     if (_covGlobal == null) _covGlobal = super.getCovMatrix();
118     return _covGlobal;
119   }
120 
121   /** 
122    * Returns <tt>SpacePointVector</tt> pointing from start to end of the segment 
123    * defining the hit in the global reference frame.
124    */
125   public SpacePointVector getSegment() {
126     if (_posGlobal == null) _posGlobal = super.getPosition();
127     SpacePoint glob = new SpacePoint(_posGlobal);
128     return new SpacePointVector(glob, glob);
129   }
130   
131 // -- Length of segment-like hit :  --------------------------------------------
132   
133   /**
134    * 
135    * Returns zero (length of the segment defining the hit). 
136    */
137   public double getLength() {
138     return 0.;
139   }
140   
141 // -- Private parts :  ---------------------------------------------------------
142 
143   Hep3Vector _posLocal;
144   Hep3Vector _posGlobal;
145   SymmetricMatrix _covLocal;
146   SymmetricMatrix _covGlobal;
147 }