View Javadoc

1   package org.lcsim.recon.tracking.trfcyl;
2   // Generator for ClusCylPhiZ objects.
3   import org.lcsim.recon.tracking.trfutil.Assert;
4   
5   import org.lcsim.recon.tracking.trfbase.HitGenerator;
6   import org.lcsim.recon.tracking.trfbase.Surface;
7   import org.lcsim.recon.tracking.trfbase.Cluster;
8   import org.lcsim.recon.tracking.trfbase.VTrack;
9   import org.lcsim.recon.tracking.trfbase.CrossStat;
10  /**
11   * Generates HitCylPhiZ hits on a cylindrical surface with a gaussian spread in the measurement.
12   *
13   *@author Norman A. Graf
14   *@version 1.0
15   *
16   */
17  public class HitCylPhiZGenerator extends HitGenerator
18  {
19      
20      // attributes
21      
22      // the surface
23      private Surface _srf;
24      
25      // the mixing parameter stereo: phiz = phi + stereo*z;
26      private double _stereo;
27      
28      // Error (standard deviation) for the measurement.
29      private double _dphiz;
30      
31      //
32      
33      /**
34       *Construct an instance from a cylinder surface, the stereo angle and the measurement uncertainty.
35       * The cylinder is cloned so user can pass subclass.
36       *
37       * @param   srf The cylindrical surface.
38       * @param   stereo The stereo angle.
39       * @param   dphiz The gaussian sigma for the phi-z stereo measurement  uncertainty.
40       */
41      public HitCylPhiZGenerator(  SurfCylinder srf, double stereo,
42      double dphiz)
43      {
44          super();
45          //   _srf = srf.new_surface();
46          _srf = new SurfCylinder(srf);
47          _stereo = stereo;
48          _dphiz =dphiz;
49          Assert.assertTrue( _dphiz >= 0.0 );
50      }
51      
52      //
53      /**
54       *Construct an instance from a cylinder surface, the stereo angle, the measurement uncertainty
55       and a random number seed.
56       * The cylinder is cloned so user can pass subclass.
57       *
58       * @param   srf The cylindrical surface.
59       * @param   stereo The stereo angle.
60       * @param   dphiz The gaussian sigma for the phi-z stereo measurement uncertainty.
61       * @param   iseed The seed for the random number used by the HitGenerator.
62       */
63      public HitCylPhiZGenerator(  SurfCylinder srf, double stereo,
64      double dphiz, long iseed)
65      {
66          super(iseed);
67          _srf = new SurfCylinder(srf);
68          _stereo = stereo;
69          _dphiz =dphiz;
70          Assert.assertTrue( _dphiz >= 0.0 );
71      }
72      
73      //
74      
75       /**
76        *Construct an instance replicating the HitCylPhiZGenerator ( copy constructor ).
77       *
78       * @param   hgen The HitCylPhiZGenerator to replicate.
79       */
80      public HitCylPhiZGenerator(  HitCylPhiZGenerator hgen)
81      {
82          super(hgen);
83          _srf = hgen._srf;
84          _stereo = hgen._stereo;
85          _dphiz = hgen._dphiz;
86          Assert.assertTrue( _dphiz >= 0.0 );
87          
88          
89      }
90      
91      //
92      
93      /**
94       *Return the surface associated with this HitCylPhiZGenerator.
95       *
96       * @return The surface associated with this HitCylPhiZGenerator.
97       */
98      public  Surface surface()
99      { return _srf;
100     }
101     
102     //
103     
104    /**
105      *Generate a new cluster.
106      * Return null for failure.
107      *
108      * @param   trv The VTrack for which to generate a cluster at this surface.
109      * @return   The cluster for this track at this surface, null for failure.
110      */
111     public Cluster newCluster(  VTrack trv )
112     {
113         return newCluster(trv, 0);
114     }
115     
116      /**
117      *Generate a new cluster with the specified Monte Carlo track ID.
118      * Return null for failure.
119      *
120     * @param   trv The VTrack for which to generate a cluster at this surface.
121      * @param   mcid The MC ID to associate with this cluster.
122      * @return   The cluster for this track at this surface, null for failure.
123      */
124     public Cluster newCluster(  VTrack trv, int mcid )
125     {
126         Cluster clu = null;
127         // Check track has been propagated to the surface.
128         Assert.assertTrue( _srf.pureEqual( trv.surface() ) );
129         if ( ! _srf.pureEqual( trv.surface() ) ) return clu;
130         
131         // Require that track is in bounds if surface is bounded.
132         CrossStat xstat = _srf.status(trv);
133         if ( (! _srf.isPure()) && (! xstat.inBounds()) ) return clu;
134         
135         // calculate phiz.
136         double phiz = trv.vector().get(0) + _stereo*trv.vector().get(1)
137         + _dphiz*gauss();
138         
139         // construct cluster
140         double radius = _srf.parameter(SurfCylinder.RADIUS);
141         clu = new ClusCylPhiZ( radius, phiz, _dphiz, _stereo, mcid );
142         
143         return clu;
144         
145     }
146     
147     
148     /**
149      *output stream
150      *
151      * @return A String representation of this instance.
152      */
153     public String toString()
154     {
155         StringBuffer sb = new StringBuffer("HitCylPhiZ Generator at \n" + surface()
156         + "\nStereo slope: " + _stereo );
157         sb.append("\nMeasurement error (dphiz): " + _dphiz);
158         sb.append(super.toString());
159         return sb.toString();
160         
161     }
162     
163 }
164