Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux on MAIN
SiD02Geometry.java+246added 1.1
CruxManager.java+3-31.4 -> 1.5
geom/CalGeometry.java+55-141.6 -> 1.7
    /CalModule.java+15-11.3 -> 1.4
    /DefaultCalGeometry.java-1891.2 removed
+319-207
1 added + 1 removed + 3 modified, total 5 files
Remove the kludge, use fixed layer ID

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux
SiD02Geometry.java added at 1.1
diff -N SiD02Geometry.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SiD02Geometry.java	24 Mar 2009 20:12:41 -0000	1.1
@@ -0,0 +1,246 @@
+package org.lcsim.contrib.onoprien.crux;
+import java.util.*;
+
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IDetectorElementVisitor;
+import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.Subdetector;
+
+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.Trajectory;
+
+import org.lcsim.contrib.onoprien.crux.geom.CalGeometry;
+import org.lcsim.contrib.onoprien.crux.geom.CalLayer;
+import org.lcsim.contrib.onoprien.crux.geom.CalModule;
+
+import static org.lcsim.contrib.onoprien.crux.geom.CalModule.Attribute.*;
+
+/**
+ * Generic {@link CalGeometry} implementation suitable for SiD cylindrical calorimeter.
+ * Optimized implementations can be written for particular detectors to improve performance.
+ * <p>
+ * 6 modules are created, one for each endcap and one for the barrel, both for ECAL and HCAL.
+ *
+ * @author D. Onoprienko
+ * @version $Id: SiD02Geometry.java,v 1.1 2009/03/24 20:12:41 onoprien Exp $
+ */
+public class SiD02Geometry extends CalGeometry implements JobEventListener {
+
+// -- Private parts :  ---------------------------------------------------------
+
+  private List<CalModule> _modules;
+  private CalModule _eBar, _hBar, _eSouthEnd, _eNorthEnd, _hSouthEnd, _hNorthEnd;
+
+
+// -- Constructors and initialization :  ---------------------------------------
+  
+  public SiD02Geometry() {
+    JobManager.defaultInstance().addListener(this);
+  }
+  
+  public void detectorChanged(JobEvent jEvent) {
+
+    // create modules
+
+    _eBar = new CalModule("ECAL_BARREL", EnumSet.of(ECAL, BARREL, ENTRY), "EMBarrel");
+    _hBar = new CalModule("HCAL_BARREL", EnumSet.of(HCAL, BARREL, EXIT), "HADBarrel");
+    _eSouthEnd = new CalModule("ECAL_ENDCAP_SOUTH", EnumSet.of(ECAL, ENDCAP, SOUTH, ENTRY), "EMEndcap");
+    _eNorthEnd = new CalModule("ECAL_ENDCAP_NORTH", EnumSet.of(ECAL, ENDCAP, NORTH, ENTRY), "EMEndcap");
+    _hSouthEnd = new CalModule("HCAL_ENDCAP_SOUTH", EnumSet.of(HCAL, ENDCAP, SOUTH, EXIT), "HADEndcap");
+    _hNorthEnd = new CalModule("HCAL_ENDCAP_NORTH", EnumSet.of(HCAL, ENDCAP, NORTH, EXIT), "HADEndcap");
+
+    _modules = new ArrayList<CalModule>(6);
+    Collections.addAll(_modules, _eBar, _hBar, _eSouthEnd, _eNorthEnd, _hSouthEnd, _hNorthEnd);
+    _modules = Collections.unmodifiableList(_modules);
+
+    // create layers
+
+    Detector det = jEvent.getDetector();
+    int idOffset = 0;
+    int moduleID = 0;
+    for (final CalModule module : _modules) {
+      Subdetector sd = det.getSubdetector(module.getSubdetectorName());
+      final List<IDetectorElement> deList = new ArrayList<IDetectorElement>(50);
+      sd.getDetectorElement().traverseDescendantsPreOrder(new IDetectorElementVisitor() {
+        public void visit(IDetectorElement de) {
+          if (de.isSensitive())  {
+            if (module.isBarrel()) {
+              deList.add(de);
+            } else {
+              IGeometryInfo gInfo = de.getGeometry();
+              double z = gInfo.getPosition().z();
+              if ((z > 0. && module.isNorth()) || (z < 0. && module.isSouth())) {
+                deList.add(de);
+              }
+            }
+          }
+        }
+        public boolean isDone() {return false;}
+      });
+      TreeMap<Integer, IDetectorElement> deMap = new TreeMap<Integer, IDetectorElement>();
+      for (IDetectorElement de : deList) {
+
+        int idLayerIndex = de.getIdentifierHelper().getFieldIndex("layer");
+        int layer = de.getExpandedIdentifier().getValue(idLayerIndex);
+
+        //String name = de.getName();
+        //name = name.replaceFirst(".*layer","");
+        //name = name.replaceFirst("_.*","");
+        //int layer = Integer.parseInt(name);
+
+        IDetectorElement duplicate = deMap.put(layer, de);
+        if (duplicate != null) throw new RuntimeException("More than 1 DetectorElement in the same layer");
+      }
+      ArrayList<CalLayer> layerList = new ArrayList<CalLayer>(deMap.size());
+      int ordinal = 0;
+      for (Map.Entry<Integer, IDetectorElement> entry : deMap.entrySet()) {
+        int layer = entry.getKey();
+        int id = idOffset + layer;
+        layerList.add(new CalLayer(module, entry.getValue(), ordinal, id, layer));
+        ordinal++;
+      }
+      module.initialize(moduleID++, sd, layerList);
+      idOffset += layerList.size();
+    }
+
+    // CalGeometry initialization
+
+    super.detectorChanged(jEvent);
+  }
+
+
+// -- Implementing CalGeometry :  ----------------------------------------------
+
+  /** Returns an unmodifiable list of calorimeter modules, ordered by module ID. */
+  public List<CalModule> getModules() {
+    return _modules;
+  }
+
+  /**
+   * Returns the next layer the specified trajectory is most likely to cross after coming out of the
+   * specified layer. The origin of the trajectory should belong to the specified layer - no checking is done.
+   */
+  public CalLayer nextLayer(CalLayer layer, Trajectory trajectory) {
+    boolean pointingOut;
+    CalModule module = layer.getModule();
+    Hep3Vector dir = trajectory.getDirection();
+    if (module.isBarrel()) {
+      Hep3Vector pos = trajectory.getPosition();
+      pointingOut = dir.x()*pos.x() + dir.y()*pos.y() > 0. ;
+    } else if (module.isNorth()) {
+      pointingOut = dir.z() > 0.;
+    } else {
+      pointingOut = dir.z() < 0.;
+    }
+    int nextOrdinal = layer.getLayerOrdinal() + ( (pointingOut) ? 1 : -1 );
+    try {
+      return module.getLayerByOrdinal(nextOrdinal);
+    } catch (IndexOutOfBoundsException x) {
+      if (module == _eBar) {
+        if (nextOrdinal == 0) {
+          return null;
+        } else {
+          return _hBar.firstLayer();
+        }
+      } else if (module == _hBar) {
+        if (nextOrdinal == 0) {
+          return _eBar.lastLayer();
+        } else {
+          return null;
+        }
+      } else if (module == _eNorthEnd) {
+        if (nextOrdinal == 0) {
+          return null;
+        } else {
+          return _hNorthEnd.firstLayer();
+        }
+      } else if (module == _eSouthEnd) {
+        if (nextOrdinal == 0) {
+          return null;
+        } else {
+          return _hSouthEnd.firstLayer();
+        }
+      } else if (module == _hNorthEnd) {
+        if (nextOrdinal == 0) {
+          return _eNorthEnd.lastLayer();
+        } else {
+          return null;
+        }
+      } else if (module == _hSouthEnd) {
+        if (nextOrdinal == 0) {
+          return _eSouthEnd.lastLayer();
+        } else {
+          return null;
+        }
+      } else {
+        throw new RuntimeException();
+      }
+    }
+  }
+
+  /**
+   * Returns a list of layers the specified trajectory might cross after coming out of the
+   * given layer - more likely first (but excluding the most likely one that would be returned
+   * by <tt>nextLayer</tt>). The origin of the trajectory should belong to the
+   * specified layer - no checking is done.
+   */
+  public List<CalLayer> nextLayers(CalLayer layer, Trajectory trajectory) {
+    Hep3Vector dir = trajectory.getDirection();
+    Hep3Vector pos = trajectory.getPosition();
+    CalModule module = layer.getModule();
+    boolean isFirstLayer = module.firstLayer() == layer;
+    boolean isLastLayer = module.lastLayer() == layer;
+    double dz = dir.z();
+    //double dirR = pos.x()*dir.x() + pos.y()*dir.y();
+    double dirZ = dz*pos.z();
+    if (module == _eBar) {
+      if (isFirstLayer) {
+        return Collections.emptyList();  // FIXME: loosing trajectories going into ECAL endcap (few, on reverse only)
+      } else {
+        if (dz > 0.) {
+          return Collections.singletonList(_hNorthEnd.firstLayer());
+        } else {
+          return Collections.singletonList(_hSouthEnd.firstLayer());
+        }
+      }
+    } else if (module == _hBar) {
+      if (isFirstLayer) {
+        if (dz > 0.) {
+          return _hNorthEnd.getLayers();
+        } else {
+          return _hSouthEnd.getLayers();
+        }
+      } else {
+        return Collections.emptyList();
+      }
+    } else if (module == _eNorthEnd || module == _eSouthEnd) {
+      if (isFirstLayer || isLastLayer) {
+        return Collections.emptyList();
+      } else {
+        return Collections.singletonList(_eBar.firstLayer());
+      }
+    } else if (module == _hNorthEnd || module == _hSouthEnd) {
+      if (isLastLayer) {
+        return Collections.emptyList();
+      } else if (isFirstLayer && dirZ < 0.) {
+        return _eBar.getLayers();
+      } else {
+        return Collections.singletonList(_hBar.firstLayer());
+      }
+    } else {
+      throw new RuntimeException();
+    }
+  }
+
+  /**
+   * Returns a list of layers the specified trajectory might cross next - more likely first.
+   */
+  public CalLayer nextLayer(Trajectory trajectory) {
+    throw new UnsupportedOperationException();
+  }
+
+}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux
CruxManager.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- CruxManager.java	19 Mar 2009 06:08:02 -0000	1.4
+++ CruxManager.java	24 Mar 2009 20:12:41 -0000	1.5
@@ -1,6 +1,6 @@
 package org.lcsim.contrib.onoprien.crux;
 
-import org.lcsim.contrib.onoprien.crux.geom.DefaultCalGeometry;
+import org.lcsim.contrib.onoprien.crux.SiD02Geometry;
 import java.util.logging.Level;
 
 import org.lcsim.contrib.onoprien.util.job.Driver;
@@ -13,7 +13,7 @@
  * Driver that initializes Crux PFA package and provides miscellaneous services to other classes.<br>
  * Current functionality:<ul>
  * <li>Provides access to {@link CalGeometry} object that handles various geometry related tasks required by other classes.
- * <li>Provides access to {@link DefaultCalGeometry} object - all kinds of data specific functionality.
+ * <li>Provides access to {@link SiD02Geometry} object - all kinds of data specific functionality.
  * <li>Allows setting the default {@link CruxClusterValidator}.
  * </ul>
  * 
@@ -21,7 +21,7 @@
  * 
  * 
  * @author D. Onoprienko
- * @version $Id: CruxManager.java,v 1.4 2009/03/19 06:08:02 onoprien Exp $
+ * @version $Id: CruxManager.java,v 1.5 2009/03/24 20:12:41 onoprien Exp $
  */
 public class CruxManager extends Driver {
   

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
CalGeometry.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- CalGeometry.java	21 Mar 2009 05:27:49 -0000	1.6
+++ CalGeometry.java	24 Mar 2009 20:12:41 -0000	1.7
@@ -30,12 +30,15 @@
  * class must implement abstract methods {@link #getModules()},
  * {@link #nextLayers(Trajectory) nextLayers(Trajectory)}, and
  * {@link #nextLayers(CalLayer, Trajectory) nextLayers(CalLayer, Trajectory)}, dividing
- * the calorimeter into modules and defining neighbor relations between them. Default
- * implementation capabale of handling simple geometries
- * is available - see {@link DefaultCalGeometry}.
+ * the calorimeter into modules and defining neighbor relations between them. If a subclass
+ * overrides {@link #detectorChanged(JobEvent) detectorChanged(JobEvent)}, it should call
+ * <tt>super.detectorChanged(JobEvent)</tt> after its own initialization. 
+ * <p>
+ * Simple generic implementation capable of handling SiD-like geometries with cylindrical
+ * calorimeters is available - see {@link SiD02Geometry}.
  * 
  * @author D. Onoprienko
- * @version $Id: CalGeometry.java,v 1.6 2009/03/21 05:27:49 onoprien Exp $
+ * @version $Id: CalGeometry.java,v 1.7 2009/03/24 20:12:41 onoprien Exp $
  */
 abstract public class CalGeometry implements JobEventListener {
 
@@ -68,16 +71,29 @@
   abstract public List<CalModule> getModules();
 
   /**
+   * Returns the next layer the specified trajectory is most likely to cross after coming out of the
+   * specified layer. The origin of the trajectory should belong to the specified layer - no checking is done.
+   */
+  abstract public CalLayer nextLayer(CalLayer layer, Trajectory trajectory);
+
+  /**
+   * Returns the next layer the specified trajectory is most likely to cross.
+   */
+  abstract public CalLayer nextLayer(Trajectory trajectory);
+
+  /**
    * Returns a list of layers the specified trajectory might cross after coming out of the
-   * given layer - more likely first. The origin of the trajectory should belong to the
+   * given layer - more likely first (but excluding the most likely one that would be returned
+   * by <tt>nextLayer</tt>). The origin of the trajectory should belong to the
    * specified layer - no checking is done.
    */
   abstract public List<CalLayer> nextLayers(CalLayer layer, Trajectory trajectory);
 
-  /**
-   * Returns a list of layers the specified trajectory might cross next - more likely first.
-   */
-  abstract public List<CalLayer> nextLayers(Trajectory trajectory);
+//  /**
+//   * Returns a list of layers the specified trajectory might cross next - more likely first
+//   * (but excluding the most likely one that would be returned by <tt>nextLayer</tt>).
+//   */
+//  abstract public List<CalLayer> nextLayers(Trajectory trajectory);
 
 
 // -- Getters :  ---------------------------------------------------------------
@@ -126,12 +142,37 @@
    * <tt>null</tt> is returned and the trajectory is not changed.
    */
   public CalLayer propagateToNextLayer(CalLayer currentLayer, Trajectory trajectory) {
+
+    // Try immediate neighbor
+
+    CalLayer immediateNeighbor = nextLayer(currentLayer, trajectory);
+    if (immediateNeighbor != null) {
+      Hep3Vector pos = propagateToLayer(trajectory, immediateNeighbor);
+      if (pos != null) return immediateNeighbor;
+    }
+
+    // Try others
+
     List<CalLayer> nextLayers = nextLayers(currentLayer, trajectory);
-    for (CalLayer candidate : nextLayers) {
-      Hep3Vector pos = propagateToLayer(trajectory, candidate);
-      if (pos != null) return candidate;
+    double sNext = Double.MAX_VALUE;
+    CalLayer nextLayer = null;
+    for (CalLayer layer : nextLayers) {
+        Intersection inter = trajectory.intersect(layer.getReferenceSurface());
+        if (inter.hasNext()) {
+          double s = inter.getPathLength();
+          if (s < sNext) {
+            sNext = s;
+            nextLayer = layer;
+          }
+        }
     }
-    return null;
+    if (nextLayer == null) {
+      return null;
+    } else {
+      trajectory.swim(sNext);
+      return nextLayer;
+    }
+
   }
 
   /**
@@ -147,7 +188,7 @@
     CalLayer nextLayer = null;
     for (CalModule module : getModules()) {
       if (module.isEntry()) {
-        CalLayer layer = module.getLayerByOrdinal(0);
+        CalLayer layer = module.firstLayer();
         Intersection inter = trajectory.intersect(layer.getReferenceSurface());
         if (inter.hasNext()) {
           double s = inter.getPathLength();

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
CalModule.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- CalModule.java	19 Feb 2009 20:46:08 -0000	1.3
+++ CalModule.java	24 Mar 2009 20:12:41 -0000	1.4
@@ -8,7 +8,7 @@
  * Class to represent a part of the calorimeter.
  * 
  * @author D. Onoprienko
- * @version $Id: CalModule.java,v 1.3 2009/02/19 20:46:08 onoprien Exp $
+ * @version $Id: CalModule.java,v 1.4 2009/03/24 20:12:41 onoprien Exp $
  */
 public class CalModule {
   
@@ -123,6 +123,20 @@
     int ordinal = layerID - _layers.get(0).getLayerID();
     return getLayerByOrdinal(ordinal);
   }
+
+  /**
+   * Returns the first (innermost) layer in this module.
+   */
+  public CalLayer firstLayer() {
+    return _layers.get(0);
+  }
+
+  /**
+   * Returns the last (outermost) layer in this module.
+   */
+  public CalLayer lastLayer() {
+    return _layers.get(_layers.size()-1);
+  }
   
 // -- Private parts :  ---------------------------------------------------------
   

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
DefaultCalGeometry.java removed after 1.2
diff -N DefaultCalGeometry.java
--- DefaultCalGeometry.java	21 Mar 2009 05:27:49 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,189 +0,0 @@
-package org.lcsim.contrib.onoprien.crux.geom;
-
-import java.util.*;
-
-import hep.physics.vec.Hep3Vector;
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.IDetectorElementVisitor;
-import org.lcsim.detector.IGeometryInfo;
-import org.lcsim.event.CalorimeterHit;
-import org.lcsim.geometry.IDDecoder;
-import org.lcsim.geometry.Detector;
-import org.lcsim.geometry.Subdetector;
-import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
-
-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.Surface;
-import org.lcsim.contrib.onoprien.util.swim.Trajectory;
-import org.lcsim.contrib.onoprien.util.swim.ZDisk;
-import org.lcsim.contrib.onoprien.util.swim.ZCylinder;
-
-import static org.lcsim.contrib.onoprien.crux.geom.CalModule.Attribute.*;
-
-/**
- * Default implementation of {@link CalGeometry}.
- * Optimized implementations can be written for particular detectors to improve performance.
- * <p>
- * Currently, this class can only handle cylindrical calorimeters. 6 modules are created,
- * one for each endcap and one for the barrel, both for ECAL and HCAL.
- *
- * @author D. Onoprienko
- * @version $Id: DefaultCalGeometry.java,v 1.2 2009/03/21 05:27:49 onoprien Exp $
- */
-public class DefaultCalGeometry extends CalGeometry implements JobEventListener {
-
-// -- Private parts :  ---------------------------------------------------------
-
-  private List<CalModule> _modules;
-  private ArrayList<List<CalModule>> _previousModules;
-  private ArrayList<List<CalModule>> _nextModules;
-
-
-// -- Constructors and initialization :  ---------------------------------------
-  
-  public DefaultCalGeometry() {
-    JobManager.defaultInstance().addListener(this);
-  }
-  
-  public void detectorChanged(JobEvent jEvent) {
-
-    // create modules
-
-    CalModule eBar = new CalModule("ECAL_BARREL", EnumSet.of(ECAL, BARREL, ENTRY), "EMBarrel");
-    CalModule hBar = new CalModule("HCAL_BARREL", EnumSet.of(HCAL, BARREL, EXIT), "HADBarrel");
-    CalModule eSouthEnd = new CalModule("ECAL_ENDCAP_SOUTH", EnumSet.of(ECAL, ENDCAP, SOUTH, ENTRY), "EMEndcap");
-    CalModule eNorthEnd = new CalModule("ECAL_ENDCAP_NORTH", EnumSet.of(ECAL, ENDCAP, NORTH, ENTRY), "EMEndcap");
-    CalModule hSouthEnd = new CalModule("HCAL_ENDCAP_SOUTH", EnumSet.of(HCAL, ENDCAP, SOUTH, EXIT), "HADEndcap");
-    CalModule hNorthEnd = new CalModule("HCAL_ENDCAP_NORTH", EnumSet.of(HCAL, ENDCAP, NORTH, EXIT), "HADEndcap");
-
-    _modules = new ArrayList<CalModule>(6);
-    Collections.addAll(_modules, eBar, hBar, eSouthEnd, eNorthEnd, hSouthEnd, hNorthEnd);
-    _modules = Collections.unmodifiableList(_modules);
-
-    // neighbors
-
-    List<CalModule> emptyList = Collections.emptyList();
-    _previousModules = new ArrayList<List<CalModule>>(6);
-    Collections.addAll( _previousModules,
-      emptyList,
-      new ArrayList<CalModule>(Arrays.asList(new CalModule[]{eBar})),
-      emptyList,
-      emptyList,
-      new ArrayList<CalModule>(Arrays.asList(new CalModule[]{eSouthEnd})),
-      new ArrayList<CalModule>(Arrays.asList(new CalModule[]{eNorthEnd}))
-    );
-    _nextModules = new ArrayList<List<CalModule>>(6);
-    Collections.addAll(_nextModules,
-      new ArrayList<CalModule>(Arrays.asList(new CalModule[]{hBar})),
-      emptyList,
-      new ArrayList<CalModule>(Arrays.asList(new CalModule[]{hSouthEnd})),
-      new ArrayList<CalModule>(Arrays.asList(new CalModule[]{hNorthEnd})),
-      emptyList,
-      emptyList
-    );
-
-    // create layers
-
-    Detector det = jEvent.getDetector();
-    int idOffset = 0;
-    int moduleID = 0;
-    for (final CalModule module : _modules) {
-      Subdetector sd = det.getSubdetector(module.getSubdetectorName());
-      final List<IDetectorElement> deList = new ArrayList<IDetectorElement>(50);
-      sd.getDetectorElement().traverseDescendantsPreOrder(new IDetectorElementVisitor() {
-        public void visit(IDetectorElement de) {
-          if (de.isSensitive())  {
-            if (module.isBarrel()) {
-              deList.add(de);
-            } else {
-              IGeometryInfo gInfo = de.getGeometry();
-              double z = gInfo.getPosition().z();
-              if ((z > 0. && module.isNorth()) || (z < 0. && module.isSouth())) {
-                deList.add(de);
-              }
-            }
-          }
-        }
-        public boolean isDone() {return false;}
-      });
-      TreeMap<Integer, IDetectorElement> deMap = new TreeMap<Integer, IDetectorElement>();
-      for (IDetectorElement de : deList) {
-
-        //int idLayerIndex = de.getIdentifierHelper().getFieldIndex("layer");
-        //int layer = de.getExpandedIdentifier().getValue(idLayerIndex);
-        String name = de.getName();
-        name = name.replaceFirst(".*layer","");
-        name = name.replaceFirst("_.*","");
-        int layer = Integer.parseInt(name);
-
-        IDetectorElement duplicate = deMap.put(layer, de);
-        if (duplicate != null) throw new RuntimeException("More than 1 DetectorElement in the same layer");
-      }
-      ArrayList<CalLayer> layerList = new ArrayList<CalLayer>(deMap.size());
-      int ordinal = 0;
-      for (Map.Entry<Integer, IDetectorElement> entry : deMap.entrySet()) {
-        int layer = entry.getKey();
-        int id = idOffset + layer;
-        layerList.add(new CalLayer(module, entry.getValue(), ordinal, id, layer));
-        ordinal++;
-      }
-      module.initialize(moduleID++, sd, layerList);
-      idOffset += layerList.size();
-    }
-
-    // CalGeometry initialization
-
-    super.detectorChanged(jEvent);
-  }
-
-
-// -- Implementing CalGeometry :  ----------------------------------------------
-
-  /** Returns an unmodifiable list of calorimeter modules, ordered by module ID. */
-  public List<CalModule> getModules() {
-    return _modules;
-  }
-
-  /**
-   * Returns a list of layers the specified trajectory might cross after coming out of the
-   * given layer - more likely first. The origin of the trajectory should belong to the
-   * specified layer - no checking is done.
-   */
-  public List<CalLayer> nextLayers(CalLayer layer, Trajectory trajectory) {
-    Surface surface = layer.getReferenceSurface();
-    Hep3Vector dir = trajectory.getDirection();
-    Hep3Vector pos = trajectory.getPosition();
-    double dirSign;
-    if (surface instanceof ZDisk) {
-      dirSign = dir.z()*pos.z();
-    } else {
-      dirSign = pos.x()*dir.x() + pos.y()*dir.y();
-    }
-    int iDirSign = (int) Math.signum(dirSign);
-    CalModule module = layer.getModule();
-    CalLayer nextLayer = module.getLayerByOrdinal(layer.getLayerOrdinal()+iDirSign);
-    ArrayList<CalLayer> out = new ArrayList<CalLayer>();
-    if (nextLayer == null) {
-      if (iDirSign > 0) {
-        List<CalModule> nextModules =  _nextModules.get(module.getID());
-        for (CalModule mod : nextModules) out.add(mod.getLayerByOrdinal(0));
-      } else {
-        List<CalModule> nextModules =  _previousModules.get(module.getID());
-        for (CalModule mod : nextModules) out.add(mod.getLayerByOrdinal(mod.getLayers().size()-1));
-      }
-    } else {
-      out.add(nextLayer);
-    }
-    return out;
-  }
-
-  /**
-   * Returns a list of layers the specified trajectory might cross next - more likely first.
-   */
-  public List<CalLayer> nextLayers(Trajectory trajectory) {
-    throw new UnsupportedOperationException();
-  }
-
-}
CVSspam 0.2.8