15 added files
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N AcceptThreadedRosary_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AcceptThreadedRosary_Basic.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,30 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+import static org.lcsim.contrib.onoprien.crux.itc.Node.Type.*;
+
+/**
+ * Implements acceptThreadedRosary(Rosary rosary).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: AcceptThreadedRosary_Basic.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class AcceptThreadedRosary_Basic implements RosaryClusterer.AcceptThreadedRosary {
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Applies cuts to freshly threaded Rosaries, returning <tt>true</tt> is the Rosary should be kept.
+ * <p>
+ * Algorithm: keep Rosaries with more than one Dot.
+ *
+ * @param rosary Rosary being threaded.
+ */
+ public boolean acceptThreadedRosary(Rosary rosary) {
+ return rosary.getNodeCount(DOT) > 1;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N ChooseSeedLayers_FirstN.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ChooseSeedLayers_FirstN.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,101 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import java.util.*;
+
+import org.lcsim.contrib.onoprien.util.NoSuchParameterException;
+import org.lcsim.contrib.onoprien.util.job.Driver;
+import org.lcsim.contrib.onoprien.util.job.JobEvent;
+import org.lcsim.contrib.onoprien.util.job.JobEventListener;
+import org.lcsim.contrib.onoprien.util.job.JobManager;
+
+import org.lcsim.contrib.onoprien.crux.geom.CalLayer;
+import org.lcsim.contrib.onoprien.crux.itc.LayerData;
+import org.lcsim.contrib.onoprien.crux.itc.LayerDataBase;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+/**
+ * Implements chooseSeedLayers().
+ * <p>
+ * Selects first N layers in every entry module.
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ChooseSeedLayers_FirstN.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class ChooseSeedLayers_FirstN implements RosaryClusterer.ChooseSeedLayers, JobEventListener {
+
+// -- Private parts : ---------------------------------------------------------
+
+ private RosaryClusterer _clusterer;
+ private int _n;
+ ArrayList<CalLayer> _seedLayers;
+
+
+// -- Constructors and initialization : ---------------------------------------
+
+ public ChooseSeedLayers_FirstN(RosaryClusterer clusterer) {
+ _clusterer = clusterer;
+ _n = -1;
+ JobManager.defaultInstance().addListener(this);
+ }
+
+ public void detectorChanged(JobEvent jEvent) {
+ _seedLayers = null;
+ }
+
+
+// -- Setters : ---------------------------------------------------------------
+
+ /**
+ * Set any parameter.
+ * The following parameters can be set with this method:
+ * <p><dl>
+ * <dt>"N"</dt> <dd>Integer value. First N layers in every entry module will be
+ * used for seeding new Rosaries. Specifiing a negative number will choose all layers.
+ * <br>Default: -1 (all layers).</dd>
+ * </dl>
+ *
+ * @param name Name of parameter to be set. Case is ignored.
+ * @param values List of values to be used for setting the parameter.
+ * @throws NoSuchParameterException Thrown if the supplied parameter name is unknown.
+ * @throws IllegalArgumentException Thrown if incorrect number of values, or a value
+ * of incorrect type is supplied.
+ */
+ public void set(String name, Object... values) {
+ try {
+ if (name.equalsIgnoreCase("N")) {
+ _n = (Integer) values[0];
+ _seedLayers = null;
+ } else {
+ throw new NoSuchParameterException(name);
+ }
+ } catch (ClassCastException x) {
+ throw new IllegalArgumentException(Driver.ERR_VIT + name, x);
+ }
+ }
+
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Returns first N layers in every entry module.
+ * The order is the same as in the clusterer's layer database.
+ * N can be spesified through a call to {@link #set set("N", numberOfSeedLayers)}.
+ * The list is compiled once after detector information has changed, and cached.
+ */
+ public List<CalLayer> chooseSeedLayers() {
+ if (_seedLayers == null) {
+ LayerDataBase layerDB = _clusterer.getLayerDB();
+ _seedLayers = new ArrayList<CalLayer>(layerDB.size());
+ for (LayerData data : layerDB) {
+ CalLayer layer = data.cruxLayer;
+ if (_n < 0 || (layer.getModule().isEntry() && layer.getLayerOrdinal() < _n)) {
+ _seedLayers.add(layer);
+ }
+ }
+ _seedLayers.trimToSize();
+ }
+ return _seedLayers;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N ComputeTrajectory_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ComputeTrajectory_Basic.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,69 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import java.util.*;
+
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
+import org.lcsim.contrib.onoprien.util.swim.Line;
+import org.lcsim.contrib.onoprien.util.swim.Trajectory;
+
+import org.lcsim.contrib.onoprien.crux.geom.CalLayer;
+import org.lcsim.contrib.onoprien.crux.itc.Bead;
+import org.lcsim.contrib.onoprien.crux.itc.Crack;
+import org.lcsim.contrib.onoprien.crux.itc.Dot;
+import org.lcsim.contrib.onoprien.crux.itc.LayerData;
+import org.lcsim.contrib.onoprien.crux.itc.Node;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+import static org.lcsim.contrib.onoprien.crux.itc.Node.Type.*;
+
+/**
+ *
+ *
+ * @author D. Onoprienko
+ * @version $Id: ComputeTrajectory_Basic.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class ComputeTrajectory_Basic implements RosaryClusterer.ComputeTrajectory {
+
+// -- Private parts : ---------------------------------------------------------
+
+
+
+// -- Constructors and initialization : ---------------------------------------
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Computes trajectory going out of the specified Rosary, and assigns it to that Rosary.
+ * <p>
+ * Algorithm :
+ *
+ * @param rosary Rosary being threaded.
+ */
+ public Trajectory computeTrajectory(Rosary rosary) {
+
+ int _nDotsFit = 2;
+
+ ArrayList<Node> tailDots = rosary.getTailNodes(_nDotsFit, Node.Type.DOT);
+ int nDots = tailDots.size();
+ if (nDots > 2) {
+ // FIXME - Fit
+ } else if (nDots == 2) {
+ Hep3Vector pos0 = ((Dot)tailDots.get(0)).getPosition();
+ Hep3Vector pos1 = ((Dot)tailDots.get(1)).getPosition();
+ rosary.setTrajectory(new Line(pos1, VecOp.sub(pos1, pos0)));
+ } else if (rosary.isTracked()) {
+ // Do nothing, use track which is already set
+ } else {
+ // Single Dot untracked rosary - if FORWARD, trajectory is already set. Otherwise, point back to center
+ if (rosary.getThreadingDirection() == Rosary.ThreadDirection.BACK) {
+ Hep3Vector pos = ((Dot)tailDots.get(0)).getPosition();
+ rosary.setTrajectory(new Line(pos, VecOp.neg(pos)));
+ }
+ }
+ return rosary.getTrajectory();
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N ContinueStepping_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ContinueStepping_Basic.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,44 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+import static org.lcsim.contrib.onoprien.crux.itc.Node.Type.*;
+
+/**
+ * Implements continueStepping(Rosary rosary).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ContinueStepping_Basic.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class ContinueStepping_Basic implements RosaryClusterer.ContinueStepping {
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Called at the end of step, returns <tt>true</tt> if the Rosary should be threaded further in the current direction.
+ * <p>
+ * Algorithm:
+ * <ul>
+ * <li>Always keep threading if the last layer is not a crack. Otherwise,
+ * <li>Stop if more than one crack in a row.
+ * <li>Stop if untracked single cluster rosary.
+ * </ul>
+ *
+ * @param rosary Rosary being threaded.
+ */
+ public boolean continueStepping(Rosary rosary) {
+
+ int tailCracks = rosary.getTailCrackCount();
+ if (tailCracks == 0) return true; // always keep threading if the last layer is not a crack
+
+ if (tailCracks > 1) return false; // stop if more than one crack in a row
+
+ if (! rosary.isTracked() && rosary.getNodeCount(DOT, BEAD) == 1) return false; // stop if untracked single cluster rosary
+
+ return true;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N ReverseThreadingDirection_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ReverseThreadingDirection_Basic.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,50 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+/**
+ * Implements reverseThreadingDirection(Rosary rosary).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ReverseThreadingDirection_Basic.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class ReverseThreadingDirection_Basic implements RosaryClusterer.ReverseThreadingDirection {
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Reverses threading direction of the Rosary, returns <tt>true</tt> if further threading is required.
+ * <p>
+ * Algorithm:
+ * <ul>
+ * <li>If the direction was FORWARD: if the Rosary includes a track, return <tt>false</tt>;
+ * otherwise, set direction to BACK, reverse the Rosary, and return <tt>true</tt>.
+ * <li>If the direction was BACK: set it to THREADED, reverse the Rosary, and return <tt>false</tt>.
+ * <li>If the direction was THREADED: return <tt>false</tt>.
+ * </ul>
+ *
+ * @param rosary Rosary being threaded.
+ */
+ public boolean reverseThreadingDirection(Rosary rosary) {
+ Rosary.ThreadDirection thDir = rosary.getThreadingDirection();
+ if (thDir == Rosary.ThreadDirection.FORWARD) {
+ if (rosary.isTracked()) {
+ return false;
+ } else {
+ rosary.setThreadingDirection(Rosary.ThreadDirection.BACK);
+ rosary.reverseDirection();
+ return true;
+ }
+ } else if (thDir == Rosary.ThreadDirection.BACK) {
+ rosary.setThreadingDirection(Rosary.ThreadDirection.THREADED);
+ rosary.reverseDirection();
+ return false;
+ } else {
+ return false;
+ }
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N SearchForBead_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SearchForBead_Basic.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,39 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.util.swim.Trajectory;
+
+import org.lcsim.contrib.onoprien.crux.itc.Bead;
+import org.lcsim.contrib.onoprien.crux.itc.LayerData;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+/**
+ * Implements searchForBead(Rosary rosary, Trajectory trajectory, LayerData layerData).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: SearchForBead_Basic.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class SearchForBead_Basic implements RosaryClusterer.SearchForBead {
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Returns Bead that should be attached to the given rosary in the given layer (<tt>null</tt> if none).
+ * <p>
+ * Algorithm: attach Bead if it contains the cell where trajectory crosses the layer.
+ *
+ * @param rosary Rosary being threaded.
+ * @param trajectory Rosary's trajectory, with its origin in the current layer (the layer where Bead is being searched for).
+ * @param layerData Data for the current layer.
+ */
+ public Bead searchForBead(Rosary rosary, Trajectory trajectory, LayerData layerData) {
+ if (layerData.beads.isEmpty()) return null;
+ Hep3Vector pos = trajectory.getPosition();
+ return layerData.beadMap.get(layerData.decoder.findCellContainingXYZ(pos));
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N SearchForDots_NN.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SearchForDots_NN.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,71 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import java.util.*;
+
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.util.swim.Trajectory;
+
+import org.lcsim.contrib.onoprien.crux.itc.LayerData;
+import org.lcsim.contrib.onoprien.crux.itc.Dot;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+/**
+ * Implements searchForDots(Rosary rosary, Trajectory trajectory, LayerData layerData).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: SearchForDots_NN.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class SearchForDots_NN implements RosaryClusterer.SearchForDots {
+
+// -- Private parts : ---------------------------------------------------------
+
+ RosaryClusterer _clusterer;
+
+
+// -- Constructors and initialization : ---------------------------------------
+
+ public SearchForDots_NN(RosaryClusterer clusterer) {
+ _clusterer = clusterer;
+ }
+
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Returns a list of Dots that can be attached to the given Rosary in the specified layer,
+ * in order of increasing distance from the trajectory.
+ * <p>
+ * Algorithm: If there is a dot that contains the cell where the
+ * trajectory crosses the layer, return it as the only choice. Otherwise, look for
+ * Dots that contain at least one of the nearest neighbours.
+ *
+ * @param rosary Rosary being threaded.
+ * @param trajectory Rosary's trajectorry, with its origin in the current layer.
+ * @param layerData Data for the current layer.
+ */
+ public List<Dot> searchForDots(Rosary rosary, Trajectory trajectory, LayerData layerData) {
+ Hep3Vector pos = trajectory.getPosition();
+ long cell = layerData.decoder.findCellContainingXYZ(pos);
+ Dot dot = layerData.dotMap.get(cell);
+ ArrayList<Dot> out;
+ if (dot != null) {
+ out = new ArrayList<Dot>(1);
+ out.add(dot);
+ } else {
+ long[] neighbors = layerData.decoder.getNeighbourIDs(0, 1, 1);
+ HashSet<Dot> dotSet = new HashSet<Dot>();
+ for (long cellID : neighbors) {
+ dot = layerData.dotMap.get(cellID);
+ if (dot != null) dotSet.add(dot);
+ }
+ out = new ArrayList<Dot>(dotSet);
+ Collections.sort(out, _clusterer.getDistanceToPointNodeComparator(pos));
+ }
+ return out;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N SearchForProximityDots_NN.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SearchForProximityDots_NN.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,76 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import java.util.*;
+
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.util.job.JobManager;
+import org.lcsim.contrib.onoprien.util.swim.Trajectory;
+
+import org.lcsim.contrib.onoprien.crux.geom.CalGeometry;
+import org.lcsim.contrib.onoprien.crux.itc.LayerData;
+import org.lcsim.contrib.onoprien.crux.itc.Dot;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+import static org.lcsim.contrib.onoprien.crux.itc.Node.Type.*;
+
+/**
+ * Implements searchForProximityDots(Rosary rosary, Trajectory trajectory, LayerData layerData).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: SearchForProximityDots_NN.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class SearchForProximityDots_NN implements RosaryClusterer.SearchForProximityDots {
+
+// -- Private parts : ---------------------------------------------------------
+
+ RosaryClusterer _clusterer;
+ CalGeometry _geom;
+
+
+// -- Constructors and initialization : ---------------------------------------
+
+ public SearchForProximityDots_NN(RosaryClusterer clusterer) {
+ _clusterer = clusterer;
+ _geom = JobManager.defaultInstance().get(CalGeometry.class);
+ }
+
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Returns a list of unattached Dots that can be attached based on proximity, in
+ * the increasing distance from the dot in the previous layer order.
+ * <p>
+ * Algorithm: Include Dots that contain at least one of the nearest neighbours
+ * of the cell closest to the Dot in previous layer.
+ *
+ * @param rosary Rosary being threaded.
+ * @param trajectory Rosary's trajectory, with its origin in the current layer
+ * (the layer where Dots are being searched for).
+ * @param layerData Data for the current layer.
+ */
+ public List<Dot> searchForProximityDots(Rosary rosary, Trajectory trajectory, LayerData layerData) {
+ Dot oldDot = (Dot) rosary.getTailNode(DOT);
+ Hep3Vector oldPos = oldDot.getPosition();
+ Hep3Vector newPos = _geom.getClosestPointOnLayer(oldPos, layerData.cruxLayer);
+ long cell = layerData.decoder.findCellContainingXYZ(newPos);
+ layerData.decoder.setID(cell);
+ long[] neighbors = layerData.decoder.getNeighbourIDs();
+ HashSet<Dot> dotSet = new HashSet<Dot>();
+ for (int i=-1; i<neighbors.length; i++) {
+ long cellID = (i == -1) ? cell : neighbors[i];
+ Dot dot = layerData.dotMap.get(cellID);
+ if (dot != null && dot.getRosaries().isEmpty()) {
+ dotSet.add(dot);
+ }
+ }
+ ArrayList<Dot> out = new ArrayList<Dot>(dotSet);
+ Collections.sort(out, _clusterer.getDistanceToPointNodeComparator(oldPos));
+ return out;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N SeedFromDot_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SeedFromDot_Basic.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,36 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.util.swim.Line;
+
+import org.lcsim.contrib.onoprien.crux.itc.Dot;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+/**
+ * Implements seedFromDot(Dot dot).
+ * <p>
+ * Single node of type Dot, trajectory is set to a Line pointing from the origin to the Dot position.
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: SeedFromDot_Basic.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class SeedFromDot_Basic implements RosaryClusterer.SeedFromDot {
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Creates and returns seed Rosary created from the specified Dot.
+ * Creates a single node of type Dot, trajectory is set to a Line pointing from the origin to the Dot position.
+ */
+ public Rosary seedFromDot(Dot dot) {
+ Rosary rosary = new Rosary();
+ rosary.addNode(dot);
+ Hep3Vector pos = dot.getPosition();
+ rosary.setTrajectory(new Line(pos, pos));
+ return rosary;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N SeedFromTrack_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SeedFromTrack_Basic.java 29 Mar 2009 23:44:23 -0000 1.1
@@ -0,0 +1,32 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import org.lcsim.contrib.onoprien.crux.infrastructure.ITrack;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+import org.lcsim.contrib.onoprien.crux.itc.Track;
+
+/**
+ * Implements seedFromTrack(ITrack track).
+ * <p>
+ * Single node of type TRACK, trajectory is set to the track trajectory at last hit.
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: SeedFromTrack_Basic.java,v 1.1 2009/03/29 23:44:23 onoprien Exp $
+ */
+public class SeedFromTrack_Basic implements RosaryClusterer.SeedFromTrack {
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Creates and returns seed Rosary created from the specified track.
+ * Creates a single node of type TRACK, trajectory is set to the track trajectory at last hit.
+ */
+ public Rosary seedFromTrack(ITrack track) {
+ Rosary rosary = new Rosary();
+ rosary.addNode(new Track(track));
+ rosary.setTrajectory(track.getTrajectory(ITrack.Point.LAST_HIT));
+ return rosary;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N SelectRosaries_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SelectRosaries_Basic.java 29 Mar 2009 23:44:24 -0000 1.1
@@ -0,0 +1,32 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import java.util.*;
+
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+/**
+ * Implements selectRosaries(ArrayList<Rosary> rosaries).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: SelectRosaries_Basic.java,v 1.1 2009/03/29 23:44:24 onoprien Exp $
+ */
+public class SelectRosaries_Basic implements RosaryClusterer.SelectRosaries {
+
+// -- Algorithms : ------------------------------------------------------------
+
+ /**
+ * Applies quality cuts, removes duplicates, and returns a list of rosaries
+ * that should be saved into the event record.
+ * <p>
+ * Algorithm : no filtering, keep all Rosaries.
+ *
+ * @param rosaries Rosary being threaded.
+ */
+ public ArrayList<Rosary> selectRosaries(ArrayList<Rosary> rosaries) {
+ return rosaries;
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N Step_Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Step_Basic.java 29 Mar 2009 23:44:24 -0000 1.1
@@ -0,0 +1,122 @@
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
+import java.util.*;
+
+import org.lcsim.contrib.onoprien.util.job.JobManager;
+import org.lcsim.contrib.onoprien.util.swim.Trajectory;
+
+import org.lcsim.contrib.onoprien.crux.geom.CalGeometry;
+import org.lcsim.contrib.onoprien.crux.geom.CalLayer;
+import org.lcsim.contrib.onoprien.crux.itc.Bead;
+import org.lcsim.contrib.onoprien.crux.itc.Crack;
+import org.lcsim.contrib.onoprien.crux.itc.Dot;
+import org.lcsim.contrib.onoprien.crux.itc.Rosary;
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
+import static org.lcsim.contrib.onoprien.crux.itc.Node.Type.*;
+
+/**
+ * Implements step(Rosary rosary, Queue<Rosary> seeds).
+ * <p>
+ * See methods javadoc for details on algorithms and implementations.
+ *
+ * @author D. Onoprienko
+ * @version $Id: Step_Basic.java,v 1.1 2009/03/29 23:44:24 onoprien Exp $
+ */
+public class Step_Basic implements RosaryClusterer.Step {
+
+// -- Private parts : ---------------------------------------------------------
+
+ protected RosaryClusterer _clusterer;
+ protected CalGeometry _geom;
+
+
+// -- Constructors and initialization : ---------------------------------------
+
+ public Step_Basic(RosaryClusterer clusterer) {
+ _clusterer = clusterer;
+ _geom = JobManager.defaultInstance().get(CalGeometry.class);
+ }
+
+
+// -- Algorithms : ------------------------------------------------------------
+
+
+ /**
+ * Adds clusters in the next layer, returns <tt>true</tt> if the Rosary needs to be threaded further.
+ * If new Rosaries are created in the process, they are added to the queue.
+ * <p>
+ * Algorithm:
+ * <ul>
+ * <li>Compute trajectory at the current layer by calling
+ * {@link ComputeTrajectory#computeTrajectory computeTrajectory(Rosary)}.
+ * <li>Propagate trajectory to the next layer. If no next layer, return
+ * {@link ReverseThreadingDirection#reverseThreadingDirection reverseThreadingDirection(Rosary)}.
+ * <li>Call {@link SearchForDots#searchForDots searchForDots(Rosary, Trajectory, LayerData)}.
+ * Attach found Dots to the Rosary. If more than one Dot
+ * is found, branch (clone the Rosary and add the clones to the queue).
+ * <li>If no Dots found, call {@link SearchForBead#searchForBead searchForBead(Rosary, Trajectory, LayerData)}.
+ * If a Bead is found, attach it to the Rosary.
+ * <li>If no Beads found, and this is an untracked single Dot Rosary, call
+ * {@link SearchForProximityDots#searchForProximityDots searchForProximityDots(Rosary, Trajectory, LayerData)}.
+ * If found, attach. If more than one, branch.
+ * <li>If nothing has been attached in this layer, attach Crack.
+ * <li>Call {@link ContinueStepping#continueStepping continueStepping(Rosary)}.
+ * If <tt>true</tt>, return <tt>true</tt>. If <tt>false</tt>, return
+ * {@link ReverseThreadingDirection#reverseThreadingDirection reverseThreadingDirection(Rosary)}.
+ * </ul>
+ */
+ public boolean step(Rosary rosary, Queue<Rosary> seeds) {
+
+ Trajectory trajectory = _clusterer.getComputeTrajectory().computeTrajectory(rosary);
+ CalLayer currentLayer = rosary.getTailNode().getLayer();
+ CalLayer layer;
+ if (currentLayer == null) {
+ layer = _geom.propagateFromTracker(trajectory);
+ } else {
+ layer = _geom.propagateToNextLayer(currentLayer, trajectory);
+ }
+ if (layer == null) {
+ return _clusterer.getReverseThreadingDirection().reverseThreadingDirection(rosary);
+ }
+
+ List<Dot> dots = _clusterer.getSearchForDots().searchForDots(rosary, trajectory, _clusterer.getLayerDB().get(layer));
+ int nDots = dots.size();
+ if (nDots > 0) {
+ rosary.addNode(dots.get(0));
+ for (int i=1; i<nDots; i++) {
+ Rosary branch = new Rosary(rosary);
+ branch.addNode(dots.get(i));
+ seeds.add(branch);
+ }
+ } else {
+ Bead bead = _clusterer.getSearchForBead().searchForBead(rosary, trajectory, _clusterer.getLayerDB().get(layer));
+ if (bead != null) {
+ rosary.addNode(bead);
+ } else {
+ if (rosary.getNodeCount(DOT) == 1 && !rosary.isTracked()) {
+ dots = _clusterer.getSearchForProximityDots().searchForProximityDots(rosary, trajectory, _clusterer.getLayerDB().get(layer));
+ nDots = dots.size();
+ if (nDots > 0) {
+ rosary.addNode(dots.get(0));
+ for (int i=1; i<nDots; i++) {
+ Rosary branch = new Rosary(rosary);
+ branch.addNode(dots.get(i));
+ seeds.add(branch);
+ }
+ } else {
+ rosary.addNode(new Crack(layer));
+ }
+ } else {
+ rosary.addNode(new Crack(layer));
+ }
+ }
+ }
+ if (_clusterer.getContinueStepping().continueStepping(rosary)) {
+ return true;
+ } else {
+ return _clusterer.getReverseThreadingDirection().reverseThreadingDirection(rosary);
+ }
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/algorithms
diff -N package-info.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ package-info.java 29 Mar 2009 23:44:24 -0000 1.1
@@ -0,0 +1,10 @@
+/**
+ * Plugins for {@link RosaryClusterer} implementing various options for various
+ * steps of the clustering algorithm. Can be mixed-and-matched to create a customized
+ * version of the clusterer - see {@link org.lcsim.contrib.onoprien.crux.itc.drivers} package
+ * for examples.
+ *
+ * @author D. Onoprienko
+ */
+package org.lcsim.contrib.onoprien.crux.itc.algorithms;
+
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/drivers
diff -N CatClusterer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CatClusterer.java 29 Mar 2009 23:44:24 -0000 1.1
@@ -0,0 +1,44 @@
+package org.lcsim.contrib.onoprien.crux.itc.drivers;
+
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+import org.lcsim.contrib.onoprien.crux.itc.algorithms.*;
+
+/**
+ *
+ *
+ * @author D. Onoprienko
+ * @version $Id: CatClusterer.java,v 1.1 2009/03/29 23:44:24 onoprien Exp $
+ */
+public class CatClusterer extends RosaryClusterer {
+
+// -- Private parts : ---------------------------------------------------------
+
+
+
+// -- Constructors and initialization : ---------------------------------------
+
+ public CatClusterer() {
+
+ ChooseSeedLayers_FirstN chooseSeedLayers = new ChooseSeedLayers_FirstN(this);
+ chooseSeedLayers.set("N", 0);
+ setChooseSeedLayers(chooseSeedLayers);
+
+ setSeedFromTrack(new SeedFromTrack_Basic());
+ setSeedFromDot(new SeedFromDot_Basic());
+
+ setStep(new Step_Basic(this));
+
+ setSearchForDots(new SearchForDots_NN(this));
+ setSearchForBead(new SearchForBead_Basic());
+ setSearchForProximityDots(new SearchForProximityDots_NN(this));
+
+ setReverseThreadingDirection(new ReverseThreadingDirection_Basic());
+ setContinueStepping(new ContinueStepping_Basic());
+ setAcceptThreadedRosary(new AcceptThreadedRosary_Basic());
+ setSelectRosaries(new SelectRosaries_Basic());
+ setComputeTrajectory(new ComputeTrajectory_Basic());
+
+ }
+
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/itc/drivers
diff -N package-info.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ package-info.java 29 Mar 2009 23:44:24 -0000 1.1
@@ -0,0 +1,9 @@
+/**
+ * Ready-to-use subclasses of {@link RosaryClusterer}, with plug-ins selected.
+ *
+ * @author D. Onoprienko
+ */
+package org.lcsim.contrib.onoprien.crux.itc.drivers;
+
+import org.lcsim.contrib.onoprien.crux.itc.RosaryClusterer;
+
CVSspam 0.2.8