5 modified files
GeomConverter/src/org/lcsim/geometry
diff -u -r1.14 -r1.15
--- IDDecoder.java 14 Feb 2006 21:14:39 -0000 1.14
+++ IDDecoder.java 15 Mar 2006 23:47:32 -0000 1.15
@@ -10,81 +10,83 @@
* @author tonyj
*/
public interface IDDecoder
-{
+{
/** Constant that flags an invalid index, i.e. for a field that does not exist. */
public static final int INVALID_INDEX = -1;
-
+
/* /\/\/\ ID decoding /\/\/\ */
-
+
/** Load the decoder with a 64-bit id value from the hit. */
public void setID(long id);
-
+
/** Get an expanded identifier that maps strings to integer values. */
public ExpandedIdentifier getExpandedIdentifier();
-
+
/** Same as getIDExpanded() except sets id. */
public ExpandedIdentifier getExpandedIdentifier(long id);
-
+
/*/\/\/\ Access to field data /\/\/\ */
- public int getValue(String field);
+ public int getValue(String field);
public int getValue(int index);
-
- /* /\/\/\ ID description /\/\/\ */
- public int getFieldCount();
- public String getFieldName(int index);
- public int getFieldIndex(String name);
- public void setIDDescription(IDDescriptor id);
+
+ /* /\/\/\ ID description /\/\/\ */
+ public int getFieldCount();
+ public String getFieldName(int index);
+ public int getFieldIndex(String name);
+ public void setIDDescription(IDDescriptor id);
public IDDescriptor getIDDescription();
-
+
/** @return layer number */
- public int getLayer();
-
+ public int getLayer();
+
/* /\/\/\ Position interface /\/\/\ */
-
+
// FIXME: change to Hep3Vector and eliminate the X/Y/Z/theta/phi methods
-
+
/** @return Hep3Vector representing the position of the current ID. */
public Hep3Vector getPositionVector();
-
+
/** @return position as double array of length 3 */
public double[] getPosition();
-
+
/** @return X coordinate */
- public double getX();
-
+ public double getX();
+
/** @return Y coordinate */
public double getY();
-
+
/** @return Z coordinate */
public double getZ();
-
+
/** @return phi angle */
public double getPhi();
-
+
/** @return theta angle */
- public double getTheta();
-
+ public double getTheta();
+
/* /\/\/\ Reverse Decoding: Position to Cell /\/\/\ */
-
+
public long findCellContainingXYZ(Hep3Vector pos);
-
+ public long findCellContainingXYZ(double[] pos);
+ public long findCellContainingXYZ(double x, double y, double z);
+
/* /\/\/\ Miscellaneous /\/\/\ */
-
+
/** Get the flag that indicates barrel or endcap, i.e. the "barrel" field. */
public BarrelEndcapFlag getBarrelEndcapFlag();
-
+
/** Get the system ID, i.e. the "system" field. */
public int getSystemID();
-
+
/** @Deprecated use getSystemID() instead */
public int getSystemNumber();
-
+
/** Get the Subdetector associated with this IDDecoder, or null if not applicable. */
public Subdetector getSubdetector();
-
+
/* /\/\/\ Neighbours /\/\/\ */
-
+
public boolean supportsNeighbours();
public long[] getNeighbourIDs();
public long[] getNeighbourIDs(int deltaLayer, int deltaTheta, int deltaPhi);
-}
\ No newline at end of file
+}
GeomConverter/src/org/lcsim/geometry/segmentation
diff -u -r1.19 -r1.20
--- GridXYZ.java 14 Feb 2006 21:15:32 -0000 1.19
+++ GridXYZ.java 15 Mar 2006 23:47:33 -0000 1.20
@@ -30,6 +30,8 @@
private int xIndex = -1;
private int yIndex = -1;
private int zIndex = -1;
+ private int barrelIndex = -1;
+ private int systemIndex = -1;
private double[] _localPos =
{ 0, 0, 0 };
@@ -58,11 +60,16 @@
}
}
+ public boolean supportsNeighbours()
+ {
+ return true;
+ }
+
/**
* Find neighbouring cells to the current cell. Cell neighbors are found
* based on the direction (theta,phi) of the reference cell w.r.t the
* origin.
- *
+ *
* @see org.lcsim.geometry.segmentation.SegmentationBase#setID()
* @return array of cellIDs for the neighbouring cells
*/
@@ -74,16 +81,16 @@
encoder.setValues(values);
long saveID = encoder.getID();
- int klay = values[layerIndex];
- int kx = values[xIndex];
- int ky = values[yIndex];
- // System.out.println("Ref.ID: ref="+klay+" "+kx+" "+ky
- // +" (hex "+Long.toHexString(saveID)+")");
- // long system = (saveID>>7) & 0x1ff;
- // System.out.println("hit pos: x="+getX()+", y="+getY()+",
- // z="+getZ()+", system="+system);
+// int klay = values[layerIndex];
+// int kx = values[xIndex];
+// int ky = values[yIndex];
+// System.out.println("Ref.ID: ref="+klay+" "+kx+" "+ky
+// +" (hex "+Long.toHexString(saveID)+")");
+// long system = (saveID>>7) & 0x1ff;
+// System.out.println("hit pos: x="+getX()+", y="+getY()
+// +", z="+getZ()+", system="+system);
- int nMax = (2 * layerRange + 1) * (2 * xRange + 1) * (2 * yRange + 1) - 1;
+ int nMax = (2*layerRange + 1) * (2*xRange + 1) * (2*yRange + 1) - 1;
long[] result = new long[nMax];
// theta and phi are used to find central neighbors in other layers
@@ -147,8 +154,8 @@
if (iy < -yBins / 2 || iy >= yBins / 2)
continue;
- // System.out.println("Adding neighbor: "+ilay+" "+ix+" "+iy
- // +", total="+ (size+1));
+// System.out.println("Adding neighbor: "+ilay+" "+ix+" "
+// +iy+", total="+ (size+1));
result[size++] = encoder.setValue(yIndex, iy);
}
}
@@ -158,28 +165,11 @@
this.setID(saveID);
if (size < result.length)
{
- // int kklay = values[layerIndex];
- // int kkx = values[xIndex];
- // int kky = values[yIndex];
- // System.out.println("In a border?
- // Neighbors="+size+"/"+result.length
- // +", ref="+kklay+" "+kkx+" "+kky);
-
long[] temp = new long[size];
System.arraycopy(result, 0, temp, 0, size);
result = temp;
}
- // int kklay = values[layerIndex];
- // int kkx = values[xIndex];
- // int kky = values[yIndex];
- // System.out.println("Neighbors="+size+"/"+result.length
- // +", ref="+kklay+" "+kkx+" "+kky
- // +" (hex "+Long.toHexString(encoder.getID())+")");
-
- // System.out.println("Leaving getNeighbours: current id="
- // +values[layerIndex]+" "+values[xIndex]
- // +" "+values[yIndex]);
return result;
}
@@ -332,12 +322,15 @@
{
zIndex = id.indexOf("z");
}
+
+ barrelIndex = id.indexOf("barrel");
+ systemIndex = id.indexOf("system");
}
/**
* Returns positive distance from IR to center of sensitive slice of any
* layer
- *
+ *
* @param layer
* layer index
*/
@@ -356,7 +349,7 @@
/**
* Return the cell which contains a given point (x,y,z). If point is not
* contained in this component, zero is returned.
- *
+ *
* @param x,y,z
* cartesian coordinates of the point
* @return ID of cell containing the point (maybe either in absorber or live
@@ -364,29 +357,27 @@
*/
public long findCellContainingXYZ(double x, double y, double z)
{
-
// validate point
double absz = Math.abs(z);
- if (absz < getZMin())
- return 0;
- if (absz > getZMax())
- return 0;
+ if (absz < getZMin()) return 0;
+ if (absz > getZMax()) return 0;
double rho = Math.sqrt(x * x + y * y);
- if (rho < getRMin())
- return 0;
- if (rho > getRMax())
- return 0;
+ if (rho < getRMin()) return 0;
+ if (rho > getRMax()) return 0;
// ok, point is valid, so a valid ID should be returned
int ix = getXBin(x);
int iy = getYBin(y);
int ilay = getLayerBin(absz);
+ int ibar = ( z<0 ? 2 : 1 );
+ int system = detector.getSystemID();
IDEncoder enc = new IDEncoder(descriptor);
- enc.setValues(values);
enc.setValue(layerIndex, ilay);
enc.setValue(xIndex, ix);
enc.setValue(yIndex, iy);
+ enc.setValue(barrelIndex, ibar);
+ enc.setValue(systemIndex, system);
long resultID = enc.getID();
return resultID;
}
@@ -458,4 +449,5 @@
{
return gridSizeZ;
}
+
}
GeomConverter/src/org/lcsim/geometry/segmentation
diff -u -r1.23 -r1.24
--- ProjectiveCylinder.java 9 Feb 2006 19:18:07 -0000 1.23
+++ ProjectiveCylinder.java 15 Mar 2006 23:47:33 -0000 1.24
@@ -17,6 +17,8 @@
private int thetaIndex;
private int phiIndex;
+ private int barrelIndex = -1;
+ private int systemIndex = -1;
ProjectiveCylinder(Element node) throws DataConversionException
{
@@ -57,6 +59,8 @@
phiIndex = id.indexOf("phi");
thetaIndex = id.indexOf("theta");
+ barrelIndex = id.indexOf("barrel");
+ systemIndex = id.indexOf("system");
}
public boolean supportsNeighbours()
@@ -146,11 +150,12 @@
double theta = Math.atan2(rho, z);
int itheta = (int) (theta * thetaBins / Math.PI);
- IDEncoder enc = new IDEncoder(descriptor);
- enc.setValues(values);
+ IDEncoder enc = new IDEncoder(descriptor);
enc.setValue(layerIndex, ilay);
enc.setValue(thetaIndex, itheta);
enc.setValue(phiIndex, iphi);
+ enc.setValue(barrelIndex, 0);
+ enc.setValue(systemIndex, detector.getSystemID());
long resultID = enc.getID();
return resultID;
GeomConverter/src/org/lcsim/geometry/segmentation
diff -u -r1.20 -r1.21
--- ProjectiveZPlane.java 15 Mar 2006 10:22:03 -0000 1.20
+++ ProjectiveZPlane.java 15 Mar 2006 23:47:33 -0000 1.21
@@ -22,6 +22,8 @@
private int thetaIndex;
private int phiIndex;
+ private int systemIndex = -1;
+ private int barrelIndex = -1;
private double thetaDim = 0;
private double phiDim = 0;
@@ -45,13 +47,13 @@
public double getPhi()
{
- double phi = (Math.PI * 2) * ((getValue(phiIndex) + 0.5) / phiBins);
+ double phi = 2 * PI * ((getValue(phiIndex) + 0.5) / phiBins);
return phi;
}
public double getTheta()
{
- return (Math.PI) * ((getValue(thetaIndex) + 0.5) / thetaBins);
+ return PI * ((getValue(thetaIndex) + 0.5) / thetaBins);
}
public double getX()
@@ -80,6 +82,8 @@
phiIndex = id.indexOf("phi");
thetaIndex = id.indexOf("theta");
+ barrelIndex = id.indexOf("barrel");
+ systemIndex = id.indexOf("system");
}
public long[] getNeighbourIDs(int deltaLayer, int deltaTheta, int deltaPhi)
@@ -112,8 +116,8 @@
continue;
int p = values[phiIndex] + k;
- if (p < 0 || p >= phiBins)
- continue;
+ if(p<0) p+=phiBins;
+ if(p>=phiBins) p-=phiBins;
result[size++] = encoder.setValue(phiIndex, p);
}
@@ -152,25 +156,29 @@
if(rho > getRMax()) return 0;
// ok, point is valid, so a valid ID should be returned
- int ilay = getLayerBin(rho);
+ int ilay = getLayerBin(z);
double phi = Math.atan2(y, x);
- if(phi < 0) phi += 2 * Math.PI;
- int iphi = (int) (phi / phiBins);
+ if(phi < 0) phi += 2 * PI;
+ int iphi = (int) ((phi * phiBins)/(2*PI) - 0.5);
double theta = Math.atan2(rho, z);
if(theta < 0)
{
// If never prints out, the whole if can be dropped
System.out.println("ProjCylinder: Is this really needed?!?");
- theta += 2. * Math.PI;
+ theta += 2. * PI;
}
- int itheta = (int) (theta / thetaBins);
+ int itheta = (int) ((theta * thetaBins)/PI - 0.5);
+ int ibar = ( z<0 ? 2 : 1 );
+ int system = detector.getSystemID();
IDEncoder enc = new IDEncoder(descriptor);
- enc.setValue("layer", ilay);
+ enc.setValue(layerIndex, ilay);
enc.setValue(thetaIndex, itheta);
enc.setValue(phiIndex, iphi);
+ enc.setValue(barrelIndex, ibar);
+ enc.setValue(systemIndex, system);
long resultID = enc.getID();
return resultID;
@@ -188,10 +196,6 @@
*/
public int getLayerBin(double z)
{
- // validate point
- if(Math.abs(z) < getZMin()) return -1;
- if(Math.abs(z) > getZMax()) return -1;
-
// In order to be general, we should not assume that all
// layers have the same thickness. Therefore, one has to
// guess the starting layer (based on average thickness), and
GeomConverter/src/org/lcsim/geometry/util
diff -u -r1.8 -r1.9
--- BaseIDDecoder.java 14 Feb 2006 21:13:05 -0000 1.8
+++ BaseIDDecoder.java 15 Mar 2006 23:47:33 -0000 1.9
@@ -17,33 +17,33 @@
* A basic implementation of org.lcsim.geometry.IDDecoder
* for others to extend. It uses the org.lcsim.geometry.util
* classes for functionality.
- *
+ *
* @author jeremym
*/
public class BaseIDDecoder
implements org.lcsim.geometry.IDDecoder
-{
+{
protected org.lcsim.geometry.util.IDDecoder decoder;
protected IDDescriptor descriptor;
protected int[] values;
protected boolean valid = false;
protected Subdetector detector;
protected int layerIndex;
-
+
public BaseIDDecoder()
{}
-
+
public BaseIDDecoder( IDDescriptor id)
{
setIDDescription(id);
}
-
+
public org.lcsim.geometry.ExpandedIdentifier getExpandedIdentifier()
{
- org.lcsim.geometry.util.ExpandedIdentifier id =
+ org.lcsim.geometry.util.ExpandedIdentifier id =
new org.lcsim.geometry.util.ExpandedIdentifier();
if (isValid())
- {
+ {
for (int i=0; i < descriptor.fieldCount(); i++)
{
String fieldname = descriptor.fieldName(i);
@@ -57,101 +57,101 @@
}
return id;
}
-
+
public org.lcsim.geometry.ExpandedIdentifier getExpandedIdentifier(long id)
{
setID(id);
return getExpandedIdentifier();
}
-
+
public double getX()
{
return 0;
}
-
+
public double getY()
{
return 0;
}
-
+
public double getZ()
{
return 0;
}
-
+
public double getPhi()
{
return 0;
}
-
+
public double getTheta()
{
return 0;
}
-
+
public double[] getPosition()
{
return new double[] { getX(), getY(), getZ() };
}
-
+
public void setID(long id)
{
decoder.setID(id);
decoder.getValues(values);
- valid = true;
+ valid = true;
}
-
+
// FIXME: dup of util.IDDecoder method
public int getValue(String field)
{
return decoder.getValue(field);
}
-
+
// FIXME: dup of util.IDDecoder method
public int getValue(int index)
{
return decoder.getValue(index);
}
-
+
// FIXME: dup of util.IDDecoder method
public String getFieldName(int index)
{
return decoder.getFieldName(index);
}
-
+
// FIXME: dup of util.IDDecoder method
public int getFieldIndex(String name)
{
return decoder.getFieldIndex(name);
}
-
+
// FIXME: dup of util.IDDecoder method
public int getFieldCount()
{
return values.length;
}
-
+
public void setIDDescription(IDDescriptor id)
- {
+ {
descriptor = id;
decoder = new org.lcsim.geometry.util.IDDecoder(id);
values = new int[id.fieldCount()];
-
+
// FIXME: doesn't belong here
setLayerIndex(id);
}
-
+
public IDDescriptor getIDDescription()
{
return descriptor;
}
-
+
// FIXME: dup of util.IDDecoder method
public String toString()
{
return decoder == null ? "NoDecoder" : decoder.toString();
}
-
+
public boolean isValid()
{
return valid;
@@ -161,27 +161,27 @@
{
return BarrelEndcapFlag.createBarrelEndcapFlag(decoder.getValue("barrel"));
}
-
+
public void setSubdetector(Subdetector d)
{
detector = d;
}
-
+
public Subdetector getSubdetector()
{
return detector;
}
-
+
private void setLayerIndex(IDDescriptor id)
{
layerIndex = id.indexOf("layer");
}
-
+
public int getLayer()
{
return values[layerIndex];
}
-
+
public int getSystemID()
{
int idx = descriptor.indexOf("system");
@@ -195,7 +195,7 @@
}
return sysid;
}
-
+
public int getSystemNumber()
{
return getSystemID();
@@ -206,12 +206,12 @@
long[] dummyNeighbours = {0, 0, 0};
return dummyNeighbours;
}
-
+
public boolean supportsNeighbours()
{
return false;
}
-
+
public long[] getNeighbourIDs()
{
return getNeighbourIDs(1,1,1);
@@ -222,8 +222,18 @@
return 0;
}
+ public long findCellContainingXYZ(double[] pos)
+ {
+ return 0;
+ }
+
+ public long findCellContainingXYZ(double x, double y, double z)
+ {
+ return 0;
+ }
+
public Hep3Vector getPositionVector()
{
return new BasicHep3Vector(getPosition());
- }
-}
\ No newline at end of file
+ }
+}
CVSspam 0.2.8