View Javadoc

1   package org.lcsim.recon.tracking.trfcyl;
2   
3   import org.lcsim.recon.tracking.trfutil.Assert;
4   import org.lcsim.recon.tracking.trfbase.SimInteractor;
5   import org.lcsim.recon.tracking.trfbase.VTrack;
6   import org.lcsim.recon.tracking.trfbase.TrackVector;
7   import org.lcsim.recon.tracking.trfeloss.DeDx;
8   
9   
10  /**
11  * Class for simulating Energy Loss in SurfCylinders.
12   *
13   *@author Norman A. Graf
14   *@version 1.0
15   *
16  */
17  public class CylElossSim extends SimInteractor
18  {
19      
20      //attributes
21      //thickness of the material in the cylinder
22      private double _thickness;
23      // type of energy loss being simulated
24      private DeDx _dedx;
25      
26      //
27      
28      /**
29       *Construct in instance with the
30       *appropriate thickness and DeDx class to model
31       * 
32       *
33       * @param   thickness Thickness of the cylindrical shell.
34       * @param   dedx The DeDx class representing energy loss.
35       */
36      public CylElossSim(double thickness, DeDx dedx)
37      {
38          _thickness = thickness;
39          _dedx = dedx;
40      }
41      
42      //
43      
44      /**
45       *Construct an instance from a CylEloss Interactor.
46       *
47       * @param   inter The CylEloss Interactor to use for simulation.
48       */
49      public CylElossSim(CylEloss inter)
50      {
51          _thickness = inter.thickness();
52          _dedx = inter.dEdX();
53      }
54      
55      //
56      
57      /**
58       *Interact the given track in this cylindrical shell,
59       *using the DeDx model for energy loss.
60       *Note that the track parameters are updated to reflect the
61       *energy lost by traversing the cylindrical shell of material.
62       *
63       * @param   vtrk The VTrack to scatter.
64       */
65      public void interact( VTrack vtrk )
66      {
67          // This can only be used with cylinders... check that we have one..
68          
69          Assert.assertTrue( vtrk.surface() instanceof SurfCylinder );
70          
71          
72          TrackVector theVec = vtrk.vector();
73          TrackVector newVector = new TrackVector(theVec);
74          
75          double pionMass = 0.13957; // GeV
76          double ptmax = 10000.; // GeV
77          
78          double pinv = Math.abs(theVec.get(SurfCylinder.IQPT)*Math.cos(Math.atan(theVec.get(SurfCylinder.ITLM))));
79          
80          // make sure pinv is greater than a threshold (1/ptmax)
81          // in this case assume q = 1, otherwise q = q/pt/abs(q/pt)
82          
83          double sign = 1;
84          if(pinv < 1./ptmax)
85              pinv = 1./ptmax;
86          else
87              sign = theVec.get(SurfCylinder.IQPT)/Math.abs(theVec.get(SurfCylinder.IQPT));
88          
89          // Evaluate the initial energy assuming the particle is a pion.
90          
91          double trackEnergy = Math.sqrt(1./pinv/pinv+pionMass*pionMass);
92          
93          double trueLength = _thickness/Math.abs(Math.cos(theVec.get(SurfCylinder.IALF)))/
94          Math.cos(Math.atan(theVec.get(SurfCylinder.ITLM)));
95          // assume the energy loss distribution to be Gaussian
96          double stdEnergy = _dedx.sigmaEnergy(trackEnergy, trueLength);
97          double stdMomentum = stdEnergy;
98          // What direction are we going?
99          // If forward, that means we lose energy
100         // backwards means gain energy
101         
102         if(vtrk.isTrackForward()) trueLength = -trueLength;
103         trackEnergy=_dedx.loseEnergy(trackEnergy, trueLength);
104         double newMomentum = trackEnergy>pionMass ?
105         Math.sqrt(trackEnergy*trackEnergy-
106         pionMass*pionMass): 1./pinv;
107         // Only vec(SurfCylinder.IQPT) changes due to E loss.
108         newVector.set(SurfCylinder.IQPT, 1./newMomentum/Math.cos(Math.atan(theVec.get(SurfCylinder.ITLM)))*sign);
109         vtrk.setVectorAndKeepDirection(newVector);
110         
111     }
112     //
113     
114     /**
115      *Return the thickness of material in the cylindrical shell.
116      *
117      * @return The thickness of the  energy loss material.
118      */
119     public double thickness()
120     { return _thickness;
121     }
122     //
123     
124      /**
125      *Return the energy loss model used in this Interactor.
126      *
127      * @return The DeDx class representing energy loss.
128      */
129     public DeDx dEdX()
130     {
131         return _dedx; //cng shallow copy!
132     }
133     
134     //
135     
136     /**
137      *Make a clone of this object.
138      * Note that new copy will have different random number generator.
139      *
140      * @return A Clone of this instance.
141      */
142     public SimInteractor newCopy()
143     {
144         return new CylElossSim(_thickness,_dedx);
145     }
146     
147     
148     /**
149      *output stream
150      *
151      * @return A String representation of this instance.
152      */
153     public String toString()
154     {
155         return "CylElossSim with thickness "+_thickness+" and energy loss "+_dedx;
156     }
157 }