View Javadoc

1   package org.lcsim.recon.tracking.trfcyl;
2   
3   import org.lcsim.recon.tracking.trfbase.ETrack;
4   import org.lcsim.recon.tracking.trfbase.VTrack;
5   import org.lcsim.recon.tracking.trfbase.CrossStat;
6   import org.lcsim.recon.tracking.trfbase.BoundedStat;
7   import org.lcsim.recon.tracking.trfbase.Surface;
8   /**
9    **
10   * Cylinder with boundaries in z.
11   *
12   *@author Norman A. Graf
13   *@version 1.0
14   *
15   */
16  public class BSurfCylinder extends SurfCylinder
17  {
18      
19      // lower z-limit
20      private double _zmin;
21      
22      // upper z-limit
23      private double _zmax;
24      
25      
26      //
27      
28      /**
29       *Return a String representation of the class' type name.
30       *Included for completeness with the C++ version.
31       *
32       * @return   A String representation of the class' type name.
33       */
34      public static String typeName()
35      { return "BSurfCylinder";
36      }
37      
38      //
39      
40      /**
41       *Return a String representation of the class' type name.
42       *Included for completeness with the C++ version.
43       *
44       * @return   A String representation of the class' type name.
45       */
46      public static String staticType()
47      { return typeName();
48      }
49      
50      
51      //
52      
53      /**
54       *Check the bounded equality of two surfaces.
55       *
56       * @param   srf The Surface to compare against.
57       * @return true if the two surfaces are equl in their bounded extent.
58       */
59      public boolean safeBoundEqual( Surface srf)
60      {
61          
62          BSurfCylinder bcy = (BSurfCylinder) srf;
63          return safePureEqual(srf) &&
64                  _zmin == bcy._zmin  && _zmax == bcy._zmax;
65      }
66      
67      //
68      
69      /**
70       *Return a String representation of the class' type name.
71       *Included for completeness with the C++ version.
72       *
73       * @return   A String representation of the class' type name.
74       */
75      public String type()
76      { return staticType();
77      }
78      
79      
80      // calculate crossing status from VTrack and error in z_track
81      // This is used by both the public status methods.
82      private CrossStat status( VTrack trv, double dztrk)
83      {
84          CrossStat xstat = pureStatus(trv);
85          // If track is not at surface exit with bounds flags undefined.
86          if ( ! xstat.at() ) return xstat;
87          // needs work here
88          //assert( ! xstat.bounds_checked() );
89          // Calculate whether z track +/- nsigma is in and/or out of bounds.
90          double ztrk = trv.vector().vector()[1];
91          double ztrk1 = ztrk - dztrk;
92          double ztrk2 = ztrk + dztrk;
93          // fully out of bounds
94          if ( ztrk2 < _zmin || ztrk1 > _zmax )
95              return new CrossStat(BoundedStat.OUT_OF_BOUNDS);
96          // fully in bounds
97          if ( ztrk1 > _zmin  &&  ztrk2 < _zmax )
98              return new CrossStat(BoundedStat.IN_BOUNDS);
99          // must be both
100         return new CrossStat(BoundedStat.BOTH_BOUNDS);
101     }
102     
103     
104     
105     //
106     
107     /**
108      *Construct an instance of a cylinder with radius, minimum and maximum z.
109      *
110      * @param   radius The radius of the bounded cylinder.
111      * @param   zmin The minimum z extent of the bounded cylinder.
112      * @param   zmax The maximum z extent of the bounded cylinder.
113      */
114     public BSurfCylinder(double radius, double zmin, double zmax)
115     {
116         super(radius);
117         if(zmin>zmax) throw new IllegalArgumentException("BSurfCylinder zmin>zmax");
118         
119         _zmin = zmin;
120         _zmax = zmax;
121     }
122     
123     
124     //
125     
126     /**
127      *Return the minimum z extent for this bounded cylinder.
128      *
129      * @return The minimum z extent for this bounded cylinder.
130      */
131     public double zMin()
132     { return _zmin;
133     }
134     
135     //
136     
137     /**
138      *Return the maximum z extent for this bounded cylinder.
139      *
140      * @return The maximum z extent for this bounded cylinder.
141      */
142     public double zMax()
143     { return _zmax;
144     }
145     
146     //
147     
148     /**
149      *Calculate crossing status for a VTrack.
150      *
151      * @param   trv  The VTrack to check.
152      * @return The crossing status for the track tre.
153      */
154     public CrossStat status( VTrack trv)
155     {
156         double prec = CrossStat.staticPrecision();
157         double dztrk = prec;
158         return status(trv,dztrk);
159     }
160     
161     //
162     
163     /**
164      *Calculate crossing status for an ETrack.
165      *
166      * @param   tre The ETrack to check.
167      * @return The crossing status for the track tre.
168      */
169     public CrossStat status( ETrack tre)
170     {
171         double nsigma = CrossStat.staticNSigma();
172         double prec = CrossStat.staticPrecision();
173         double dztrk = nsigma*Math.sqrt(tre.error().matrix()[1][1]) + prec;
174         return status(tre,dztrk);
175     }
176     
177     /**
178      * A String representation of this instance.
179      * @return A String representation of this instance.
180      */
181     public String toString()
182     {
183         return super.toString()+ " zmin= "+_zmin+" zmax= "+_zmax;
184     }
185     
186 }
187