View Javadoc

1   package org.lcsim.recon.tracking.trfxyp;
2   // Generator for ClusXYPlane1 objects.
3   
4   import org.lcsim.recon.tracking.trfutil.Assert;
5   
6   import org.lcsim.recon.tracking.trfbase.HitGenerator;
7   import org.lcsim.recon.tracking.trfbase.VTrack;
8   import org.lcsim.recon.tracking.trfbase.Surface;
9   import org.lcsim.recon.tracking.trfbase.Cluster;
10  
11  /**
12   * Generates one dimensional xy hits on an xy plane with a gaussian spread in the measurement.
13   *
14   *@author Norman A. Graf
15   *@version 1.0
16   *
17   */
18  public class HitXYPlane1Generator extends HitGenerator
19  {
20      
21      // attributes
22      
23      // the surface
24      private SurfXYPlane _sxyp;
25      
26      // the v axis weight
27      private double _wv;
28      
29      // the z axis weight
30      private double _wz;
31      
32      // the error (standard deviation) for the measurement avz = wv*v + wz*z
33      private double _davz;
34      
35      
36      /**
37       *Construct an instance from the xy plane disance and angle, mixing and measurement uncertainty as a gaussian sigma.
38       *
39       * @param dist The shortest distance to the plane from the z axis.
40       * @param phi The angle of the normal to the plane with respect to the x axis.
41       * @param wv The stereo angle in the v direction.
42       * @param wz The stereo angle in the z direction.
43       * @param davz The gaussian sigma for the vz measurement uncertainty.
44       */
45      public HitXYPlane1Generator(double dist, double phi,
46              double wv,   double wz,
47              double davz)
48      {
49          super();
50          _sxyp = new SurfXYPlane(dist,phi);
51          _wv = wv;
52          _wz = wz;
53          _davz = davz;
54          Assert.assertTrue( _davz >= 0.0 );
55      }
56      
57      /**
58       *Construct an instance from the xy plane disance and angle, mixing, measurement
59       * uncertainty as a gaussian sigma and random number seed.
60       *
61       * @param dist The shortest distance to the plane from the z axis.
62       * @param phi The angle of the normal to the plane with respect to the x axis.
63       * @param wv The stereo angle in the v direction.
64       * @param wz The stereo angle in the z direction.
65       * @param davz The gaussian sigma for the vz measurement uncertainty.
66       * @param iseed  The seed for the random number used by the HitGenerator.
67       */
68      public HitXYPlane1Generator(double dist, double phi,
69              double wv,   double wz,
70              double davz, long iseed)
71      {
72          super(iseed);
73          _sxyp = new SurfXYPlane(dist,phi);
74          _wv = wv;
75          _wz = wz;
76          _davz = davz;
77          Assert.assertTrue( _davz >= 0.0 );
78      }
79      
80      /**
81       *Construct an instance replicating the HitZPlane1Generator ( copy constructor ).
82       *
83       * @param  gen The HitZPlane1Generator to replicate.
84       */
85      public HitXYPlane1Generator( HitXYPlane1Generator gen)
86      {
87          super(gen);
88          _sxyp =  new SurfXYPlane(gen._sxyp);
89          _wv = gen._wv;
90          _wz = gen._wz;
91          _davz =  gen._davz;
92          Assert.assertTrue( _davz >= 0.0 );
93      }
94      
95      /**
96       *Return the surface associated with this HitXYPlane1Generator.
97       *
98       * @return The surface associated with this HitXYPlane1Generator.
99       */
100     public  Surface surface()
101     { return _sxyp; }
102     
103     /**
104      *Generate a new cluster.
105      * Return null for failure.
106      *
107      * @param   trv The VTrack for which to generate a cluster at this surface.
108      * @return   The cluster for this track at this surface, null for failure.
109      */
110     public Cluster newCluster( VTrack trv)
111     {
112         return newCluster(trv, 0);
113     }
114     
115     /**
116      *Generate a new cluster with the specified Monte Carlo track ID.
117      * Return null for failure.
118      *
119      * @param   trv The VTrack for which to generate a cluster at this surface.
120      * @param   mcid The MC ID to associate with this cluster.
121      * @return   The cluster for this track at this surface, null for failure.
122      */
123     public Cluster newCluster( VTrack trv, int mcid)
124     {
125         // Check track has been propagated to the surface.
126         Assert.assertTrue( _sxyp.pureEqual( trv.surface() ) );
127         if ( ! _sxyp.pureEqual( trv.surface() ) ) return null;
128         
129         // calculate avz.
130         double v_track = trv.vector().get(SurfXYPlane.IV);
131         double z_track = trv.vector().get(SurfXYPlane.IZ);
132         double avz = _wv*v_track + _wz*z_track
133                 + _davz*gauss();
134         
135         // construct cluster
136         double dist = _sxyp.parameter(SurfXYPlane.DISTNORM);
137         double  phi = _sxyp.parameter(SurfXYPlane.NORMPHI);
138         return new ClusXYPlane1(dist, phi, _wv, _wz, avz, _davz, mcid );
139         
140     }
141     
142     /**
143      *output stream
144      *
145      * @return A String representation of this instance.
146      */
147     public String toString()
148     {
149         return "Surface: " + _sxyp +
150                 "\n V slope: " + _wv +
151                 "\n Z slope: " + _wz+
152                 "\n Measurement error (davz): " + _davz;
153     }
154     
155 }
156