lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
diff -u -r1.4 -r1.5
--- CalGeometry.java 19 Mar 2009 06:08:03 -0000 1.4
+++ CalGeometry.java 19 Mar 2009 19:08:22 -0000 1.5
@@ -14,6 +14,7 @@
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.util.swim.Intersection;
import org.lcsim.contrib.onoprien.util.swim.Trajectory;
import org.lcsim.contrib.onoprien.util.swim.Surface;
import org.lcsim.contrib.onoprien.util.swim.ZCylinder;
@@ -25,7 +26,7 @@
* calling <tt>JobManager.defaultInstance().get(CalGeometry.class)</tt>.
*
* @author D. Onoprienko
- * @version $Id: CalGeometry.java,v 1.4 2009/03/19 06:08:03 onoprien Exp $
+ * @version $Id: CalGeometry.java,v 1.5 2009/03/19 19:08:22 onoprien Exp $
*/
abstract public class CalGeometry implements JobEventListener {
@@ -42,6 +43,7 @@
public void detectorChanged(JobEvent jEvent) {
_detector = jEvent.getDetector();
+ _de2cl = new HashMap<IDetectorElement, CalLayer>();
for (CalModule module : getModules()) {
for (CalLayer layer : module.getLayers()) {
_de2cl.put(layer.getDetectorElement(), layer);
@@ -96,7 +98,14 @@
* and the trajectory is not changed.
*/
public Hep3Vector propagateToLayer(Trajectory trajectory, CalLayer layer) {
- throw new UnsupportedOperationException(); // FIXME
+ Surface refSurface = layer.getReferenceSurface();
+ Intersection inter = refSurface.intersect(trajectory);
+ if (inter.hasNext()) {
+ trajectory.swim(inter.getPathLength());
+ return trajectory.getPosition();
+ } else {
+ return null;
+ }
}
/**
@@ -120,11 +129,31 @@
* <tt>CalLayer</tt> object associated with that layer is returned, and
* the origin of the supplied <tt>Trajectory</tt> is set to a point where it
* crosses that layer's reference surface. The origin of the specified trajectory
- * is assumed to be outside the calorimeter, no checking is done. If the trajectory
+ * is assumed to be inside the tracker volume, no checking is done. If the trajectory
* does not enter calorimeter, <tt>null</tt> is returned and the trajectory is not changed.
*/
- public CalLayer propagateToCalorimeter(Trajectory trajectory) {
- throw new UnsupportedOperationException(); // FIXME
+ public CalLayer propagateFromTracker(Trajectory trajectory) {
+ double sNext = Double.MAX_VALUE;
+ CalLayer nextLayer = null;
+ for (CalModule module : getModules()) {
+ if (module.isEntry()) {
+ CalLayer layer = module.getLayerByOrdinal(0);
+ Intersection inter = trajectory.intersect(layer.getReferenceSurface());
+ if (inter.hasNext()) {
+ double s = inter.getPathLength();
+ if (s < sNext) {
+ sNext = s;
+ nextLayer = layer;
+ }
+ }
+ }
+ }
+ if (nextLayer == null) {
+ return null;
+ } else {
+ trajectory.swim(sNext);
+ return nextLayer;
+ }
}
/**