1 package org.lcsim.recon.tracking.trflayer; 2 3 import java.util.*; 4 5 import org.lcsim.recon.tracking.trfbase.Hit; 6 import org.lcsim.recon.tracking.trfbase.Miss; 7 import org.lcsim.recon.tracking.trfbase.ETrack; 8 9 /** 10 * Layer status contains the results of propagation to a layer surface. 11 * It includes: 12 * 13 * <li> the layer 14 * <li> a flag indicating whether this is the last surface in the layer 15 * <li> an optional miss which provides the likelihood that the track 16 * would not have produced any clusters 17 * <li> an optional cluster finder which provides access to the clusters 18 * associated with the layer surface and 19 * <li> an integer to record the internal state of the layer 20 *<p> 21 * This is a concrete class and is not intended to be used for inheritance. 22 * Layers can save and then retrieve their state in the layer status. 23 *<p> 24 * Layer status objects form a linked list which is intended to be managed 25 * from the top; when an object is deleted, children (and not parents) 26 * are deleted recursively. 27 *<p> 28 * The miss object is managed here, i.e. it is deleted when the layer 29 * status is deleted. The layer and finder are not managed here. 30 * 31 * 32 *@author Norman A. Graf 33 *@version 1.0 34 * 35 **/ 36 public class LayerStat 37 { 38 39 40 private boolean debug; 41 // the layer that produced this status 42 private Layer _layer; 43 44 // flag indicating this is the last surface in this layer 45 private boolean _at_exit; 46 47 // crossing of track with layer surface 48 private Miss _miss; 49 50 // The object managing the list of clusters. 51 // The object is not managed here; it is managed by the layer. 52 // We are in trouble if the layer is deleted. 53 // Null => this layer surface does not hold clusters (default). 54 private ClusterFinder _finder; 55 56 // layer internal state 57 private int _layer_state; 58 59 60 // constructors 61 62 // 63 64 /** 65 * default constructor 66 * 67 */ 68 public LayerStat() 69 { 70 reset(); 71 } 72 73 // 74 75 /** 76 *constructor from layer 77 * 78 * @param layer Layer for which to create a status 79 */ 80 public LayerStat(Layer layer) 81 { 82 // need clone method here... 83 _layer = layer; 84 reset(); 85 } 86 87 // 88 /** 89 *copy constructor 90 * 91 * @param lstat LayerStat to replicate 92 */ 93 public LayerStat(LayerStat lstat) 94 { 95 _layer = lstat._layer; 96 _at_exit = lstat._at_exit; 97 _miss = lstat._miss ; 98 _finder = lstat._finder ; 99 _layer_state = lstat._layer_state; 100 if(debug) System.out.println(this); 101 } 102 103 104 /** 105 *output stream 106 * 107 * @return String representation of this class 108 */ 109 public String toString() 110 { 111 StringBuffer sb = new StringBuffer( getClass().getName()+" is "); 112 if ( ! _at_exit ) sb.append("not "); 113 sb.append( "at exit.\n"); 114 // Display the miss, finder and state. 115 if ( _miss != null ) sb.append( _miss + "\n"); 116 else sb.append( "No miss. \n"); 117 if ( _finder != null ) sb.append( _finder +"\n"); 118 else sb.append( "No cluster finder.\n"); 119 sb.append( "Layer state: " + _layer_state); 120 return sb.toString(); 121 } 122 123 // modifiers 124 125 // 126 127 /** 128 *reset flag, miss, finder and state 129 * 130 */ 131 public void reset() 132 { 133 _at_exit = false; 134 _miss = null; 135 _finder = null; 136 _layer_state = 0; 137 } 138 139 // 140 141 /** 142 *set exit 143 * 144 */ 145 public void setAtExit() 146 { 147 setAtExit(true); 148 } 149 150 151 /** 152 *set at exit 153 * 154 * @param value to set at exit 155 */ 156 public void setAtExit(boolean value) 157 { 158 _at_exit = value; 159 } 160 161 // 162 163 /** 164 *set the miss 165 * 166 * @param miss Miss to set for this status 167 */ 168 public void setMiss(Miss miss) 169 { 170 _miss = miss.newCopy(); 171 } 172 173 // 174 175 /** 176 *drop the miss 177 * 178 */ 179 public void unsetMiss() 180 { 181 _miss = null; 182 } 183 184 // 185 186 /** 187 *set the cluster finder 188 * 189 * @param finder ClusterFinder for this Layer's surface 190 */ 191 public void setFinder(ClusterFinder finder) 192 { 193 _finder = finder; 194 } 195 196 // 197 198 /** 199 *set the layer state 200 * 201 * @param layer_state for this layer 202 */ 203 public void setState(int layer_state) 204 { 205 _layer_state = layer_state; 206 } 207 208 // accessors 209 210 // 211 212 /** 213 *return the layer 214 * 215 * @return Layer 216 */ 217 public Layer layer() 218 { 219 return _layer; 220 } 221 222 // 223 224 /** 225 *return true if the track is at the exit of this layer 226 * 227 * @return true if track is at exit 228 */ 229 public boolean atExit() 230 { 231 return _at_exit; 232 } 233 234 // 235 236 /** 237 *Return whether this surface has clusters. 238 * 239 * @return true if this layer contains clusters 240 */ 241 public boolean hasClusters() 242 { 243 if (_finder == null) return false; 244 return true; 245 } 246 247 // 248 249 /** 250 *Return all the clusters associated with this surface 251 * in the layer. 252 * Default here is to return all clusters from the last layer in the nest. 253 * 254 * @return a List of clusters on this layer 255 */ 256 public List clusters() 257 { 258 if ( _finder == null ) return new ArrayList(); 259 return _finder.clusters(); 260 261 } 262 263 // 264 265 266 /** 267 *Return all the clusters near the specified track associated with 268 * the track's surface in the current layer surface. 269 * Default here is to return all clusters from the last layer in the nest. 270 * 271 * @param tre ETrack 272 * @return List of clusters near ETrack tre 273 */ 274 public List clusters(ETrack tre) 275 { 276 if ( _finder == null ) return new ArrayList(); 277 return _finder.clusters(tre); 278 } 279 280 // 281 282 /** 283 *Return the miss. 284 * 285 * @return the Miss for this layer 286 */ 287 public Miss miss() 288 { 289 return _miss; 290 } 291 292 // 293 294 /** 295 *Fetch the layer state 296 * 297 * @return the state of this layer 298 */ 299 public int state() 300 { 301 return _layer_state; 302 } 303 304 // //cng 305 306 /** 307 *Return the finder 308 * 309 * @return the finder associated with this layer 310 */ 311 public ClusterFinder finder() 312 { 313 return _finder; 314 } 315 316 } 317