Print

Print


Commit in lcsim/src/org/lcsim/contrib/onoprien/crux on MAIN
CruxConfig.java+233added 1.1
CruxManager.java+85added 1.1
geom/CalGeometry.java+133added 1.1
    /CalLayer.java+85added 1.1
    /CalModule.java+109added 1.1
    /package-info.java+4added 1.1
infrastructure/CruxTrackAnchorHit.java+35added 1.1
              /CruxTrackNode.java+33added 1.1
              /ITrack.java+75added 1.1
              /ITrackAnchor.java+25added 1.1
              /ITrackNode.java+24added 1.1
              /ITrackVertex.java+11added 1.1
+852
12 added files
Updating Crux to fix the build (not the functional version yet)

lcsim/src/org/lcsim/contrib/onoprien/crux
CruxConfig.java added at 1.1
diff -N CruxConfig.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CruxConfig.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,233 @@
+package org.lcsim.contrib.onoprien.crux;
+
+import java.util.*;
+
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.contrib.onoprien.crux.geom.CalLayer;
+import org.lcsim.contrib.onoprien.crux.geom.CalModule;
+import org.lcsim.contrib.onoprien.crux.infrastructure.*;
+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.*;
+
+/**
+ * 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.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public class CruxConfig implements JobEventListener {
+  
+// -- Constructors :  ----------------------------------------------------------
+  
+  protected CruxConfig(CruxManager cruxMan) {
+    
+    _cruxMan = cruxMan;
+    JobManager.defaultInstance().addListener(this);
+    
+    digiHitColNamesConstruct();
+    
+    moduleConstruct();
+  }
+  
+// -- 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), "EMBarrel");
+    CalModule hBar = new CalModule("HCAL_BARREL", EnumSet.of(HCAL, BARREL), "HADBarrel");
+    CalModule eSouthEnd = new CalModule("ECAL_ENDCAP_SOUTH", EnumSet.of(ECAL, ENDCAP, SOUTH), "EMEndcap");
+    CalModule eNorthEnd = new CalModule("ECAL_ENDCAP_NORTH", EnumSet.of(ECAL, ENDCAP, NORTH), "EMEndcap");
+    CalModule hSouthEnd = new CalModule("HCAL_ENDCAP_SOUTH", EnumSet.of(HCAL, ENDCAP, SOUTH), "HADEndcap");
+    CalModule hNorthEnd = new CalModule("HCAL_ENDCAP_NORTH", EnumSet.of(HCAL, ENDCAP, NORTH), "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.getPoint();
+    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 :  ---------------------------------------------------------
+  
+  protected CruxManager _cruxMan;
+  
+}

lcsim/src/org/lcsim/contrib/onoprien/crux
CruxManager.java added at 1.1
diff -N CruxManager.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CruxManager.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,85 @@
+package org.lcsim.contrib.onoprien.crux;
+
+import java.lang.ref.WeakReference;
+import java.util.*;
+
+import org.lcsim.conditions.ConditionsListener;
+import org.lcsim.conditions.ConditionsEvent;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsManager.ConditionsSetNotFoundException;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.aida.AIDA;
+
+import org.lcsim.contrib.onoprien.util.Driver;
+
+import org.lcsim.contrib.onoprien.crux.geom.CalGeometry;
+import org.lcsim.contrib.onoprien.crux.infrastructure.*;
+
+/**
+ * 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>Allows setting the default {@link CruxClusterValidator}.
+ * </ul>
+ * 
+ * 
+ * 
+ * 
+ * @author D. Onoprienko
+ * @version $Id: CruxManager.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public class CruxManager extends Driver {
+  
+// -- Constructors and initialization :  ---------------------------------------
+  
+  private CruxManager() {
+    _config = new CruxConfig(this);
+    _geom = new CalGeometry(this);
+  }
+  
+  
+// -- Getters :  ---------------------------------------------------------------
+  
+  /** Returns default instance of <tt>CruxManager</tt>. */
+  static public CruxManager defaultInstance() {
+    if (_defInstance == null) _defInstance = new CruxManager();
+    return _defInstance;
+  }
+  
+  /**
+   * Returns <tt>CalGeometry</tt> object associated with this <tt>CruxManager</tt>.
+   */
+  public CalGeometry getGeometry() {
+    return _geom;
+  }
+  
+  /** 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;
+  }
+
+  
+// -- Setters :  ---------------------------------------------------------------
+  
+  /** Set default cluster validator. */
+  public void setDefaultClusterValidator(CruxClusterValidator validator) {
+    _defaultClusterValidator = validator;
+  }
+
+  
+// -- Private parts :  ---------------------------------------------------------
+  
+  static private CruxManager _defInstance;
+  
+  private CalGeometry _geom;
+  private CruxConfig _config;
+  private CruxClusterValidator _defaultClusterValidator;
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/geom
CalGeometry.java added at 1.1
diff -N CalGeometry.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CalGeometry.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,133 @@
+package org.lcsim.contrib.onoprien.crux.geom;
+
+import java.util.*;
+
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.contrib.onoprien.crux.CruxConfig;
+import org.lcsim.contrib.onoprien.crux.CruxManager;
+import org.lcsim.contrib.onoprien.crux.infrastructure.*;
+import org.lcsim.event.CalorimeterHit;
+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;
+
+/**
+ * Singleton of this class is created by {@link CruxManager}, and provides various 
+ * detector geometry related services to other classes.
+ * 
+ * @author D. Onoprienko
+ * @version $Id: CalGeometry.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public class CalGeometry implements JobEventListener {
+  
+// -- Constructors and initialization :  ---------------------------------------
+  
+  public CalGeometry(CruxManager cruxManager) {
+    _cruxMan = cruxManager;
+    JobManager.defaultInstance().addListener(this, cruxManager.getConfig());
+  }
+
+  public void detectorChanged(JobEvent jEvent) {
+    _config = _cruxMan.getConfig();
+    _detector = jEvent.getDetector();
+    _modules = new ArrayList(_config.getModules());
+  }
+  
+// -- Getters :  ---------------------------------------------------------------
+  
+  /** Returns currently used <tt>Detector</tt> object. */
+  public Detector getDetector() {
+    return _detector;
+  }
+  
+  /** Returns a 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);
+  }
+  
+  public CalLayer getLayer(CalorimeterHit hit) {
+    int iLayer = hit.getIDDecoder().getLayer();
+    CalModule module = getModule(hit);
+    return module.getLayerByNumber(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();
+  }
+  
+// -- 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.
+   */
+  public List<CalLayer> findNeighbors(CalLayer layer, Trajectory trajectory) {
+    return _config.findNeighbors(layer, trajectory);
+  }
+
+  /**
+   * 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.
+   */
+  public CalLayer propagateToNextLayer(CalLayer currentLayer, Trajectory trajectory) {
+    List<CalLayer> nextLayers = findNeighbors(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.
+   * <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.
+   */
+  public CalLayer propagateToNextLayer(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) {
+    throw new UnsupportedOperationException();  // FIXME
+  }
+  
+// -- Point to layer projection :  ---------------------------------------------
+  
+  public Hep3Vector getClosestPointOnLayer(Hep3Vector point, CalLayer layer) {
+    throw new UnsupportedOperationException();  // FIXME
+  }
+  
+// -- Private parts :  ---------------------------------------------------------
+  
+  private CruxManager _cruxMan;
+  private CruxConfig _config;
+
+  private Detector _detector;
+  private ArrayList<CalModule> _modules;
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/geom
CalLayer.java added at 1.1
diff -N CalLayer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CalLayer.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,85 @@
+package org.lcsim.contrib.onoprien.crux.geom;
+
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.geometry.IDDecoder;
+
+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.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public class CalLayer implements Comparable<CalLayer> {
+  
+// -- Constructors :  ----------------------------------------------------------
+  
+  public CalLayer(CalModule module, IDetectorElement detectorElement, int ordinal, int layerID, int layerNumber) {
+    _module = module;
+    _ordinal = ordinal;
+    _detEl = detectorElement;
+    _layer = layerNumber;
+    _id = layerID;
+  }
+  
+// -- Getters :  ---------------------------------------------------------------
+  
+  /** Returns calorimeter module this layer belongs to. */
+  public CalModule getModule() {
+    return _module;
+  }
+  
+  /** Returns reference surface of this layer. */
+  public Surface getReferenceSurface() {
+    return _refSurf;
+  }
+  
+  /** 
+   * Returns layer number as reported by {@link IDDecoder} for hits in this layer.
+   * Note that layers in a module are not necessarily numbered starting from zero.
+   */
+  public int getLayerNumber() {
+    return _layer;
+  }
+  
+  /** 
+   * Returns global layer ID (unique within the detector).
+   * IDs for all <tt>CruxCalLayers</tt> in the detector form a continuous sequence 
+   * starting with 0, in the increasing module ID order (increasing layer number inside
+   * modules).
+   */
+  public int getLayerID() {
+    return _id;
+  }
+  
+  /**
+   * Returns layer position in a module, numbered from inside to outside, starting from zero.
+   */
+  public int getLayerOrdinal() {
+    return _ordinal;
+  }
+  
+  /** Returns <tt>DetectorElement</tt> associated with this layer. */
+  public IDetectorElement getDetectorElement() {
+    return _detEl;
+  }
+  
+  
+// -- Ordering :  --------------------------------------------------------------
+  
+  /** Defines natural ordering of layers (increasing ID order). */
+  public int compareTo(CalLayer layer) {
+    return _id - layer._id;
+  }
+  
+// -- Private parts :  ---------------------------------------------------------
+  
+  private CalModule _module;
+  private int _layer;
+  private int _id;
+  private int _ordinal;
+  private IDetectorElement _detEl;
+  private Surface _refSurf;
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/geom
CalModule.java added at 1.1
diff -N CalModule.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CalModule.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,109 @@
+package org.lcsim.contrib.onoprien.crux.geom;
+
+import java.util.*;
+import org.lcsim.contrib.onoprien.crux.infrastructure.*;
+
+import org.lcsim.geometry.Subdetector;
+
+/**
+ * Class to represent a part of the calorimeter.
+ * 
+ * 
+ * @author D. Onoprienko
+ * @version $Id: CalModule.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public class CalModule {
+  
+  public enum Attribute {ECAL, HCAL, BARREL, ENDCAP, SOUTH, NORTH}
+  
+// -- Constructors and initialization :  ---------------------------------------
+  
+  public CalModule(String name, EnumSet<Attribute> attributes, String subdetectorName) {
+    _name = name;
+    _attributes = attributes;
+    _sdName = subdetectorName;
+  }
+
+  public void initialize(int moduleID, Subdetector subDet, List<CalLayer> layers) {
+    _id = moduleID;
+    _sd = subDet;
+    _layers = new ArrayList<CalLayer>(layers);
+  }
+  
+// -- Getters :  ---------------------------------------------------------------
+  
+  public int getID() {
+    return _id;
+  }
+  
+  public String getName() {
+    return _name;
+  }
+  
+  public EnumSet<Attribute> getAttributes() {
+    return _attributes;
+  }
+  
+  public boolean isECal() {
+    return _attributes.contains(Attribute.ECAL);
+  }
+  
+  public boolean isHCal() {
+    return _attributes.contains(Attribute.HCAL);
+  }
+  
+  public boolean isBarrel() {
+    return _attributes.contains(Attribute.BARREL);
+  }
+  
+  public boolean isEndcap() {
+    return _attributes.contains(Attribute.ENDCAP);
+  }
+  
+  public boolean isSouth() {
+    return _attributes.contains(Attribute.SOUTH);
+  }
+  
+  public boolean isNorth() {
+    return _attributes.contains(Attribute.NORTH);
+  }
+  
+  public Subdetector getSubdetector() {
+    return _sd;
+  }
+  
+  public String getSubdetectorName() {
+    return _sdName;
+  }
+  
+  public List<CalLayer> getLayers() {
+    return Collections.unmodifiableList(_layers);
+  }
+  
+  public CalLayer getLayerByOrdinal(int ordinal) {
+    try {
+      return _layers.get(ordinal);
+    } catch (IndexOutOfBoundsException x) {
+      return null;
+    }
+  }
+  
+  public CalLayer getLayerByNumber(int layerNumber) {
+    int ordinal = layerNumber - _layers.get(0).getLayerNumber();
+    return getLayerByOrdinal(ordinal);
+  }
+  
+  public CalLayer getLayerByID(int layerID) {
+    int ordinal = layerID - _layers.get(0).getLayerID();
+    return getLayerByOrdinal(ordinal);
+  }
+  
+// -- Private parts :  ---------------------------------------------------------
+  
+  private int _id;
+  private String _name;
+  private EnumSet<Attribute> _attributes;
+  private String _sdName;
+  private Subdetector _sd;
+  private ArrayList<CalLayer> _layers;
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/geom
package-info.java added at 1.1
diff -N package-info.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ package-info.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,4 @@
+/**
+ * Classes used in describing detector geometry and providing various geometry-related services.
+ */
+package org.lcsim.contrib.onoprien.crux.geom;

lcsim/src/org/lcsim/contrib/onoprien/crux/infrastructure
CruxTrackAnchorHit.java added at 1.1
diff -N CruxTrackAnchorHit.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CruxTrackAnchorHit.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,35 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure;
+
+import org.lcsim.contrib.onoprien.util.swim.Helix;
+import org.lcsim.contrib.onoprien.vsegment.hit.ITrackerHit;
+
+/**
+ * {@link ITrackAnchor} implementation that wraps {@link ITrackerHit}.
+ *
+ * @author D. Onoprienko
+ * @version $Id: CruxTrackAnchorHit.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public class CruxTrackAnchorHit implements ITrackAnchor {
+  
+// -- Constructors :  ----------------------------------------------------------
+  
+  public CruxTrackAnchorHit(ITrackerHit hit) {
+    _hit = hit;
+  }
+  
+// -- Implementing ITrackAnchor :  ---------------------------------------------
+
+  public double chi2(Helix trajectory) {
+    throw new UnsupportedOperationException();
+  }
+  
+// -- Getters :  ---------------------------------------------------------------
+
+  public ITrackerHit getTrackerHit() {
+    return _hit;
+  }
+
+// -- Private parts :  ---------------------------------------------------------
+  
+  ITrackerHit _hit;
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/infrastructure
CruxTrackNode.java added at 1.1
diff -N CruxTrackNode.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CruxTrackNode.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,33 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure;
+
+import org.lcsim.contrib.onoprien.util.swim.Helix;
+
+/**
+ * Basic implementation of {@link ITtrackNode}.
+ *
+ * @author D. Onoprienko
+ * @version $Id: CruxTrackNode.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public class CruxTrackNode implements ITrackNode {
+  
+// -- Constructors :  ----------------------------------------------------------
+  
+  public CruxTrackNode(Helix helix) {
+    _helix = helix;
+  }
+  
+// -- Implementing ITrackNode :  -----------------------------------------------
+  
+  /**
+   * Returns trajectory at the node.
+   * The origin of the trajectory is set to the node position.
+   */
+  public Helix getTrajectory() {
+    return _helix;
+  }
+  
+// -- Private parts :  ---------------------------------------------------------
+  
+  private Helix _helix;
+  
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/infrastructure
ITrack.java added at 1.1
diff -N ITrack.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ITrack.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,75 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure;
+
+import java.util.*;
+
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.event.MCParticle;
+
+import org.lcsim.contrib.onoprien.util.swim.Helix;
+import org.lcsim.contrib.onoprien.vsegment.hit.ITrackerHit;
+
+/**
+ * Generic interface to be implemented by classes that represent found tracks.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ITrack.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public interface ITrack {
+  
+  /** Enumeration of functional points along a reconstructed track. */
+  public enum Point {START, END, 
+                    FIRST_HIT, LAST_HIT, 
+                    ECAL_ENTRY, ECAL_EXIT, HCAL_ENTRY, HCAL_EXIT}
+
+// -- Access to vertices :  ----------------------------------------------------
+  
+  /** Returns the vertex from which this track originated. */
+  ITrackVertex getStartVertex();
+  
+  /** Returns the vertex where this track terminated. */
+  ITrackVertex getEndVertex();
+  
+  /** 
+   * Rerurns a list of intermediate vertices associated with this track. 
+   * The list returned is owned by this <tt>CruxTrack</tt> object, any modifications
+   * will persist.
+   */
+  ArrayList<? extends ITrackVertex> getIntermediateVertexes();
+  
+// -- Access to MC truth :  ----------------------------------------------------
+  
+  /** Returnes <tt>MCParticle</tt> associated with this track. */
+  MCParticle getMCParticle();
+  
+// -- Fitted trajectory parameters :  ------------------------------------------
+  
+  /** Returns particle charge value assigned to this track. */
+  int getCharge();
+  
+  /** Returns position of the given point on this track in global coordinates. */
+  Hep3Vector getPosition(Point where);
+  
+  /** Returns momentum of this track at the given point. */
+  Hep3Vector getMomentum(Point where);
+  
+  /** Returns unit vector in the direction of momentum of this track at the given point. */
+  Hep3Vector getDirection(Point where);
+  
+  /** Returns trajectory at the specified point. */
+  Helix getTrajectory(Point where);
+  
+// -- Nodes and hits :  --------------------------------------------------------
+  
+  /** Returns a list of track nodes, ordered along the trajectory. */
+  List<? extends ITrackNode> getNodes();
+  
+  /** Returns a list of achors for this track, ordered along the trajectory. */
+  List<? extends ITrackAnchor> getAnchors();
+  
+  /** Returns a list of tracker clusters for this track, ordered along the trajectory. */
+  List<? extends ITrackerHit> getTrackerClusters();
+  
+  /** Returns a list of tracker hits anchoring this track, ordered along the trajectory. */
+  List<? extends ITrackerHit> getAnchorHits();
+
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/infrastructure
ITrackAnchor.java added at 1.1
diff -N ITrackAnchor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ITrackAnchor.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,25 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure;
+
+import org.lcsim.contrib.onoprien.util.swim.Helix;
+import org.lcsim.contrib.onoprien.vsegment.hit.ITrackerHit;
+
+/**
+ * Track anchor - something that knows how to calculate chi-square to a trajectory.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ITrackAnchor.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public interface ITrackAnchor {
+  
+  /**
+   * Returns chi-square from this anchor to the specified trajectory.
+   */
+  double chi2(Helix trajectory);
+  
+  /**
+   * Returns tracker hit associated with this anchor.
+   * Returns <tt>null</tt> if this anchor is not a wrapped <tt>ITrackerHit</tt>.
+   */
+  ITrackerHit getTrackerHit();
+  
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/infrastructure
ITrackNode.java added at 1.1
diff -N ITrackNode.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ITrackNode.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,24 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure;
+
+import org.lcsim.contrib.onoprien.util.swim.Helix;
+
+/**
+ * Pivot point on a track.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ITrackNode.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public interface ITrackNode {
+  
+  /**
+   * Returns trajectory at the node.
+   * The origin of the trajectory is set to the node position.
+   */
+  Helix getTrajectory();
+  
+//  /**
+//   * Returns track momentum amplitude at the node.
+//   */
+//  double getP();
+  
+}

lcsim/src/org/lcsim/contrib/onoprien/crux/infrastructure
ITrackVertex.java added at 1.1
diff -N ITrackVertex.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ITrackVertex.java	25 Nov 2008 21:17:00 -0000	1.1
@@ -0,0 +1,11 @@
+package org.lcsim.contrib.onoprien.crux.infrastructure;
+
+/**
+ * Generic interface to be implemented by classes that represent track vertices.
+ *
+ * @author D. Onoprienko
+ * @version $Id: ITrackVertex.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ */
+public interface ITrackVertex {
+  
+}
CVSspam 0.2.8