View Javadoc

1   package org.lcsim.recon.tracking.trfcyl;
2   
3   
4   import org.lcsim.recon.tracking.trfutil.TRFMath;
5   import org.lcsim.recon.tracking.trfutil.Assert;
6   
7   import org.lcsim.recon.tracking.trfbase.TrackDerivative;
8   import org.lcsim.recon.tracking.trfbase.TrackVector;
9   import org.lcsim.recon.tracking.trfbase.Propagator;
10  import org.lcsim.recon.tracking.trfbase.PropDirected;
11  import org.lcsim.recon.tracking.trfbase.PropDir;
12  import org.lcsim.recon.tracking.trfbase.PropStat;
13  import org.lcsim.recon.tracking.trfbase.Surface;
14  import org.lcsim.recon.tracking.trfbase.VTrack;
15  import org.lcsim.recon.tracking.trfbase.ETrack;
16  
17  /**
18   * PropJoinCyl propagates tracks from a starting surface to a cylinder and
19   * then to the final surface.  The radius of the intermediate
20   * cylinder is calculated from two parameters rmin and rfac and
21   * the starting radius r0:
22   * if rfac*r0 < rmin, then r = rmin, otherwise r = rfac*r0.
23   *
24   *@author Norman A. Graf
25   *@version 1.0
26   *
27   */
28  
29  public class PropJoinCyl extends PropDirected
30  {
31      
32      // static methods
33      
34      //
35      
36      /**
37       *Return a String representation of the class' type name.
38       *Included for completeness with the C++ version.
39       *
40       * @return   A String representation of the class' type name.
41       */
42      public static String typeName()
43      { return "PropJoinCyl";
44      }
45      
46      //
47      
48      /**
49       *Return a String representation of the class' type name.
50       *Included for completeness with the C++ version.
51       *
52       * @return   A String representation of the class' type name.
53       */
54      public static String staticType()
55      { return typeName();
56      }
57      
58      // attributes
59      
60      // parameters to calculate radius
61      private double _rmin;
62      private double _rfac;
63      
64      // The propagators.
65      private Propagator _prop1;
66      private Propagator _prop2;
67      
68      //methods
69      
70      
71      //
72      
73      /**
74       *Construct an instance from the two constituent propagators.
75       *
76       * @param   rmin The minimum radius.
77       * @param   rfac The maximum radius.
78       * @param   prop1 The first Propagator.
79       * @param   prop2 The second Propagator.
80       */
81      public PropJoinCyl(double rmin, double rfac, Propagator prop1,
82              Propagator prop2)
83      {
84          _rmin = rmin;
85          _rfac = rfac;
86          _prop1 = prop1.newPropagator();
87          _prop2 = prop2.newPropagator();
88      }
89      
90      //
91      
92      /**
93       *Construct a clone of this instance
94       *
95       * @return A Clone of this instance.
96       */
97      public Propagator newPropagator( )
98      {
99          return new PropJoinCyl(_rmin, _rfac, _prop1.newPropagator(), _prop2.newPropagator());
100     }
101     
102     //
103     
104     /**
105      *Return a String representation of the class' type name.
106      *Included for completeness with the C++ version.
107      *
108      * @return   A String representation of the class' type name.
109      */
110     public String type()
111     { return staticType();
112     }
113     
114     //
115     
116     /**
117      *Return the minimum radius.
118      *
119      * @return The minimum radius.
120      */
121     public double minRadius()
122     { return _rmin;
123     }
124     
125     /**
126      *Return the maximum radius.
127      *
128      * @return The maximum radius.
129      */
130     public double maxRadius()
131     { return _rfac;
132     }
133     
134     /**
135      * Return the first Propagator.
136      *
137      * @return The first Propagator.
138      */
139     public  Propagator prop1()
140     { return _prop1.newPropagator();
141     }
142     
143     /**
144      * Return the second Propagator.
145      *
146      * @return The second Propagator.
147      */
148     public  Propagator prop2()
149     { return _prop2.newPropagator();
150     }
151     
152     //
153     
154     /**
155      *Propagate a track without error in the specified direction.
156      *
157      * @param   trv The Vtrack to propagate.
158      * @param   srf The surface to which to propagate.
159      * @param   dir The direction in which to propagate.
160      * @return The propagation status.
161      */
162     public PropStat vecDirProp(VTrack trv,  Surface srf, PropDir dir)
163     {
164         TrackDerivative der = null;
165         return vecDirProp(trv,srf,dir,der);
166     }
167     
168     //
169     
170     /**
171      *Propagate a track without error in the specified direction
172      * and update the track derivatives at the final surface.
173      *
174      * @param   trv The Vtrack to propagate.
175      * @param   srf The surface to which to propagate.
176      * @param   dir The direction in which to propagate.
177      * @param   der the track derivatives to update at the surface srf.
178      * @return The propagation status.
179      */
180     public PropStat vecDirProp(VTrack trv,  Surface srf,
181             PropDir dir, TrackDerivative der )
182     {
183         // Construct intermediate derivatives.
184         TrackDerivative tmpder1 = null;
185         TrackDerivative tmpder2 = null;
186         if (der != null)
187         {
188             tmpder1 = new TrackDerivative();
189             tmpder2 = new TrackDerivative();
190         }
191         
192         //System.out.println("In PropJoinCyl!");
193         // Propagate from starting surface to cylinder.
194         double r = _rfac*trv.spacePoint().rxy();
195         if ( r < _rmin ) r = _rmin;
196         PropStat pstat = _prop1.vecDirProp(trv, new SurfCylinder(r),
197                 PropDir.NEAREST, tmpder1);
198         if ( ! pstat.success() )
199         {
200             return pstat;
201         }
202         
203         // Propagate from cylinder to final surface.
204         pstat = _prop2.vecDirProp(trv, srf, dir, tmpder2);
205         if ( ! pstat.success() )
206         {
207             return pstat;
208         }
209         
210         // Calculate the overall derivative matrix.
211         if ( der != null )
212         {
213             der = new TrackDerivative( tmpder2.times(tmpder1) );
214         }
215         
216         // Return the final status.
217         return pstat;
218         
219     }
220     //
221     
222     /**
223      *Propagate a track with error in the specified direction.
224      *
225      * @param   trv The Etrack to propagate.
226      * @param   srf The surface to which to propagate.
227      * @param   dir The direction in which to propagate.
228      * @return The propagation status.
229      */
230     public PropStat errDirProp(ETrack trv, Surface srf,
231             PropDir dir)
232     {
233         TrackDerivative der = null;
234         return errDirProp(trv,srf,dir,der);
235     }
236     
237     //
238     
239     /**
240      *propagate a track with error in the specified direction
241      *
242      * @param   trv The Etrack to propagate.
243      * @param   srf The surface to which to propagate.
244      * @param   dir The direction in which to propagate.
245      * @param   der the track derivatives to update at the surface srf.
246      * @return The propagation status.
247      */
248     public PropStat errDirProp(ETrack trv, Surface srf,
249             PropDir dir, TrackDerivative der)
250     {
251         TrackDerivative tmpder1 = null;
252         TrackDerivative tmpder2 = null;
253         if (der != null)
254         {
255             // Construct intermediate derivatives.
256             tmpder1 = new TrackDerivative();
257             tmpder2 = new TrackDerivative();
258         }
259         
260         // Propagate from starting surface to cylinder.
261         double r = _rfac*trv.spacePoint().rxy();
262         
263         if ( r < _rmin ) r = _rmin;
264         PropStat pstat = _prop1.errDirProp(trv, new SurfCylinder(r),
265                 PropDir.NEAREST, tmpder1 );
266         if ( ! pstat.success() )
267         {
268             return pstat;
269         }
270         
271         // Propagate from cylinder to final surface.
272         pstat = _prop2.errDirProp(trv, srf, dir, tmpder2);
273         if ( ! pstat.success() )
274         {
275             return pstat;
276         }
277         // Calculate the overall derivative matrix.
278         if ( der != null )
279         {
280             der = new TrackDerivative( tmpder2.times(tmpder1) );
281         }
282         // Return the final status.
283         return pstat;
284         
285     }
286     
287     
288     
289     /**
290      *output stream
291      *
292      * @return A String representation of this instance.
293      */
294     public String toString()
295     {
296         StringBuffer sb = new StringBuffer("Propagator using intermediate cylinder.\n");
297         sb.append("rmin = " + _rmin + "; rfac = " + _rfac + "\n");
298         sb.append("First propagator: " + _prop1 + "\n");
299         sb.append("Second propagator: " + _prop2 + "\n");
300         return sb.toString();
301     }
302 }