View Javadoc

1   package org.lcsim.recon.tracking.trfbase;
2   
3   import org.lcsim.recon.tracking.trfutil.RandomGenerator;
4   import org.lcsim.recon.tracking.trfutil.Assert;
5   
6   /**Generates VTrack objects with parameters chosen randomly.
7   * The track surface and the ranges for the parameters are
8   * specified in the constructor
9    *
10  * @author Norman A. Graf
11  * @version 1.0
12  */
13  
14  public class VTrackGenerator extends RandomGenerator {
15  
16    // attributes
17  
18    // min and max values for each parameter.
19    private TrackVector _min;
20    private TrackVector _max;
21  
22    // surface.
23    private Surface _srf;
24   
25  //methods
26  
27    // 
28  
29  	/**
30  	 *constructor
31  	 *
32  	 * @param   srf surface at which to generate track 
33  	 * @param   min minimum values for random track parameters 
34  	 * @param   max maximum values for random track parameters 
35  	 */
36    public VTrackGenerator(  Surface srf,   TrackVector min,
37                                          TrackVector max)
38                                          {
39  											_srf = srf.newPureSurface();
40  											 _min = min;
41  											  _max = max;
42    for ( int i=0; i<5; ++i ) Assert.assertTrue( _min.get(i) <= _max.get(i) );
43                                          }
44  
45    // 
46  
47  	/**
48  	 *Copy constructor.
49  	 *
50  	 * @param   vtg  VTrackGenerator to replicate
51  	 */
52    public VTrackGenerator(  VTrackGenerator vtg)
53    {
54    	super(vtg);
55  	_min = vtg._min; 
56  	_max = vtg._max; 
57  	_srf = vtg._srf;
58    }
59  
60   
61    //
62  
63  	/**
64  	 * Return the surface.
65  	 *
66  	 * @return Surface at which tracks are to be generated    
67  	 */
68      public Surface surface()   { return _srf; }
69  
70    //  
71  
72  	/**
73  	 *Generate a new track. 
74  	 *
75  	 * @return new random VTrack with track parameters distributed 
76  	 * evenly between minimum and maximum TrackVector values 
77  	 */
78    public VTrack newTrack()
79    {
80    TrackVector vec = new TrackVector();
81    for ( int i=0; i<5; ++i ) vec.set(i, flat( _min.get(i), _max.get(i) ) );
82    VTrack trv = new VTrack(_srf,vec);
83    // If the direction is not set, make it forward
84  //  if ( trv.is_forward() ) return trv;
85  //  if ( trv.is_backward() ) return trv;
86    trv.setForward();
87    return trv;  
88    }
89    
90  
91  	/**
92  	 * String representation of VTrackGenerator
93  	 *
94  	 * @return  String representation of VTrackGenerator   
95  	 */
96    public String toString()
97    {
98    String className = getClass().getName();
99    int lastDot = className.lastIndexOf('.');
100   if(lastDot!=-1)className = className.substring(lastDot+1);
101   
102 	return className+" Lower limit: " +_min +
103    "\nUpper limit: " + _max +  
104     "\nSurface: " + _srf; 
105   }
106 
107 }