Print

Print


Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux on MAIN
CruxManager.java+4-101.3 -> 1.4
CruxConfig.java-2361.4 removed
analysis/DefinitionCrux.java+2-41.1 -> 1.2
        /IDefinition.java+3-21.1 -> 1.2
geom/DefaultCalGeometry.java+179added 1.1
    /CalGeometry.java+102-641.3 -> 1.4
    /CalLayer.java+5-31.2 -> 1.3
    /CalGeometryConfig.java-311.1.1.1 removed
recon/CalorimeterDriver.java+20-151.2 -> 1.3
+315-365
1 added + 2 removed + 6 modified, total 9 files
Calorimeter modules geometry update
(compiles but does not work - waiting for detector element sensitivity flag fix)

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux
CruxManager.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- CruxManager.java	19 Feb 2009 20:46:07 -0000	1.3
+++ CruxManager.java	19 Mar 2009 06:08:02 -0000	1.4
@@ -1,5 +1,6 @@
 package org.lcsim.contrib.onoprien.crux;
 
+import org.lcsim.contrib.onoprien.crux.geom.DefaultCalGeometry;
 import java.util.logging.Level;
 
 import org.lcsim.contrib.onoprien.util.job.Driver;
@@ -12,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 CruxConfig} object - all kinds of data specific functionality.
+ * <li>Provides access to {@link DefaultCalGeometry} object - all kinds of data specific functionality.
  * <li>Allows setting the default {@link CruxClusterValidator}.
  * </ul>
  * 
@@ -20,15 +21,14 @@
  * 
  * 
  * @author D. Onoprienko
- * @version $Id: CruxManager.java,v 1.3 2009/02/19 20:46:07 onoprien Exp $
+ * @version $Id: CruxManager.java,v 1.4 2009/03/19 06:08:02 onoprien Exp $
  */
 public class CruxManager extends Driver {
   
 // -- Constructors and initialization :  ---------------------------------------
   
   private CruxManager() {
-    _config = CruxConfig.defaultInstance();
-    JobManager.defaultInstance().put(this, CruxManager.class);
+    JobManager.defaultInstance().put( CruxManager.class,this);
     log("Created CruxManager", Level.SEVERE);
   }
   
@@ -41,11 +41,6 @@
     return _defInstance;
   }
   
-  /** Returns <tt>CruxConfig</tt> object associated with this <tt>CruxManager</tt>. */
-  public CruxConfig getConfig() {
-    return _config;
-  }
-  
   /** Returns default cluster validator. */
   public CruxClusterValidator getDefaultClusterValidator() {
     return _defaultClusterValidator;
@@ -64,6 +59,5 @@
   
   static private CruxManager _defInstance;
   
-  private CruxConfig _config;
   private CruxClusterValidator _defaultClusterValidator;
 }

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux
CruxConfig.java removed after 1.4
diff -N CruxConfig.java
--- CruxConfig.java	19 Feb 2009 20:46:07 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,236 +0,0 @@
-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.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 org.lcsim.contrib.onoprien.crux.geom.CalGeometryConfig;
-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.*;
-
-/**
- * Crux package custom configuration class.
- * <p>
- * This class is intended to be a single location where all the ugly detector-specific
- * or running mode specific code is placed. {@link CruxManager} creates a single instance
- * of this class. Its {@link #detectorChanged detectorChanged(CruxEvent)} method is called 
- * by the framework once the event processing starts. During event processing,
- * any client class has access to <tt>CruxConfig</tt> singleton through {@link CruxManager#getConfig()}.
- * <p>
- * Current content:
- * <ul>
- * <li>Names of digitized hits collections coming from DigiSim
- * <li>How the calorimeter is split into modules, modules into layers, and related services.
- *     Creation of <tt>CruxCalModules</tt> and <tt>CruxCalLayers</tt>. The implementation of
- *     this part is extremely ugly at the moment due to bugs and missing functionality in the
- *     org.lcsim geometry system.
- * </ul>
- *
- * @author D. Onoprienko
- * @version $Id: CruxConfig.java,v 1.4 2009/02/19 20:46:07 onoprien Exp $
- */
-public class CruxConfig implements JobEventListener, CalGeometryConfig {
-  
-// -- Constructors :  ----------------------------------------------------------
-  
-  private CruxConfig() {
-    
-    JobManager.defaultInstance().addListener(this);
-    
-    digiHitColNamesConstruct();
-    
-    moduleConstruct();
-  }
-
-  static public CruxConfig defaultInstance() {
-    return (_def == null) ? _def = new CruxConfig() : _def ;
-  }
-  
-// -- Initialization :  --------------------------------------------------------
-  
-  public void detectorChanged(JobEvent jEvent) {
-    
-    moduleInit(jEvent);
-    
-  }
-  
-// -- Digitized calorimeter hits collection names :  ---------------------------
-  
-  protected void digiHitColNamesConstruct() {
-    _digiHitColNames = new String[]{"EcalBarrDigiHits","EcalEndcapDigiHits","HcalBarrDigiHits","HcalEndcapDigiHits"};
-  }
-  
-  public String[] getDigiHitCollectionNames() {
-    return _digiHitColNames;
-  }
-  
-  protected String[] _digiHitColNames;
-  
-// -- Division of calorimeter into modules :  ----------------------------------
-  
-  protected void moduleConstruct() {
-  }
-  
-  protected void moduleInit(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);
-    
-    // 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
-    );
-    
-    // assign DetectorElements
-    
-    Detector det = jEvent.getDetector();
-    int idOffset = 0;
-    int moduleID = 0;
-    for (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) {
-          String name = de.getName();
-          if (name.contains("layer") || name.contains("sensor")) {
-            deList.add(de);
-          }
-        }
-        public boolean isDone() {return false;}
-      });
-      TreeMap<Integer, IDetectorElement> deMap = new TreeMap<Integer, IDetectorElement>();
-      for (IDetectorElement de : deList) {
-        String name = de.getName();
-        if (module.isBarrel() || 
-             ((name.contains("negative") && module.isSouth()) || (name.contains("positive") && module.isNorth()))) {
-          name = name.replaceFirst(".*layer","");
-          name = name.replaceFirst(".*sensor","");
-          int layer = Integer.parseInt(name);
-          deMap.put(layer, de);
-        }
-      }
-      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();
-    }
-  }
-  
-  /**
-   * Looks up <tt>CalModule</tt> the hit belongs to.
-   */
-  public CalModule getModule(CalorimeterHit hit) {
-    IDDecoder decoder = hit.getIDDecoder();
-    decoder.setID(hit.getCellID());
-    Subdetector subDet = decoder.getSubdetector();
-    if (subDet == _modules.get(0).getSubdetector()) {
-      return _modules.get(0);
-    } else if (subDet == _modules.get(1).getSubdetector()) {
-      return _modules.get(1);
-    } else {
-      BarrelEndcapFlag flag = decoder.getBarrelEndcapFlag();
-      if (subDet == _modules.get(2).getSubdetector()) {
-        return (flag.isEndcapSouth()) ? _modules.get(2) : _modules.get(3) ;
-      } else {
-        return (flag.isEndcapSouth()) ? _modules.get(4) : _modules.get(5) ;
-      }
-    }
-  }
-
-  /** Returns a list of all modules. */
-  public List<CalModule> getModules() {
-    return Collections.unmodifiableList(_modules);
-  }
-  
-  /**
-   * Returns a list of layers the specified trajectory might cross after coming out of the 
-   * given layer - more likely first. The origing of the trajectory should belong to the
-   * specified layer - no checking is done.
-   * <i>Current implementation: next layer in the same subdetector. Need to handle
-   *    transitions between barrel and endcap, curling.</i>
-   */
-  public List<CalLayer> findNeighbors(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;
-  }
-
-  protected ArrayList<CalModule> _modules;
-  protected ArrayList<List<CalModule>> _previousModules;
-  protected ArrayList<List<CalModule>> _nextModules;
-  
-// -- Private parts :  ---------------------------------------------------------
-
-  static private CruxConfig _def;
-}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/analysis
DefinitionCrux.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- DefinitionCrux.java	3 Mar 2009 21:25:32 -0000	1.1
+++ DefinitionCrux.java	19 Mar 2009 06:08:03 -0000	1.2
@@ -9,7 +9,6 @@
 
 import org.lcsim.contrib.onoprien.util.NoSuchParameterException;
 import org.lcsim.contrib.onoprien.util.WeightedTable;
-import org.lcsim.contrib.onoprien.util.constants.Particles;
 import org.lcsim.contrib.onoprien.util.job.JobManager;
 
 import org.lcsim.contrib.onoprien.vsegment.geom.SegmentationManager;
@@ -17,12 +16,11 @@
 import org.lcsim.contrib.onoprien.vsegment.hit.ITrackerHit;
 import org.lcsim.contrib.onoprien.vsegment.mctruth.MCTruthVS;
 
-import org.lcsim.contrib.onoprien.crux.analysis.RecType;
 import org.lcsim.contrib.onoprien.crux.mctruth.MCTruthCrux;
 import org.lcsim.contrib.onoprien.crux.mctruth.MCTruthDriverCrux;
 
 /**
- * Simple configurable implementation of {@link IRecoDefinition}.
+ * Extended configurable implementation of {@link IDefinition}.
  * Used by track finder cheaters and tracking performance analysis classes.
  * In addition to cuts implemented by {@link Definition}, this definition allowes
  * cats based on Monte Carlo truth information accessible through {@link MCTruthCrux}
@@ -31,7 +29,7 @@
  * <tt>endEvent()</tt> to clean it up once the event is processed.
  *
  * @author D. Onoprienko
- * @version $Id: DefinitionCrux.java,v 1.1 2009/03/03 21:25:32 onoprien Exp $
+ * @version $Id: DefinitionCrux.java,v 1.2 2009/03/19 06:08:03 onoprien Exp $
  */
 public class DefinitionCrux extends Definition {
 

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/analysis
IDefinition.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- IDefinition.java	3 Mar 2009 21:25:32 -0000	1.1
+++ IDefinition.java	19 Mar 2009 06:08:03 -0000	1.2
@@ -6,7 +6,8 @@
 import org.lcsim.event.MCParticle;
 
 /**
- * Interface to be implemented by classes that define reconstructable MCParticle.
+ * Interface to be implemented by classes that define "findable", "reconstructed"
+ * MCParticle, and "fake" reconstructed object.
  * Used by cheaters and performance analysis classes.
  * <p>
  * An implementation of this interface that uses event-specific data (like MCTruth objects)
@@ -15,7 +16,7 @@
  * definitions and call their <tt>startEvent</tt> methods should also call <tt>endEvent()</tt>.
  *
  * @author D. Onoprienko
- * @version $Id: IDefinition.java,v 1.1 2009/03/03 21:25:32 onoprien Exp $
+ * @version $Id: IDefinition.java,v 1.2 2009/03/19 06:08:03 onoprien Exp $
  */
 public interface IDefinition {
 

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
DefaultCalGeometry.java added at 1.1
diff -N DefaultCalGeometry.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DefaultCalGeometry.java	19 Mar 2009 06:08:03 -0000	1.1
@@ -0,0 +1,179 @@
+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.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.
+ *
+ * @author D. Onoprienko
+ * @version $Id: DefaultCalGeometry.java,v 1.1 2009/03/19 06:08:03 onoprien Exp $
+ */
+public class DefaultCalGeometry extends CalGeometry implements JobEventListener {
+
+// -- Private parts :  ---------------------------------------------------------
+
+  private ArrayList<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) {
+    moduleInit(jEvent);
+    super.detectorChanged(jEvent);
+  }
+
+
+// -- Implementing CalGeometry :  ----------------------------------------------
+
+  /** Returns an unmodifiable list of calorimeter modules, ordered by module ID. */
+  public List<CalModule> getModules() {
+    return Collections.unmodifiableList(_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();
+  }
+
+
+// -- Division of calorimeter into modules :  ----------------------------------
+  
+  protected void moduleInit(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);
+    
+    // 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
+    );
+    
+    // assign DetectorElements
+    
+    Detector det = jEvent.getDetector();
+    int idOffset = 0;
+    int moduleID = 0;
+    for (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) {
+          String name = de.getName();
+          if (name.contains("layer") || name.contains("sensor")) {
+            deList.add(de);
+          }
+        }
+        public boolean isDone() {return false;}
+      });
+      TreeMap<Integer, IDetectorElement> deMap = new TreeMap<Integer, IDetectorElement>();
+      for (IDetectorElement de : deList) {
+        String name = de.getName();
+        if (module.isBarrel() || 
+             ((name.contains("negative") && module.isSouth()) || (name.contains("positive") && module.isNorth()))) {
+          name = name.replaceFirst(".*layer","");
+          name = name.replaceFirst(".*sensor","");
+          int layer = Integer.parseInt(name);
+          deMap.put(layer, de);
+        }
+      }
+      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();
+    }
+  }
+
+}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
CalGeometry.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- CalGeometry.java	19 Feb 2009 20:46:08 -0000	1.3
+++ CalGeometry.java	19 Mar 2009 06:08:03 -0000	1.4
@@ -3,6 +3,10 @@
 import java.util.*;
 
 import hep.physics.vec.Hep3Vector;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.detector.solids.ISolid;
+import org.lcsim.detector.solids.Tube;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.IDDecoder;
@@ -11,6 +15,9 @@
 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.util.swim.Surface;
+import org.lcsim.contrib.onoprien.util.swim.ZCylinder;
+import org.lcsim.contrib.onoprien.util.swim.ZDisk;
 
 /**
  * Provides various calorimeter geometry related services to other classes.
@@ -18,112 +25,116 @@
  * calling <tt>JobManager.defaultInstance().get(CalGeometry.class)</tt>.
  * 
  * @author D. Onoprienko
- * @version $Id: CalGeometry.java,v 1.3 2009/02/19 20:46:08 onoprien Exp $
+ * @version $Id: CalGeometry.java,v 1.4 2009/03/19 06:08:03 onoprien Exp $
  */
-public class CalGeometry implements JobEventListener {
+abstract public class CalGeometry implements JobEventListener {
 
-  static public CalGeometry defaultInstance() {
-    return new CalGeometry();
-  }
+// -- Private parts :  ---------------------------------------------------------
+
+  private Detector _detector;
+  private HashMap<IDetectorElement, CalLayer> _de2cl;
   
 // -- Constructors and initialization :  ---------------------------------------
   
-  private CalGeometry() {
+  public CalGeometry() {
     JobManager.defaultInstance().addListener(this);
   }
 
-  public void setConfig(CalGeometryConfig config) {
-    if (_config != null) throw new IllegalStateException("Geometry config has already been set.");
-    _config = config;
-    JobManager jobManager = JobManager.defaultInstance();
-    jobManager.addListener(this, config);
-  }
-
   public void detectorChanged(JobEvent jEvent) {
-    if (_config == null) throw new IllegalStateException("Geometry config has not been set.");
     _detector = jEvent.getDetector();
-    _modules = new ArrayList(_config.getModules());
+    for (CalModule module : getModules()) {
+      for (CalLayer layer : module.getLayers()) {
+        _de2cl.put(layer.getDetectorElement(), layer);
+      }
+    }
   }
+
+
+// -- Abstract methods :  ------------------------------------------------------
   
+  /** Returns an unmodifiable list of calorimeter modules, ordered by module ID. */
+  abstract public List<CalModule> getModules();
+
+  /**
+   * 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.
+   */
+  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);
+
+
 // -- Getters :  ---------------------------------------------------------------
-  
+
   /** Returns currently used <tt>Detector</tt> object. */
   public Detector getDetector() {
     return _detector;
   }
   
-  /** Returns an unmodifiable list of calorimeter modules. */
-  public List<CalModule> getModules() {
-    return Collections.unmodifiableList(_modules);
-  }
-  
   /** Returns calorimeter module the given hit belongs to. */
   public CalModule getModule(CalorimeterHit hit) {
-    return _config.getModule(hit);
+    return getLayer(hit).getModule();
   }
-  
+
+  /** Returns calorimeter layer the specified hit belongs to. */
   public CalLayer getLayer(CalorimeterHit hit) {
-    IDDecoder dec = hit.getIDDecoder();
-    dec.setID(hit.getCellID());
-    int iLayer = dec.getLayer();
-    CalModule module = getModule(hit);
-    return module.getLayerByDecoded(iLayer);
-  }
-  
-  /** Returns <tt>true</tt> id the given hit belongs to EM calorimeter. */
-  public boolean isECal(CalorimeterHit hit) {
-    return getModule(hit).isECal();
-  }
-  
-  /** Returns <tt>true</tt> id the given hit belongs to hadronic calorimeter. */
-  public boolean isHCal(CalorimeterHit hit) {
-    return getModule(hit).isHCal();
+    return getLayer(hit.getDetectorElement());
   }
+
   
 // -- Trajectory propagation :  ------------------------------------------------
-  
+
   /**
-   * 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.
+   * Propagates the given trajectory to the given calorimeter layer.
+   * Returns the point where the trajectory intersects the layer's reference surface.
+   * Origin of the supplied <tt>Trajectory</tt> is set to that point.
+   * If the trajectory does not cross the specified layer, <tt>null</tt> is returned
+   * and the trajectory is not changed.
    */
-  public List<CalLayer> findNeighbors(CalLayer layer, Trajectory trajectory) {
-    return _config.findNeighbors(layer, trajectory);
+  public Hep3Vector propagateToLayer(Trajectory trajectory, CalLayer layer) {
+    throw new UnsupportedOperationException();  // FIXME
   }
 
   /**
    * Propagates the given trajectory from the specified layer to the next calorimeter layer it crosses.
    * <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.
+   * crosses that layer's reference surface. If the trajectory leaves the calorimeter,
+   * <tt>null</tt> is returned and the trajectory is not changed.
    */
   public CalLayer propagateToNextLayer(CalLayer currentLayer, Trajectory trajectory) {
-    List<CalLayer> nextLayers = findNeighbors(currentLayer, trajectory);
+    List<CalLayer> nextLayers = nextLayers(currentLayer, trajectory);
     for (CalLayer candidate : nextLayers) {
       Hep3Vector pos = propagateToLayer(trajectory, candidate);
       if (pos != null) return candidate;
     }
     return null;
   }
-  
+
   /**
-   * Propagates the given trajectory to the next calorimeter layer it crosses.
+   * Propagates the given trajectory from outside the calorimeter to its entry layer.
    * <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.
+   * 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
+   * does not enter calorimeter, <tt>null</tt> is returned and the trajectory is not changed.
    */
-  public CalLayer propagateToNextLayer(Trajectory trajectory) {
+  public CalLayer propagateToCalorimeter(Trajectory trajectory) {
     throw new UnsupportedOperationException();  // FIXME
   }
-  
+
   /**
-   * Propagates the given trajectory to the given calorimeter layer.
-   * Returns the point where the trajectory intersects the layer's reference surface.
-   * Origin of the supplied <tt>Trajectory</tt> is set to that point.
-   * If the trajectory does not cross the specified layer, <tt>null</tt> is returned
-   * and the trajectory is not changed.
-   */  
-  public Hep3Vector propagateToLayer(Trajectory trajectory, CalLayer layer) {
+   * Propagates the given trajectory to the next calorimeter layer it crosses.
+   * <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. If the trajectory does not cross any
+   * calorimeter layers, <tt>null</tt> is returned and the trajectory is not changed.
+   */
+  public CalLayer propagateToNextLayer(Trajectory trajectory) {
     throw new UnsupportedOperationException();  // FIXME
   }
   
@@ -132,11 +143,38 @@
   public Hep3Vector getClosestPointOnLayer(Hep3Vector point, CalLayer layer) {
     throw new UnsupportedOperationException();  // FIXME
   }
-  
-// -- Private parts :  ---------------------------------------------------------
-  
-  private CalGeometryConfig _config;
 
-  private Detector _detector;
-  private ArrayList<CalModule> _modules;
+
+// -- Protected helper methods :  ----------------------------------------------
+
+  protected CalLayer getLayer(IDetectorElement de) {
+    return _de2cl.get(de);
+  }
+
+  /**
+   * Creates and returns reference surface object corresponding to the specified detector element.
+   */
+  protected Surface createReferenceSurface(IDetectorElement detEl) {
+    IGeometryInfo gInfo = detEl.getGeometry();
+    ISolid solid = gInfo.getLogicalVolume().getSolid();
+    if (solid instanceof Tube) {
+      Tube tube = (Tube) solid;
+      double rMin = tube.getInnerRadius();
+      double rMax = tube.getOuterRadius();
+      double zHalf = tube.getZHalfLength();
+      Hep3Vector pos = gInfo.getPosition();
+      double z = pos.z();
+      if (pos.x() > Double.MIN_VALUE || pos.y() > Double.MIN_VALUE) {
+        throw new IllegalArgumentException("Cannot create reference surface for Tube at position "+ pos);
+      }
+      if (Math.abs(z)  < zHalf) { // barrel cylinder
+        return new ZCylinder((rMin+rMax)/2., z-zHalf, z+zHalf);
+      } else { // endcap disk
+        return new ZDisk(z, rMin, rMax);
+      }
+    } else {
+      throw new IllegalArgumentException("Creating reference surfaces for solids other than Tube is not implemented");
+    }
+  }
+
 }

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
CalLayer.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- CalLayer.java	19 Feb 2009 20:46:08 -0000	1.2
+++ CalLayer.java	19 Mar 2009 06:08:03 -0000	1.3
@@ -1,15 +1,15 @@
 package org.lcsim.contrib.onoprien.crux.geom;
 
 import org.lcsim.detector.IDetectorElement;
-import org.lcsim.geometry.IDDecoder;
 
+import org.lcsim.contrib.onoprien.util.job.JobManager;
 import org.lcsim.contrib.onoprien.util.swim.Surface;
 
 /**
  * Class that represents a layer inside a calorimeter module.
  * 
  * @author D. Onoprienko
- * @version $Id: CalLayer.java,v 1.2 2009/02/19 20:46:08 onoprien Exp $
+ * @version $Id: CalLayer.java,v 1.3 2009/03/19 06:08:03 onoprien Exp $
  */
 public class CalLayer implements Comparable<CalLayer> {
   
@@ -21,8 +21,10 @@
     _detEl = detectorElement;
     _layer = layerNumber;
     _id = layerID;
+    _refSurf = JobManager.defaultInstance().get(CalGeometry.class).createReferenceSurface(detectorElement);
   }
-  
+
+
 // -- Getters :  ---------------------------------------------------------------
   
   /** Returns calorimeter module this layer belongs to. */

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/geom
CalGeometryConfig.java removed after 1.1.1.1
diff -N CalGeometryConfig.java
--- CalGeometryConfig.java	10 Dec 2008 22:03:06 -0000	1.1.1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,31 +0,0 @@
-package org.lcsim.contrib.onoprien.crux.geom;
-
-import java.util.*;
-
-import org.lcsim.event.CalorimeterHit;
-
-import org.lcsim.contrib.onoprien.util.job.JobEventListener;
-import org.lcsim.contrib.onoprien.util.swim.Trajectory;
-
-/**
- * Calorimeter geometry configuration.
- *
- * @author D. Onoprienko
- * @version $Id: CalGeometryConfig.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
- */
-public interface CalGeometryConfig extends JobEventListener {
-  
-  /** Returns a list of all modules. */
-  List<CalModule> getModules();
-
-  /** Looks up <tt>CalModule</tt> the hit belongs to. */
-  CalModule getModule(CalorimeterHit hit);
-  
-  /**
-   * 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.
-   */
-  List<CalLayer> findNeighbors(CalLayer layer, Trajectory trajectory);
-  
-}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/crux/recon
CalorimeterDriver.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- CalorimeterDriver.java	18 Feb 2009 03:29:07 -0000	1.2
+++ CalorimeterDriver.java	19 Mar 2009 06:08:03 -0000	1.3
@@ -10,7 +10,6 @@
 import org.lcsim.contrib.onoprien.util.job.JobManager;
 
 import org.lcsim.contrib.onoprien.crux.geom.CalGeometry;
-import org.lcsim.contrib.onoprien.crux.geom.CalGeometryConfig;
 
 /**
  * Driver that initializes calorimeter geometry and processes hits.
@@ -19,26 +18,25 @@
  * to the event record.
  *
  * @author D. Onoprienko
- * @version $Id: CalorimeterDriver.java,v 1.2 2009/02/18 03:29:07 onoprien Exp $
+ * @version $Id: CalorimeterDriver.java,v 1.3 2009/03/19 06:08:03 onoprien Exp $
  */
 public class CalorimeterDriver extends Driver implements JobEventListener {
 
 // -- Private parts :  ---------------------------------------------------------
 
   private String _outMapName;
+  private String[] _inHitsName;
 
   
 // -- Constructors and initialization :  ---------------------------------------
   
   public CalorimeterDriver() {
-    JobManager jobMan = JobManager.defaultInstance();
-    CalGeometry geom = jobMan.get(CalGeometry.class);
-    jobMan.addListener(this, geom);
+    JobManager.defaultInstance().addListener(this);
   }
 
   public void detectorChanged(JobEvent jEvent) {
     
-    if (_outMapName == null) throw new IllegalStateException(ERR_NS);
+    if (_outMapName == null || _inHitsName == null) throw new IllegalStateException(ERR_NS);
     
     //    Output of DigiSim is hit collections: "EcalBarrDigiHits", "EcalEndcapDigiHits", 
     //    "HcalBarrDigiHits", "HcalEndcapDigiHits" (added to the event).
@@ -52,7 +50,7 @@
     // Put hits into map
 
     HitMapFilterDriver mapMaker = new HitMapFilterDriver();
-    mapMaker.set("INPUT", "EcalBarrDigiHits","EcalEndcapDigiHits","HcalBarrDigiHits","HcalEndcapDigiHits");
+    mapMaker.set("INPUT", (Object[]) _inHitsName);
     mapMaker.set("OUTPUT", _outMapName);
     add(mapMaker);
   }
@@ -65,10 +63,12 @@
    * Set any parameter. 
    * The following parameters can be set with this method:
    * <p><dl>
-   * <dt>"OUTPUT_MAP_NAME"</dt> <dd>Name of output collection.<br>
-   *             Default: <tt>null</tt> (must be specified before this driver can be used).</dd>
-   * <dt>"GEOMETRY_CONFIG"</dt> <dd>{@link CalGeometryConfig} object to be used by this driver.<br>
-   *             Default: <tt>null</tt> (must be set before this driver can be used).</dd>
+   * <dt>"INPUT_HITS"</dt> <dd>Names of input collections of calorimeter hits.<br>
+   *             Default: none (must be specified before this driver can be used).</dd>
+   * <dt>"OUTPUT_HITS"</dt> <dd>Name of output collection.<br>
+   *             Default: none (must be specified before this driver can be used).</dd>
+   * <dt>"GEOMETRY"</dt> <dd>{@link CalGeometry} object to be used by this driver.<br>
+   *             Default: none (must be set before this driver can be used).</dd>
    * </dl>
    * 
    * @param name   Name of parameter to be set. Case is ignored.
@@ -80,11 +80,16 @@
   public void set(String name, Object... values) {
     Object value = values.length == 0 ? null : values[0];
     try {
-      if (name.equalsIgnoreCase("OUTPUT_MAP_NAME")) {
+      if (name.equalsIgnoreCase("INPUT_HITS")) {
+        _inHitsName = new String[values.length];
+        for (int i=0; i<values.length; i++) _inHitsName[i] = (String) values[i];
+      } else if (name.equalsIgnoreCase("OUTPUT_HITS")) {
         _outMapName = (String) value;
-      } else if (name.equalsIgnoreCase("GEOMETRY_CONFIG")) {
-        CalGeometryConfig geomConfig = (CalGeometryConfig) value;
-        JobManager.defaultInstance().get(CalGeometry.class).setConfig(geomConfig);
+      } else if (name.equalsIgnoreCase("GEOMETRY")) {
+        CalGeometry geom = (CalGeometry) value;
+        JobManager jobMan = JobManager.defaultInstance();
+        jobMan.put(CalGeometry.class, geom);
+        jobMan.addListener(this, geom);
       } else {
         super.set(name, values);
       }
CVSspam 0.2.8