View Javadoc

1   /*
2    * ZPlaneEloss.java
3    *
4    * Created on September 10, 2007, 10:40 AM
5    *
6    * $Id: ZPlaneEloss.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trfzp;
10  
11  import org.lcsim.recon.tracking.trfbase.ETrack;
12  import org.lcsim.recon.tracking.trfbase.Interactor;
13  import org.lcsim.recon.tracking.trfbase.PropDir;
14  import org.lcsim.recon.tracking.trfbase.Propagator;
15  import org.lcsim.recon.tracking.trfbase.Surface;
16  import org.lcsim.recon.tracking.trfbase.TrackError;
17  import org.lcsim.recon.tracking.trfbase.TrackVector;
18  import org.lcsim.recon.tracking.trfeloss.DeDx;
19  import org.lcsim.recon.tracking.trfutil.Assert;
20  
21  import static java.lang.Math.abs;
22  import static java.lang.Math.sqrt;
23  
24  import static org.lcsim.recon.tracking.trfzp.SurfZPlane.IX;
25  import static org.lcsim.recon.tracking.trfzp.SurfZPlane.IY;
26  import static org.lcsim.recon.tracking.trfzp.SurfZPlane.IDXDZ;
27  import static org.lcsim.recon.tracking.trfzp.SurfZPlane.IDYDZ;
28  import static org.lcsim.recon.tracking.trfzp.SurfZPlane.IQP;
29  
30  /**
31   * Class for modifying the covariance matrix of a track which
32   * has been propagated to an InteractingLayer containing
33   * a LayerZPlane.
34   * @author Norman Graf
35   */
36  public class ZPlaneEloss extends Interactor
37  {
38      
39      //attributes
40      
41      private double _thickness;
42      private DeDx _dedx;
43      
44      /** Creates a new instance of ZPlaneEloss */
45      // constructor.  The Interactor is constructed with the
46      // appropriate thickness and De/dx class.
47      public ZPlaneEloss(double thickness,   DeDx dedx)
48      {
49          _thickness = thickness;
50          _dedx = dedx;
51      }
52      
53      public void interact(ETrack tre)
54      {
55      }
56      
57      public void interact_dir( ETrack theTrack, PropDir direction )
58      {
59          
60          // This can only be used with z-planes... check that we have one..
61          Surface srf = theTrack.surface();
62          Assert.assertTrue( srf instanceof SurfZPlane);
63          
64          
65          // Reduced direction must be forward or backward.
66          Propagator.reduceDirection(direction);
67          Assert.assertTrue(direction == PropDir.FORWARD || direction == PropDir.BACKWARD);
68          
69          
70          TrackError cleanError = theTrack.error();
71          
72          
73          TrackError newError = new TrackError(cleanError);
74          
75          TrackVector theVec = theTrack.vector();
76          TrackVector newVector = new TrackVector(theVec);
77          
78          double pionMass = 0.13957; // GeV
79          double ptmax = 10000.; // GeV
80          
81          double pinv = abs(theVec.get(IQP));
82          double dxdz = theVec.get(IDXDZ);
83          double dydz = theVec.get(IDYDZ);
84          double lfac = sqrt(1. + dxdz*dxdz + dydz*dydz);
85          
86          // make sure pinv is greater than a threshold (1/ptmax)
87          // in this case assume q = 1, otherwise q = q/p/abs(q/p)
88          
89          double sign = 1.;
90          if ( pinv < 1./ptmax )
91              pinv = 1./ptmax;
92          else
93              sign = theVec.get(IQP) > 0. ? 1. : -1.;
94          
95          // Evaluate the initial energy assuming the particle is a pion.
96          
97          double trackEnergy = sqrt(1./(pinv*pinv) + pionMass*pionMass);
98          
99          double trueLength = lfac * _thickness;
100         
101         // assume the energy loss distribution to be Gaussian
102         double stdEnergy = _dedx.sigmaEnergy(trackEnergy, trueLength);
103         
104         if(direction == PropDir.BACKWARD) trueLength = -trueLength;
105         _dedx.loseEnergy(trackEnergy, trueLength);
106         
107         double newMomentum = trackEnergy>pionMass ?
108             sqrt(trackEnergy*trackEnergy - pionMass*pionMass) :
109             1./pinv;
110         
111         // Only vec(IQP) changes due to E loss.
112         newVector.set(IQP, sign/newMomentum);
113         
114         // Also only error(IQP,IQP) changes.
115         double stdVec = theVec.get(IQP)*theVec.get(IQP)*stdEnergy;
116         stdVec *= stdVec;
117         newError.set(IQP, IQP, newError.get(IQP, IQP)+stdVec);
118         
119         // Store modified track parameters.
120         theTrack.setVectorAndKeepDirection(newVector);
121         theTrack.setError( newError );
122         
123     }
124     
125     
126     /**
127      * Return the thickness of material in the z plane.
128      *
129      * @return The thickness of the energy loss material.
130      */
131     public double thickness()
132     {
133         return _thickness;
134     }
135     
136     /**
137      *Return the energy loss model used in this Interactor.
138      *
139      * @return The DeDx class representing energy loss.
140      */
141     public DeDx dEdX()
142     {
143         return _dedx; //cng shallow copy!
144     }
145     
146     /**
147      *Make a clone of this object.
148      *
149      * @return A Clone of this instance.
150      */
151     public Interactor newCopy()
152     {
153         return new ZPlaneEloss(_thickness, _dedx);
154     }
155     
156     /**
157      *output stream
158      *
159      * @return A String representation of this instance.
160      */
161     public String toString()
162     {
163         return "ZPlaneEloss with thickness "+_thickness+" and energy loss "+_dedx;
164     }
165     
166     
167 }