View Javadoc

1   package org.lcsim.recon.tracking.trflayer;
2   import java.util.List;
3   import java.util.ArrayList;
4   
5   import java.util.Iterator;
6   
7   import org.lcsim.recon.tracking.trfbase.Propagator;
8   import org.lcsim.recon.tracking.trfbase.Surface;
9   import org.lcsim.recon.tracking.trfbase.ETrack;
10  import org.lcsim.recon.tracking.trfbase.TrackError;
11  import org.lcsim.recon.tracking.trfbase.Interactor;
12  import org.lcsim.recon.tracking.trfbase.Cluster;
13  
14  /**
15   * Class which inherits from Layer, and adds some interaction to Layer's
16   * track list.  The InteractingLayer contains a concrete layer
17   * (a LayerCylinder, for instance), and a concrete interactor
18   * (a ThinCylMS, for instance).  To add an interaction to tracks after
19   * the tracks have been propagated to the layer, one simply calls
20   * InteractingLayer.propagate(...).  The contained layer's propagate is
21   * then called, and the interaction appropriate to the contained interactor
22   * is applied.
23   *
24   *@author Norman A. Graf
25   *@version 1.0
26   *
27   */
28  
29  public class InteractingLayer extends Layer
30  {
31      
32      // static methods
33      
34      //
35      
36      /**
37       *Return the type name.
38       *
39       * @return String representation of class type
40       *Included for completeness with C++ version
41       */
42      public static String typeName()
43      { return "InteractingLayer";
44      }
45      
46      //
47      
48      /**
49       *Return the type.
50       *
51       * @return String representation of class type
52       *Included for completeness with C++ version
53       */
54      public static String staticType()
55      { return typeName();
56      }
57      
58      // attributes
59      
60      private Layer _lyr;
61      
62      private Interactor _inter;
63      
64      // methods
65      //
66      
67      /**
68       *Propagate a track to the next surface in this layer.
69       * The list of successful propagations is returned.
70       * This calls _propagate of its layer
71       *
72       * @param   tr1 LTrack
73       * @param   prop Propagator
74       * @return List of successful propagations
75       */
76      public List _propagate(LTrack tr1, Propagator prop)
77      {
78          // update the status chain
79          LTrack trl0 = new LTrack(tr1);
80          trl0.popStatus();
81          LayerStat lstat = new LayerStat(_lyr);
82          trl0.pushStatus(lstat);
83          
84          List ltracks = _lyr.propagate(trl0, prop);
85          
86          Iterator ltrIter;
87          for( ltrIter=ltracks.iterator(); ltrIter.hasNext();  )
88          {
89              ETrack etrk = ((LTrack)ltrIter.next()).track();
90              _inter.interact( etrk );
91              //needs work here... what's going on?
92              //(*ltrIter).pop_status();
93              TrackError terr = etrk.error();
94          }
95          
96          return ltracks;
97      }
98      
99      // Interact a track.
100     private void _interact(ETrack tre)
101     {
102         _inter.interact(tre);
103     }
104     
105     // methods
106     
107     //
108     
109     /**
110      *constructor from a Layer and an Interactor
111      *
112      * @param   lyr Layer
113      * @param   inter Interactor
114      */
115     public InteractingLayer(  Layer lyr,   Interactor inter)
116     {
117         _lyr = lyr;
118         _inter = inter;
119     }
120     
121     //
122     
123     /**
124      *Return the type.
125      *
126      * @return String representation of class type
127      *Included for completeness with C++ version
128      */
129     public String type()
130     { return staticType();
131     }
132     
133     //
134     
135     /**
136      *Return the layer.
137      *
138      * @return Layer
139      */
140     public  Layer layer()
141     { return _lyr;
142     }
143     
144     //
145     
146     /**
147      *Return the interactor.
148      *
149      * @return Interactor
150      */
151     public  Interactor interactor()
152     { return _inter;
153     }
154     
155     //
156     
157     /**
158      *call the contained class's has_clusters:
159      *
160      * @return true if layer contains clusters
161      */
162     public boolean hasClusters()
163     { return _lyr.hasClusters();
164     }
165     
166     //
167     
168     /**
169      *call the containing class's get_cluster_surfaces()
170      *
171      * @return List of surfaces
172      */
173     public List clusterSurfaces()
174     {
175         return _lyr.clusterSurfaces();
176     }
177     
178     //
179     
180     /**
181      *Return all the clusters associated with the current layer
182      * or its descendants.
183      * Default here is to return an error.
184      *
185      * @return List of clusters
186      */
187     public   List clusters()
188     {
189         return _lyr.clusters();
190     }
191     
192     //
193     
194     /**
195      *Return all the clusters associated with a particular surface
196      * in this layer.
197      * This method should call report_invalid_surface(Surface)
198      * if it does not recognize the argument.
199      *
200      * @param   srf Surface
201      * @return list of clusters for Surface srf
202      */
203     public List clusters( Surface srf)
204     {
205         return _lyr.clusters(srf);
206     }
207     
208     //
209     
210     /**
211      *Add a cluster to the layer.
212      * Default here is to return an error.
213      *
214      * @param   clu Cluster to add
215      * @return 0 if successful
216      */
217     public  int addCluster( Cluster clu)
218     {
219         return _lyr.addCluster( clu );
220     }
221     
222     //
223     
224     /**
225      *Add a cluster to a particular surface in the layer.
226      * Default here is to return an error.
227      *
228      * @param   clu Cluster
229      * @param   srf Surface
230      * @return 0 if successful
231      */
232     public  int addCluster( Cluster clu, Surface srf)
233     {
234         return _lyr.addCluster( clu, srf );
235     }
236     
237     //
238     
239     /**
240      *Drop all clusters from this layer.
241      * Default here is to return an error.
242      *
243      */
244     public  void dropClusters()
245     {
246         _lyr.dropClusters();
247         
248     }
249     
250     
251     /**
252      *output stream
253      *
254      * @return String representation of this class
255      */
256     public String toString()
257     {
258         return getClass().getName()+" "+_lyr + "\n with " + _inter;
259         
260     }
261     
262 }
263