lcsim/src/org/lcsim/contrib/onoprien/tracking/hitmaking/hitmakers
diff -u -r1.1 -r1.2
--- TrackerHitMakerBasic.java 1 Oct 2007 20:36:26 -0000 1.1
+++ TrackerHitMakerBasic.java 18 Feb 2008 22:34:35 -0000 1.2
@@ -4,8 +4,7 @@
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
import hep.physics.vec.VecOp;
-import org.lcsim.contrib.onoprien.tracking.hitmaking.*;
-
+import org.lcsim.recon.cat.util.NoSuchParameterException;
import org.lcsim.units.clhep.SystemOfUnits;
import org.lcsim.contrib.onoprien.tracking.geom.Sensor;
@@ -15,7 +14,11 @@
import org.lcsim.contrib.onoprien.tracking.hit.TrackerHit;
import org.lcsim.contrib.onoprien.tracking.hit.base.TrackerHitPoint;
import org.lcsim.contrib.onoprien.tracking.hit.base.TrackerHitSegment;
+import org.lcsim.contrib.onoprien.tracking.hitmaking.TrackerHitMaker;
import org.lcsim.contrib.onoprien.tracking.track.TrackPoint;
+import org.lcsim.contrib.onoprien.tracking.transform.CartesianToCylindrical;
+import org.lcsim.contrib.onoprien.tracking.transform.Rotation3D;
+import org.lcsim.contrib.onoprien.tracking.transform.Transformation3D;
/**
* Simplistic <tt>TrackerHitMaker</tt>.
@@ -25,13 +28,51 @@
* of the shortest strip.
*
* @author D. Onoprienko
- * @version $Id: TrackerHitMakerBasic.java,v 1.1 2007/10/01 20:36:26 onoprien Exp $
+ * @version $Id: TrackerHitMakerBasic.java,v 1.2 2008/02/18 22:34:35 onoprien Exp $
*/
public class TrackerHitMakerBasic implements TrackerHitMaker {
// -- Constructors : ----------------------------------------------------------
public TrackerHitMakerBasic() {
+ set("ERROR_PIXELS", 0.005);
+ set("ERROR_STRIPS", 0.007);
+ }
+
+// -- Setters : ---------------------------------------------------------------
+
+ /**
+ * Set algorithm parameters.
+ * The following parameters can be set with this method (see {@link Validator.set} for additional parameters) :
+ * <p><dl>
+ * <dt>"ERROR_PIXELS"</dt> <dd>The <tt>values</tt> argument should be a double value
+ * giving the minimal error to be assigned to hits in pixels, in millimeters.
+ * <br>Default: <tt>0.005</tt> (no smearing).</dd>
+ * <dt>"ERROR_STRIPS"</dt> <dd>The <tt>values</tt> argument should be a double value
+ * giving the minimal error to be assigned to hits in stripss, in millimeters.
+ * <br>Default: <tt>0.007</tt> (no smearing).</dd></dl>
+ *
+ * @param name Name of parameter to be set. Case is ignored.
+ * @param values Zero or more objects or numbers defining the value of the parameter.
+ * @throws NoSuchParameterException Thrown if the supplied parameter name is unknown.
+ */
+ public void set(String name, Object... values) {
+ Object value = values.length == 0 ? null : values[0];
+ try {
+ if (name.equalsIgnoreCase("ERROR_PIXELS")) {
+ _err2Pixels = ((Double) values[0]) * SystemOfUnits.mm;
+ _err2Pixels *= _err2Pixels;
+ } else if (name.equalsIgnoreCase("ERROR_STRIPS")) {
+ _err2Strips = ((Double) values[0]) * SystemOfUnits.mm;
+ _err2Strips *= _err2Strips;
+ } else {
+ throw new NoSuchParameterException(name, this.getClass());
+ }
+ } catch (ClassCastException x) {
+ throw new IllegalArgumentException(x);
+ } catch (ArrayIndexOutOfBoundsException xx){
+ throw new IllegalArgumentException(xx);
+ }
}
// -- Making and updating hits : ----------------------------------------------
@@ -47,7 +88,7 @@
double[] minDim = new double[]{Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE};
int[] minDimChannel = new int[3];
double[] posMean = new double[3];
- double[] pos2Mean = new double[3];
+// double[] pos2Mean = new double[3];
for (DigiTrackerHit digiHit : cluster.getDigiHits()) {
double s = digiHit.getSignal();
signal += s;
@@ -56,7 +97,7 @@
double[] dim = sType.getChannelDimensions(channel).v();
for (int i=0; i<3; i++) {
posMean[i] += pos[i]*s;
- pos2Mean[i] += pos[i]*pos[i]*s;
+// pos2Mean[i] += pos[i]*pos[i]*s;
if (dim[i] < minDim[i]) {
minDim[i] = dim[i];
minDimChannel[i] = channel;
@@ -64,23 +105,38 @@
}
}
- double[] pos = new double[3];
- double[] error = new double[3];
+// double[] pos = new double[3];
+// double[] error = new double[3];
for (int i=0; i<3; i++) {
posMean[i] /= signal;
- pos2Mean[i] /= signal;
- double err2 = pos2Mean[i] - posMean[i]*posMean[i];
- error[i] = (err2 > _err2Min) ? Math.sqrt(err2) : minDim[i]*_errFlat;
- pos[i] = posMean[i];
+// pos2Mean[i] /= signal;
+// double err2 = pos2Mean[i] - posMean[i]*posMean[i];
+// error[i] = (err2 > _err2Min) ? err2 : (minDim[i]*minDim[i])/12.;
+// pos[i] = posMean[i];
+ }
+
+ Transformation3D trans = sensor.getRotation();
+ double cU = 1.;
+ if (trans instanceof CartesianToCylindrical) {
+ cU = posMean[2];
+ } else if (trans instanceof Rotation3D) {
+ cU = 1.;
+ } else {
+ throw new RuntimeException("TrackerHitMakerBasic is only intended to work with flat or cylindrical sensors");
}
TrackerHit hit;
- SymmetricMatrix covMatrix = new SymmetricMatrix(3, new double[]{error[0], 0., error[1],0., 0., error[2]}, true);
if (sType.getHitDimension() == 1) { // Strips
- pos[1] = sType.getChannelPosition(minDimChannel[1]).y();
- hit = new TrackerHitSegment(cluster, new BasicHep3Vector(pos), minDim[1], covMatrix, true);
+ posMean[1] = sType.getChannelPosition(minDimChannel[1]).y();
+ double cUU = _err2Strips / (cU*cU);
+ double length = minDim[1];
+ double cVV = (length*length)/12.;
+ SymmetricMatrix cov = new SymmetricMatrix(3, new double[]{cUU, 0., cVV,0., 0., 0.}, true);
+ hit = new TrackerHitSegment(cluster, new BasicHep3Vector(posMean), length, cov, true);
} else { // Pixels
- hit = new TrackerHitPoint(cluster, new BasicHep3Vector(pos), covMatrix, true);
+ double cUU = _err2Pixels / (cU*cU);
+ SymmetricMatrix cov = new SymmetricMatrix(3, new double[]{cUU, 0., _err2Pixels,0., 0., 0.}, true);
+ hit = new TrackerHitPoint(cluster, new BasicHep3Vector(posMean), cov, true);
}
return hit;
}
@@ -101,7 +157,7 @@
}
// -- Helper methods: ---------------------------------------------------------
-
+
private Hep3Vector sqr(Hep3Vector v) {
double[] a = v.v();
for (int i=0; i<3; i++) a[i] = a[i]*a[i];
@@ -110,7 +166,6 @@
// -- Private parts : ---------------------------------------------------------
- private double _err2Min = (0.1 * SystemOfUnits.um) * (0.1 * SystemOfUnits.um);
- private double _errFlat = 1./Math.sqrt(12.);
-
+ private double _err2Pixels;
+ private double _err2Strips;
}