lcdd/include/lcdd/detectors
diff -u -r1.9 -r1.10
--- CellReadout.hh 6 Sep 2013 03:29:23 -0000 1.9
+++ CellReadout.hh 6 Sep 2013 04:09:00 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CellReadout.hh,v 1.9 2013/09/06 03:29:23 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CellReadout.hh,v 1.10 2013/09/06 04:09:00 jeremy Exp $
#ifndef LCDD_DETECTORS_CELLREADOUT_HH
#define LCDD_DETECTORS_CELLREADOUT_HH 1
@@ -17,15 +17,19 @@
public:
- /** A 2D position, which will usually be XY in the local coordinate system. */
+ /** 2D XY position. */
struct Position2D
{
double x;
double y;
};
- /** A cell ID represented as a list of int values. */
- typedef std::vector<int> CellId;
+ /** 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;
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.5
--- CellReadout2D.cc 6 Sep 2013 03:29:23 -0000 1.4
+++ CellReadout2D.cc 6 Sep 2013 04:09:00 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2D.cc,v 1.4 2013/09/06 03:29:23 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2D.cc,v 1.5 2013/09/06 04:09:00 jeremy Exp $
// LCDD
#include "lcdd/detectors/CellReadout2D.hh"
@@ -20,8 +20,8 @@
CellReadout2D::Position2D CellReadout2D::position(CellReadout2D::CellId cellId)
{
Position2D position;
- position.x = getCellPositionX(cellId[0]);
- position.y = getCellPositionY(cellId[1]);
+ position.x = getCellPositionX(cellId.ix);
+ position.y = getCellPositionY(cellId.iy);
return position;
}
@@ -42,8 +42,8 @@
// 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[0] + j, cellId[1] + i);
+ //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.
@@ -103,8 +103,8 @@
CellReadout2D::CellId CellReadout2D::createCell(int x, int y)
{
CellId cell;
- cell.push_back(x);
- cell.push_back(y);
+ cell.ix = x;
+ cell.iy = y;
return cell;
}
@@ -131,22 +131,22 @@
bool CellReadout2D::isValidCell(CellId cell)
{
// DEBUG
- std::cout << "isValidCell: " << cell[0] << ", " << cell[1] << std::endl;
+ //std::cout << "isValidCell: " << cell.ix << ", " << cell.iy << std::endl;
- if (cell[0] <= 0 || cell[1] <= 0) {
- std::cout << "field value < 0" << 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[0] > xmax) {
- std::cout << cell[0] << " exceeds max allowed X index" << std::endl;
+ //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[1] > ymax) {
- std::cout << cell[1] << " exceeds max allowed Y index" << std::endl;
+ //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;
lcdd/src/lcdd/detectors
diff -u -r1.6 -r1.7
--- CellReadout2DSegmentation.cc 6 Sep 2013 03:29:23 -0000 1.6
+++ CellReadout2DSegmentation.cc 6 Sep 2013 04:09:00 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2DSegmentation.cc,v 1.6 2013/09/06 03:29:23 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2DSegmentation.cc,v 1.7 2013/09/06 04:09:00 jeremy Exp $
// LCDD
#include "lcdd/detectors/CellReadout2DSegmentation.hh"
@@ -52,16 +52,16 @@
CellReadout::CellId cell = _readout->cellId(readoutStepPosition);
// DEBUG
- std::cout << "cell: " << cell[0] << " " << cell[1] << std::endl;
+ std::cout << "cell: " << cell.ix << " " << cell.iy << std::endl;
// Get the cell's readout position from the cell ID.
- CellReadout::Position2D cellPosition = _readout->position(cell);
+ CellReadout::Position2D cellReadoutPosition = _readout->position(cell);
// DEBUG
- std::cout << "cellPosition: " << cellPosition.x << " " << cellPosition.y << std::endl;
+ std::cout << "cellReadoutPosition: " << cellReadoutPosition.x << " " << cellReadoutPosition.y << std::endl;
// Convert from readout back to localcoordinates.
- G4ThreeVector localCellPosition = readoutToLocalCoordinates(cellPosition);
+ G4ThreeVector localCellPosition = readoutToLocalCoordinates(cellReadoutPosition);
// DEBUG
std::cout << "localCellPosition: "<< localCellPosition.x() << " " << localCellPosition.y() << " " << localCellPosition.z() << std::endl;
@@ -90,8 +90,8 @@
// DEBUG
G4ThreeVector prePosition = aStep->GetPreStepPoint()->GetPosition();
- std::setprecision(10);
- std::cout << "pre-step pos: " << prePosition.x() << " " << prePosition.y() << " " << prePosition.z() << std::endl;
+ //std::setprecision(10);
+ std::cout << "step pos: " << prePosition.x() << " " << prePosition.y() << " " << prePosition.z() << std::endl;
// Set state from current step.
setup(aStep);
@@ -109,27 +109,27 @@
std::cout << "localStepPos: " << localStepPos.x() << " " << localStepPos.y() << " " << localStepPos.z() << std::endl;
// Compute the X and Y readout coordinates from the local position.
- CellReadout::Position2D cellPosition = localToReadoutCoordinates(localStepPos);
+ CellReadout::Position2D readoutPosition = localToReadoutCoordinates(localStepPos);
// DEBUG
- std::cout << "cell pos XY: " << cellPosition.x << " " << cellPosition.y << std::endl;
+ std::cout << "readoutPosition: " << readoutPosition.x << " " << readoutPosition.y << std::endl;
// Get the cell for the position.
- CellReadout::CellId cell = _readout->cellId(cellPosition);
+ CellReadout::CellId cell = _readout->cellId(readoutPosition);
// DEBUG
- std::cout << "cell ID: " << cell[0] << " " << cell[1] << std::endl;
+ std::cout << "cellID: " << cell.ix << " " << cell.iy << std::endl;
// Set the segmentation's bin values.
- this->setBin(0, cellPosition.x);
- this->setBin(1, cellPosition.y);
+ this->setBin(0, readoutPosition.x);
+ this->setBin(1, readoutPosition.y);
// 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)[0] << ", " << (*it)[1] << std::endl;
+ std::cout << " " << (*it).ix << ", " << (*it).iy << std::endl;
}
std::cout << std::endl;
@@ -143,11 +143,11 @@
void CellReadout2DSegmentation::setup(const G4Step* aStep)
{
- // Set dimensions from box volume.
+ // Set dimensions from current box volume.
G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint(aStep->GetPreStepPoint());
G4Box* box = dynamic_cast<G4Box*>(solid);
if (box == 0) {
- std::cerr << "Volume is not a box" << std::endl;
+ 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);