View Javadoc

1   /*
2    * HelicalTrackStrip.java
3    *
4    * Created on May 1, 2008, 10:06 AM
5    *
6    */
7   
8   package org.lcsim.fit.helicaltrack;
9   
10  import java.util.ArrayList;
11  import java.util.List;
12  
13  import hep.physics.vec.Hep3Vector;
14  import hep.physics.vec.VecOp;
15  
16  import org.lcsim.event.MCParticle;
17  import org.lcsim.event.TrackerHit;
18  import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
19  
20  /**
21   * Encapsulate strip information used to construct HelicalTrack2DHit and
22   * HelicalTrackCross hits.  The hit position is given by:
23   *
24   * pos = origin + umeas * uhat + v * vhat
25   *
26   * where v is the unmeasured coordinate along the strip direction.
27   * @author Richard Partridge
28   * @version 1.0
29   */
30  public class HelicalTrackStrip {
31      private Hep3Vector _origin;
32      protected Hep3Vector _u;
33      protected Hep3Vector _v;
34      protected Hep3Vector _w;
35      private double _umeas;
36      private double _du;
37      private double _vmin;
38      private double _vmax;
39      private double _dEdx;
40      private double _time;
41      private List _rawhits;
42      private String _detector;
43      private int _layer;
44      private BarrelEndcapFlag _beflag;
45      private List<MCParticle> _mcplist;
46      private double _eps = 1.0e-6;
47      
48      /**
49       * Creates a new instance of HelicalTrackStripHit.
50       * @param origin global position of local coordinate origin
51       * @param u vector parallel to the measurement direction
52       * @param v vector parallel to the strip direction
53       * @param umeas measured coordinate
54       * @param du uncertainty in the measured coordinate
55       * @param vmin minimum value of the unmeasured coordinate
56       * @param vmax maximum value of the unmeasured coordinate
57       */
58      public HelicalTrackStrip(Hep3Vector origin, Hep3Vector u, Hep3Vector v, double umeas, double du,
59              double vmin, double vmax, double dEdx, double time, List rawhits, String detector,
60              int layer, BarrelEndcapFlag beflag) {
61          _origin = origin;
62          _u = VecOp.unit(u);
63          _v = VecOp.unit(v);
64          _umeas = umeas;
65          _du = du;
66          _vmin = vmin;
67          _vmax = vmax;
68          _dEdx = dEdx;
69          _time = time;
70          _rawhits = rawhits;
71          _detector = detector;
72          _layer = layer;
73          _beflag = beflag;
74          _mcplist = new ArrayList<MCParticle>();
75          
76          //  Check if the origin is located at the center of the strip
77          double vmiddle = 0.5 * (_vmin + _vmax);
78          if (Math.abs(vmiddle) > _eps) {
79              //  Relocate the origin to be at the center of the strip
80              _origin = VecOp.add(origin, VecOp.mult(vmiddle, _v));
81              _vmin -= vmiddle;
82              _vmax -= vmiddle;
83          }
84          
85          if(Math.abs(_vmin+_vmax) > 2*_eps)
86              throw new RuntimeException("_vmin != -_vmax - vmin: "+vmin+" vmax: "+vmax);
87                  
88          //  Make sure that vmin < vmax
89          if (_vmin > _vmax) {
90              double vtemp = _vmin;
91              _vmin = _vmax;
92              _vmax = vtemp;
93          }
94  
95  	//Find the sensor normal        
96          initW();
97  
98      }
99      
100     protected void initW() {
101         //  Find the sensor normal and make sure it is pointing in the "outgoing" direction
102         _w = VecOp.cross(_u, _v);
103         if (VecOp.dot(_w, _origin) < 0) {
104             _v = VecOp.mult(-1., _v);
105             _w = VecOp.cross(_u, _v);
106         }
107     }
108     
109     /**
110      * Return the global position of the origin for the local strip coordinates.
111      * @return origin of the local coordinates
112      */
113     public Hep3Vector origin() {
114         return _origin;
115     }
116     
117     /**
118      * Return a unit vector parallel to the measurement direction for the strip.
119      * @return measured direction unit vector
120      */
121     public Hep3Vector u() {
122         return _u;
123     }
124     
125     /**
126      * Return a unit vector that is parallel to the strip.
127      * @return unmeasured direction unit vector
128      */
129     public Hep3Vector v() {
130         return _v;
131     }
132     
133     /**
134      * Return a unit vector that is normal to the sensor plane (u x v = w).
135      * @return sensor normal unit vector
136      */
137     public Hep3Vector w() {
138         return _w;
139     }
140     
141     /**
142      * Return the measured coordinate.
143      * @return measured coordinate
144      */
145     public double umeas() {
146         return _umeas;
147     }
148     
149     /**
150      * Return the uncertainty in the measured coordinate.
151      * @return uncertainty in the measured coordinate
152      */
153     public double du() {
154         return _du;
155     }
156     
157     /**
158      * Return the minimum value for the unmeasured coordinate.
159      * @return minimum of the unmeasured coordinate
160      */
161     public double vmin() {
162         return _vmin;
163     }
164     
165     /**
166      * Return the maximum value for the unmeasured coordinate.
167      * @return maximum of the measured coordinate
168      */
169     public double vmax() {
170         return _vmax;
171     }
172     
173     public double dEdx() {
174         return _dEdx;
175     }
176     
177     public double time() {
178         return _time;
179     }
180     
181     public List rawhits() {
182         return _rawhits;
183     }
184     
185     public String detector() {
186         return _detector;
187     }
188     
189     public int layer() {
190         return _layer;
191     }
192     
193     public BarrelEndcapFlag BarrelEndcapFlag() {
194         return _beflag;
195     }
196     public void addMCParticle(MCParticle mcp) {
197         if (!_mcplist.contains(mcp)) _mcplist.add(mcp);
198         return;
199     }
200     
201     public List<MCParticle> MCParticles() {
202         return _mcplist;
203     }
204     
205     public String toString(){
206         return ("Strip with u="+this.u().toString()+"\n v="+this.v().toString() + "\n vmin="+this.vmin() + "\n vmax="+this.vmax() + "\n umeas="+this.umeas()+"\n origin="+this.origin().toString()); 
207     }
208 }