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