GeomConverter/src/org/lcsim/geometry
diff -u -r1.8.2.1 -r1.8.2.2
--- IDDecoder.java 28 Sep 2005 05:44:15 -0000 1.8.2.1
+++ IDDecoder.java 27 Oct 2005 23:58:41 -0000 1.8.2.2
@@ -8,25 +8,47 @@
*/
public interface IDDecoder
{
- /* ID decoding */
+ /* /\/\/\ ID decoding /\/\/\ */
+
+ /* Load the decoder with a 64-bit id value from the hit. */
public void setID(long id);
+
+ /* @return value of the field from the name */
public int getValue(String field);
- public int getValue(int index);
- /* ID description */
+ /* @return value of the field from the index */
+ public int getValue(int index);
+
+ /* @return true if setID() has been called, false if not */
+ public boolean isValid();
+
+ /* /\/\/\ ID description /\/\/\ */
+
+ /* @return number of fields in the descriptor*/
public int getFieldCount();
+
+ /* @return name of the field from the index */
public String getFieldName(int index);
+
+ /* @return index of the field from the name */
public int getFieldIndex(String name);
+
+ /* Load the IDDecoder with an IDDescriptor. */
public void setIDDescription(IDDescriptor id);
+
+ /* @return currently loaded IDDescriptor */
public IDDescriptor getIDDescription();
/*
- * layer number
- * WARNING: Used in at least 31 places, so better not change.
+ * @return layer number
+ * WARNING: Used in at least 31 places.
+ * FIXME: This redundant, because it is already accessible by calling getValue("layer").
+ * --JM
*/
public int getLayer();
- /* Position interface */
+ /* /\/\/\ Position interface /\/\/\ */
+ /* FIXME: Why can't the user just get this information from the hit, instead? --JM */
public double[] getPosition();
public double getX();
public double getY();
GeomConverter/src/org/lcsim/geometry/util
diff -u -r1.1.2.2 -r1.1.2.3
--- BaseIDDecoder.java 29 Sep 2005 00:06:14 -0000 1.1.2.2
+++ BaseIDDecoder.java 27 Oct 2005 23:58:41 -0000 1.1.2.3
@@ -14,83 +14,108 @@
* @author jeremym
*/
public class BaseIDDecoder
- implements org.lcsim.geometry.IDDecoder {
+ implements org.lcsim.geometry.IDDecoder
+{
protected org.lcsim.geometry.util.IDDecoder decoder;
protected IDDescriptor descriptor;
protected int[] values;
+ protected boolean valid = false;
- public BaseIDDecoder() {
- }
+ public BaseIDDecoder()
+ {}
- public BaseIDDecoder( IDDescriptor id) {
+ public BaseIDDecoder( IDDescriptor id)
+ {
setIDDescription(id);
}
- public double getX() {
+ public double getX()
+ {
return 0;
}
- public double getY() {
+ public double getY()
+ {
return 0;
}
- public double getZ() {
+ public double getZ()
+ {
return 0;
}
- public int getLayer() {
+ public int getLayer()
+ {
return -1;
}
- public double getPhi() {
+ public double getPhi()
+ {
return 0;
}
- public double getTheta() {
+ public double getTheta()
+ {
return 0;
}
- public double[] getPosition() {
+ public double[] getPosition()
+ {
return new double[] { getX(), getY(), getZ() };
}
- public void setID(long id) {
+ public void setID(long id)
+ {
decoder.setID(id);
decoder.getValues(values);
+ valid = true;
}
- public int getValue(String field) {
+ public int getValue(String field)
+ {
return decoder.getValue(field);
}
- public int getValue(int index) {
+ public int getValue(int index)
+ {
return decoder.getValue(index);
}
- public String getFieldName(int index) {
+ public String getFieldName(int index)
+ {
return decoder.getFieldName(index);
}
- public int getFieldIndex(String name) {
+ public int getFieldIndex(String name)
+ {
return decoder.getFieldIndex(name);
}
- public int getFieldCount() {
+ public int getFieldCount()
+ {
return values.length;
}
- public void setIDDescription(IDDescriptor id) {
+ public void setIDDescription(IDDescriptor id)
+ {
descriptor = id;
decoder = new org.lcsim.geometry.util.IDDecoder(id);
values = new int[id.fieldCount()];
}
- public IDDescriptor getIDDescription() {
+ public IDDescriptor getIDDescription()
+ {
return descriptor;
}
- public String toString() {
+ public String toString()
+ {
return decoder == null ? "NoDecoder" : decoder.toString();
- }
+ }
+
+ public boolean isValid()
+ {
+ return valid;
+ }
}
\ No newline at end of file