1 package org.lcsim.recon.tracking.trfbase;
2 import java.util.*;
3 import org.lcsim.recon.tracking.trfutil.Assert;
4 /** Abstract interface for clusters.
5 *
6 * The abstract base class Cluster represents a detector observation
7 * that is independent of other such observations. I.e., the track
8 * crossing contributing to a particular cluster does not contribute
9 * to any others. Due to finite detector resolution, more than one track
10 * crossing may contribute to a single cluster.
11 *<p>
12 * The abstract base class Hit represents a measurement derived from
13 * a cluster which is assigned to a single track. If the hit only makes
14 * use of a portion of the cluster, then it is assumed that the remainder
15 * of the cluster is independent of the track crossing which produced the
16 * portion of interest.
17 *<p>
18 * The only requirement on a cluster is that it is able to generate a list
19 * hits from a track. The track must first be propagated to the cluster
20 * surface. The returned list contains reference-counting pointers so
21 * that each hit is deleted when its list element
22 * is deleted.
23 *<p>
24 *@author Norman A. Graf
25 *@version 1.0
26 */
27 public abstract class Cluster
28 {
29
30 /**
31 *Return the type name.
32 *
33 * @return String name of this class.
34 * Included for consistency with C++ version
35 */
36 public static String typeName()
37 { return "Cluster"; }
38 //
39
40 /**
41 *Return the type.
42 *
43 * @return String name of this class
44 * Included for consistency with C++ versio
45 */
46 public static String staticType()
47 { return typeName(); }
48
49
50 //
51
52 /**
53 *equality
54 * Return true if and only if the two clusters are identical.
55 *
56 * @param clus Cluster to compare with
57 * @return true if Clusters are equal
58 */
59 public abstract boolean equal( Cluster clus ) ;
60
61 //
62
63 /**
64 *Generate and return the predictions for a track.
65 *
66 * @param tre ETrack generating the prediction
67 * @return Cluster for this ETrack
68 */
69 public abstract List predict( ETrack tre) ;
70
71 //
72
73 /**
74 *constructor
75 *
76 */
77 public Cluster()
78 {
79 }
80
81 //
82
83 /**
84 *copy constructor
85 *
86 * @param clus Cluster to replicate
87 */
88 public Cluster( Cluster clus)
89 {
90 }
91
92 //
93
94 /**
95 *Return the type.
96 *
97 * @return String representation of generic type
98 * Included for consistency with C++ versio
99 */
100 public String genericType()
101 { return staticType(); }
102
103 /**
104 *Return the type.
105 *
106 * @return String representation of the type
107 * Included for consistency with C++ version
108 */
109 public String type()
110 { return staticType(); }
111
112 //
113
114 /**
115 *Return the cluster surface.
116 *
117 * @return The Surface at which this Cluster is defined
118 */
119 public abstract Surface surface() ;
120
121 //
122
123
124 /**
125 *Return the ID's of MC tracks contributing to this cluster.
126 * The default implementation returns an empty list
127 *
128 * @return a list of Monte Carlo ID's contributing to this Cluster
129 */
130 public List mcIds()
131 {
132 return new ArrayList();
133 }
134
135
136 /**
137 *Return the ID's of MC tracks contributing to this cluster.
138 * The default implementation returns an empty list
139 *
140 * @return n array of Monte Carlo ID's contributing to this Cluster
141 */
142 public int[] mcIdArray()
143 {
144 return new int[0];
145
146 }
147
148 //
149
150 /**
151 *Generate and return the predictions for a track.
152 * This is a list of Hits.
153 * The specified parent is assigned to each prediction.
154 *
155 * @param tre The ETrack for which to generate a prediction
156 * @param clus The predicted Cluster
157 * @return a list of Hits for this prediction
158 */
159 public List predict( ETrack tre, Cluster clus)
160 {
161 // check clus points to this cluster
162 Assert.assertTrue( this == clus );
163 // use virtual method to fetch list
164 List hits = predict(tre);
165 // Iterate through the list and
166 // assign the parent cluster for each prediction
167 for (Iterator it = hits.iterator(); it.hasNext(); )
168 {
169 ((Hit)it.next()).setParentPointer(clus);
170 }
171 return hits;
172 }
173
174 //
175
176 /**
177 *equality
178 * false if the cluster predictions are of diffent type
179 * otherwise compare with public abstract function equal
180 *
181 * @param clus Cluster to compare with
182 * @return true if Clusters are equal
183 */
184 public boolean equals( Cluster clus )
185 {
186 if( !type().equals(clus.type()) ) return false;
187 return equal(clus);
188 }
189
190 //
191
192 /** inequality
193 *
194 * @param clus Cluster to compare with
195 * @return true if Clusters are not equal
196 */
197 public boolean notEquals( Cluster clus )
198 {
199 return ! equals(clus);
200 }
201
202 }