View Javadoc

1   package org.lcsim.recon.tracking.vsegment.hit.base;
2   
3   import hep.physics.matrix.SymmetricMatrix;
4   import hep.physics.vec.BasicHep3Vector;
5   import hep.physics.vec.Hep3Matrix;
6   import hep.physics.vec.Hep3Vector;
7   import hep.physics.vec.VecOp;
8   import org.lcsim.spacegeom.SpacePoint;
9   import org.lcsim.spacegeom.SpacePointVector;
10  import org.lcsim.recon.tracking.vsegment.transform.Transformation3D;
11  
12  import org.lcsim.recon.tracking.vsegment.hit.TrackerCluster;
13  import org.lcsim.recon.tracking.vsegment.hit.TrackerHit;
14  import org.lcsim.recon.tracking.vsegment.geom.Sensor;
15  
16  /**
17   * An adapter to be extended by classes implementing {@link TrackerHit} interface.
18   * Methods returning position and covariance matrix in global frame are defined using
19   * methods returning position and covariance matrix in local frame, and vice versa.
20   *
21   * @author D.Onoprienko
22   * @version $Id: TrackerHitAdapter.java,v 1.1 2008/12/06 21:53:44 onoprien Exp $
23   */
24  abstract public class TrackerHitAdapter implements TrackerHit {
25    
26  // -- Constructors :  ----------------------------------------------------------
27    
28    protected TrackerHitAdapter(TrackerCluster cluster) {
29      _cluster = cluster;
30      _signal = cluster.getSignal();
31      _time = cluster.getTime();
32    }
33    
34    protected TrackerHitAdapter(TrackerCluster cluster, double signal, double time) {
35      _cluster = cluster;
36      _signal = signal;
37      _time = time;
38    }
39    
40  // -- Position and covariance matrix in local coordinates :  -------------------
41    
42    /** 
43     * Returns position of the hit in local reference frame of the {@link Sensor}.
44     * For a segment-like hit, this is the center of the segment.
45     * Default implementation relies on {@link #getPosition()} method.
46     */
47    public Hep3Vector getLocalPosition() {
48      return getSensor().globalToLocal(getPosition());
49    }
50    
51    /** 
52     * Returns covariance matrix in local frame. 
53     * Default implementation relies on {@link #getCovMatrix()} method.
54     */
55    public SymmetricMatrix getLocalCovMatrix() {
56      return getSensor().globalToLocal(getCovMatrix(), getPosition());
57    }
58    
59    /** 
60     * Returns <tt>SpacePointVector</tt> pointing from start to end of the segment 
61     * defining the hit in the local reference frame.
62     * Default implementation relies on {@link #getSegment()} method.
63     */
64    public SpacePointVector getLocalSegment() {
65      SpacePointVector glob = getSegment();
66      Sensor sensor = getSensor();
67      return new SpacePointVector(new SpacePoint(sensor.globalToLocal(glob.getStartPoint())), 
68                                  new SpacePoint(sensor.globalToLocal(glob.getEndPoint())));
69    }
70    
71  // -- Position and covariance matrix in global coordinates :  ------------------
72    
73    /**
74     * 
75     * Returns position of the hit in global reference frame.
76     * For a segment-like hit, this is the center of the segment.
77     * Default implementation relies on {@link #getLocalPosition()} method.
78     */
79    public Hep3Vector getPosition() {
80      return getSensor().localToGlobal(getLocalPosition());
81    }
82    
83    /** 
84     * Returns covariance matrix of the hit in global reference frame. 
85     * Default implementation relies on {@link #getLocalCovMatrix()} method.
86     */
87    public SymmetricMatrix getCovMatrix() {
88      return getSensor().localToGlobal(getLocalCovMatrix(), getLocalPosition());
89    }
90  
91    /** 
92     * Returns <tt>SpacePointVector</tt> pointing from start to end of the segment 
93     * defining the hit in the global reference frame.
94     * Default implementation relies on {@link #getLocalSegment()} method.
95     */
96    public SpacePointVector getSegment() {
97      SpacePointVector local = getLocalSegment();
98      Sensor sensor = getSensor();
99      return new SpacePointVector(new SpacePoint(sensor.localToGlobal(local.getStartPoint())), 
100                                 new SpacePoint(sensor.localToGlobal(local.getEndPoint())));
101   }
102   
103 // -- Length of segment-like hit :  --------------------------------------------
104   
105   /**
106    * 
107    * Returns length of the segment defining the hit. 
108    * Default implementation relies on {@link #getSegment()} method.
109    */
110   public double getLength() {
111     return getSegment().magnitude();
112   }
113 
114 // -- Signal and time :  -------------------------------------------------------
115   
116   /** Returns signal amplitude associated with this hit. */
117   public double getSignal() {return _signal;}
118   
119   /** Set signal value associated with this hit. */
120   public void setSignal(double signal) {_signal = signal;}
121   
122   /** Returns time associated with this hit. */
123   public double getTime() {return _time;}
124   
125   /** Set time associated with this hit. */
126   public void setTime(double time) {_time = time;}
127 
128 // -- Access to underlying Sensor and TrackerCluster objects :  ----------------
129   
130   /** Returns {@link Sensor} object for this hit. */
131   public Sensor getSensor() {
132     return _cluster.getSensor();
133   }
134   
135   /** Points back to <tt>TrackerCluster</tt> that produced this hit. */
136   public TrackerCluster getCluster() {return _cluster;}
137   
138 // -- Private parts :  ---------------------------------------------------------
139 
140   protected TrackerCluster _cluster;
141   protected double _signal;
142   protected double _time;
143   
144 }