Commit in lcdd on MAIN
include/lcdd/detectors/CalorimeterSD.hh+2-21.7 -> 1.8
                      /SensitiveDetectorFactory.hh+2-21.5 -> 1.6
                      /CellReadout.hh-711.10 removed
                      /CellReadout2D.hh-1731.9 removed
                      /CellReadout2DSegmentation.hh-751.8 removed
                      /GlobalGridXYSegmentation.hh-1111.6 removed
                      /GridXYZSegmentation.hh-1141.7 removed
                      /NonprojectiveCylinderSegmentation.hh-1221.7 removed
                      /ProjectiveCylinderSegmentation.hh-691.4 removed
                      /ProjectiveSegmentation.hh-1361.8 removed
                      /ProjectiveZPlaneSegmentation.hh-511.4 removed
                      /Segmentation.hh-1901.9 removed
                      /SegmentationFactory.hh-361.4 removed
include/lcdd/segmentation/CellReadout.hh+71added 1.1
                         /CellReadout2D.hh+173added 1.1
                         /CellReadout2DSegmentation.hh+75added 1.1
                         /GlobalGridXYSegmentation.hh+111added 1.1
                         /GridXYZSegmentation.hh+114added 1.1
                         /NonprojectiveCylinderSegmentation.hh+122added 1.1
                         /ProjectiveCylinderSegmentation.hh+69added 1.1
                         /ProjectiveSegmentation.hh+136added 1.1
                         /ProjectiveZPlaneSegmentation.hh+51added 1.1
                         /Segmentation.hh+190added 1.1
                         /SegmentationFactory.hh+36added 1.1
src/lcdd/detectors/CalorimeterSD.cc+1-21.7 -> 1.8
                  /CellReadout.cc-111.4 removed
                  /CellReadout2D.cc-1611.5 removed
                  /CellReadout2DSegmentation.cc-1901.8 removed
                  /GlobalGridXYSegmentation.cc-781.4 removed
                  /GridXYZSegmentation.cc-1531.4 removed
                  /NonprojectiveCylinderSegmentation.cc-2411.5 removed
                  /ProjectiveCylinderSegmentation.cc-741.2 removed
                  /ProjectiveSegmentation.cc-2291.6 removed
                  /ProjectiveZPlaneSegmentation.cc-451.2 removed
                  /Segmentation.cc-1281.6 removed
                  /SegmentationFactory.cc-1761.2 removed
src/lcdd/id/IdFactory.cc+2-21.3 -> 1.4
src/lcdd/segmentation/CellReadout.cc+11added 1.1
                     /CellReadout2D.cc+161added 1.1
                     /CellReadout2DSegmentation.cc+190added 1.1
                     /GlobalGridXYSegmentation.cc+78added 1.1
                     /GridXYZSegmentation.cc+153added 1.1
                     /NonprojectiveCylinderSegmentation.cc+241added 1.1
                     /ProjectiveCylinderSegmentation.cc+74added 1.1
                     /ProjectiveSegmentation.cc+229added 1.1
                     /ProjectiveZPlaneSegmentation.cc+45added 1.1
                     /Segmentation.cc+128added 1.1
                     /SegmentationFactory.cc+176added 1.1
src/lcdd/subscribers/calorimeterSubscriber.cc+1-21.3 -> 1.4
+2642-2644
22 added + 22 removed + 5 modified, total 49 files
move segmentation classes to separate dir from detectors

lcdd/include/lcdd/detectors
CalorimeterSD.hh 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- CalorimeterSD.hh	22 Aug 2013 22:32:16 -0000	1.7
+++ CalorimeterSD.hh	10 Sep 2013 21:57:32 -0000	1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.7 2013/08/22 22:32:16 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.8 2013/09/10 21:57:32 jeremy Exp $
 
 #ifndef LCDD_DETECTORS_CALORIMETERSD_HH
 #define LCDD_DETECTORS_CALORIMETERSD_HH 1
@@ -7,7 +7,7 @@
 #include "lcdd/detectors/SensitiveDetector.hh"
 #include "lcdd/detectors/HitComparator.hh"
 #include "lcdd/hits/CalorimeterHit.hh"
-#include "lcdd/detectors/Segmentation.hh"
+#include "lcdd/segmentation/Segmentation.hh"
 
 /**
  * @brief The implementation of a calorimeter that accumulates energy depositions by event.

lcdd/include/lcdd/detectors
SensitiveDetectorFactory.hh 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- SensitiveDetectorFactory.hh	22 Aug 2013 22:32:16 -0000	1.5
+++ SensitiveDetectorFactory.hh	10 Sep 2013 21:57:32 -0000	1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetectorFactory.hh,v 1.5 2013/08/22 22:32:16 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetectorFactory.hh,v 1.6 2013/09/10 21:57:32 jeremy Exp $
 
 #ifndef LCDD_DETECTORS_SENSITIVEDETECTORFACTORY_HH
 #define LCDD_DETECTORS_SENSITIVEDETECTORFACTORY_HH 1
@@ -10,7 +10,7 @@
 #include "lcdd/schema/tracker.hh"
 #include "lcdd/schema/IdSpecType.hh"
 #include "lcdd/detectors/SensitiveDetector.hh"
-#include "lcdd/detectors/SegmentationFactory.hh"
+#include "lcdd/segmentation/SegmentationFactory.hh"
 #include "lcdd/id/IdManager.hh"
 #include "lcdd/id/IdSpec.hh"
 

lcdd/include/lcdd/detectors
CellReadout.hh removed after 1.10
diff -N CellReadout.hh
--- CellReadout.hh	6 Sep 2013 04:09:00 -0000	1.10
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/CellReadout.hh,v 1.10 2013/09/06 04:09:00 jeremy Exp $
-
-#ifndef LCDD_DETECTORS_CELLREADOUT_HH
-#define LCDD_DETECTORS_CELLREADOUT_HH 1
-
-// STL
-#include <vector>
-#include <map>
-#include <string>
-
-/**
- * @brief Pure virtual base class for calorimeter cell readouts to implement.
- * @todo Move to DDSegmentation package.
- */
-class CellReadout
-{
-
-public:
-
-    /** 2D XY position. */
-    struct Position2D
-    {
-        double x;
-        double y;
-    };
-
-    /** Cell ID represented as a pair of int values. */
-    struct CellId
-    {
-        int ix;
-        int iy;
-    };
-
-    /** A list of a cell's neighbor IDs. */
-    typedef std::vector<CellId> Neighbors;
-
-public:
-
-    /**
-     * Class constructor.
-     */
-    CellReadout();
-
-    /**
-     * Class destructor.
-     */
-    virtual ~CellReadout();
-
-    /**
-     * Compute cell ID from local position.
-     * @param[in] pos A 2D position.
-     * @return A CellId from the position.
-     */
-    virtual CellId cellId(Position2D pos) = 0;
-
-    /**
-     * Compute local position of a cell ID.
-     * @param[in] id The cell id.
-     * @return The position from the CellId.
-     */
-    virtual Position2D position(CellId id) = 0;
-
-    /**
-     * Create a list of neighbor cells from a cell ID.
-     * @param[in] id The cell id.
-     * @return The list of Neighbors for the given CellId.
-     */
-    virtual Neighbors neighbors(CellId id) = 0;
-};
-
-#endif

lcdd/include/lcdd/detectors
CellReadout2D.hh removed after 1.9
diff -N CellReadout2D.hh
--- CellReadout2D.hh	6 Sep 2013 03:47:35 -0000	1.9
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,173 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/CellReadout2D.hh,v 1.9 2013/09/06 03:47:35 jeremy Exp $
-
-#ifndef LCDD_DETECTORS_CELLREADOUT2D_HH
-#define LCDD_DETECTORS_CELLREADOUT2D_HH 1
-
-// LCDD
-#include "CellReadout.hh"
-
-// STL
-#include <vector>
-#include <map>
-
-/**
- * @brief
- * A concrete implementation of CellReadout using a 2D grid
- * with coordinate origin in the lower lefthand corner of the
- * readout volume.
- */
-class CellReadout2D: public CellReadout
-{
-
-public:
-
-    /**
-     * Class destructor.
-     */
-    virtual ~CellReadout2D();
-
-    /**
-     * Class constructor.
-     */
-    CellReadout2D(double cellSizeX, double cellSizeY);
-
-    /**
-     * ----------------------------------------------------------
-     * Implementation of CellReadout
-     * ----------------------------------------------------------
-     */
-
-    /**
-     * Get the position of the cell.
-     * @param[in] id The CellId.
-     */
-    Position2D position(CellId id);
-
-    /**
-     * Compute cell ID from local position.
-     * @param[in] pos The 2D position.
-     */
-    CellId cellId(Position2D pos);
-
-    /**
-     * Create a list of neighbor cells from a cell ID.
-     * @param[in] id The CellId.
-     */
-    Neighbors neighbors(CellId id);
-
-    /**
-     * ----------------------------------------------------------
-     * Functionality specific to this implementation.
-     * ----------------------------------------------------------
-     */
-
-    /**
-     * Get the X cell size.
-     * @return The cell size X.
-     */
-    double getCellSizeX();
-
-    /**
-     * Get the Y cell size.
-     * @return The cell size Y.
-     */
-    double getCellSizeY();
-
-    /**
-     * Get the X index from a position.
-     * @param[in] x The X coordinate.
-     * @return The X bin value.
-     */
-    int getXIndex(double x);
-
-    /**
-     * Get the Y index from a position.
-     * @param[in] y The Y coordinate.
-     * @return The Y bin value.
-     */
-    int getYIndex(double y);
-
-    /*
-     * Get the X position from a cell index.
-     * @param[in] ix The X index.
-     * @return The X coordinate.
-     */
-    double getCellPositionX(int ix);
-
-    /**
-     * Get the Y position from a Y bin value.
-     * @param[in] iy The Y index.
-     * @return The Y coordinate.
-     */
-    double getCellPositionY(int iy);
-
-    /**
-     * Create a pair of indices representing a cell.
-     * @param[in] x The X cell index.
-     * @param[in] y The Y cell index.
-     */
-    CellId createCell(int x, int y);
-
-    /**
-     * Given an index and cell size, compute the corresponding coordinate.
-     * @param[in] u        The cell index.
-     * @param[in] cellSize The size of the cell in the corresponding dimension.
-     */
-    double getCellCoordinate(int u, double cellSize);
-
-    /**
-     * Given a coordinate and cell size, compute the corresponding cell index.
-     * @param[in] x        The coordinate value.
-     * @param[in] cellSize The size of the cell in the corresponding dimension.
-     */
-    int getCellIndex(double x, double cellSize);
-
-    /**
-     * Set the current X dimension.
-     * @param[in] dimensionX The dimension in X.
-     */
-    void setDimensionX(double dimensionX);
-
-    /**
-     * Set the current Y dimension.
-     * @param[in] dimensionY The dimension in Y.
-     */
-
-    void setDimensionY(double dimensionY);
-
-    /**
-     * Get the current dimension in X.
-     * @return The dimension in X.
-     */
-    double getDimensionX();
-
-    /**
-     * Get the current dimension in Y.
-     * @return The dimension in Y.
-     */
-    double getDimensionY();
-
-    /**
-     * Check if a CellId is valid.
-     * @param[in] The CellId to check.
-     * @return True if valid; false if not.
-     */
-    bool isValidCell(CellId cell);
-
-    /**
-     * Check if a Position2D is valid.
-     * @param[in] The position to check.
-     * @return True if valid; false if not.
-     */
-    bool isValidPosition(Position2D position);
-
-private:
-
-    double _cellSizeX;
-    double _cellSizeY;
-
-    double _dimensionX;
-    double _dimensionY;
-};
-
-#endif

lcdd/include/lcdd/detectors
CellReadout2DSegmentation.hh removed after 1.8
diff -N CellReadout2DSegmentation.hh
--- CellReadout2DSegmentation.hh	6 Sep 2013 02:17:48 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-#ifndef LCDD_CELLREADOUT2DSEGMENTATION_HH
-#define LCDD_CELLREADOUT2DSEGMENTATION_HH 1
-
-// LCDD
-#include "Segmentation.hh"
-#include "CellReadout2D.hh"
-
-// Geant4
-#include "G4ThreeVector.hh"
-
-class G4Step;
-
-/**
- * @brief Adapt a CellReadout2D object to the LCDD Segmentation interface.
- */
-class CellReadout2DSegmentation: public Segmentation
-{
-
-public:
-
-	/**
-	 * Class constructor.
-	 * @param[in] cellSizeX The cell size X.
-	 * @param[in] cellSizeY The cell size Y.
-	 */
-    CellReadout2DSegmentation(double cellSizeX, double cellSizeY);
-
-    /**
-     * Class destructor.
-     */
-    virtual ~CellReadout2DSegmentation();
-
-    /**
-     * Get the global cell center position from a step.
-     * @param[in] The Geant4 step.
-     * @return The cell's 3D position.
-     */
-    G4ThreeVector getGlobalHitPosition(const G4Step* step);
-
-    /**
-     * Compute the bin values from a Geant4 step.
-     * @param[in] The G4Step object.
-     */
-    void setBins(const G4Step* step);
-
-    /**
-     * Set the bin names for this Segmentation.
-     */
-    void setBinNames();
-
-    /**
-     * Setup derived state of the Segmentation from a G4Step.
-     * @param[in] The G4Step object.
-     */
-    void setup(const G4Step* step);
-
-    /**
-     * Convert local to readout coordinates.
-     * @param[in] pos The local position.
-     * @return The readout coordinates.
-     */
-    CellReadout::Position2D localToReadoutCoordinates(G4ThreeVector& pos);
-
-    /**
-     * Convert unsigned readout coordinates back to local.
-     * @return The local coordinates converted from readout XY position.
-     */
-    G4ThreeVector readoutToLocalCoordinates(CellReadout::Position2D position);
-
-private:
-
-    CellReadout2D* _readout;
-};
-
-#endif

lcdd/include/lcdd/detectors
GlobalGridXYSegmentation.hh removed after 1.6
diff -N GlobalGridXYSegmentation.hh
--- GlobalGridXYSegmentation.hh	11 Jul 2013 20:41:53 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,111 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/GlobalGridXYSegmentation.hh,v 1.6 2013/07/11 20:41:53 jeremy Exp $
-
-#ifndef LCDD_DETECTORS_GLOBALGRIDXYSEGMENTATION_HH
-#define LCDD_DETECTORS_GLOBALGRIDXYSEGMENTATION_HH 1
-
-// LCDD
-#include "Segmentation.hh"
-
-// Geant4
-#include "globals.hh"
-
-/**
- * @brief An XY grid Segmentation in global coordinates.
- * @note This is a version of grid segmentation with binning on global coordinates.
- */
-class GlobalGridXYSegmentation: public Segmentation
-{
-
-public:
-
-	/**
-	 * Class constructor.
-	 * @param[in] gridSizeX The grid size X.
-	 * @param[in] gridSizeY The grid size Y.
-	 */
-    GlobalGridXYSegmentation(double gridSizeX, double gridSizeY);
-
-    /**
-     * Class destructor.
-     */
-    virtual ~GlobalGridXYSegmentation();
-
-public:
-
-    /**
-     * Compute a global hit position from a G4Step.
-     * @param[in] The G4Step object.
-     * @return The cell global position.
-     */
-    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
-
-    /**
-     * Compute a local cell position from a local step position.
-     * @param[in] localStepPos The local step position.
-     * @return The local cell position.
-     */
-    //G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute the ID bin values from a step.
-     * @param[in] aStep The G4Step object.
-     */
-    void setBins(const G4Step* aStep);
-
-    /**
-     * Set the bin names for this Segmentation.
-     */
-    void setBinNames();
-
-private:
-
-    /**
-     * Compute the X bin value from a local coordinate.
-     * @param[in] localStepPos The local step position.
-     * @return The X bin value.
-     */
-    int computeBinX(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute the Y bin value from a local coordinate.
-     * @param[in] localStepPos The local step position.
-     * @return The Y bin value.
-     */
-    int computeBinY(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute the z bin value from a local coordinate.
-     * @param[in] localStepPos The local step position.
-     * @return The Z bin value.
-     */
-    int computeBinZ(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute the X coordinate from a bin value.
-     * @param[in] The X bin value.
-     * @return The X coordinate value.
-     */
-    double computeDimX(int bin);
-
-    /**
-     * Compute the Y coordinate from a bin value.
-     * @param[in] The Y bin value.
-     * @return The Y coordinate value.
-     */
-    double computeDimY(int bin);
-
-    /**
-     * Compute the Z coordinate from a bin value.
-     * @param[in] The Z bin value.
-     * @return The Z coordinate value.
-     */
-    double computeDimZ(int bin);
-
-private:
-
-    double _gridSizeX;
-    double _gridSizeY;
-    double _gridSizeZ;
-};
-
-#endif

lcdd/include/lcdd/detectors
GridXYZSegmentation.hh removed after 1.7
diff -N GridXYZSegmentation.hh
--- GridXYZSegmentation.hh	11 Jul 2013 20:41:53 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,114 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/GridXYZSegmentation.hh,v 1.7 2013/07/11 20:41:53 jeremy Exp $
-#ifndef LCDD_DETECTORS_G4GRIDXYZSEGMENTATION_HH
-#define LCDD_DETECTORS_G4GRIDXYZSEGMENTATION_HH 1
-
-// LCDD
-#include "Segmentation.hh"
-
-// Geant4
-#include "globals.hh"
-
-/**
- * @brief A Segmentation that defines a grid in a combination of X, Y or Z coordinates.
- * @brief This class performs calculations to divide a box-like volume into a uniform, 3D grid of cells.
- */
-class GridXYZSegmentation: public Segmentation
-{
-
-public:
-
-	/**
-	 * Class constructor.
-	 * @param[in] gridSizeX The grid size in X.
-	 * @param[in] gridSizeY The grid size in Y.
-	 * @param[in] gridSizeZ The grid size in Z.
-	 */
-    GridXYZSegmentation(double gridSizeX, double gridSizeY, double gridSizeZ);
-
-    /**
-     * Class destructor.
-     */
-    virtual ~GridXYZSegmentation();
-
-public:
-
-    /**
-     * Compute the global hit position from a step.
-     * @param[in] aStep The G4Step object.
-     * @return The global hit position.
-     */
-    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
-
-    /**
-     * Compute the bin values from a step.
-     * @param[in] aStep The G4Step object.
-     */
-    void setBins(const G4Step* aStep);
-
-    // DEPRECATED
-    //G4ThreeVector getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint);
-
-    /**
-     * Compute the local hit position from a local step position.
-     * @param[in] localStepPos The local step position.
-     * @return The local hit position.
-     */
-    G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
-
-protected:
-
-    /**
-     * Set the valid bin names for this Segmentation.
-     */
-    void setBinNames();
-
-    /**
-     * Compute X bin value from a local coordinate.
-     * @param[in] localStepPos The local step position.
-     * @return The X bin value.
-     */
-    int computeBinX(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute Y bin value from a local coordinate.
-     * @param[in] localStepPos The local step position.
-     * @return The Y bin value.
-     */
-    int computeBinY(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute Z bin value from a local coordinate.
-     * @param[in] localStepPos The local step position.
-     * @return The Z bin value.
-     */
-    int computeBinZ(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute a cell center X coordinate from a bin value.
-     * @param[in] The bin value.
-     * @return The corresponding 1D cell coordinate value.
-     */
-    double computeDimX(int bin);
-
-    /**
-     * Compute a cell center Y coordinate from a bin value.
-     * @param[in] The bin value.
-     * @return The corresponding 1D cell coordinate value.
-     */
-    double computeDimY(int bin);
-
-    /**
-     * Compute a cell center Z coordinate from a bin value.
-     * @param[in] The bin value.
-     * @return The corresponding 1D cell coordinate value.
-     */
-    double computeDimZ(int bin);
-
-private:
-
-    double _gridSizeX;
-    double _gridSizeY;
-    double _gridSizeZ;
-};
-
-#endif

lcdd/include/lcdd/detectors
NonprojectiveCylinderSegmentation.hh removed after 1.7
diff -N NonprojectiveCylinderSegmentation.hh
--- NonprojectiveCylinderSegmentation.hh	11 Jul 2013 20:41:54 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,122 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/NonprojectiveCylinderSegmentation.hh,v 1.7 2013/07/11 20:41:54 jeremy Exp $
-#ifndef LCDD_DETECTORS_G4NONPROJECTIVECYLINDERSEGMENTATION
-#define LCDD_DETECTORS_G4NONPROJECTIVECYLINDERSEGMENTATION 1
-
-// LCDD
-#include "Segmentation.hh"
-
-/**
- * @brief A Segmentation class that implements a nonprojective cylinder.
- * @todo This class needs much better documentation.  Much of the computational code is a black box.
- */
-class NonprojectiveCylinderSegmentation: public Segmentation
-{
-
-public:
-
-	/**
-	 * Class constructor.
-	 * @param[in] gridSizePhi The grid size in phi (radians).
-	 * @param[in] gridSizeZ   The grid size in Z (mm).
-	 */
-    NonprojectiveCylinderSegmentation(double gridSizePhi, double gridSizeZ);
-
-    /**
-     * Class destructor.
-     */
-    virtual ~NonprojectiveCylinderSegmentation();
-
-public:
-
-    /**
-     * Compute the global hit position from a step.
-     * @param[in] aStep The G4Step object.
-     * @return The global hit position for the step.
-     */
-    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
-
-    /**
-     * Compute the global hit position a step point.
-     * @param[in] aPreStepPoint The G4StepPoint object.
-     * @return The global hit position for the step point.
-     */
-    //G4ThreeVector getGlobalHitPos(const G4StepPoint* aPreStepPoint);
-
-    /**
-     * Compute bin values from a step.
-     * @param[in] aStep The G4Step object.
-     */
-    void setBins(const G4Step* aStep);
-
-    /**
-     * Compute bin values from a step point.
-     * @param[in] aPreStepStep The G4StepPoint object.
-     */
-    //void setBins(const G4StepPoint* aPreStepPoint);
-
-    G4ThreeVector getLocalHitPos(const G4Step* aStep);
-
-    /**
-     * @todo This method should not exist.
-     */
-    G4ThreeVector getLocalHitPos(const G4StepPoint* aPreStepPoint);
-
-    /**
-     * Check if a G4VSolid is valid for this segmentation.
-     * @return True if solid is valid; false if not.
-     */
-    bool isValidSolid(G4VSolid*);
-
-protected:
-
-    /**
-     * Set the valid bin names for this Segmentation.
-     */
-    void setBinNames();
-
-private:
-
-    /**
-     * Computes the delta phi from a step.
-     * @param[in] aStep A G4Step object.
-     * @return The delta phi.
-     */
-    double computeDeltaPhi(const G4Step* aStep);
-
-    /**
-     * Compute the phi bin from a step.
-     * @param[in] aStep A G4Step object.
-     * @return The phi bin.
-     */
-    int computeBinPhi(const G4Step* aStep);
-
-    /**
-     * Compute the Z bin from a step.
-     * @param[in] aStep A G4Step object.
-     * @return The Z bin.
-     * @todo Remove this method.
-     */
-    int computeBinZ(const G4ThreeVector& localStepPos);
-
-    /**
-     * Compute the phi bin from a step point.
-     * @param[in] aPreStepPoint The G4StepPoint object.
-     * @return The phi bin.
-     * @todo Remove this method.
-     */
-    int computeBinPhi(const G4StepPoint* aPreStepPoint);
-
-    /**
-     * Compute the delta phi from a step point.
-     * @param[in] aPreStepPoint The G4StepPoint object.
-     * @return The delta phi.
-     */
-    double computeDeltaPhi(const G4StepPoint* aPreStepPoint);
-
-private:
-
-    double _gridSizePhi;
-    double _gridSizeZ;
-};
-
-#endif

lcdd/include/lcdd/detectors
ProjectiveCylinderSegmentation.hh removed after 1.4
diff -N ProjectiveCylinderSegmentation.hh
--- ProjectiveCylinderSegmentation.hh	10 Jul 2013 18:06:17 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/ProjectiveCylinderSegmentation.hh,v 1.4 2013/07/10 18:06:17 jeremy Exp $
-#ifndef LCDD_DETECTORS_G4PROJECTIVECYLINDERSEGMENTATION_HH
-#define LCDD_DETECTORS_G4PROJECTIVECYLINDERSEGMENTATION_HH 1
-
-// LCDD
-#include "lcdd/detectors/ProjectiveSegmentation.hh"
-
-// Geant4
-#include "globals.hh"
-
-/**
- * @brief Segmentation that divides cylinders into theta and phi bins.
- */
-class ProjectiveCylinderSegmentation: public ProjectiveSegmentation
-{
-
-public:
-
-	/**
-	 * Class constructor.
-	 * @param[in] ntheta Number of cells in theta.
-	 * @param[in] nphi   Number of cells in phi.
-	 */
-    ProjectiveCylinderSegmentation(G4int ntheta, G4int nphi);
-
-    /**
-     * Class destructor.
-     */
-    virtual ~ProjectiveCylinderSegmentation();
-
-    /**
-     * Check whether a Geant4 solid is valid for this Segmentation.
-     * @param[in] s The G4VSolid object.
-     * @return True if input sold is valid for the Segmentation; false if not.
-     */
-    bool isValidSolid(G4VSolid* s);
-
-protected:
-
-    /**
-     * Get the radial position of the solid pointed to by the step.
-     * @param[in] aStep The G4Step object.
-     * @return The radial position of the step's cell.
-     */
-    double getRadius(const G4Step* aStep);
-
-    /**
-     * Get the Z coordinate of a cell from the step.
-     * @param[in] aStep The G4Step object.
-     * @return The Z coordinate of the step's cell.
-     */
-    double getZ(const G4Step* aStep);
-
-    /**
-     * Get the radial position of the cell pointed to by the step point.
-     * @param[in] aPreStepPoint The G4StepPoint object.
-     * @return The radial position of the step point's cell.
-     */
-    //double getRadius(const G4StepPoint* aPreStepPoint);
-
-    /**
-     * Get the Z coordinate of a cell from a step point.
-     * @param[in] aPreStepPoint The G4PreStepPoint object.
-     * @return The Z coordinate of the step point's cell.
-     */
-    //double getZ(const G4StepPoint* aPreStepPoint);
-};
-
-#endif

lcdd/include/lcdd/detectors
ProjectiveSegmentation.hh removed after 1.8
diff -N ProjectiveSegmentation.hh
--- ProjectiveSegmentation.hh	11 Jul 2013 20:41:54 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,136 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/ProjectiveSegmentation.hh,v 1.8 2013/07/11 20:41:54 jeremy Exp $
-#ifndef LCDD_DETECTORS_PROJECTIVESEGMENTATION_HH
-#define LCDD_DETECTORS_PROJECTIVESEGMENTATION_HH 1
-
-#include "Segmentation.hh"
-
-#include "globals.hh"
-
-/**
- * @brief The base class for Segmentation classes with projective readouts.
- * @todo Should this class be pure virtual or have a protected constructor?
- */
-class ProjectiveSegmentation: public Segmentation
-{
-
-public:
-
-	/**
-	 * Class constructor.
-	 * @param[in] ntheta The number of cells in theta per 180 degrees.
-	 * @param[in] nphi   The number of cells in phi per 360 degrees.
-	 */
-    ProjectiveSegmentation(int ntheta, int nphi);
-
-    /**
-     * Class destructor.
-     */
-    virtual ~ProjectiveSegmentation();
-
-public:
-
-    /**
-     * Compute the global hit position from the step.
-     * @param[in] aStep The G4Step object.
-     * @return The global hit position at the step.
-     */
-    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
-
-    /**
-     * Compute the bin values from a step.
-     * @param[in] aStep The G4Step object.
-     */
-    void setBins(const G4Step* aStep);
-
-    //G4ThreeVector getGlobalHitPos(const G4StepPoint* aPreStepPoint);
-    //void setBins(const G4StepPoint* aPreStepPoint);
-
-protected:
-
-    /**
-     * Get the valid bin names for this Segmentation.
-     */
-    void setBinNames();
-
-    /**
-     * Get the number of theta cells.
-     * @return The number of theta cells.
-     */
-    int getNtheta() const;
-
-    /**
-     * Get the number of phi cells.
-     * @return The number of phi cells.
-     */
-    int getNphi() const;
-
-    /**
-     * Compute the theta bin from a 3D position.
-     * @return The theta bin.
-     */
-    int getThetaBin(const G4ThreeVector& globalStepPos);
-
-    /**
-     * Compute the phi bin from a 3D position.
-     * @return The phi bin.
-     */
-    int getPhiBin(const G4ThreeVector& globalStepPos);
-
-    /**
-     * Compute a theta coordinate from a bin value.
-     * @return The theta coordinate.
-     */
-    double getThetaDim(const int &thetaBin) const;
-
-    /**
-     * Compute a phi coordinate from a bin value.
-     * @return The phi coordinate.
-     */
-    double getPhiDim(const int &phiBin) const;
-
-    /**
-     * Compute a theta coordinate from a step.
-     * @param[in] aStep The G4Step object.
-     * @return The theta coordinate.
-     */
-    double getThetaDim(const G4Step* aStep);
-
-    /**
-     * Compute a phi coordinate from a step.
-     * @param[in] aStep The G4Step object.
-     * @return The phi coordinate.
-     */
-    double getPhiDim(const G4Step* aStep);
-
-    /**
-     * Get the radius at the step, taken from the geometric cylinder layer at that point.
-     * @return The radius at the step from the geometric cylinder.
-     */
-    virtual double getRadius(const G4Step* aStep);
-
-    /**
-     * Get the Z at the step, taken from the layer of the geometric cylinder layer at that point.
-     * @return The Z at the step from the geometric layer.
-     */
-    virtual double getZ(const G4Step* aStep);
-
-    // dim from prestep
-    //double getThetaDim(const G4StepPoint* aPreStepPoint);
-    // dim from prestep point:
-    //double getPhiDim(const G4StepPoint* aPreStepPoint);
-    //virtual double getRadius(const G4StepPoint* aPreStepPoint);
-    //virtual double getZ(const G4StepPoint* aPreStepPoint);
-
-private:
-
-    /**
-     * Compute the size of the bins from the input parameters.
-     */
-    void computeDivisions();
-
-private:
-    int _ntheta, _nphi;
-    double _divTheta, _divPhi;
-};
-
-#endif

lcdd/include/lcdd/detectors
ProjectiveZPlaneSegmentation.hh removed after 1.4
diff -N ProjectiveZPlaneSegmentation.hh
--- ProjectiveZPlaneSegmentation.hh	10 Jul 2013 18:06:17 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,51 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/ProjectiveZPlaneSegmentation.hh,v 1.4 2013/07/10 18:06:17 jeremy Exp $
-#ifndef LCDD_DETECTORS_PROJECTIVEZPLANESEGMENTATION_HH
-#define LCDD_DETECTORS_PROJECTIVEZPLANESEGMENTATION_HH 1
-
-// LCDD
-#include "ProjectiveSegmentation.hh"
-
-// Geant4
-#include "globals.hh"
-
-/**
- * @brief This is a projective Segmentation using Z and phi.
- * @note This class uses Z from current volume rather than the cylindrical radius.
- * @todo Document this class better.
- */
-class ProjectiveZPlaneSegmentation: public ProjectiveSegmentation
-{
-
-public:
-
-	/**
-	 * Class constructor.
-	 * @param[in] ntheta The number of theta bins per 180 degrees.
-	 * @param[in] nphi   The number of phi bins per 360 degrees.
-	 */
-    ProjectiveZPlaneSegmentation(int ntheta, int nphi);
-
-    /**
-     * Class destructor.
-     */
-    virtual ~ProjectiveZPlaneSegmentation();
-
-protected:
-
-    /**
-     * Get the radius of the step from the cylinder at that point.
-     * @return The radius at the step.
-     */
-    virtual double getRadius(const G4Step* aStep);
-
-    /**
-     * Get the Z of the step from the cylinder at that point.
-     * @return The Z at the step.
-     */
-    virtual double getZ(const G4Step* aStep);
-
-    //virtual double getRadius(const G4StepPoint* aPreStepPoint);
-    //virtual double getZ(const G4StepPoint* aPreStepPoint);
-};
-
-#endif

lcdd/include/lcdd/detectors
Segmentation.hh removed after 1.9
diff -N Segmentation.hh
--- Segmentation.hh	11 Jul 2013 20:41:54 -0000	1.9
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,190 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/Segmentation.hh,v 1.9 2013/07/11 20:41:54 jeremy Exp $
-
-#ifndef LCDD_DETECTORS_SEGMENTATION_HH
-#define LCDD_DETECTORS_SEGMENTATION_HH 1
-
-// Geant4
-#include "G4ThreeVector.hh"
-#include "G4Step.hh"
-
-// STL
-#include <iostream>
-#include <vector>
-
-/**
- * @brief Base class for calorimeter virtual segmentation implementations.
- * @todo Add method setVolume(G4LogicalVolume*) for setting up segmentation from the current G4Step.
- */
-class Segmentation
-{
-public:
-
-	/**
-	 * Defines the basic type of Segmentation, e.g. projective or non-projective.
-	 */
-    enum EType
-    {
-        eProjective = 1, eNonprojective
-    };
-
-    /**
-     * Type definition for list of bin names.
-     */
-    typedef std::vector<std::string> BinNames;
-
-public:
-
-    /**
-     * Class Constructor.
-     * @param[in] segType The type of Segmentation.
-     * @param[in] nbins   The number of bins defined by this Segmentation.
-     */
-    Segmentation(EType segType, int nbins = 2);
-
-    virtual ~Segmentation();
-
-public:
-
-    /**
-     * Compute the global hit position from a step using this Segmentation.
-     * @param[in] aStep The Geant4 step.
-     * @return The hit's global position.
-     */
-    virtual G4ThreeVector getGlobalHitPosition(const G4Step* aStep) = 0;
-
-    /**
-     * Set the identifier bin values from a step.
-     * @param[in] aStep The Geant4 step.
-     */
-    virtual void setBins(const G4Step* aStep) = 0;
-
-    /*
-     * Check whether the solid is valid for this segmentation.
-     * @return True if solid is valid; false if not.
-     */
-    virtual bool isValidSolid(G4VSolid*);
-
-    /**
-     * @deprecated Only used by G4OpticalCalorimeter.
-     * @todo n     Move to G4OpticalCalorimeter.
-     * @warning    Dummy method only.  Specific Segmentation types must implement.
-     */
-    G4ThreeVector getLocalHitPosition(const G4ThreeVector& localStepPos);
-
-    /**
-     * Reset the bins values to all zero.
-     */
-    void resetBins();
-
-    /**
-     * Get the type of this segmentation.
-     * @return The Segmentation type as an enum.
-     */
-    EType getType();
-
-    /**
-     * Get a string for this Segmentation type.
-     * @return The Segmentation type as a string.
-     */
-    const G4String& getTypeString();
-
-    /**
-     * Get a bin value from an index.
-     * @param[in] idx The index of the bin.
-     * @return The bin value.
-     * @todo Change this method's name to "getBinValue".
-     */
-    int getBin(int idx);
-
-    /**
-     * Get the name of a bin from an index.
-     * @param[in] idx The bin index.
-     * @return The name of the bin.
-     */
-    const std::string& getBinName(int idx);
-
-    /**
-     * Get the number of bins defined by this Segmentation.
-     * @return The number of bins.
-     */
-    int getNumberOfBins();
-
-    /**
-     * Get a list of current bin values.
-     * @return A list of bin values.
-     */
-    const std::vector<int>& getBins();
-
-    /**
-     * Get a list of bin names.
-     * @return The list of bin names.
-     */
-    const std::vector<std::string>& getBinNames();
-
-    /**
-     * Print this object's bin values to an output stream.
-     * @param[in] os The output stream.
-     */
-    void printOutBins(std::ostream& os);
-
-protected:
-
-    /**
-     * Set the valid bin names for this Segmentation.
-     * @note This should only be called once.
-     */
-    virtual void setBinNames() = 0;
-
-    /**
-     * Add a bin name to the end of the list.
-     * @param[in] The name of the bin.
-     */
-    void addBinName(const std::string& binName);
-
-    /**
-     * Set the bin value.
-     * @param[in] binIdx The index of the bin.
-     * @param[in] binVal The value of the bin.
-     * @todo Change method name to "setBinValue".
-     */
-    void setBin(int binIdx, int binVal);
-
-    /**
-     * Print the bin values to an output stream.
-     * @param[in] os   The output stream.
-     * @param[in] bins The list of bin values.
-     */
-    static void printOutBins(std::ostream& os, const std::vector<int>& bins);
-
-    /**
-     * Compute the bin given a coordinate in one dimension.
-     * @param[in] localDim The 1D coordinate value.
-     * @param[in] gridDim  The dimension of the readout grid.
-     * @return The value of the bin at that coordinate.
-     */
-    static int computeBin(double localDim, double gridDim);
-
-    /**
-     * Compute the coordinate of a cell center at a given a bin value.
-     * @param[in] bin  The bin value.
-     * @param[in] incr The grid size.
-     * @return The coordinate of the cell center.
-     */
-    static double computeDim(const int &bin, const double &incr);
-
-private:
-
-    /** The current bin values. */
-    std::vector<int> _bins;
-
-    /** The list of bin names. */
-    BinNames _binNames;
-
-    /** The number of bins. */
-    int _numBins;
-
-    /** The type of Segmentation. */
-    EType _type;
-};
-
-#endif

lcdd/include/lcdd/detectors
SegmentationFactory.hh removed after 1.4
diff -N SegmentationFactory.hh
--- SegmentationFactory.hh	10 Jul 2013 18:06:17 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,36 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/SegmentationFactory.hh,v 1.4 2013/07/10 18:06:17 jeremy Exp $
-
-#ifndef LCDD_DETECTORS_SEGMENTATIONFACTORY_HH
-#define LCDD_DETECTORS_SEGMENTATIONFACTORY_HH 1
-
-class Segmentation;
-class SAXObject;
-
-// STL
-#include <string>
-
-/**
- * @brief Factory for creating Segmentation objects from SAX objects and their tag names.
- */
-class SegmentationFactory
-{
-
-private:
-
-	/**
-	 * Class constructor which should not be accessed.
-	 */
-    SegmentationFactory();
-
-public:
-
-    /**
-     * Create a Segmentation object from a SAX object and tag name.
-     * @param[in] obj The SAXObject of the segmentation.
-     * @param[in] tag The segmentation's tag name.
-     * @return The Segmentation object.
-     */
-    static Segmentation* createSegmentation(SAXObject* obj, const std::string& tag);
-};
-
-#endif

lcdd/include/lcdd/segmentation
CellReadout.hh added at 1.1
diff -N CellReadout.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellReadout.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,71 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/CellReadout.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+
+#ifndef LCDD_SEGMENTATION_CELLREADOUT_HH
+#define LCDD_SEGMENTATION_CELLREADOUT_HH 1
+
+// STL
+#include <vector>
+#include <map>
+#include <string>
+
+/**
+ * @brief Pure virtual base class for calorimeter cell readouts to implement.
+ * @todo Move to DDSegmentation package.
+ */
+class CellReadout
+{
+
+public:
+
+    /** 2D XY position. */
+    struct Position2D
+    {
+        double x;
+        double y;
+    };
+
+    /** Cell ID represented as a pair of int values. */
+    struct CellId
+    {
+        int ix;
+        int iy;
+    };
+
+    /** A list of a cell's neighbor IDs. */
+    typedef std::vector<CellId> Neighbors;
+
+public:
+
+    /**
+     * Class constructor.
+     */
+    CellReadout();
+
+    /**
+     * Class destructor.
+     */
+    virtual ~CellReadout();
+
+    /**
+     * Compute cell ID from local position.
+     * @param[in] pos A 2D position.
+     * @return A CellId from the position.
+     */
+    virtual CellId cellId(Position2D pos) = 0;
+
+    /**
+     * Compute local position of a cell ID.
+     * @param[in] id The cell id.
+     * @return The position from the CellId.
+     */
+    virtual Position2D position(CellId id) = 0;
+
+    /**
+     * Create a list of neighbor cells from a cell ID.
+     * @param[in] id The cell id.
+     * @return The list of Neighbors for the given CellId.
+     */
+    virtual Neighbors neighbors(CellId id) = 0;
+};
+
+#endif

lcdd/include/lcdd/segmentation
CellReadout2D.hh added at 1.1
diff -N CellReadout2D.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellReadout2D.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,173 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/CellReadout2D.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+
+#ifndef LCDD_SEGMENTATION_CELLREADOUT2D_HH
+#define LCDD_SEGMENTATION_CELLREADOUT2D_HH 1
+
+// LCDD
+#include "lcdd/segmentation/CellReadout.hh"
+
+// STL
+#include <vector>
+#include <map>
+
+/**
+ * @brief
+ * A concrete implementation of CellReadout using a 2D grid
+ * with coordinate origin in the lower lefthand corner of the
+ * readout volume.
+ */
+class CellReadout2D: public CellReadout
+{
+
+public:
+
+    /**
+     * Class destructor.
+     */
+    virtual ~CellReadout2D();
+
+    /**
+     * Class constructor.
+     */
+    CellReadout2D(double cellSizeX, double cellSizeY);
+
+    /**
+     * ----------------------------------------------------------
+     * Implementation of CellReadout
+     * ----------------------------------------------------------
+     */
+
+    /**
+     * Get the position of the cell.
+     * @param[in] id The CellId.
+     */
+    Position2D position(CellId id);
+
+    /**
+     * Compute cell ID from local position.
+     * @param[in] pos The 2D position.
+     */
+    CellId cellId(Position2D pos);
+
+    /**
+     * Create a list of neighbor cells from a cell ID.
+     * @param[in] id The CellId.
+     */
+    Neighbors neighbors(CellId id);
+
+    /**
+     * ----------------------------------------------------------
+     * Functionality specific to this implementation.
+     * ----------------------------------------------------------
+     */
+
+    /**
+     * Get the X cell size.
+     * @return The cell size X.
+     */
+    double getCellSizeX();
+
+    /**
+     * Get the Y cell size.
+     * @return The cell size Y.
+     */
+    double getCellSizeY();
+
+    /**
+     * Get the X index from a position.
+     * @param[in] x The X coordinate.
+     * @return The X bin value.
+     */
+    int getXIndex(double x);
+
+    /**
+     * Get the Y index from a position.
+     * @param[in] y The Y coordinate.
+     * @return The Y bin value.
+     */
+    int getYIndex(double y);
+
+    /*
+     * Get the X position from a cell index.
+     * @param[in] ix The X index.
+     * @return The X coordinate.
+     */
+    double getCellPositionX(int ix);
+
+    /**
+     * Get the Y position from a Y bin value.
+     * @param[in] iy The Y index.
+     * @return The Y coordinate.
+     */
+    double getCellPositionY(int iy);
+
+    /**
+     * Create a pair of indices representing a cell.
+     * @param[in] x The X cell index.
+     * @param[in] y The Y cell index.
+     */
+    CellId createCell(int x, int y);
+
+    /**
+     * Given an index and cell size, compute the corresponding coordinate.
+     * @param[in] u        The cell index.
+     * @param[in] cellSize The size of the cell in the corresponding dimension.
+     */
+    double getCellCoordinate(int u, double cellSize);
+
+    /**
+     * Given a coordinate and cell size, compute the corresponding cell index.
+     * @param[in] x        The coordinate value.
+     * @param[in] cellSize The size of the cell in the corresponding dimension.
+     */
+    int getCellIndex(double x, double cellSize);
+
+    /**
+     * Set the current X dimension.
+     * @param[in] dimensionX The dimension in X.
+     */
+    void setDimensionX(double dimensionX);
+
+    /**
+     * Set the current Y dimension.
+     * @param[in] dimensionY The dimension in Y.
+     */
+
+    void setDimensionY(double dimensionY);
+
+    /**
+     * Get the current dimension in X.
+     * @return The dimension in X.
+     */
+    double getDimensionX();
+
+    /**
+     * Get the current dimension in Y.
+     * @return The dimension in Y.
+     */
+    double getDimensionY();
+
+    /**
+     * Check if a CellId is valid.
+     * @param[in] The CellId to check.
+     * @return True if valid; false if not.
+     */
+    bool isValidCell(CellId cell);
+
+    /**
+     * Check if a Position2D is valid.
+     * @param[in] The position to check.
+     * @return True if valid; false if not.
+     */
+    bool isValidPosition(Position2D position);
+
+private:
+
+    double _cellSizeX;
+    double _cellSizeY;
+
+    double _dimensionX;
+    double _dimensionY;
+};
+
+#endif

lcdd/include/lcdd/segmentation
CellReadout2DSegmentation.hh added at 1.1
diff -N CellReadout2DSegmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellReadout2DSegmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,75 @@
+#ifndef LCDD_SEGMENTATION_CELLREADOUT2DSEGMENTATION_HH
+#define LCDD_SEGMENTATION_CELLREADOUT2DSEGMENTATION_HH 1
+
+// LCDD
+#include "lcdd/segmentation/Segmentation.hh"
+#include "lcdd/segmentation/CellReadout2D.hh"
+
+// Geant4
+#include "G4ThreeVector.hh"
+
+class G4Step;
+
+/**
+ * @brief Adapt a CellReadout2D object to the LCDD Segmentation interface.
+ */
+class CellReadout2DSegmentation: public Segmentation
+{
+
+public:
+
+	/**
+	 * Class constructor.
+	 * @param[in] cellSizeX The cell size X.
+	 * @param[in] cellSizeY The cell size Y.
+	 */
+    CellReadout2DSegmentation(double cellSizeX, double cellSizeY);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~CellReadout2DSegmentation();
+
+    /**
+     * Get the global cell center position from a step.
+     * @param[in] The Geant4 step.
+     * @return The cell's 3D position.
+     */
+    G4ThreeVector getGlobalHitPosition(const G4Step* step);
+
+    /**
+     * Compute the bin values from a Geant4 step.
+     * @param[in] The G4Step object.
+     */
+    void setBins(const G4Step* step);
+
+    /**
+     * Set the bin names for this Segmentation.
+     */
+    void setBinNames();
+
+    /**
+     * Setup derived state of the Segmentation from a G4Step.
+     * @param[in] The G4Step object.
+     */
+    void setup(const G4Step* step);
+
+    /**
+     * Convert local to readout coordinates.
+     * @param[in] pos The local position.
+     * @return The readout coordinates.
+     */
+    CellReadout::Position2D localToReadoutCoordinates(G4ThreeVector& pos);
+
+    /**
+     * Convert unsigned readout coordinates back to local.
+     * @return The local coordinates converted from readout XY position.
+     */
+    G4ThreeVector readoutToLocalCoordinates(CellReadout::Position2D position);
+
+private:
+
+    CellReadout2D* _readout;
+};
+
+#endif

lcdd/include/lcdd/segmentation
GlobalGridXYSegmentation.hh added at 1.1
diff -N GlobalGridXYSegmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GlobalGridXYSegmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,111 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/GlobalGridXYSegmentation.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+
+#ifndef LCDD_SEGMENTATION_GLOBALGRIDXYSEGMENTATION_HH
+#define LCDD_SEGMENTATION_GLOBALGRIDXYSEGMENTATION_HH 1
+
+// LCDD
+#include "lcdd/segmentation/Segmentation.hh"
+
+// Geant4
+#include "globals.hh"
+
+/**
+ * @brief An XY grid Segmentation in global coordinates.
+ * @note This is a version of grid segmentation with binning on global coordinates.
+ */
+class GlobalGridXYSegmentation: public Segmentation
+{
+
+public:
+
+	/**
+	 * Class constructor.
+	 * @param[in] gridSizeX The grid size X.
+	 * @param[in] gridSizeY The grid size Y.
+	 */
+    GlobalGridXYSegmentation(double gridSizeX, double gridSizeY);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~GlobalGridXYSegmentation();
+
+public:
+
+    /**
+     * Compute a global hit position from a G4Step.
+     * @param[in] The G4Step object.
+     * @return The cell global position.
+     */
+    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
+
+    /**
+     * Compute a local cell position from a local step position.
+     * @param[in] localStepPos The local step position.
+     * @return The local cell position.
+     */
+    //G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute the ID bin values from a step.
+     * @param[in] aStep The G4Step object.
+     */
+    void setBins(const G4Step* aStep);
+
+    /**
+     * Set the bin names for this Segmentation.
+     */
+    void setBinNames();
+
+private:
+
+    /**
+     * Compute the X bin value from a local coordinate.
+     * @param[in] localStepPos The local step position.
+     * @return The X bin value.
+     */
+    int computeBinX(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute the Y bin value from a local coordinate.
+     * @param[in] localStepPos The local step position.
+     * @return The Y bin value.
+     */
+    int computeBinY(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute the z bin value from a local coordinate.
+     * @param[in] localStepPos The local step position.
+     * @return The Z bin value.
+     */
+    int computeBinZ(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute the X coordinate from a bin value.
+     * @param[in] The X bin value.
+     * @return The X coordinate value.
+     */
+    double computeDimX(int bin);
+
+    /**
+     * Compute the Y coordinate from a bin value.
+     * @param[in] The Y bin value.
+     * @return The Y coordinate value.
+     */
+    double computeDimY(int bin);
+
+    /**
+     * Compute the Z coordinate from a bin value.
+     * @param[in] The Z bin value.
+     * @return The Z coordinate value.
+     */
+    double computeDimZ(int bin);
+
+private:
+
+    double _gridSizeX;
+    double _gridSizeY;
+    double _gridSizeZ;
+};
+
+#endif

lcdd/include/lcdd/segmentation
GridXYZSegmentation.hh added at 1.1
diff -N GridXYZSegmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GridXYZSegmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,114 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/GridXYZSegmentation.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+#ifndef LCDD_SEGMENTATION_G4GRIDXYZSEGMENTATION_HH
+#define LCDD_SEGMENTATION_G4GRIDXYZSEGMENTATION_HH 1
+
+// LCDD
+#include "lcdd/segmentation/Segmentation.hh"
+
+// Geant4
+#include "globals.hh"
+
+/**
+ * @brief A Segmentation that defines a grid in a combination of X, Y or Z coordinates.
+ * @brief This class performs calculations to divide a box-like volume into a uniform, 3D grid of cells.
+ */
+class GridXYZSegmentation: public Segmentation
+{
+
+public:
+
+	/**
+	 * Class constructor.
+	 * @param[in] gridSizeX The grid size in X.
+	 * @param[in] gridSizeY The grid size in Y.
+	 * @param[in] gridSizeZ The grid size in Z.
+	 */
+    GridXYZSegmentation(double gridSizeX, double gridSizeY, double gridSizeZ);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~GridXYZSegmentation();
+
+public:
+
+    /**
+     * Compute the global hit position from a step.
+     * @param[in] aStep The G4Step object.
+     * @return The global hit position.
+     */
+    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
+
+    /**
+     * Compute the bin values from a step.
+     * @param[in] aStep The G4Step object.
+     */
+    void setBins(const G4Step* aStep);
+
+    // DEPRECATED
+    //G4ThreeVector getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint);
+
+    /**
+     * Compute the local hit position from a local step position.
+     * @param[in] localStepPos The local step position.
+     * @return The local hit position.
+     */
+    G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
+
+protected:
+
+    /**
+     * Set the valid bin names for this Segmentation.
+     */
+    void setBinNames();
+
+    /**
+     * Compute X bin value from a local coordinate.
+     * @param[in] localStepPos The local step position.
+     * @return The X bin value.
+     */
+    int computeBinX(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute Y bin value from a local coordinate.
+     * @param[in] localStepPos The local step position.
+     * @return The Y bin value.
+     */
+    int computeBinY(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute Z bin value from a local coordinate.
+     * @param[in] localStepPos The local step position.
+     * @return The Z bin value.
+     */
+    int computeBinZ(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute a cell center X coordinate from a bin value.
+     * @param[in] The bin value.
+     * @return The corresponding 1D cell coordinate value.
+     */
+    double computeDimX(int bin);
+
+    /**
+     * Compute a cell center Y coordinate from a bin value.
+     * @param[in] The bin value.
+     * @return The corresponding 1D cell coordinate value.
+     */
+    double computeDimY(int bin);
+
+    /**
+     * Compute a cell center Z coordinate from a bin value.
+     * @param[in] The bin value.
+     * @return The corresponding 1D cell coordinate value.
+     */
+    double computeDimZ(int bin);
+
+private:
+
+    double _gridSizeX;
+    double _gridSizeY;
+    double _gridSizeZ;
+};
+
+#endif

lcdd/include/lcdd/segmentation
NonprojectiveCylinderSegmentation.hh added at 1.1
diff -N NonprojectiveCylinderSegmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ NonprojectiveCylinderSegmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,122 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/NonprojectiveCylinderSegmentation.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+#ifndef LCDD_SEGMENTATION_G4NONPROJECTIVECYLINDERSEGMENTATION
+#define LCDD_SEGMENTATION_G4NONPROJECTIVECYLINDERSEGMENTATION 1
+
+// LCDD
+#include "lcdd/segmentation/Segmentation.hh"
+
+/**
+ * @brief A Segmentation class that implements a nonprojective cylinder.
+ * @todo This class needs much better documentation.  Much of the computational code is a black box.
+ */
+class NonprojectiveCylinderSegmentation: public Segmentation
+{
+
+public:
+
+	/**
+	 * Class constructor.
+	 * @param[in] gridSizePhi The grid size in phi (radians).
+	 * @param[in] gridSizeZ   The grid size in Z (mm).
+	 */
+    NonprojectiveCylinderSegmentation(double gridSizePhi, double gridSizeZ);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~NonprojectiveCylinderSegmentation();
+
+public:
+
+    /**
+     * Compute the global hit position from a step.
+     * @param[in] aStep The G4Step object.
+     * @return The global hit position for the step.
+     */
+    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
+
+    /**
+     * Compute the global hit position a step point.
+     * @param[in] aPreStepPoint The G4StepPoint object.
+     * @return The global hit position for the step point.
+     */
+    //G4ThreeVector getGlobalHitPos(const G4StepPoint* aPreStepPoint);
+
+    /**
+     * Compute bin values from a step.
+     * @param[in] aStep The G4Step object.
+     */
+    void setBins(const G4Step* aStep);
+
+    /**
+     * Compute bin values from a step point.
+     * @param[in] aPreStepStep The G4StepPoint object.
+     */
+    //void setBins(const G4StepPoint* aPreStepPoint);
+
+    G4ThreeVector getLocalHitPos(const G4Step* aStep);
+
+    /**
+     * @todo This method should not exist.
+     */
+    G4ThreeVector getLocalHitPos(const G4StepPoint* aPreStepPoint);
+
+    /**
+     * Check if a G4VSolid is valid for this segmentation.
+     * @return True if solid is valid; false if not.
+     */
+    bool isValidSolid(G4VSolid*);
+
+protected:
+
+    /**
+     * Set the valid bin names for this Segmentation.
+     */
+    void setBinNames();
+
+private:
+
+    /**
+     * Computes the delta phi from a step.
+     * @param[in] aStep A G4Step object.
+     * @return The delta phi.
+     */
+    double computeDeltaPhi(const G4Step* aStep);
+
+    /**
+     * Compute the phi bin from a step.
+     * @param[in] aStep A G4Step object.
+     * @return The phi bin.
+     */
+    int computeBinPhi(const G4Step* aStep);
+
+    /**
+     * Compute the Z bin from a step.
+     * @param[in] aStep A G4Step object.
+     * @return The Z bin.
+     * @todo Remove this method.
+     */
+    int computeBinZ(const G4ThreeVector& localStepPos);
+
+    /**
+     * Compute the phi bin from a step point.
+     * @param[in] aPreStepPoint The G4StepPoint object.
+     * @return The phi bin.
+     * @todo Remove this method.
+     */
+    int computeBinPhi(const G4StepPoint* aPreStepPoint);
+
+    /**
+     * Compute the delta phi from a step point.
+     * @param[in] aPreStepPoint The G4StepPoint object.
+     * @return The delta phi.
+     */
+    double computeDeltaPhi(const G4StepPoint* aPreStepPoint);
+
+private:
+
+    double _gridSizePhi;
+    double _gridSizeZ;
+};
+
+#endif

lcdd/include/lcdd/segmentation
ProjectiveCylinderSegmentation.hh added at 1.1
diff -N ProjectiveCylinderSegmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProjectiveCylinderSegmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,69 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/ProjectiveCylinderSegmentation.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+#ifndef LCDD_SEGMENTATION_PROJECTIVECYLINDERSEGMENTATION_HH
+#define LCDD_SEGMENTATION_PROJECTIVECYLINDERSEGMENTATION_HH 1
+
+// LCDD
+#include "lcdd/segmentation/ProjectiveSegmentation.hh"
+
+// Geant4
+#include "globals.hh"
+
+/**
+ * @brief Segmentation that divides cylinders into theta and phi bins.
+ */
+class ProjectiveCylinderSegmentation: public ProjectiveSegmentation
+{
+
+public:
+
+	/**
+	 * Class constructor.
+	 * @param[in] ntheta Number of cells in theta.
+	 * @param[in] nphi   Number of cells in phi.
+	 */
+    ProjectiveCylinderSegmentation(G4int ntheta, G4int nphi);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~ProjectiveCylinderSegmentation();
+
+    /**
+     * Check whether a Geant4 solid is valid for this Segmentation.
+     * @param[in] s The G4VSolid object.
+     * @return True if input sold is valid for the Segmentation; false if not.
+     */
+    bool isValidSolid(G4VSolid* s);
+
+protected:
+
+    /**
+     * Get the radial position of the solid pointed to by the step.
+     * @param[in] aStep The G4Step object.
+     * @return The radial position of the step's cell.
+     */
+    double getRadius(const G4Step* aStep);
+
+    /**
+     * Get the Z coordinate of a cell from the step.
+     * @param[in] aStep The G4Step object.
+     * @return The Z coordinate of the step's cell.
+     */
+    double getZ(const G4Step* aStep);
+
+    /**
+     * Get the radial position of the cell pointed to by the step point.
+     * @param[in] aPreStepPoint The G4StepPoint object.
+     * @return The radial position of the step point's cell.
+     */
+    //double getRadius(const G4StepPoint* aPreStepPoint);
+
+    /**
+     * Get the Z coordinate of a cell from a step point.
+     * @param[in] aPreStepPoint The G4PreStepPoint object.
+     * @return The Z coordinate of the step point's cell.
+     */
+    //double getZ(const G4StepPoint* aPreStepPoint);
+};
+
+#endif

lcdd/include/lcdd/segmentation
ProjectiveSegmentation.hh added at 1.1
diff -N ProjectiveSegmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProjectiveSegmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,136 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/ProjectiveSegmentation.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+#ifndef LCDD_SEGMENTATION_PROJECTIVESEGMENTATION_HH
+#define LCDD_SEGMENTATION_PROJECTIVESEGMENTATION_HH 1
+
+#include "lcdd/segmentation/Segmentation.hh"
+
+#include "globals.hh"
+
+/**
+ * @brief The base class for Segmentation classes with projective readouts.
+ * @todo Should this class be pure virtual or have a protected constructor?
+ */
+class ProjectiveSegmentation: public Segmentation
+{
+
+public:
+
+	/**
+	 * Class constructor.
+	 * @param[in] ntheta The number of cells in theta per 180 degrees.
+	 * @param[in] nphi   The number of cells in phi per 360 degrees.
+	 */
+    ProjectiveSegmentation(int ntheta, int nphi);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~ProjectiveSegmentation();
+
+public:
+
+    /**
+     * Compute the global hit position from the step.
+     * @param[in] aStep The G4Step object.
+     * @return The global hit position at the step.
+     */
+    G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
+
+    /**
+     * Compute the bin values from a step.
+     * @param[in] aStep The G4Step object.
+     */
+    void setBins(const G4Step* aStep);
+
+    //G4ThreeVector getGlobalHitPos(const G4StepPoint* aPreStepPoint);
+    //void setBins(const G4StepPoint* aPreStepPoint);
+
+protected:
+
+    /**
+     * Get the valid bin names for this Segmentation.
+     */
+    void setBinNames();
+
+    /**
+     * Get the number of theta cells.
+     * @return The number of theta cells.
+     */
+    int getNtheta() const;
+
+    /**
+     * Get the number of phi cells.
+     * @return The number of phi cells.
+     */
+    int getNphi() const;
+
+    /**
+     * Compute the theta bin from a 3D position.
+     * @return The theta bin.
+     */
+    int getThetaBin(const G4ThreeVector& globalStepPos);
+
+    /**
+     * Compute the phi bin from a 3D position.
+     * @return The phi bin.
+     */
+    int getPhiBin(const G4ThreeVector& globalStepPos);
+
+    /**
+     * Compute a theta coordinate from a bin value.
+     * @return The theta coordinate.
+     */
+    double getThetaDim(const int &thetaBin) const;
+
+    /**
+     * Compute a phi coordinate from a bin value.
+     * @return The phi coordinate.
+     */
+    double getPhiDim(const int &phiBin) const;
+
+    /**
+     * Compute a theta coordinate from a step.
+     * @param[in] aStep The G4Step object.
+     * @return The theta coordinate.
+     */
+    double getThetaDim(const G4Step* aStep);
+
+    /**
+     * Compute a phi coordinate from a step.
+     * @param[in] aStep The G4Step object.
+     * @return The phi coordinate.
+     */
+    double getPhiDim(const G4Step* aStep);
+
+    /**
+     * Get the radius at the step, taken from the geometric cylinder layer at that point.
+     * @return The radius at the step from the geometric cylinder.
+     */
+    virtual double getRadius(const G4Step* aStep);
+
+    /**
+     * Get the Z at the step, taken from the layer of the geometric cylinder layer at that point.
+     * @return The Z at the step from the geometric layer.
+     */
+    virtual double getZ(const G4Step* aStep);
+
+    // dim from prestep
+    //double getThetaDim(const G4StepPoint* aPreStepPoint);
+    // dim from prestep point:
+    //double getPhiDim(const G4StepPoint* aPreStepPoint);
+    //virtual double getRadius(const G4StepPoint* aPreStepPoint);
+    //virtual double getZ(const G4StepPoint* aPreStepPoint);
+
+private:
+
+    /**
+     * Compute the size of the bins from the input parameters.
+     */
+    void computeDivisions();
+
+private:
+    int _ntheta, _nphi;
+    double _divTheta, _divPhi;
+};
+
+#endif

lcdd/include/lcdd/segmentation
ProjectiveZPlaneSegmentation.hh added at 1.1
diff -N ProjectiveZPlaneSegmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProjectiveZPlaneSegmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,51 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/ProjectiveZPlaneSegmentation.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+#ifndef LCDD_SEGMENTATION_PROJECTIVEZPLANESEGMENTATION_HH
+#define LCDD_SEGMENTATION_PROJECTIVEZPLANESEGMENTATION_HH 1
+
+// LCDD
+#include "lcdd/segmentation/ProjectiveSegmentation.hh"
+
+// Geant4
+#include "globals.hh"
+
+/**
+ * @brief This is a projective Segmentation using Z and phi.
+ * @note This class uses Z from current volume rather than the cylindrical radius.
+ * @todo Document this class better.
+ */
+class ProjectiveZPlaneSegmentation: public ProjectiveSegmentation
+{
+
+public:
+
+	/**
+	 * Class constructor.
+	 * @param[in] ntheta The number of theta bins per 180 degrees.
+	 * @param[in] nphi   The number of phi bins per 360 degrees.
+	 */
+    ProjectiveZPlaneSegmentation(int ntheta, int nphi);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~ProjectiveZPlaneSegmentation();
+
+protected:
+
+    /**
+     * Get the radius of the step from the cylinder at that point.
+     * @return The radius at the step.
+     */
+    virtual double getRadius(const G4Step* aStep);
+
+    /**
+     * Get the Z of the step from the cylinder at that point.
+     * @return The Z at the step.
+     */
+    virtual double getZ(const G4Step* aStep);
+
+    //virtual double getRadius(const G4StepPoint* aPreStepPoint);
+    //virtual double getZ(const G4StepPoint* aPreStepPoint);
+};
+
+#endif

lcdd/include/lcdd/segmentation
Segmentation.hh added at 1.1
diff -N Segmentation.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Segmentation.hh	10 Sep 2013 21:57:32 -0000	1.1
@@ -0,0 +1,190 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/Segmentation.hh,v 1.1 2013/09/10 21:57:32 jeremy Exp $
+
+#ifndef LCDD_SEGMENTATION_SEGMENTATION_HH
+#define LCDD_SEGMENTATION_SEGMENTATION_HH 1
+
+// Geant4
+#include "G4ThreeVector.hh"
+#include "G4Step.hh"
+
+// STL
+#include <iostream>
+#include <vector>
+
+/**
+ * @brief Base class for calorimeter virtual segmentation implementations.
+ * @todo Add method setVolume(G4LogicalVolume*) for setting up segmentation from the current G4Step.
+ */
+class Segmentation
+{
+public:
+
+	/**
+	 * Defines the basic type of Segmentation, e.g. projective or non-projective.
+	 */
+    enum EType
+    {
+        eProjective = 1, eNonprojective
+    };
+
+    /**
+     * Type definition for list of bin names.
+     */
+    typedef std::vector<std::string> BinNames;
+
+public:
+
+    /**
+     * Class Constructor.
+     * @param[in] segType The type of Segmentation.
+     * @param[in] nbins   The number of bins defined by this Segmentation.
+     */
+    Segmentation(EType segType, int nbins = 2);
+
+    virtual ~Segmentation();
+
+public:
+
+    /**
+     * Compute the global hit position from a step using this Segmentation.
+     * @param[in] aStep The Geant4 step.
+     * @return The hit's global position.
+     */
+    virtual G4ThreeVector getGlobalHitPosition(const G4Step* aStep) = 0;
+
+    /**
+     * Set the identifier bin values from a step.
+     * @param[in] aStep The Geant4 step.
+     */
+    virtual void setBins(const G4Step* aStep) = 0;
+
+    /*
+     * Check whether the solid is valid for this segmentation.
+     * @return True if solid is valid; false if not.
+     */
+    virtual bool isValidSolid(G4VSolid*);
+
+    /**
+     * @deprecated Only used by G4OpticalCalorimeter.
+     * @todo n     Move to G4OpticalCalorimeter.
+     * @warning    Dummy method only.  Specific Segmentation types must implement.
+     */
+    G4ThreeVector getLocalHitPosition(const G4ThreeVector& localStepPos);
+
+    /**
+     * Reset the bins values to all zero.
+     */
+    void resetBins();
+
+    /**
+     * Get the type of this segmentation.
+     * @return The Segmentation type as an enum.
+     */
+    EType getType();
+
+    /**
+     * Get a string for this Segmentation type.
+     * @return The Segmentation type as a string.
+     */
+    const G4String& getTypeString();
+
+    /**
+     * Get a bin value from an index.
+     * @param[in] idx The index of the bin.
+     * @return The bin value.
+     * @todo Change this method's name to "getBinValue".
+     */
+    int getBin(int idx);
+
+    /**
+     * Get the name of a bin from an index.
+     * @param[in] idx The bin index.
+     * @return The name of the bin.
+     */
+    const std::string& getBinName(int idx);
+
+    /**
+     * Get the number of bins defined by this Segmentation.
+     * @return The number of bins.
+     */
+    int getNumberOfBins();
+
+    /**
+     * Get a list of current bin values.
+     * @return A list of bin values.
+     */
+    const std::vector<int>& getBins();
+
+    /**
+     * Get a list of bin names.
+     * @return The list of bin names.
+     */
+    const std::vector<std::string>& getBinNames();
+
+    /**
+     * Print this object's bin values to an output stream.
+     * @param[in] os The output stream.
+     */
+    void printOutBins(std::ostream& os);
+
+protected:
+
+    /**
+     * Set the valid bin names for this Segmentation.
+     * @note This should only be called once.
+     */
+    virtual void setBinNames() = 0;
+
+    /**
+     * Add a bin name to the end of the list.
+     * @param[in] The name of the bin.
+     */
+    void addBinName(const std::string& binName);
+
+    /**
+     * Set the bin value.
+     * @param[in] binIdx The index of the bin.
+     * @param[in] binVal The value of the bin.
+     * @todo Change method name to "setBinValue".
+     */
+    void setBin(int binIdx, int binVal);
+
+    /**
+     * Print the bin values to an output stream.
+     * @param[in] os   The output stream.
+     * @param[in] bins The list of bin values.
+     */
+    static void printOutBins(std::ostream& os, const std::vector<int>& bins);
+
+    /**
+     * Compute the bin given a coordinate in one dimension.
+     * @param[in] localDim The 1D coordinate value.
+     * @param[in] gridDim  The dimension of the readout grid.
+     * @return The value of the bin at that coordinate.
+     */
+    static int computeBin(double localDim, double gridDim);
+
+    /**
+     * Compute the coordinate of a cell center at a given a bin value.
+     * @param[in] bin  The bin value.
+     * @param[in] incr The grid size.
+     * @return The coordinate of the cell center.
+     */
+    static double computeDim(const int &bin, const double &incr);
+
+private:
+
+    /** The current bin values. */
+    std::vector<int> _bins;
+
+    /** The list of bin names. */
+    BinNames _binNames;
+
+    /** The number of bins. */
+    int _numBins;
+
+    /** The type of Segmentation. */
+    EType _type;
+};
+
+#endif

lcdd/include/lcdd/segmentation
SegmentationFactory.hh added at 1.1
diff -N SegmentationFactory.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SegmentationFactory.hh	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,36 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/segmentation/SegmentationFactory.hh,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+#ifndef LCDD_SEGMENTATION_SEGMENTATIONFACTORY_HH
+#define LCDD_SEGMENTATION_SEGMENTATIONFACTORY_HH 1
+
+class Segmentation;
+class SAXObject;
+
+// STL
+#include <string>
+
+/**
+ * @brief Factory for creating Segmentation objects from SAX objects and their tag names.
+ */
+class SegmentationFactory
+{
+
+private:
+
+	/**
+	 * Class constructor which should not be accessed.
+	 */
+    SegmentationFactory();
+
+public:
+
+    /**
+     * Create a Segmentation object from a SAX object and tag name.
+     * @param[in] obj The SAXObject of the segmentation.
+     * @param[in] tag The segmentation's tag name.
+     * @return The Segmentation object.
+     */
+    static Segmentation* createSegmentation(SAXObject* obj, const std::string& tag);
+};
+
+#endif

lcdd/src/lcdd/detectors
CalorimeterSD.cc 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- CalorimeterSD.cc	22 Aug 2013 22:32:17 -0000	1.7
+++ CalorimeterSD.cc	10 Sep 2013 21:57:33 -0000	1.8
@@ -1,8 +1,7 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.7 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.8 2013/09/10 21:57:33 jeremy Exp $
 
 // LCDD
 #include "lcdd/detectors/CalorimeterSD.hh"
-#include "lcdd/detectors/Segmentation.hh"
 #include "lcdd/detectors/PositionComparator.hh"
 #include "lcdd/id/IdComparator.hh"
 

lcdd/src/lcdd/detectors
CellReadout.cc removed after 1.4
diff -N CellReadout.cc
--- CellReadout.cc	6 Sep 2013 04:09:00 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/CellReadout.cc,v 1.4 2013/09/06 04:09:00 jeremy Exp $
-
-#include "lcdd/detectors/CellReadout.hh"
-
-CellReadout::CellReadout()
-{
-}
-
-CellReadout::~CellReadout()
-{
-}

lcdd/src/lcdd/detectors
CellReadout2D.cc removed after 1.5
diff -N CellReadout2D.cc
--- CellReadout2D.cc	6 Sep 2013 04:09:00 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,161 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/CellReadout2D.cc,v 1.5 2013/09/06 04:09:00 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/CellReadout2D.hh"
-
-// STL
-#include <cmath>
-#include <iostream>
-#include <stdexcept>
-
-CellReadout2D::CellReadout2D(double cellSizeX, double cellSizeY)
-    : _cellSizeX(cellSizeX), _cellSizeY(cellSizeY), _dimensionX(0.), _dimensionY(0.)
-{
-}
-
-CellReadout2D::~CellReadout2D()
-{
-}
-
-CellReadout2D::Position2D CellReadout2D::position(CellReadout2D::CellId cellId)
-{
-    Position2D position;
-    position.x = getCellPositionX(cellId.ix);
-    position.y = getCellPositionY(cellId.iy);
-    return position;
-}
-
-CellReadout::CellId CellReadout2D::cellId(Position2D position)
-{
-    return createCell(getXIndex(position.x), getYIndex(position.y));
-}
-
-CellReadout::Neighbors CellReadout2D::neighbors(CellId cellId)
-{
-    Neighbors neighbors;
-    CellId cell;
-
-    // Loop over delta Y.
-    for (int i = -1; i <= 1; i++) {
-        // Loop over delta X.
-        for (int j = -1; j <= 1; j++) {
-            // Ignore this cell.
-            if (i != 0 || j != 0) {
-                // Create CellId for this neighbor.
-                //std::cout << "creating neighbor i, j: " << i << ", " << j << std::endl;
-                cell = createCell(cellId.ix + j, cellId.iy + i);
-                // Check if valid.
-                if (isValidCell(cell)) {
-                    // Add if cell is valid.
-                    neighbors.push_back(cell);
-                }
-            }
-        }
-    }
-
-    return neighbors;
-
-}
-
-double CellReadout2D::getCellSizeX()
-{
-    return _cellSizeX;
-}
-
-double CellReadout2D::getCellSizeY()
-{
-    return _cellSizeY;
-}
-
-int CellReadout2D::getXIndex(double x)
-{
-    return getCellIndex(x, _cellSizeX);
-}
-
-int CellReadout2D::getYIndex(double y)
-{
-    return getCellIndex(y, _cellSizeY);
-}
-
-double CellReadout2D::getCellCoordinate(int i, double cellSize)
-{
-    return (i * cellSize) - cellSize / 2;
-}
-
-int CellReadout2D::getCellIndex(double c, double cellSize)
-{
-    int v = std::ceil(c / cellSize);
-    if (v == 0)
-        v = 1;
-    return v;
-}
-
-double CellReadout2D::getCellPositionX(int ix)
-{
-    return getCellCoordinate(ix, _cellSizeX);
-}
-
-double CellReadout2D::getCellPositionY(int iy)
-{
-    return getCellCoordinate(iy, _cellSizeY);
-}
-
-CellReadout2D::CellId CellReadout2D::createCell(int x, int y)
-{
-    CellId cell;
-    cell.ix = x;
-    cell.iy = y;
-    return cell;
-}
-
-void CellReadout2D::setDimensionX(double dimensionX)
-{
-    _dimensionX = dimensionX;
-}
-
-void CellReadout2D::setDimensionY(double dimensionY)
-{
-    _dimensionY = dimensionY;
-}
-
-double CellReadout2D::getDimensionX()
-{
-    return _dimensionX;
-}
-
-double CellReadout2D::getDimensionY()
-{
-    return _dimensionY;
-}
-
-bool CellReadout2D::isValidCell(CellId cell)
-{
-    // DEBUG
-    //std::cout << "isValidCell: " << cell.ix << ", " << cell.iy << std::endl;
-
-    if (cell.ix <= 0 || cell.iy <= 0) {
-        //std::cout << "field value < 0" << std::endl;
-        return false;
-    }
-    int xmax = std::floor(getDimensionX() / getCellSizeX());
-    //std::cout << "xmax: " << xmax << std::endl;
-    if (cell.ix > xmax) {
-        //std::cout << cell.ix << " exceeds max allowed X index" << std::endl;
-        return false;
-    }
-    int ymax = std::floor(getDimensionY() / getCellSizeY());
-    //std::cout << "ymax: " << ymax << std::endl;
-    if (cell.iy > ymax) {
-        //std::cout << cell.iy << " exceeds max allowed Y index" << std::endl;
-        return false;
-    }
-    return true;
-}
-
-bool CellReadout2D::isValidPosition(Position2D position)
-{
-    if (position.x > getDimensionX() || position.x < 0) return false;
-    if (position.y > getDimensionY() || position.y < 0) return false;
-    return true;
-}
-

lcdd/src/lcdd/detectors
CellReadout2DSegmentation.cc removed after 1.8
diff -N CellReadout2DSegmentation.cc
--- CellReadout2DSegmentation.cc	9 Sep 2013 22:11:17 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,190 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/CellReadout2DSegmentation.cc,v 1.8 2013/09/09 22:11:17 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/CellReadout2DSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4Step.hh"
-#include "G4Box.hh"
-
-// STL
-#include <cmath>
-
-// Comment out to remove debug prints.
-#define CellReadout2DSegmentation_DEBUG 1
-
-CellReadout2DSegmentation::CellReadout2DSegmentation(double cellSizeX, double cellSizeY) :
-        Segmentation(Segmentation::eNonprojective, 2)
-{
-    _readout = new CellReadout2D(cellSizeX, cellSizeY);
-    setBinNames();
-}
-
-CellReadout2DSegmentation::~CellReadout2DSegmentation()
-{
-    delete _readout;
-}
-
-G4ThreeVector CellReadout2DSegmentation::getGlobalHitPosition(const G4Step* aStep)
-{
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "CellReadout2DSegmentation::getGlobalHitPosition" << std::endl;
-#endif
-
-    // Setup the readout with step dependent information.
-    setup(aStep);
-
-    // Compute the mid-point of the global step.
-    G4ThreeVector globalStepPosition = ReadoutUtil::computeMidPos(aStep);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "globalStepPosition: " << globalStepPosition.x() << " " << globalStepPosition.y() << " " << globalStepPosition.z() << std::endl;
-#endif
-
-    // Compute the local step position.
-    G4ThreeVector localStepPosition = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPosition);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "localStepPosition: " << localStepPosition.x() << " " << localStepPosition.y() << " " << localStepPosition.z() << std::endl;
-#endif
-
-    // Convert into readout coordinates.
-    CellReadout::Position2D readoutStepPosition = localToReadoutCoordinates(localStepPosition);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "readoutStepPosition: " << readoutStepPosition.x << " " << readoutStepPosition.y << std::endl;
-#endif
-
-    // Compute the cell indices from the position.
-    CellReadout::CellId cell = _readout->cellId(readoutStepPosition);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "cell: " << cell.ix << " " << cell.iy << std::endl;
-#endif
-
-    // Get the cell's readout position from the cell ID.
-    CellReadout::Position2D cellReadoutPosition = _readout->position(cell);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "cellReadoutPosition: " << cellReadoutPosition.x << " " << cellReadoutPosition.y << std::endl;
-#endif
-
-    // Convert from readout back to localcoordinates.
-    G4ThreeVector localCellPosition = readoutToLocalCoordinates(cellReadoutPosition);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "localCellPosition: "<< localCellPosition.x() << " " << localCellPosition.y() << " " << localCellPosition.z() << std::endl;
-#endif
-
-    // Finally, convert from the local coordinates into global.
-    G4ThreeVector globalCellPosition = ReadoutUtil::transformLocalToGlobal(aStep, localCellPosition);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "globalCellPosition: "
-            << globalCellPosition.x() << " "
-            << globalCellPosition.y() << " "
-            << globalCellPosition.z() << std::endl;
-    std::cout << std::endl;
-#endif
-
-    return globalCellPosition;
-}
-
-void CellReadout2DSegmentation::setBins(const G4Step* aStep)
-{
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "CellReadout2DSegmentation::setBins" << std::endl;
-#endif
-
-    // Setup the readout with step dependent information.
-    setup(aStep);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    G4ThreeVector prePosition = aStep->GetPreStepPoint()->GetPosition();
-    std::cout << "step pos: " << prePosition.x() << " " << prePosition.y() << " " << prePosition.z() << std::endl;
-#endif
-
-    // Set state from current step.
-    setup(aStep);
-
-    // Compute the global mid-point of the step.
-    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "globalStepPos: " << globalStepPos.x() << " " << globalStepPos.y() << " " << globalStepPos.z() << std::endl;
-#endif
-
-    // Compute the local step position from the global mid-point.
-    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "localStepPos: " << localStepPos.x() << " " << localStepPos.y() << " " << localStepPos.z() << std::endl;
-#endif
-
-    // Compute the X and Y readout coordinates from the local position.
-    CellReadout::Position2D readoutPosition = localToReadoutCoordinates(localStepPos);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "readoutPosition: " << readoutPosition.x << " " << readoutPosition.y << std::endl;
-#endif
-
-    // Get the cell for the position.
-    CellReadout::CellId cell = _readout->cellId(readoutPosition);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "cellID: " << cell.ix << " " << cell.iy << std::endl;
-#endif
-
-    // Set the segmentation's bin values.
-    this->setBin(0, readoutPosition.x);
-    this->setBin(1, readoutPosition.y);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    // print the neighbor CellIds
-    CellReadout::Neighbors neighbors = _readout->neighbors(cell);
-    std::cout << "neighbors: " << std::endl;
-    for (CellReadout::Neighbors::const_iterator it = neighbors.begin(); it != neighbors.end(); it++) {
-        std::cout << "  " << (*it).ix << ", " << (*it).iy << std::endl;
-    }
-    std::cout << std::endl;
-#endif
-}
-
-void CellReadout2DSegmentation::setBinNames()
-{
-    addBinName("ix");
-    addBinName("iy");
-}
-
-void CellReadout2DSegmentation::setup(const G4Step* aStep)
-{
-    // Set dimensions from current box volume.
-    G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint(aStep->GetPreStepPoint());
-    G4Box* box = dynamic_cast<G4Box*>(solid);
-    if (box == 0) {
-        std::cerr << "Current volume is not a box!!!" << std::endl;
-        G4Exception("", "", FatalException, "CellReadout2D points to a shape that is not a G4Box.");
-    }
-    _readout->setDimensionX(box->GetXHalfLength() * 2);
-    _readout->setDimensionY(box->GetYHalfLength() * 2);
-
-#ifdef CellReadout2DSegmentation_DEBUG
-    std::cout << "set readout dimensions XY: " << _readout->getDimensionX() << " " << _readout->getDimensionY() << std::endl;
-#endif
-}
-
-CellReadout::Position2D CellReadout2DSegmentation::localToReadoutCoordinates(G4ThreeVector& vec)
-{
-    CellReadout::Position2D position;
-    position.x = vec.x() + _readout->getDimensionX() / 2.;
-    position.y = vec.y() + _readout->getDimensionY() / 2.;
-    return position;
-}
-
-G4ThreeVector CellReadout2DSegmentation::readoutToLocalCoordinates(CellReadout::Position2D position)
-{
-    double x = position.x - _readout->getDimensionX() / 2.;
-    double y = position.y - _readout->getDimensionY() / 2.;
-    return G4ThreeVector(x, y, 0);
-}

lcdd/src/lcdd/detectors
GlobalGridXYSegmentation.cc removed after 1.4
diff -N GlobalGridXYSegmentation.cc
--- GlobalGridXYSegmentation.cc	11 Jul 2013 20:41:54 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,78 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/GlobalGridXYSegmentation.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/GlobalGridXYSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4NavigationHistory.hh"
-
-GlobalGridXYSegmentation::GlobalGridXYSegmentation(double gridSizeX, double gridSizeY) :
-        Segmentation(Segmentation::eNonprojective), _gridSizeX(gridSizeX), _gridSizeY(gridSizeY)
-{
-    setBinNames();
-}
-
-GlobalGridXYSegmentation::~GlobalGridXYSegmentation()
-{
-}
-
-void GlobalGridXYSegmentation::setBinNames()
-{
-    addBinName("x");
-    addBinName("y");
-    addBinName("z");
-}
-
-G4ThreeVector GlobalGridXYSegmentation::getGlobalHitPosition(const G4Step* aStep)
-{
-    // Compute the midpoint of the global step.
-    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
-    // Create 3vec for cell position.
-    G4ThreeVector globalCellPos;
-
-    // Set binned coordinates of cell position.
-    globalCellPos.setX(computeDimX(computeBinX(globalStepPos)));
-    globalCellPos.setY(computeDimY(computeBinY(globalStepPos)));
-
-    // Set Z coordinate of cell position from the volume's Z center position.
-    G4ThreeVector vpos = ReadoutUtil::getVolumeGlobalPosition(aStep->GetPreStepPoint());
-    globalCellPos.setZ(vpos.z());
-
-    return globalCellPos;
-}
-
-void GlobalGridXYSegmentation::setBins(const G4Step* aStep)
-{
-    // Compute the midpoint of the step.
-    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
-    // Compute the bin values.
-    int binX = computeBinX(globalStepPos);
-    int binY = computeBinY(globalStepPos);
-
-    // Set the bin values.
-    setBin(0, binX);
-    setBin(1, binY);
-}
-
-int GlobalGridXYSegmentation::computeBinX(const G4ThreeVector& stepPos)
-{
-    return Segmentation::computeBin(stepPos.x(), _gridSizeX);
-}
-
-int GlobalGridXYSegmentation::computeBinY(const G4ThreeVector& stepPos)
-{
-    return Segmentation::computeBin(stepPos.y(), _gridSizeY);
-}
-
-double GlobalGridXYSegmentation::computeDimX(int bin)
-{
-    return Segmentation::computeDim(bin, _gridSizeX);
-}
-
-double GlobalGridXYSegmentation::computeDimY(int bin)
-{
-    return Segmentation::computeDim(bin, _gridSizeY);
-}

lcdd/src/lcdd/detectors
GridXYZSegmentation.cc removed after 1.4
diff -N GridXYZSegmentation.cc
--- GridXYZSegmentation.cc	11 Jul 2013 20:41:54 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,153 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/GridXYZSegmentation.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/GridXYZSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4NavigationHistory.hh"
-
-GridXYZSegmentation::GridXYZSegmentation(double gridSizeX, double gridSizeY, double gridSizeZ) :
-        Segmentation(Segmentation::eNonprojective), _gridSizeX(gridSizeX), _gridSizeY(gridSizeY), _gridSizeZ(gridSizeZ)
-{
-    setBinNames();
-}
-
-GridXYZSegmentation::~GridXYZSegmentation()
-{
-}
-
-void GridXYZSegmentation::setBinNames()
-{
-    addBinName("x");
-    addBinName("y");
-    addBinName("z");
-}
-
-G4ThreeVector GridXYZSegmentation::getGlobalHitPosition(const G4Step* aStep)
-{
-    // compute midpoint
-    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
-    // figure local step pos using touchable and global midpoint
-    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
-
-    // local cell pos
-    G4ThreeVector localCellPos = this->getLocalHitPos(localStepPos);
-
-    // global cell pos
-    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
-
-    return globalCellPos;
-}
-
-void GridXYZSegmentation::setBins(const G4Step* aStep)
-{
-    // Compute the midpoint of the step.
-    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
-    // Transform from global coordinate system to local coordinate system of volume pointed to by this step.
-    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
-
-    // Compute the bin values.
-    int binX = computeBinX(localStepPos);
-    int binY = computeBinY(localStepPos);
-    int binZ = computeBinZ(localStepPos);
-
-    // Set the bins.
-    int idx = 0;
-
-    setBin(idx, binX);
-    ++idx;
-
-    setBin(idx, binY);
-    ++idx;
-
-    setBin(idx, binZ);
-    ++idx;
-}
-
-int GridXYZSegmentation::computeBinX(const G4ThreeVector& localStepPos)
-{
-    int ret;
-    if (_gridSizeX != 0) {
-        ret = Segmentation::computeBin(localStepPos.x(), _gridSizeX);
-    } else {
-        ret = 0;
-    }
-    return ret;
-}
-
-int GridXYZSegmentation::computeBinY(const G4ThreeVector& localStepPos)
-{
-    int ret;
-    if (_gridSizeY != 0) {
-        ret = Segmentation::computeBin(localStepPos.y(), _gridSizeY);
-    } else {
-        ret = 0;
-    }
-    return ret;
-}
-
-int GridXYZSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
-{
-    int ret;
-    if (_gridSizeZ != 0) {
-        ret = Segmentation::computeBin(localStepPos.z(), _gridSizeZ);
-    } else {
-        ret = 0;
-    }
-    return ret;
-}
-
-double GridXYZSegmentation::computeDimX(int bin)
-{
-    return Segmentation::computeDim(bin, _gridSizeX);
-}
-
-double GridXYZSegmentation::computeDimY(int bin)
-{
-    return Segmentation::computeDim(bin, _gridSizeY);
-}
-
-double GridXYZSegmentation::computeDimZ(int bin)
-{
-    return Segmentation::computeDim(bin, _gridSizeZ);
-}
-
-/*
-G4ThreeVector GridXYZSegmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
-{
-    G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
-
-    // Figure out local step pos using touchable and global midpoint.
-    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint, globalStepPos);
-
-    // Compute local cell pos.
-    G4ThreeVector localCellPos = this->getLocalHitPos(localStepPos);
-
-    // Compute global cell pos.
-    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aPreStepPoint, localCellPos);
-
-    return globalCellPos;
-}
-*/
-
-G4ThreeVector GridXYZSegmentation::getLocalHitPos(const G4ThreeVector& localStepPos)
-{
-    G4ThreeVector localHitPos;
-
-    if (_gridSizeX > 0) {
-        localHitPos.setX(computeDimX(computeBinX(localStepPos)));
-    }
-
-    if (_gridSizeY > 0) {
-        localHitPos.setY(computeDimY(computeBinY(localStepPos)));
-    }
-
-    if (_gridSizeZ > 0) {
-        localHitPos.setZ(computeDimZ(computeBinZ(localStepPos)));
-    }
-
-    return localHitPos;
-}

lcdd/src/lcdd/detectors
NonprojectiveCylinderSegmentation.cc removed after 1.5
diff -N NonprojectiveCylinderSegmentation.cc
--- NonprojectiveCylinderSegmentation.cc	11 Jul 2013 20:41:54 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,241 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/NonprojectiveCylinderSegmentation.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/NonprojectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4Tubs.hh"
-
-// STL
-#include <cmath>
-
-NonprojectiveCylinderSegmentation::NonprojectiveCylinderSegmentation(double gridSizePhi, double gridSizeZ) :
-        Segmentation(Segmentation::eNonprojective), _gridSizePhi(gridSizePhi), _gridSizeZ(gridSizeZ)
-
-{
-    setBinNames();
-}
-
-NonprojectiveCylinderSegmentation::~NonprojectiveCylinderSegmentation()
-{
-}
-
-void NonprojectiveCylinderSegmentation::setBinNames()
-{
-    addBinName("phi");
-    addBinName("z");
-}
-
-G4ThreeVector NonprojectiveCylinderSegmentation::getGlobalHitPosition(const G4Step* aStep)
-{
-    // local cell pos
-    G4ThreeVector localCellPos = getLocalHitPos(aStep);
-
-    // global cell pos
-    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
-
-    return localCellPos;
-}
-
-/*
-G4ThreeVector NonprojectiveCylinderSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
-{
-    // local cell pos
-    G4ThreeVector localCellPos = getLocalHitPos(aPreStepPoint);
-
-    // global cell pos
-    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aPreStepPoint, localCellPos);
-
-    // DEBUG: print local, global cell pos
-    //G4cout << "localCellPos " << localCellPos << G4endl;
-    //G4cout << "globalCellPos " << globalCellPos << G4endl;
-    //
-
-    return localCellPos;
-}
-*/
-
-G4ThreeVector NonprojectiveCylinderSegmentation::getLocalHitPos(const G4Step* aStep)
-{
-    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
-
-    // retrieve G4Tubs
-    const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
-
-    assert(tubs);
-
-    // rcyl of cell = mid rad of current tubs
-    double rcyl = ReadoutUtil::computeTubsMidRadius(tubs);
-
-    // compute single delta phi in degrees
-    double deltaPhi = computeDeltaPhi(aStep);
-
-    // phi index
-    int iphi = computeBinPhi(aStep);
-
-    // z index in local
-    int iz = computeBinZ(ReadoutUtil::transformGlobalToLocal(aStep, globalMidPos));
-
-    // compute cell Z, phi
-    double cellPhi = computeDim(iphi, deltaPhi);
-    double cellZ = computeDim(iz, _gridSizeZ);
-
-    // compute X, Y
-    double cellX = rcyl * cos(cellPhi);
-    double cellY = rcyl * sin(cellPhi);
-
-    G4ThreeVector cellCenter(cellX, cellY, cellZ);
-
-    return cellCenter;
-}
-
-G4ThreeVector NonprojectiveCylinderSegmentation::getLocalHitPos(const G4StepPoint* aPreStepPoint)
-{
-    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
-
-    // retrieve G4Tubs
-    const G4Tubs* tubs = ReadoutUtil::getTubs(aPreStepPoint);
-
-    assert(tubs);
-
-    // rcyl of cell = mid rad of current tubs
-    double rcyl = ReadoutUtil::computeTubsMidRadius(tubs);
-
-    // compute single delta phi in degrees
-    double deltaPhi = computeDeltaPhi(aPreStepPoint);
-
-    // phi index
-    int iphi = computeBinPhi(aPreStepPoint);
-
-    // z index in local
-    int iz = computeBinZ(ReadoutUtil::transformGlobalToLocal(aPreStepPoint, globalPos));
-
-    // compute cell Z, phi
-    double cellPhi = computeDim(iphi, deltaPhi);
-    double cellZ = computeDim(iz, _gridSizeZ);
-
-    // compute X, Y
-    double cellX = rcyl * cos(cellPhi);
-    double cellY = rcyl * sin(cellPhi);
-
-    G4ThreeVector cellCenter(cellX, cellY, cellZ);
-
-    return cellCenter;
-}
-
-double NonprojectiveCylinderSegmentation::computeDeltaPhi(const G4Step* aStep)
-{
-    // mid radius of current tubs
-    double mid_rad_layer = ReadoutUtil::computeTubsMidRadius(aStep);
-
-    // circumference of current tubs
-    double circ = 2.0 * ReadoutUtil::PI * mid_rad_layer;
-
-    // number of cells along phi in curr layer
-    int nphi = (int) floor(circ / _gridSizePhi);
-
-    // single phi division in degrees
-    double deltaPhi = (360.0 * deg) / nphi;
-
-    return deltaPhi;
-}
-double NonprojectiveCylinderSegmentation::computeDeltaPhi(const G4StepPoint* aPreStepPoint)
-{
-    // mid radius of current tubs
-    double mid_rad_layer = ReadoutUtil::computeTubsMidRadius(aPreStepPoint);
-
-    // circumference of current tubs
-    double circ = 2.0 * ReadoutUtil::PI * mid_rad_layer;
-
-    // number of cells along phi in curr layer
-    int nphi = (int) floor(circ / _gridSizePhi);
-
-    // single phi division in degrees
-    double deltaPhi = (360.0 * deg) / nphi;
-
-    return deltaPhi;
-}
-void NonprojectiveCylinderSegmentation::setBins(const G4Step* aStep)
-{
-    //G4cout << "G4NonprojectiveCylinderSegmentation::setBins()" << G4endl;
-
-    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
-
-    int bphi = computeBinPhi(aStep);
-    int bz = computeBinZ(globalMidPos);
-
-    setBin(0, bphi);
-    setBin(1, bz);
-}
-//void NonprojectiveCylinderSegmentation::setBins(const G4StepPoint* aPreStepPoint)
-//{
-//    //G4cout << "G4NonprojectiveCylinderSegmentation::setBins()" << G4endl;
-//
-//    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
-//
-//    int bphi = computeBinPhi(aPreStepPoint);
-//    int bz = computeBinZ(globalPos);
-//
-//    setBin(0, bphi);
-//    setBin(1, bz);
-//}
-int NonprojectiveCylinderSegmentation::computeBinPhi(const G4Step* aStep)
-{
-    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
-
-    const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
-    assert(tubs);
-
-    // compute single delta phi in degrees
-    double deltaPhi = computeDeltaPhi(aStep);
-
-    // step phi
-    double stepPhi = globalMidPos.phi();
-
-    if (stepPhi < 0) {
-        stepPhi += 2.0 * ReadoutUtil::PI;
-    }
-
-    // phi index
-    return computeBin(stepPhi, deltaPhi / radian);
-}
-
-int NonprojectiveCylinderSegmentation::computeBinPhi(const G4StepPoint* aPreStepPoint)
-{
-    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
-
-    const G4Tubs* tubs = ReadoutUtil::getTubs(aPreStepPoint);
-    assert(tubs);
-
-    // compute single delta phi in degrees
-    double deltaPhi = computeDeltaPhi(aPreStepPoint);
-
-    // step phi
-    double stepPhi = globalPos.phi();
-
-    if (stepPhi < 0) {
-        stepPhi += 2.0 * ReadoutUtil::PI;
-    }
-
-    // phi index
-    return computeBin(stepPhi, deltaPhi / radian);
-}
-
-int NonprojectiveCylinderSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
-{
-    return computeBin(localStepPos.z(), _gridSizeZ);
-}
-
-bool NonprojectiveCylinderSegmentation::isValidSolid(G4VSolid* s)
-{
-    bool valid = Segmentation::isValidSolid(s);
-
-    if (valid) {
-        if (s->GetEntityType() != "G4Tubs") {
-            valid = false;
-        }
-    }
-
-    return valid;
-}

lcdd/src/lcdd/detectors
ProjectiveCylinderSegmentation.cc removed after 1.2
diff -N ProjectiveCylinderSegmentation.cc
--- ProjectiveCylinderSegmentation.cc	2 Jul 2013 22:57:43 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/ProjectiveCylinderSegmentation.cc,v 1.2 2013/07/02 22:57:43 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/ProjectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4StepPoint.hh"
-#include "G4NavigationHistory.hh"
-#include "G4VPhysicalVolume.hh"
-#include "G4LogicalVolume.hh"
-#include "G4Tubs.hh"
-
-ProjectiveCylinderSegmentation::ProjectiveCylinderSegmentation(G4int ntheta, G4int nphi) :
-        ProjectiveSegmentation(ntheta, nphi)
-{
-}
-
-ProjectiveCylinderSegmentation::~ProjectiveCylinderSegmentation()
-{
-}
-
-double ProjectiveCylinderSegmentation::getRadius(const G4Step* aStep)
-{
-    return ReadoutUtil::computeTubsMidRadius(ReadoutUtil::getTubs(aStep));
-}
-
-/*
-double ProjectiveCylinderSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
-{
-    return ReadoutUtil::computeTubsMidRadius(ReadoutUtil::getTubs(aPreStepPoint));
-}
-*/
-
-double ProjectiveCylinderSegmentation::getZ(const G4Step* aStep)
-{
-    double rcyl = getRadius(aStep);
-
-    double ctheta = getThetaDim(aStep);
-
-    // ctheta in 0 to pi ...
-    // ctheta < pi/2 should be negative
-
-    double zcell = rcyl / tan(ctheta);
-
-    return zcell;
-}
-/*
-double ProjectiveCylinderSegmentation::getZ(const G4StepPoint* aPreStepPoint)
-{
-    double rcyl = getRadius(aPreStepPoint);
-
-    double ctheta = getThetaDim(aPreStepPoint);
-
-    // ctheta in 0 to pi ...
-    // ctheta < pi/2 should be negative
-
-    double zcell = rcyl / tan(ctheta);
-
-    return zcell;
-}
-*/
-bool ProjectiveCylinderSegmentation::isValidSolid(G4VSolid* s)
-{
-    bool valid = Segmentation::isValidSolid(s);
-
-    if (valid) {
-        if (s->GetEntityType() != "G4Tubs") {
-            valid = false;
-        }
-    }
-
-    return valid;
-}

lcdd/src/lcdd/detectors
ProjectiveSegmentation.cc removed after 1.6
diff -N ProjectiveSegmentation.cc
--- ProjectiveSegmentation.cc	11 Jul 2013 20:41:54 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,229 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/ProjectiveSegmentation.cc,v 1.6 2013/07/11 20:41:54 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/ProjectiveSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4StepPoint.hh"
-#include "G4NavigationHistory.hh"
-#include "G4VPhysicalVolume.hh"
-#include "G4LogicalVolume.hh"
-#include "G4Tubs.hh"
-
-ProjectiveSegmentation::ProjectiveSegmentation(G4int ntheta, G4int nphi) :
-        Segmentation(Segmentation::eProjective), _ntheta(ntheta), _nphi(nphi)
-{
-    computeDivisions();
-    setBinNames();
-}
-
-ProjectiveSegmentation::~ProjectiveSegmentation()
-{
-}
-
-void ProjectiveSegmentation::setBinNames()
-{
-    addBinName("theta");
-    addBinName("phi");
-}
-
-G4ThreeVector ProjectiveSegmentation::getGlobalHitPosition(const G4Step* aStep)
-{
-    // divide entire theta, phi range into bins; bins always positive
-    // theta, phi coord of step midpoint
-    // compute bin numbers
-    // get dim from bins
-
-    // get radius, z components (probably from subclass function)
-    double rcyl = getRadius(aStep);
-    double zcell = getZ(aStep);
-
-    // get phi component
-    double cphi = getPhiDim(aStep);
-
-    // compute x, y cells
-    double xcell = rcyl * cos(cphi);
-    double ycell = rcyl * sin(cphi);
-
-    G4ThreeVector pos(xcell, ycell, zcell);
-
-    //G4ThreeVector midPos = ReadoutUtil::computeMidPos( aStep );
-
-    return pos;
-}
-
-/*
-G4ThreeVector ProjectiveSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
-{
-    // DEBUG
-    //G4cout << "G4ProjectiveSegmentation::getGlobalHitPos()" << G4endl;
-    //
-
-    // divide entire theta, phi range into bins; bins always positive
-    // theta, phi coord of step midpoint
-    // compute bin numbers
-    // get dim from bins
-
-    // get radius, z components (probably from subclass function)
-    double rcyl = getRadius(aPreStepPoint);
-    double zcell = getZ(aPreStepPoint);
-
-    // get phi component
-    double cphi = getPhiDim(aPreStepPoint);
-
-    // compute x, y cells
-    double xcell = rcyl * cos(cphi);
-    double ycell = rcyl * sin(cphi);
-
-    G4ThreeVector pos(xcell, ycell, zcell);
-
-    //G4ThreeVector midPos = ReadoutUtil::computeMidPos( aStep );
-
-    // DEBUG: print all
-    //G4cout << "sphi <" << midPos.phi() << ">" << G4endl;
-    //G4cout << "cphi <" << cphi << ">" << G4endl;
-    //G4cout << "sphi - cphi = " << midPos.phi() - cphi << G4endl;
-
-    //G4cout << "stheta <" << midPos.theta() << ">" << G4endl;
-    //G4cout << "ctheta <" << getThetaDim( aStep ) << ">" << G4endl;
-    //G4cout << "stheta - ctheta = " << midPos.theta() - getThetaDim( aStep ) << G4endl;
-
-    //G4cout << "rcyl <" << rcyl << ">" << G4endl;
-    //G4cout << "zcell <" << zcell << ">" << G4endl;
-    //G4cout << "globalCellPos <" << pos << ">" << G4endl;
-    //
-
-    return pos;
-}
-*/
-
-void ProjectiveSegmentation::setBins(const G4Step* aStep)
-{
-    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
-
-    setBin(0, getThetaBin(globalMidPos));
-    setBin(1, getPhiBin(globalMidPos));
-}
-
-/*
-void ProjectiveSegmentation::setBins(const G4StepPoint* aPreStepPoint)
-{
-    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
-
-    setBin(0, getThetaBin(globalPos));
-    setBin(1, getPhiBin(globalPos));
-}
-*/
-
-G4int ProjectiveSegmentation::getNtheta() const
-{
-    return _ntheta;
-}
-
-G4int ProjectiveSegmentation::getNphi() const
-{
-    return _nphi;
-}
-
-void ProjectiveSegmentation::computeDivisions()
-{
-    _divTheta = (180.0 * deg) / _ntheta;
-    _divPhi = (360.0 * deg) / _nphi;
-}
-
-int ProjectiveSegmentation::getThetaBin(const G4ThreeVector& globalStepPos)
-{
-    // theta needs to be in range 0 - PI
-    return Segmentation::computeBin(globalStepPos.theta(), _divTheta / radian);
-}
-
-int ProjectiveSegmentation::getPhiBin(const G4ThreeVector& globalStepPos)
-{
-
-    // adjust phi for < 0
-    double sphi = globalStepPos.phi();
-
-    if (sphi < 0.0) {
-        sphi += 360.0 * deg;
-    }
-
-    // needs more checks, for phi in range 0 - TWOPI
-    // if > TWOPI, then subtract TWOPI
-    //
-    // OR use X, Y for phi calc
-
-    // compute and return bin
-    return Segmentation::computeBin(sphi, _divPhi / radian);
-}
-
-// default impl. returns mag of pos 
-double ProjectiveSegmentation::getRadius(const G4Step* aStep)
-{
-    //G4cout << "G4ProjectiveSegmentation::getRadius()" << G4endl;
-
-    return ReadoutUtil::computeMidPos(aStep).mag();
-}
-
-//double ProjectiveSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
-//{
-    //G4cout << "G4ProjectiveSegmentation::getRadius()" << G4endl;
-//    return aPreStepPoint->GetPosition().mag();
-//}
-
-// default impl. returns z of pos
-double ProjectiveSegmentation::getZ(const G4Step* aStep)
-{
-    //G4cout << "G4ProjectiveSegmentation::getZ()" << G4endl;
-    return ReadoutUtil::computeMidPos(aStep).z();
-}
-
-//double ProjectiveSegmentation::getZ(const G4StepPoint* aPreStepPoint)
-//{
-    //G4cout << "G4ProjectiveSegmentation::getZ()" << G4endl;
-//    return aPreStepPoint->GetPosition().z();
-//}
-
-double ProjectiveSegmentation::getThetaDim(const int &thetaBin) const
-{
-    return Segmentation::computeDim(thetaBin, _divTheta);
-}
-
-double ProjectiveSegmentation::getPhiDim(const int &phiBin) const
-{
-    return Segmentation::computeDim(phiBin, _divPhi);
-}
-
-double ProjectiveSegmentation::getThetaDim(const G4Step* aStep)
-{
-    //G4cout << "G4ProjectiveSegmentation::getThetaDim(G4Step*)" << G4endl;
-    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-    double ctheta = getThetaDim(getThetaBin(globalStepPos));
-    return ctheta;
-}
-
-//double ProjectiveSegmentation::getThetaDim(const G4StepPoint* aPreStepPoint)
-//{
-    //G4cout << "G4ProjectiveSegmentation::getThetaDim(G4Step*)" << G4endl;
-//    G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
-//    double ctheta = getThetaDim(getThetaBin(globalStepPos));
-//    return ctheta;
-//}
-
-double ProjectiveSegmentation::getPhiDim(const G4Step* aStep)
-{
-    //G4cout << "G4ProjectiveSegmentation::getPhiDim(G4Step*)" << G4endl;
-
-    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-    double cphi = getPhiDim(getPhiBin(globalStepPos));
-    return cphi;
-}
-//double ProjectiveSegmentation::getPhiDim(const G4StepPoint* aPreStepPoint)
-//{
-    //G4cout << "G4ProjectiveSegmentation::getPhiDim(G4Step*)" << G4endl;
-
-//    G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
-//    double cphi = getPhiDim(getPhiBin(globalStepPos));
-//    return cphi;
-//}
-

lcdd/src/lcdd/detectors
ProjectiveZPlaneSegmentation.cc removed after 1.2
diff -N ProjectiveZPlaneSegmentation.cc
--- ProjectiveZPlaneSegmentation.cc	2 Jul 2013 22:57:43 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,45 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/ProjectiveZPlaneSegmentation.cc,v 1.2 2013/07/02 22:57:43 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/ProjectiveZPlaneSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-ProjectiveZPlaneSegmentation::ProjectiveZPlaneSegmentation(G4int ntheta, G4int nphi) :
-        ProjectiveSegmentation(ntheta, nphi)
-{
-}
-
-ProjectiveZPlaneSegmentation::~ProjectiveZPlaneSegmentation()
-{
-}
-
-double ProjectiveZPlaneSegmentation::getRadius(const G4Step* aStep)
-{
-    double zcell = getZ(aStep);
-    double ctheta = ProjectiveSegmentation::getThetaDim(aStep);
-    double rcyl = zcell * tan(ctheta);
-    return rcyl;
-}
-/*
-double ProjectiveZPlaneSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
-{
-    double zcell = getZ(aPreStepPoint);
-    double ctheta = ProjectiveSegmentation::getThetaDim(aPreStepPoint);
-    double rcyl = zcell * tan(ctheta);
-    return rcyl;
-}
-*/
-
-double ProjectiveZPlaneSegmentation::getZ(const G4Step* aStep)
-{
-    G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aStep->GetPreStepPoint(), G4ThreeVector());
-    return gpos.z();
-}
-
-/*
-double ProjectiveZPlaneSegmentation::getZ(const G4StepPoint* aPreStepPoint)
-{
-    G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aPreStepPoint, G4ThreeVector());
-    return gpos.z();
-}
-*/

lcdd/src/lcdd/detectors
Segmentation.cc removed after 1.6
diff -N Segmentation.cc
--- Segmentation.cc	11 Jul 2013 20:41:54 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,128 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/Segmentation.cc,v 1.6 2013/07/11 20:41:54 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/Segmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-Segmentation::Segmentation(EType segType, int nbins) :
-        _numBins(nbins), _type(segType)
-{
-    // reserve nbins
-    _bins.reserve(_numBins);
-
-    // fill in 0 vals
-    resetBins();
-}
-
-Segmentation::~Segmentation()
-{
-}
-
-void Segmentation::setBin(int binIdx, int binVal)
-{
-    _bins.insert(_bins.begin() + binIdx, binVal);
-}
-
-int Segmentation::getNumberOfBins()
-{
-    return _numBins;
-}
-
-const std::vector<int>& Segmentation::getBins()
-{
-    return _bins;
-}
-
-Segmentation::EType Segmentation::getType()
-{
-    return _type;
-}
-
-//G4ThreeVector Segmentation::getGlobalHitPos(const G4Step* aStep)
-//{
-//    return ReadoutUtil::computeMidPos(aStep);
-//}
-
-//G4ThreeVector Segmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
-//{
-//    //G4Exception("Do not use this method!");
-//    return aPreStepPoint->GetPosition();
-//}
-
-G4ThreeVector Segmentation::getLocalHitPosition(const G4ThreeVector& localStepPos)
-{
-    return localStepPos;
-}
-
-void Segmentation::resetBins()
-{
-    _bins.clear();
-}
-
-void Segmentation::printOutBins(std::ostream& os, const std::vector<int>& bins)
-{
-    os << "segmentationBins <" << bins.size() << "> :: ";
-    for (std::vector<int>::const_iterator iter = bins.begin(); iter != bins.end(); iter++) {
-        os << *iter << " ";
-    }
-    os << std::endl;
-}
-
-bool Segmentation::isValidSolid(G4VSolid* s)
-{
-    bool valid = true;
-
-    if (0 == s) {
-        valid = false;
-    }
-
-    return valid;
-}
-
-const G4String& Segmentation::getTypeString()
-{
-    static G4String typestr;
-    if (_type == Segmentation::eProjective) {
-        typestr = "Projective";
-    } else if (_type == Segmentation::eNonprojective) {
-        typestr = "Nonprojective";
-    } else {
-        typestr = "Unknown";
-    }
-    return typestr;
-}
-
-int Segmentation::getBin(int idx)
-{
-    return _bins.at(idx);
-}
-
-const std::string& Segmentation::getBinName(int idx)
-{
-    return _binNames.at(idx);
-}
-
-void Segmentation::addBinName(const std::string& binName)
-{
-    _binNames.push_back(binName);
-}
-
-const std::vector<std::string>& Segmentation::getBinNames()
-{
-    return _binNames;
-}
-
-void Segmentation::printOutBins(std::ostream& os)
-{
-    printOutBins(os, _bins);
-}
-
-int Segmentation::computeBin(double localDim, double gridDim)
-{
-    return int(floor(localDim / gridDim));
-}
-
-double Segmentation::computeDim(const int &bin, const double &incr)
-{
-    return (double(bin) + .5) * incr;
-}

lcdd/src/lcdd/detectors
SegmentationFactory.cc removed after 1.2
diff -N SegmentationFactory.cc
--- SegmentationFactory.cc	9 Jul 2013 18:51:54 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,176 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/SegmentationFactory.cc,v 1.2 2013/07/09 18:51:54 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/SegmentationFactory.hh"
-#include "lcdd/schema/grid_xyz.hh"
-#include "lcdd/schema/global_grid_xy.hh"
-#include "lcdd/schema/nonprojective_cylinder.hh"
-#include "lcdd/schema/projective_cylinder.hh"
-#include "lcdd/schema/projective_zplane.hh"
-#include "lcdd/schema/cell_readout_2d.hh"
-#include "lcdd/detectors/Segmentation.hh"
-#include "lcdd/detectors/GridXYZSegmentation.hh"
-#include "lcdd/detectors/GlobalGridXYSegmentation.hh"
-#include "lcdd/detectors/ProjectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/ProjectiveZPlaneSegmentation.hh"
-#include "lcdd/detectors/NonprojectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/CellReadout2DSegmentation.hh"
-
-// GDML
-#include "Saxana/SAXObject.h"
-#include "G4Processor/GDMLProcessor.h"
-#include "G4Evaluator/GDMLExpressionEvaluator.h"
-
-// STL
-#include <iostream>
-
-SegmentationFactory::SegmentationFactory()
-{
-}
-
-Segmentation* SegmentationFactory::createSegmentation(SAXObject* obj, const std::string& tag)
-{
-    Segmentation* seg = 0;
-    GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
-
-    if (tag == "projective_cylinder") {
-        projective_cylinder* prj = dynamic_cast<projective_cylinder*>(obj);
-        if (prj) {
-            int ntheta, nphi;
-            std::string sval = prj->get_ntheta();
-            ntheta = (int) calc->Eval(sval);
-            sval = prj->get_nphi();
-            nphi = (int) calc->Eval(sval);
-            seg = new ProjectiveCylinderSegmentation(ntheta, nphi);
-        } else {
-            std::cerr << "Failed cast to projective_cylinder!" << std::endl;
-        }
-
-    } else if (tag == "grid_xyz") {
-        // GridXYZ
-        grid_xyz* np = dynamic_cast<grid_xyz*>(obj);
-        if (np) {
-            double gsx, gsy, gsz;
-            gsx = gsy = gsz = 0.;
-            std::string lunit = np->get_lunit();
-
-            std::string sval = np->get_gridSizeX();
-            sval += "*" + lunit;
-            gsx = calc->Eval(sval);
-
-            sval = np->get_gridSizeY();
-            sval += "*" + lunit;
-            gsy = calc->Eval(sval);
-
-            sval = np->get_gridSizeZ();
-            sval += "*" + lunit;
-            gsz = calc->Eval(sval);
-
-            //std::cout << "grid x, y, z: " << gsx << ", " << gsy << ", " << gsz << std::endl;
-
-            seg = new GridXYZSegmentation(gsx, gsy, gsz);
-        } else {
-            std::cerr << "Failed cast to grid_xyz!" << std::endl;
-        }
-    }
-    // GlobalGridXY
-    else if (tag == "global_grid_xy") {
-        global_grid_xy* gridxy = dynamic_cast<global_grid_xy*>(obj);
-        if (gridxy) {
-            double gsx, gsy;
-            gsx = gsy = 0.;
-            std::string lunit = gridxy->get_lunit();
-
-            std::string sval = gridxy->get_gridSizeX();
-            sval += "*" + lunit;
-            gsx = calc->Eval(sval);
-
-            sval = gridxy->get_gridSizeY();
-            sval += "*" + lunit;
-            gsy = calc->Eval(sval);
-
-            seg = new GlobalGridXYSegmentation(gsx, gsy);
-        } else {
-            std::cerr << "Failed cast to global_grid_xy!" << std::endl;
-        }
-    } else if (tag == "nonprojective_cylinder") {
-        // handle NP cylinder
-
-        //std::cout << "add nonprojective_cylinder here" << std::endl;
-
-        nonprojective_cylinder* np = dynamic_cast<nonprojective_cylinder*>(obj);
-        if (np) {
-
-            double gsp = 0;
-            double gsz = 0;
-
-            std::string lunit = np->get_lunit();
-
-            std::string sval = np->get_gridSizePhi();
-            sval += "*" + lunit;
-            gsp = calc->Eval(sval);
-
-            sval = np->get_gridSizeZ();
-            sval += "*" + lunit;
-            gsz = calc->Eval(sval);
-
-            seg = new NonprojectiveCylinderSegmentation(gsp, gsz);
-        } else {
-            std::cerr << "Failed cast to nonprojective_cylinder!" << std::endl;
-        }
-    } else if (tag == "projective_zplane") {
-        // handle projective_zplane
-
-        //std::cout << "add projective_zplane here" << std::endl;
-
-        projective_zplane* prj = dynamic_cast<projective_zplane*>(obj);
-
-        if (prj) {
-
-            int ntheta, nphi;
-            std::string sval = prj->get_ntheta();
-            ntheta = (int) calc->Eval(sval);
-            sval = prj->get_nphi();
-            nphi = (int) calc->Eval(sval);
-
-            //std::cout << "ntheta, nphi : " 
-            //		<< ntheta << ", " 
-            //		<< nphi << std::endl;
-
-            seg = new ProjectiveZPlaneSegmentation(ntheta, nphi);
-        } else {
-            std::cerr << "Failed cast to projective_zplane!" << std::endl;
-        } // prj no exist
-    } else if (tag == "cell_readout_2d") {
-
-        //std::cout << "building cell_readout_2d" << std::endl;
-
-        cell_readout_2d* elem = dynamic_cast<cell_readout_2d*>(obj);
-        if (0 != elem) {
-            double cellSizeX, cellSizeY;
-            cellSizeX = cellSizeY = 0;
-            std::string lengthUnit = elem->getLengthUnit();
-
-            std::string val = elem->getCellSizeX();
-            val += "*" + lengthUnit;
-            cellSizeX = calc->Eval(val);
-
-            val = elem->getCellSizeY();
-            val += "*" + lengthUnit;
-            cellSizeY = calc->Eval(val);
-
-            //std::cout << "G4SegmentationFactory creating CellReadout2DSegmentation(x,y): " << cellSizeX << " " << cellSizeY << std::endl;
-
-            seg = new CellReadout2DSegmentation(cellSizeX, cellSizeY);
-        }
-    } else {
-        // bad segmentation tag
-        std::cerr << "Unknown child tag for calorimeter: " << tag << "." << std::endl;
-    }
-
-    if (seg == 0) {
-        G4Exception("", "", FatalException, "Failed to create segmentation.");
-    }
-
-    return seg;
-}

lcdd/src/lcdd/id
IdFactory.cc 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- IdFactory.cc	3 Jul 2013 23:00:46 -0000	1.3
+++ IdFactory.cc	10 Sep 2013 21:57:33 -0000	1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdFactory.cc,v 1.3 2013/07/03 23:00:46 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdFactory.cc,v 1.4 2013/09/10 21:57:33 jeremy Exp $
 
 // Uncomment to enable verbose debug output from this class.
 //#define ID_DEBUG 1
@@ -6,7 +6,7 @@
 // LCDD
 #include "lcdd/detectors/SensitiveDetector.hh"
 #include "lcdd/detectors/CalorimeterSD.hh"
-#include "lcdd/detectors/Segmentation.hh"
+#include "lcdd/segmentation/Segmentation.hh"
 #include "lcdd/id/IdManager.hh"
 #include "lcdd/id/IdFactory.hh"
 #include "lcdd/detectors/ReadoutUtil.hh"

lcdd/src/lcdd/segmentation
CellReadout.cc added at 1.1
diff -N CellReadout.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellReadout.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,11 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/CellReadout.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+#include "lcdd/segmentation/CellReadout.hh"
+
+CellReadout::CellReadout()
+{
+}
+
+CellReadout::~CellReadout()
+{
+}

lcdd/src/lcdd/segmentation
CellReadout2D.cc added at 1.1
diff -N CellReadout2D.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellReadout2D.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,161 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/CellReadout2D.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/CellReadout2D.hh"
+
+// STL
+#include <cmath>
+#include <iostream>
+#include <stdexcept>
+
+CellReadout2D::CellReadout2D(double cellSizeX, double cellSizeY)
+    : _cellSizeX(cellSizeX), _cellSizeY(cellSizeY), _dimensionX(0.), _dimensionY(0.)
+{
+}
+
+CellReadout2D::~CellReadout2D()
+{
+}
+
+CellReadout2D::Position2D CellReadout2D::position(CellReadout2D::CellId cellId)
+{
+    Position2D position;
+    position.x = getCellPositionX(cellId.ix);
+    position.y = getCellPositionY(cellId.iy);
+    return position;
+}
+
+CellReadout::CellId CellReadout2D::cellId(Position2D position)
+{
+    return createCell(getXIndex(position.x), getYIndex(position.y));
+}
+
+CellReadout::Neighbors CellReadout2D::neighbors(CellId cellId)
+{
+    Neighbors neighbors;
+    CellId cell;
+
+    // Loop over delta Y.
+    for (int i = -1; i <= 1; i++) {
+        // Loop over delta X.
+        for (int j = -1; j <= 1; j++) {
+            // Ignore this cell.
+            if (i != 0 || j != 0) {
+                // Create CellId for this neighbor.
+                //std::cout << "creating neighbor i, j: " << i << ", " << j << std::endl;
+                cell = createCell(cellId.ix + j, cellId.iy + i);
+                // Check if valid.
+                if (isValidCell(cell)) {
+                    // Add if cell is valid.
+                    neighbors.push_back(cell);
+                }
+            }
+        }
+    }
+
+    return neighbors;
+
+}
+
+double CellReadout2D::getCellSizeX()
+{
+    return _cellSizeX;
+}
+
+double CellReadout2D::getCellSizeY()
+{
+    return _cellSizeY;
+}
+
+int CellReadout2D::getXIndex(double x)
+{
+    return getCellIndex(x, _cellSizeX);
+}
+
+int CellReadout2D::getYIndex(double y)
+{
+    return getCellIndex(y, _cellSizeY);
+}
+
+double CellReadout2D::getCellCoordinate(int i, double cellSize)
+{
+    return (i * cellSize) - cellSize / 2;
+}
+
+int CellReadout2D::getCellIndex(double c, double cellSize)
+{
+    int v = std::ceil(c / cellSize);
+    if (v == 0)
+        v = 1;
+    return v;
+}
+
+double CellReadout2D::getCellPositionX(int ix)
+{
+    return getCellCoordinate(ix, _cellSizeX);
+}
+
+double CellReadout2D::getCellPositionY(int iy)
+{
+    return getCellCoordinate(iy, _cellSizeY);
+}
+
+CellReadout2D::CellId CellReadout2D::createCell(int x, int y)
+{
+    CellId cell;
+    cell.ix = x;
+    cell.iy = y;
+    return cell;
+}
+
+void CellReadout2D::setDimensionX(double dimensionX)
+{
+    _dimensionX = dimensionX;
+}
+
+void CellReadout2D::setDimensionY(double dimensionY)
+{
+    _dimensionY = dimensionY;
+}
+
+double CellReadout2D::getDimensionX()
+{
+    return _dimensionX;
+}
+
+double CellReadout2D::getDimensionY()
+{
+    return _dimensionY;
+}
+
+bool CellReadout2D::isValidCell(CellId cell)
+{
+    // DEBUG
+    //std::cout << "isValidCell: " << cell.ix << ", " << cell.iy << std::endl;
+
+    if (cell.ix <= 0 || cell.iy <= 0) {
+        //std::cout << "field value < 0" << std::endl;
+        return false;
+    }
+    int xmax = std::floor(getDimensionX() / getCellSizeX());
+    //std::cout << "xmax: " << xmax << std::endl;
+    if (cell.ix > xmax) {
+        //std::cout << cell.ix << " exceeds max allowed X index" << std::endl;
+        return false;
+    }
+    int ymax = std::floor(getDimensionY() / getCellSizeY());
+    //std::cout << "ymax: " << ymax << std::endl;
+    if (cell.iy > ymax) {
+        //std::cout << cell.iy << " exceeds max allowed Y index" << std::endl;
+        return false;
+    }
+    return true;
+}
+
+bool CellReadout2D::isValidPosition(Position2D position)
+{
+    if (position.x > getDimensionX() || position.x < 0) return false;
+    if (position.y > getDimensionY() || position.y < 0) return false;
+    return true;
+}
+

lcdd/src/lcdd/segmentation
CellReadout2DSegmentation.cc added at 1.1
diff -N CellReadout2DSegmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellReadout2DSegmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,190 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/CellReadout2DSegmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/CellReadout2DSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4Step.hh"
+#include "G4Box.hh"
+
+// STL
+#include <cmath>
+
+// Comment out to remove debug prints.
+#define CellReadout2DSegmentation_DEBUG 1
+
+CellReadout2DSegmentation::CellReadout2DSegmentation(double cellSizeX, double cellSizeY) :
+        Segmentation(Segmentation::eNonprojective, 2)
+{
+    _readout = new CellReadout2D(cellSizeX, cellSizeY);
+    setBinNames();
+}
+
+CellReadout2DSegmentation::~CellReadout2DSegmentation()
+{
+    delete _readout;
+}
+
+G4ThreeVector CellReadout2DSegmentation::getGlobalHitPosition(const G4Step* aStep)
+{
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "CellReadout2DSegmentation::getGlobalHitPosition" << std::endl;
+#endif
+
+    // Setup the readout with step dependent information.
+    setup(aStep);
+
+    // Compute the mid-point of the global step.
+    G4ThreeVector globalStepPosition = ReadoutUtil::computeMidPos(aStep);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "globalStepPosition: " << globalStepPosition.x() << " " << globalStepPosition.y() << " " << globalStepPosition.z() << std::endl;
+#endif
+
+    // Compute the local step position.
+    G4ThreeVector localStepPosition = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPosition);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "localStepPosition: " << localStepPosition.x() << " " << localStepPosition.y() << " " << localStepPosition.z() << std::endl;
+#endif
+
+    // Convert into readout coordinates.
+    CellReadout::Position2D readoutStepPosition = localToReadoutCoordinates(localStepPosition);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "readoutStepPosition: " << readoutStepPosition.x << " " << readoutStepPosition.y << std::endl;
+#endif
+
+    // Compute the cell indices from the position.
+    CellReadout::CellId cell = _readout->cellId(readoutStepPosition);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "cell: " << cell.ix << " " << cell.iy << std::endl;
+#endif
+
+    // Get the cell's readout position from the cell ID.
+    CellReadout::Position2D cellReadoutPosition = _readout->position(cell);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "cellReadoutPosition: " << cellReadoutPosition.x << " " << cellReadoutPosition.y << std::endl;
+#endif
+
+    // Convert from readout back to localcoordinates.
+    G4ThreeVector localCellPosition = readoutToLocalCoordinates(cellReadoutPosition);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "localCellPosition: "<< localCellPosition.x() << " " << localCellPosition.y() << " " << localCellPosition.z() << std::endl;
+#endif
+
+    // Finally, convert from the local coordinates into global.
+    G4ThreeVector globalCellPosition = ReadoutUtil::transformLocalToGlobal(aStep, localCellPosition);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "globalCellPosition: "
+            << globalCellPosition.x() << " "
+            << globalCellPosition.y() << " "
+            << globalCellPosition.z() << std::endl;
+    std::cout << std::endl;
+#endif
+
+    return globalCellPosition;
+}
+
+void CellReadout2DSegmentation::setBins(const G4Step* aStep)
+{
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "CellReadout2DSegmentation::setBins" << std::endl;
+#endif
+
+    // Setup the readout with step dependent information.
+    setup(aStep);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    G4ThreeVector prePosition = aStep->GetPreStepPoint()->GetPosition();
+    std::cout << "step pos: " << prePosition.x() << " " << prePosition.y() << " " << prePosition.z() << std::endl;
+#endif
+
+    // Set state from current step.
+    setup(aStep);
+
+    // Compute the global mid-point of the step.
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "globalStepPos: " << globalStepPos.x() << " " << globalStepPos.y() << " " << globalStepPos.z() << std::endl;
+#endif
+
+    // Compute the local step position from the global mid-point.
+    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "localStepPos: " << localStepPos.x() << " " << localStepPos.y() << " " << localStepPos.z() << std::endl;
+#endif
+
+    // Compute the X and Y readout coordinates from the local position.
+    CellReadout::Position2D readoutPosition = localToReadoutCoordinates(localStepPos);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "readoutPosition: " << readoutPosition.x << " " << readoutPosition.y << std::endl;
+#endif
+
+    // Get the cell for the position.
+    CellReadout::CellId cell = _readout->cellId(readoutPosition);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "cellID: " << cell.ix << " " << cell.iy << std::endl;
+#endif
+
+    // Set the segmentation's bin values.
+    this->setBin(0, readoutPosition.x);
+    this->setBin(1, readoutPosition.y);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    // print the neighbor CellIds
+    CellReadout::Neighbors neighbors = _readout->neighbors(cell);
+    std::cout << "neighbors: " << std::endl;
+    for (CellReadout::Neighbors::const_iterator it = neighbors.begin(); it != neighbors.end(); it++) {
+        std::cout << "  " << (*it).ix << ", " << (*it).iy << std::endl;
+    }
+    std::cout << std::endl;
+#endif
+}
+
+void CellReadout2DSegmentation::setBinNames()
+{
+    addBinName("ix");
+    addBinName("iy");
+}
+
+void CellReadout2DSegmentation::setup(const G4Step* aStep)
+{
+    // Set dimensions from current box volume.
+    G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint(aStep->GetPreStepPoint());
+    G4Box* box = dynamic_cast<G4Box*>(solid);
+    if (box == 0) {
+        std::cerr << "Current volume is not a box!!!" << std::endl;
+        G4Exception("", "", FatalException, "CellReadout2D points to a shape that is not a G4Box.");
+    }
+    _readout->setDimensionX(box->GetXHalfLength() * 2);
+    _readout->setDimensionY(box->GetYHalfLength() * 2);
+
+#ifdef CellReadout2DSegmentation_DEBUG
+    std::cout << "set readout dimensions XY: " << _readout->getDimensionX() << " " << _readout->getDimensionY() << std::endl;
+#endif
+}
+
+CellReadout::Position2D CellReadout2DSegmentation::localToReadoutCoordinates(G4ThreeVector& vec)
+{
+    CellReadout::Position2D position;
+    position.x = vec.x() + _readout->getDimensionX() / 2.;
+    position.y = vec.y() + _readout->getDimensionY() / 2.;
+    return position;
+}
+
+G4ThreeVector CellReadout2DSegmentation::readoutToLocalCoordinates(CellReadout::Position2D position)
+{
+    double x = position.x - _readout->getDimensionX() / 2.;
+    double y = position.y - _readout->getDimensionY() / 2.;
+    return G4ThreeVector(x, y, 0);
+}

lcdd/src/lcdd/segmentation
GlobalGridXYSegmentation.cc added at 1.1
diff -N GlobalGridXYSegmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GlobalGridXYSegmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,78 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/GlobalGridXYSegmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/GlobalGridXYSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4NavigationHistory.hh"
+
+GlobalGridXYSegmentation::GlobalGridXYSegmentation(double gridSizeX, double gridSizeY) :
+        Segmentation(Segmentation::eNonprojective), _gridSizeX(gridSizeX), _gridSizeY(gridSizeY)
+{
+    setBinNames();
+}
+
+GlobalGridXYSegmentation::~GlobalGridXYSegmentation()
+{
+}
+
+void GlobalGridXYSegmentation::setBinNames()
+{
+    addBinName("x");
+    addBinName("y");
+    addBinName("z");
+}
+
+G4ThreeVector GlobalGridXYSegmentation::getGlobalHitPosition(const G4Step* aStep)
+{
+    // Compute the midpoint of the global step.
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+    // Create 3vec for cell position.
+    G4ThreeVector globalCellPos;
+
+    // Set binned coordinates of cell position.
+    globalCellPos.setX(computeDimX(computeBinX(globalStepPos)));
+    globalCellPos.setY(computeDimY(computeBinY(globalStepPos)));
+
+    // Set Z coordinate of cell position from the volume's Z center position.
+    G4ThreeVector vpos = ReadoutUtil::getVolumeGlobalPosition(aStep->GetPreStepPoint());
+    globalCellPos.setZ(vpos.z());
+
+    return globalCellPos;
+}
+
+void GlobalGridXYSegmentation::setBins(const G4Step* aStep)
+{
+    // Compute the midpoint of the step.
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+    // Compute the bin values.
+    int binX = computeBinX(globalStepPos);
+    int binY = computeBinY(globalStepPos);
+
+    // Set the bin values.
+    setBin(0, binX);
+    setBin(1, binY);
+}
+
+int GlobalGridXYSegmentation::computeBinX(const G4ThreeVector& stepPos)
+{
+    return Segmentation::computeBin(stepPos.x(), _gridSizeX);
+}
+
+int GlobalGridXYSegmentation::computeBinY(const G4ThreeVector& stepPos)
+{
+    return Segmentation::computeBin(stepPos.y(), _gridSizeY);
+}
+
+double GlobalGridXYSegmentation::computeDimX(int bin)
+{
+    return Segmentation::computeDim(bin, _gridSizeX);
+}
+
+double GlobalGridXYSegmentation::computeDimY(int bin)
+{
+    return Segmentation::computeDim(bin, _gridSizeY);
+}

lcdd/src/lcdd/segmentation
GridXYZSegmentation.cc added at 1.1
diff -N GridXYZSegmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GridXYZSegmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,153 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/GridXYZSegmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/GridXYZSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4NavigationHistory.hh"
+
+GridXYZSegmentation::GridXYZSegmentation(double gridSizeX, double gridSizeY, double gridSizeZ) :
+        Segmentation(Segmentation::eNonprojective), _gridSizeX(gridSizeX), _gridSizeY(gridSizeY), _gridSizeZ(gridSizeZ)
+{
+    setBinNames();
+}
+
+GridXYZSegmentation::~GridXYZSegmentation()
+{
+}
+
+void GridXYZSegmentation::setBinNames()
+{
+    addBinName("x");
+    addBinName("y");
+    addBinName("z");
+}
+
+G4ThreeVector GridXYZSegmentation::getGlobalHitPosition(const G4Step* aStep)
+{
+    // compute midpoint
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+    // figure local step pos using touchable and global midpoint
+    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
+
+    // local cell pos
+    G4ThreeVector localCellPos = this->getLocalHitPos(localStepPos);
+
+    // global cell pos
+    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
+
+    return globalCellPos;
+}
+
+void GridXYZSegmentation::setBins(const G4Step* aStep)
+{
+    // Compute the midpoint of the step.
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+    // Transform from global coordinate system to local coordinate system of volume pointed to by this step.
+    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
+
+    // Compute the bin values.
+    int binX = computeBinX(localStepPos);
+    int binY = computeBinY(localStepPos);
+    int binZ = computeBinZ(localStepPos);
+
+    // Set the bins.
+    int idx = 0;
+
+    setBin(idx, binX);
+    ++idx;
+
+    setBin(idx, binY);
+    ++idx;
+
+    setBin(idx, binZ);
+    ++idx;
+}
+
+int GridXYZSegmentation::computeBinX(const G4ThreeVector& localStepPos)
+{
+    int ret;
+    if (_gridSizeX != 0) {
+        ret = Segmentation::computeBin(localStepPos.x(), _gridSizeX);
+    } else {
+        ret = 0;
+    }
+    return ret;
+}
+
+int GridXYZSegmentation::computeBinY(const G4ThreeVector& localStepPos)
+{
+    int ret;
+    if (_gridSizeY != 0) {
+        ret = Segmentation::computeBin(localStepPos.y(), _gridSizeY);
+    } else {
+        ret = 0;
+    }
+    return ret;
+}
+
+int GridXYZSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
+{
+    int ret;
+    if (_gridSizeZ != 0) {
+        ret = Segmentation::computeBin(localStepPos.z(), _gridSizeZ);
+    } else {
+        ret = 0;
+    }
+    return ret;
+}
+
+double GridXYZSegmentation::computeDimX(int bin)
+{
+    return Segmentation::computeDim(bin, _gridSizeX);
+}
+
+double GridXYZSegmentation::computeDimY(int bin)
+{
+    return Segmentation::computeDim(bin, _gridSizeY);
+}
+
+double GridXYZSegmentation::computeDimZ(int bin)
+{
+    return Segmentation::computeDim(bin, _gridSizeZ);
+}
+
+/*
+G4ThreeVector GridXYZSegmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
+{
+    G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+
+    // Figure out local step pos using touchable and global midpoint.
+    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint, globalStepPos);
+
+    // Compute local cell pos.
+    G4ThreeVector localCellPos = this->getLocalHitPos(localStepPos);
+
+    // Compute global cell pos.
+    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aPreStepPoint, localCellPos);
+
+    return globalCellPos;
+}
+*/
+
+G4ThreeVector GridXYZSegmentation::getLocalHitPos(const G4ThreeVector& localStepPos)
+{
+    G4ThreeVector localHitPos;
+
+    if (_gridSizeX > 0) {
+        localHitPos.setX(computeDimX(computeBinX(localStepPos)));
+    }
+
+    if (_gridSizeY > 0) {
+        localHitPos.setY(computeDimY(computeBinY(localStepPos)));
+    }
+
+    if (_gridSizeZ > 0) {
+        localHitPos.setZ(computeDimZ(computeBinZ(localStepPos)));
+    }
+
+    return localHitPos;
+}

lcdd/src/lcdd/segmentation
NonprojectiveCylinderSegmentation.cc added at 1.1
diff -N NonprojectiveCylinderSegmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ NonprojectiveCylinderSegmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,241 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/NonprojectiveCylinderSegmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/NonprojectiveCylinderSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4Tubs.hh"
+
+// STL
+#include <cmath>
+
+NonprojectiveCylinderSegmentation::NonprojectiveCylinderSegmentation(double gridSizePhi, double gridSizeZ) :
+        Segmentation(Segmentation::eNonprojective), _gridSizePhi(gridSizePhi), _gridSizeZ(gridSizeZ)
+
+{
+    setBinNames();
+}
+
+NonprojectiveCylinderSegmentation::~NonprojectiveCylinderSegmentation()
+{
+}
+
+void NonprojectiveCylinderSegmentation::setBinNames()
+{
+    addBinName("phi");
+    addBinName("z");
+}
+
+G4ThreeVector NonprojectiveCylinderSegmentation::getGlobalHitPosition(const G4Step* aStep)
+{
+    // local cell pos
+    G4ThreeVector localCellPos = getLocalHitPos(aStep);
+
+    // global cell pos
+    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
+
+    return localCellPos;
+}
+
+/*
+G4ThreeVector NonprojectiveCylinderSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
+{
+    // local cell pos
+    G4ThreeVector localCellPos = getLocalHitPos(aPreStepPoint);
+
+    // global cell pos
+    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aPreStepPoint, localCellPos);
+
+    // DEBUG: print local, global cell pos
+    //G4cout << "localCellPos " << localCellPos << G4endl;
+    //G4cout << "globalCellPos " << globalCellPos << G4endl;
+    //
+
+    return localCellPos;
+}
+*/
+
+G4ThreeVector NonprojectiveCylinderSegmentation::getLocalHitPos(const G4Step* aStep)
+{
+    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
+
+    // retrieve G4Tubs
+    const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
+
+    assert(tubs);
+
+    // rcyl of cell = mid rad of current tubs
+    double rcyl = ReadoutUtil::computeTubsMidRadius(tubs);
+
+    // compute single delta phi in degrees
+    double deltaPhi = computeDeltaPhi(aStep);
+
+    // phi index
+    int iphi = computeBinPhi(aStep);
+
+    // z index in local
+    int iz = computeBinZ(ReadoutUtil::transformGlobalToLocal(aStep, globalMidPos));
+
+    // compute cell Z, phi
+    double cellPhi = computeDim(iphi, deltaPhi);
+    double cellZ = computeDim(iz, _gridSizeZ);
+
+    // compute X, Y
+    double cellX = rcyl * cos(cellPhi);
+    double cellY = rcyl * sin(cellPhi);
+
+    G4ThreeVector cellCenter(cellX, cellY, cellZ);
+
+    return cellCenter;
+}
+
+G4ThreeVector NonprojectiveCylinderSegmentation::getLocalHitPos(const G4StepPoint* aPreStepPoint)
+{
+    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
+
+    // retrieve G4Tubs
+    const G4Tubs* tubs = ReadoutUtil::getTubs(aPreStepPoint);
+
+    assert(tubs);
+
+    // rcyl of cell = mid rad of current tubs
+    double rcyl = ReadoutUtil::computeTubsMidRadius(tubs);
+
+    // compute single delta phi in degrees
+    double deltaPhi = computeDeltaPhi(aPreStepPoint);
+
+    // phi index
+    int iphi = computeBinPhi(aPreStepPoint);
+
+    // z index in local
+    int iz = computeBinZ(ReadoutUtil::transformGlobalToLocal(aPreStepPoint, globalPos));
+
+    // compute cell Z, phi
+    double cellPhi = computeDim(iphi, deltaPhi);
+    double cellZ = computeDim(iz, _gridSizeZ);
+
+    // compute X, Y
+    double cellX = rcyl * cos(cellPhi);
+    double cellY = rcyl * sin(cellPhi);
+
+    G4ThreeVector cellCenter(cellX, cellY, cellZ);
+
+    return cellCenter;
+}
+
+double NonprojectiveCylinderSegmentation::computeDeltaPhi(const G4Step* aStep)
+{
+    // mid radius of current tubs
+    double mid_rad_layer = ReadoutUtil::computeTubsMidRadius(aStep);
+
+    // circumference of current tubs
+    double circ = 2.0 * ReadoutUtil::PI * mid_rad_layer;
+
+    // number of cells along phi in curr layer
+    int nphi = (int) floor(circ / _gridSizePhi);
+
+    // single phi division in degrees
+    double deltaPhi = (360.0 * deg) / nphi;
+
+    return deltaPhi;
+}
+double NonprojectiveCylinderSegmentation::computeDeltaPhi(const G4StepPoint* aPreStepPoint)
+{
+    // mid radius of current tubs
+    double mid_rad_layer = ReadoutUtil::computeTubsMidRadius(aPreStepPoint);
+
+    // circumference of current tubs
+    double circ = 2.0 * ReadoutUtil::PI * mid_rad_layer;
+
+    // number of cells along phi in curr layer
+    int nphi = (int) floor(circ / _gridSizePhi);
+
+    // single phi division in degrees
+    double deltaPhi = (360.0 * deg) / nphi;
+
+    return deltaPhi;
+}
+void NonprojectiveCylinderSegmentation::setBins(const G4Step* aStep)
+{
+    //G4cout << "G4NonprojectiveCylinderSegmentation::setBins()" << G4endl;
+
+    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
+
+    int bphi = computeBinPhi(aStep);
+    int bz = computeBinZ(globalMidPos);
+
+    setBin(0, bphi);
+    setBin(1, bz);
+}
+//void NonprojectiveCylinderSegmentation::setBins(const G4StepPoint* aPreStepPoint)
+//{
+//    //G4cout << "G4NonprojectiveCylinderSegmentation::setBins()" << G4endl;
+//
+//    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
+//
+//    int bphi = computeBinPhi(aPreStepPoint);
+//    int bz = computeBinZ(globalPos);
+//
+//    setBin(0, bphi);
+//    setBin(1, bz);
+//}
+int NonprojectiveCylinderSegmentation::computeBinPhi(const G4Step* aStep)
+{
+    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
+
+    const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
+    assert(tubs);
+
+    // compute single delta phi in degrees
+    double deltaPhi = computeDeltaPhi(aStep);
+
+    // step phi
+    double stepPhi = globalMidPos.phi();
+
+    if (stepPhi < 0) {
+        stepPhi += 2.0 * ReadoutUtil::PI;
+    }
+
+    // phi index
+    return computeBin(stepPhi, deltaPhi / radian);
+}
+
+int NonprojectiveCylinderSegmentation::computeBinPhi(const G4StepPoint* aPreStepPoint)
+{
+    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
+
+    const G4Tubs* tubs = ReadoutUtil::getTubs(aPreStepPoint);
+    assert(tubs);
+
+    // compute single delta phi in degrees
+    double deltaPhi = computeDeltaPhi(aPreStepPoint);
+
+    // step phi
+    double stepPhi = globalPos.phi();
+
+    if (stepPhi < 0) {
+        stepPhi += 2.0 * ReadoutUtil::PI;
+    }
+
+    // phi index
+    return computeBin(stepPhi, deltaPhi / radian);
+}
+
+int NonprojectiveCylinderSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
+{
+    return computeBin(localStepPos.z(), _gridSizeZ);
+}
+
+bool NonprojectiveCylinderSegmentation::isValidSolid(G4VSolid* s)
+{
+    bool valid = Segmentation::isValidSolid(s);
+
+    if (valid) {
+        if (s->GetEntityType() != "G4Tubs") {
+            valid = false;
+        }
+    }
+
+    return valid;
+}

lcdd/src/lcdd/segmentation
ProjectiveCylinderSegmentation.cc added at 1.1
diff -N ProjectiveCylinderSegmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProjectiveCylinderSegmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,74 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/ProjectiveCylinderSegmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/ProjectiveCylinderSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4StepPoint.hh"
+#include "G4NavigationHistory.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4LogicalVolume.hh"
+#include "G4Tubs.hh"
+
+ProjectiveCylinderSegmentation::ProjectiveCylinderSegmentation(G4int ntheta, G4int nphi) :
+        ProjectiveSegmentation(ntheta, nphi)
+{
+}
+
+ProjectiveCylinderSegmentation::~ProjectiveCylinderSegmentation()
+{
+}
+
+double ProjectiveCylinderSegmentation::getRadius(const G4Step* aStep)
+{
+    return ReadoutUtil::computeTubsMidRadius(ReadoutUtil::getTubs(aStep));
+}
+
+/*
+double ProjectiveCylinderSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
+{
+    return ReadoutUtil::computeTubsMidRadius(ReadoutUtil::getTubs(aPreStepPoint));
+}
+*/
+
+double ProjectiveCylinderSegmentation::getZ(const G4Step* aStep)
+{
+    double rcyl = getRadius(aStep);
+
+    double ctheta = getThetaDim(aStep);
+
+    // ctheta in 0 to pi ...
+    // ctheta < pi/2 should be negative
+
+    double zcell = rcyl / tan(ctheta);
+
+    return zcell;
+}
+/*
+double ProjectiveCylinderSegmentation::getZ(const G4StepPoint* aPreStepPoint)
+{
+    double rcyl = getRadius(aPreStepPoint);
+
+    double ctheta = getThetaDim(aPreStepPoint);
+
+    // ctheta in 0 to pi ...
+    // ctheta < pi/2 should be negative
+
+    double zcell = rcyl / tan(ctheta);
+
+    return zcell;
+}
+*/
+bool ProjectiveCylinderSegmentation::isValidSolid(G4VSolid* s)
+{
+    bool valid = Segmentation::isValidSolid(s);
+
+    if (valid) {
+        if (s->GetEntityType() != "G4Tubs") {
+            valid = false;
+        }
+    }
+
+    return valid;
+}

lcdd/src/lcdd/segmentation
ProjectiveSegmentation.cc added at 1.1
diff -N ProjectiveSegmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProjectiveSegmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,229 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/ProjectiveSegmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/ProjectiveSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4StepPoint.hh"
+#include "G4NavigationHistory.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4LogicalVolume.hh"
+#include "G4Tubs.hh"
+
+ProjectiveSegmentation::ProjectiveSegmentation(G4int ntheta, G4int nphi) :
+        Segmentation(Segmentation::eProjective), _ntheta(ntheta), _nphi(nphi)
+{
+    computeDivisions();
+    setBinNames();
+}
+
+ProjectiveSegmentation::~ProjectiveSegmentation()
+{
+}
+
+void ProjectiveSegmentation::setBinNames()
+{
+    addBinName("theta");
+    addBinName("phi");
+}
+
+G4ThreeVector ProjectiveSegmentation::getGlobalHitPosition(const G4Step* aStep)
+{
+    // divide entire theta, phi range into bins; bins always positive
+    // theta, phi coord of step midpoint
+    // compute bin numbers
+    // get dim from bins
+
+    // get radius, z components (probably from subclass function)
+    double rcyl = getRadius(aStep);
+    double zcell = getZ(aStep);
+
+    // get phi component
+    double cphi = getPhiDim(aStep);
+
+    // compute x, y cells
+    double xcell = rcyl * cos(cphi);
+    double ycell = rcyl * sin(cphi);
+
+    G4ThreeVector pos(xcell, ycell, zcell);
+
+    //G4ThreeVector midPos = ReadoutUtil::computeMidPos( aStep );
+
+    return pos;
+}
+
+/*
+G4ThreeVector ProjectiveSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
+{
+    // DEBUG
+    //G4cout << "G4ProjectiveSegmentation::getGlobalHitPos()" << G4endl;
+    //
+
+    // divide entire theta, phi range into bins; bins always positive
+    // theta, phi coord of step midpoint
+    // compute bin numbers
+    // get dim from bins
+
+    // get radius, z components (probably from subclass function)
+    double rcyl = getRadius(aPreStepPoint);
+    double zcell = getZ(aPreStepPoint);
+
+    // get phi component
+    double cphi = getPhiDim(aPreStepPoint);
+
+    // compute x, y cells
+    double xcell = rcyl * cos(cphi);
+    double ycell = rcyl * sin(cphi);
+
+    G4ThreeVector pos(xcell, ycell, zcell);
+
+    //G4ThreeVector midPos = ReadoutUtil::computeMidPos( aStep );
+
+    // DEBUG: print all
+    //G4cout << "sphi <" << midPos.phi() << ">" << G4endl;
+    //G4cout << "cphi <" << cphi << ">" << G4endl;
+    //G4cout << "sphi - cphi = " << midPos.phi() - cphi << G4endl;
+
+    //G4cout << "stheta <" << midPos.theta() << ">" << G4endl;
+    //G4cout << "ctheta <" << getThetaDim( aStep ) << ">" << G4endl;
+    //G4cout << "stheta - ctheta = " << midPos.theta() - getThetaDim( aStep ) << G4endl;
+
+    //G4cout << "rcyl <" << rcyl << ">" << G4endl;
+    //G4cout << "zcell <" << zcell << ">" << G4endl;
+    //G4cout << "globalCellPos <" << pos << ">" << G4endl;
+    //
+
+    return pos;
+}
+*/
+
+void ProjectiveSegmentation::setBins(const G4Step* aStep)
+{
+    G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
+
+    setBin(0, getThetaBin(globalMidPos));
+    setBin(1, getPhiBin(globalMidPos));
+}
+
+/*
+void ProjectiveSegmentation::setBins(const G4StepPoint* aPreStepPoint)
+{
+    G4ThreeVector globalPos = aPreStepPoint->GetPosition();
+
+    setBin(0, getThetaBin(globalPos));
+    setBin(1, getPhiBin(globalPos));
+}
+*/
+
+G4int ProjectiveSegmentation::getNtheta() const
+{
+    return _ntheta;
+}
+
+G4int ProjectiveSegmentation::getNphi() const
+{
+    return _nphi;
+}
+
+void ProjectiveSegmentation::computeDivisions()
+{
+    _divTheta = (180.0 * deg) / _ntheta;
+    _divPhi = (360.0 * deg) / _nphi;
+}
+
+int ProjectiveSegmentation::getThetaBin(const G4ThreeVector& globalStepPos)
+{
+    // theta needs to be in range 0 - PI
+    return Segmentation::computeBin(globalStepPos.theta(), _divTheta / radian);
+}
+
+int ProjectiveSegmentation::getPhiBin(const G4ThreeVector& globalStepPos)
+{
+
+    // adjust phi for < 0
+    double sphi = globalStepPos.phi();
+
+    if (sphi < 0.0) {
+        sphi += 360.0 * deg;
+    }
+
+    // needs more checks, for phi in range 0 - TWOPI
+    // if > TWOPI, then subtract TWOPI
+    //
+    // OR use X, Y for phi calc
+
+    // compute and return bin
+    return Segmentation::computeBin(sphi, _divPhi / radian);
+}
+
+// default impl. returns mag of pos 
+double ProjectiveSegmentation::getRadius(const G4Step* aStep)
+{
+    //G4cout << "G4ProjectiveSegmentation::getRadius()" << G4endl;
+
+    return ReadoutUtil::computeMidPos(aStep).mag();
+}
+
+//double ProjectiveSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
+//{
+    //G4cout << "G4ProjectiveSegmentation::getRadius()" << G4endl;
+//    return aPreStepPoint->GetPosition().mag();
+//}
+
+// default impl. returns z of pos
+double ProjectiveSegmentation::getZ(const G4Step* aStep)
+{
+    //G4cout << "G4ProjectiveSegmentation::getZ()" << G4endl;
+    return ReadoutUtil::computeMidPos(aStep).z();
+}
+
+//double ProjectiveSegmentation::getZ(const G4StepPoint* aPreStepPoint)
+//{
+    //G4cout << "G4ProjectiveSegmentation::getZ()" << G4endl;
+//    return aPreStepPoint->GetPosition().z();
+//}
+
+double ProjectiveSegmentation::getThetaDim(const int &thetaBin) const
+{
+    return Segmentation::computeDim(thetaBin, _divTheta);
+}
+
+double ProjectiveSegmentation::getPhiDim(const int &phiBin) const
+{
+    return Segmentation::computeDim(phiBin, _divPhi);
+}
+
+double ProjectiveSegmentation::getThetaDim(const G4Step* aStep)
+{
+    //G4cout << "G4ProjectiveSegmentation::getThetaDim(G4Step*)" << G4endl;
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+    double ctheta = getThetaDim(getThetaBin(globalStepPos));
+    return ctheta;
+}
+
+//double ProjectiveSegmentation::getThetaDim(const G4StepPoint* aPreStepPoint)
+//{
+    //G4cout << "G4ProjectiveSegmentation::getThetaDim(G4Step*)" << G4endl;
+//    G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+//    double ctheta = getThetaDim(getThetaBin(globalStepPos));
+//    return ctheta;
+//}
+
+double ProjectiveSegmentation::getPhiDim(const G4Step* aStep)
+{
+    //G4cout << "G4ProjectiveSegmentation::getPhiDim(G4Step*)" << G4endl;
+
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+    double cphi = getPhiDim(getPhiBin(globalStepPos));
+    return cphi;
+}
+//double ProjectiveSegmentation::getPhiDim(const G4StepPoint* aPreStepPoint)
+//{
+    //G4cout << "G4ProjectiveSegmentation::getPhiDim(G4Step*)" << G4endl;
+
+//    G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+//    double cphi = getPhiDim(getPhiBin(globalStepPos));
+//    return cphi;
+//}
+

lcdd/src/lcdd/segmentation
ProjectiveZPlaneSegmentation.cc added at 1.1
diff -N ProjectiveZPlaneSegmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProjectiveZPlaneSegmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,45 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/ProjectiveZPlaneSegmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/ProjectiveZPlaneSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+ProjectiveZPlaneSegmentation::ProjectiveZPlaneSegmentation(G4int ntheta, G4int nphi) :
+        ProjectiveSegmentation(ntheta, nphi)
+{
+}
+
+ProjectiveZPlaneSegmentation::~ProjectiveZPlaneSegmentation()
+{
+}
+
+double ProjectiveZPlaneSegmentation::getRadius(const G4Step* aStep)
+{
+    double zcell = getZ(aStep);
+    double ctheta = ProjectiveSegmentation::getThetaDim(aStep);
+    double rcyl = zcell * tan(ctheta);
+    return rcyl;
+}
+/*
+double ProjectiveZPlaneSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
+{
+    double zcell = getZ(aPreStepPoint);
+    double ctheta = ProjectiveSegmentation::getThetaDim(aPreStepPoint);
+    double rcyl = zcell * tan(ctheta);
+    return rcyl;
+}
+*/
+
+double ProjectiveZPlaneSegmentation::getZ(const G4Step* aStep)
+{
+    G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aStep->GetPreStepPoint(), G4ThreeVector());
+    return gpos.z();
+}
+
+/*
+double ProjectiveZPlaneSegmentation::getZ(const G4StepPoint* aPreStepPoint)
+{
+    G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aPreStepPoint, G4ThreeVector());
+    return gpos.z();
+}
+*/

lcdd/src/lcdd/segmentation
Segmentation.cc added at 1.1
diff -N Segmentation.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Segmentation.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,128 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/Segmentation.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/Segmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+Segmentation::Segmentation(EType segType, int nbins) :
+        _numBins(nbins), _type(segType)
+{
+    // reserve nbins
+    _bins.reserve(_numBins);
+
+    // fill in 0 vals
+    resetBins();
+}
+
+Segmentation::~Segmentation()
+{
+}
+
+void Segmentation::setBin(int binIdx, int binVal)
+{
+    _bins.insert(_bins.begin() + binIdx, binVal);
+}
+
+int Segmentation::getNumberOfBins()
+{
+    return _numBins;
+}
+
+const std::vector<int>& Segmentation::getBins()
+{
+    return _bins;
+}
+
+Segmentation::EType Segmentation::getType()
+{
+    return _type;
+}
+
+//G4ThreeVector Segmentation::getGlobalHitPos(const G4Step* aStep)
+//{
+//    return ReadoutUtil::computeMidPos(aStep);
+//}
+
+//G4ThreeVector Segmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
+//{
+//    //G4Exception("Do not use this method!");
+//    return aPreStepPoint->GetPosition();
+//}
+
+G4ThreeVector Segmentation::getLocalHitPosition(const G4ThreeVector& localStepPos)
+{
+    return localStepPos;
+}
+
+void Segmentation::resetBins()
+{
+    _bins.clear();
+}
+
+void Segmentation::printOutBins(std::ostream& os, const std::vector<int>& bins)
+{
+    os << "segmentationBins <" << bins.size() << "> :: ";
+    for (std::vector<int>::const_iterator iter = bins.begin(); iter != bins.end(); iter++) {
+        os << *iter << " ";
+    }
+    os << std::endl;
+}
+
+bool Segmentation::isValidSolid(G4VSolid* s)
+{
+    bool valid = true;
+
+    if (0 == s) {
+        valid = false;
+    }
+
+    return valid;
+}
+
+const G4String& Segmentation::getTypeString()
+{
+    static G4String typestr;
+    if (_type == Segmentation::eProjective) {
+        typestr = "Projective";
+    } else if (_type == Segmentation::eNonprojective) {
+        typestr = "Nonprojective";
+    } else {
+        typestr = "Unknown";
+    }
+    return typestr;
+}
+
+int Segmentation::getBin(int idx)
+{
+    return _bins.at(idx);
+}
+
+const std::string& Segmentation::getBinName(int idx)
+{
+    return _binNames.at(idx);
+}
+
+void Segmentation::addBinName(const std::string& binName)
+{
+    _binNames.push_back(binName);
+}
+
+const std::vector<std::string>& Segmentation::getBinNames()
+{
+    return _binNames;
+}
+
+void Segmentation::printOutBins(std::ostream& os)
+{
+    printOutBins(os, _bins);
+}
+
+int Segmentation::computeBin(double localDim, double gridDim)
+{
+    return int(floor(localDim / gridDim));
+}
+
+double Segmentation::computeDim(const int &bin, const double &incr)
+{
+    return (double(bin) + .5) * incr;
+}

lcdd/src/lcdd/segmentation
SegmentationFactory.cc added at 1.1
diff -N SegmentationFactory.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SegmentationFactory.cc	10 Sep 2013 21:57:33 -0000	1.1
@@ -0,0 +1,176 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/segmentation/SegmentationFactory.cc,v 1.1 2013/09/10 21:57:33 jeremy Exp $
+
+// LCDD
+#include "lcdd/segmentation/SegmentationFactory.hh"
+#include "lcdd/schema/grid_xyz.hh"
+#include "lcdd/schema/global_grid_xy.hh"
+#include "lcdd/schema/nonprojective_cylinder.hh"
+#include "lcdd/schema/projective_cylinder.hh"
+#include "lcdd/schema/projective_zplane.hh"
+#include "lcdd/schema/cell_readout_2d.hh"
+#include "lcdd/segmentation/Segmentation.hh"
+#include "lcdd/segmentation/GridXYZSegmentation.hh"
+#include "lcdd/segmentation/GlobalGridXYSegmentation.hh"
+#include "lcdd/segmentation/ProjectiveCylinderSegmentation.hh"
+#include "lcdd/segmentation/ProjectiveZPlaneSegmentation.hh"
+#include "lcdd/segmentation/NonprojectiveCylinderSegmentation.hh"
+#include "lcdd/segmentation/CellReadout2DSegmentation.hh"
+
+// GDML
+#include "Saxana/SAXObject.h"
+#include "G4Processor/GDMLProcessor.h"
+#include "G4Evaluator/GDMLExpressionEvaluator.h"
+
+// STL
+#include <iostream>
+
+SegmentationFactory::SegmentationFactory()
+{
+}
+
+Segmentation* SegmentationFactory::createSegmentation(SAXObject* obj, const std::string& tag)
+{
+    Segmentation* seg = 0;
+    GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+    if (tag == "projective_cylinder") {
+        projective_cylinder* prj = dynamic_cast<projective_cylinder*>(obj);
+        if (prj) {
+            int ntheta, nphi;
+            std::string sval = prj->get_ntheta();
+            ntheta = (int) calc->Eval(sval);
+            sval = prj->get_nphi();
+            nphi = (int) calc->Eval(sval);
+            seg = new ProjectiveCylinderSegmentation(ntheta, nphi);
+        } else {
+            std::cerr << "Failed cast to projective_cylinder!" << std::endl;
+        }
+
+    } else if (tag == "grid_xyz") {
+        // GridXYZ
+        grid_xyz* np = dynamic_cast<grid_xyz*>(obj);
+        if (np) {
+            double gsx, gsy, gsz;
+            gsx = gsy = gsz = 0.;
+            std::string lunit = np->get_lunit();
+
+            std::string sval = np->get_gridSizeX();
+            sval += "*" + lunit;
+            gsx = calc->Eval(sval);
+
+            sval = np->get_gridSizeY();
+            sval += "*" + lunit;
+            gsy = calc->Eval(sval);
+
+            sval = np->get_gridSizeZ();
+            sval += "*" + lunit;
+            gsz = calc->Eval(sval);
+
+            //std::cout << "grid x, y, z: " << gsx << ", " << gsy << ", " << gsz << std::endl;
+
+            seg = new GridXYZSegmentation(gsx, gsy, gsz);
+        } else {
+            std::cerr << "Failed cast to grid_xyz!" << std::endl;
+        }
+    }
+    // GlobalGridXY
+    else if (tag == "global_grid_xy") {
+        global_grid_xy* gridxy = dynamic_cast<global_grid_xy*>(obj);
+        if (gridxy) {
+            double gsx, gsy;
+            gsx = gsy = 0.;
+            std::string lunit = gridxy->get_lunit();
+
+            std::string sval = gridxy->get_gridSizeX();
+            sval += "*" + lunit;
+            gsx = calc->Eval(sval);
+
+            sval = gridxy->get_gridSizeY();
+            sval += "*" + lunit;
+            gsy = calc->Eval(sval);
+
+            seg = new GlobalGridXYSegmentation(gsx, gsy);
+        } else {
+            std::cerr << "Failed cast to global_grid_xy!" << std::endl;
+        }
+    } else if (tag == "nonprojective_cylinder") {
+        // handle NP cylinder
+
+        //std::cout << "add nonprojective_cylinder here" << std::endl;
+
+        nonprojective_cylinder* np = dynamic_cast<nonprojective_cylinder*>(obj);
+        if (np) {
+
+            double gsp = 0;
+            double gsz = 0;
+
+            std::string lunit = np->get_lunit();
+
+            std::string sval = np->get_gridSizePhi();
+            sval += "*" + lunit;
+            gsp = calc->Eval(sval);
+
+            sval = np->get_gridSizeZ();
+            sval += "*" + lunit;
+            gsz = calc->Eval(sval);
+
+            seg = new NonprojectiveCylinderSegmentation(gsp, gsz);
+        } else {
+            std::cerr << "Failed cast to nonprojective_cylinder!" << std::endl;
+        }
+    } else if (tag == "projective_zplane") {
+        // handle projective_zplane
+
+        //std::cout << "add projective_zplane here" << std::endl;
+
+        projective_zplane* prj = dynamic_cast<projective_zplane*>(obj);
+
+        if (prj) {
+
+            int ntheta, nphi;
+            std::string sval = prj->get_ntheta();
+            ntheta = (int) calc->Eval(sval);
+            sval = prj->get_nphi();
+            nphi = (int) calc->Eval(sval);
+
+            //std::cout << "ntheta, nphi : " 
+            //		<< ntheta << ", " 
+            //		<< nphi << std::endl;
+
+            seg = new ProjectiveZPlaneSegmentation(ntheta, nphi);
+        } else {
+            std::cerr << "Failed cast to projective_zplane!" << std::endl;
+        } // prj no exist
+    } else if (tag == "cell_readout_2d") {
+
+        //std::cout << "building cell_readout_2d" << std::endl;
+
+        cell_readout_2d* elem = dynamic_cast<cell_readout_2d*>(obj);
+        if (0 != elem) {
+            double cellSizeX, cellSizeY;
+            cellSizeX = cellSizeY = 0;
+            std::string lengthUnit = elem->getLengthUnit();
+
+            std::string val = elem->getCellSizeX();
+            val += "*" + lengthUnit;
+            cellSizeX = calc->Eval(val);
+
+            val = elem->getCellSizeY();
+            val += "*" + lengthUnit;
+            cellSizeY = calc->Eval(val);
+
+            //std::cout << "G4SegmentationFactory creating CellReadout2DSegmentation(x,y): " << cellSizeX << " " << cellSizeY << std::endl;
+
+            seg = new CellReadout2DSegmentation(cellSizeX, cellSizeY);
+        }
+    } else {
+        // bad segmentation tag
+        std::cerr << "Unknown child tag for calorimeter: " << tag << "." << std::endl;
+    }
+
+    if (seg == 0) {
+        G4Exception("", "", FatalException, "Failed to create segmentation.");
+    }
+
+    return seg;
+}

lcdd/src/lcdd/subscribers
calorimeterSubscriber.cc 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- calorimeterSubscriber.cc	10 Jul 2013 18:06:20 -0000	1.3
+++ calorimeterSubscriber.cc	10 Sep 2013 21:57:33 -0000	1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/calorimeterSubscriber.cc,v 1.3 2013/07/10 18:06:20 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/calorimeterSubscriber.cc,v 1.4 2013/09/10 21:57:33 jeremy Exp $
 
 // GDML
 #include "Saxana/SAXSubscriber.h"
@@ -9,7 +9,6 @@
 #include "lcdd/schema/calorimeter.hh"
 #include "lcdd/core/LCDDProcessor.hh"
 #include "lcdd/detectors/CalorimeterSD.hh"
-#include "lcdd/detectors/SegmentationFactory.hh"
 #include "lcdd/detectors/SensitiveDetectorFactory.hh"
 #include "lcdd/id/IdManager.hh"
 #include "lcdd/id/IdSpec.hh"
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1