View Javadoc

1   package org.lcsim.recon.tracking.digitization.sisim;
2   /*
3    * TrackSegment.java
4    *
5    * Created on July 27, 2005, 3:34 PM
6    *
7    * To change this template, choose Tools | Options and locate the template under
8    * the Source Creation and Management node. Right-click the template and choose
9    * Open. You can then make changes to the template in the Source Editor.
10   */
11  
12  import hep.physics.vec.Hep3Vector;
13  import hep.physics.vec.BasicHep3Vector;
14  import hep.physics.vec.VecOp;
15  
16  import org.lcsim.event.SimTrackerHit;
17  import org.lcsim.detector.ITransform3D;
18  
19  import java.util.*;
20  
21  /**
22   *
23   * @author tknelson
24   */
25  public class TrackSegment
26  {
27      
28      // Fields
29      private Hep3Vector _p1;
30      private Hep3Vector _p2;
31      private double _energy_loss;
32      
33      /**
34       * Creates a new instance of TrackSegment
35       */
36      
37      public TrackSegment(Hep3Vector p1, Hep3Vector p2, double energy_loss)
38      {
39          _p1 = p1;
40          _p2 = p2;
41          _energy_loss = energy_loss;
42      }
43      
44      public TrackSegment(SimTrackerHit hit)
45      {
46          _p1 = new BasicHep3Vector(hit.getStartPoint());
47          _p2 = new BasicHep3Vector(hit.getEndPoint());
48          _energy_loss = hit.getdEdx();
49      }
50      
51      // Accessors
52      public Hep3Vector getP1()
53      {
54          return _p1;
55      }
56      
57      public Hep3Vector getP2()
58      {
59          return _p2;
60      }
61      
62      public double getEloss()
63      {
64          return _energy_loss;
65      }
66      
67      public Hep3Vector getVector()
68      {
69          return VecOp.sub(_p2,_p1);
70      }
71      
72      public Hep3Vector getDirection()
73      {
74          return VecOp.unit(getVector());
75      }
76      
77      public double getLength()
78      {
79          return getVector().magnitude();
80      }
81      
82      public double getDedx()
83      {
84          return _energy_loss/getLength();
85      }
86      
87      public void transform(ITransform3D transformation)
88      {
89          transformation.transform(_p1);
90          transformation.transform(_p2);
91      }
92      
93  }