Loading src/core/geometry/Detector.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ void Detector::build_transform() { // * The shift from the origin to the detector position ROOT::Math::Transform3D transform_center(rotation_center, translation_center); // Transform from locally centered to local coordinates ROOT::Math::Translation3D translation_local(static_cast<ROOT::Math::XYZVector>(model_->getCenter())); ROOT::Math::Translation3D translation_local(static_cast<ROOT::Math::XYZVector>(model_->getMatrixCenter())); ROOT::Math::Transform3D transform_local(translation_local); // Compute total transform local to global by first transforming local to locally centered and then to global coordinates transform_ = transform_center * transform_local.Inverse(); Loading src/core/geometry/DetectorModel.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ DetectorModel::DetectorModel(std::string type, ConfigReader reader) : type_(std: } } ROOT::Math::XYZPoint DetectorModel::getGeometricalCenter() const { ROOT::Math::XYZPoint DetectorModel::getModelCenter() const { // Prepare detector assembly stack (sensor, chip, supports) with z-positions and thicknesses: std::vector<std::pair<double, double>> stack = {{getSensorCenter().z(), getSensorSize().z()}, Loading @@ -115,7 +115,7 @@ ROOT::Math::XYZPoint DetectorModel::getGeometricalCenter() const { // half thickness) auto center = ((element_first.first - element_first.second / 2.0) + (element_last.first + element_last.second / 2.0)) / 2.0; return ROOT::Math::XYZPoint(getCenter().x(), getCenter().y(), center); return ROOT::Math::XYZPoint(getMatrixCenter().x(), getMatrixCenter().y(), center); } std::vector<Configuration> DetectorModel::getConfigurations() const { Loading Loading @@ -168,10 +168,10 @@ ROOT::Math::XYZVector DetectorModel::getSize() const { } ROOT::Math::XYZVector size; size.SetX(2 * std::max(max.x() - getCenter().x(), getCenter().x() - min.x())); size.SetY(2 * std::max(max.y() - getCenter().y(), getCenter().y() - min.y())); size.SetZ((max.z() - getCenter().z()) + (getCenter().z() - min.z())); // max.z() is positive (chip side) and min.z() is negative (sensor side) size.SetX(2 * std::max(max.x() - getMatrixCenter().x(), getMatrixCenter().x() - min.x())); size.SetY(2 * std::max(max.y() - getMatrixCenter().y(), getMatrixCenter().y() - min.y())); size.SetZ((max.z() - getMatrixCenter().z()) + (getMatrixCenter().z() - min.z())); // max.z() is positive (chip side) and min.z() is negative (sensor side) return size; } Loading @@ -190,7 +190,7 @@ std::vector<DetectorModel::SupportLayer> DetectorModel::getSupportLayers() const chip_offset += layer.size_.z(); } layer.center_ = getCenter() + offset; layer.center_ = getMatrixCenter() + offset; } return ret_layers; Loading Loading @@ -224,14 +224,14 @@ bool DetectorModel::isWithinImplant(const ROOT::Math::XYZPoint& local_pos) const /** * The definition of the pixel grid size is determined by the detector model */ bool DetectorModel::isWithinPixelGrid(const Pixel::Index& pixel_index) const { bool DetectorModel::isWithinMatrix(const Pixel::Index& pixel_index) const { return !(pixel_index.x() >= number_of_pixels_.x() || pixel_index.y() >= number_of_pixels_.y()); } /** * The definition of the pixel grid size is determined by the detector model */ bool DetectorModel::isWithinPixelGrid(const int x, const int y) const { bool DetectorModel::isWithinMatrix(const int x, const int y) const { return !(x < 0 || x >= static_cast<int>(number_of_pixels_.x()) || y < 0 || y >= static_cast<int>(number_of_pixels_.y())); } Loading @@ -255,7 +255,7 @@ std::set<Pixel::Index> DetectorModel::getNeighbors(const Pixel::Index& idx, cons for(int x = static_cast<int>(idx.x() - distance); x <= static_cast<int>(idx.x() + distance); x++) { for(int y = static_cast<int>(idx.y() - distance); y <= static_cast<int>(idx.y() + distance); y++) { if(!isWithinPixelGrid(x, y)) { if(!isWithinMatrix(x, y)) { continue; } neighbors.insert({static_cast<unsigned int>(x), static_cast<unsigned int>(y)}); Loading src/core/geometry/DetectorModel.hpp +16 −15 Original line number Diff line number Diff line Loading @@ -182,9 +182,10 @@ namespace allpix { * * The center coordinate corresponds to the \ref Detector::getPosition "position" in the global frame. */ virtual ROOT::Math::XYZPoint getCenter() const { return { getGridSize().x() / 2.0 - getPixelSize().x() / 2.0, getGridSize().y() / 2.0 - getPixelSize().y() / 2.0, 0}; virtual ROOT::Math::XYZPoint getMatrixCenter() const { return {getMatrixSize().x() / 2.0 - getPixelSize().x() / 2.0, getMatrixSize().y() / 2.0 - getPixelSize().y() / 2.0, 0}; } /** Loading @@ -192,15 +193,15 @@ namespace allpix { * @note This returns the center of the geometry model, i.e. including all support layers, passive readout chips et * cetera. */ virtual ROOT::Math::XYZPoint getGeometricalCenter() const; virtual ROOT::Math::XYZPoint getModelCenter() const; /** * @brief Get size of the wrapper box around the model that contains all elements * @return Size of the detector model * * All elements of the model are covered by a box centered around \ref DetectorModel::getGeometricalCenter. This * All elements of the model are covered by a box centered around \ref DetectorModel::getModelCenter. This * means that the extend of the model should be calculated using the geometrical center as reference, not the * position returned by \ref DetectorModel::getCenter. * position returned by \ref DetectorModel::getMatrixCenter. */ virtual ROOT::Math::XYZVector getSize() const; Loading Loading @@ -246,7 +247,7 @@ namespace allpix { * @warning The grid has zero thickness * @note This is basically a 2D method, but provided in 3D because it is primarily used there */ virtual ROOT::Math::XYZVector getGridSize() const { virtual ROOT::Math::XYZVector getMatrixSize() const { return {getNPixels().x() * getPixelSize().x(), getNPixels().y() * getPixelSize().y(), 0}; } Loading @@ -255,13 +256,13 @@ namespace allpix { * @brief Get size of the sensor * @return Size of the sensor * * Calculated from \ref DetectorModel::getGridSize "pixel grid size", sensor excess and sensor thickness * Calculated from \ref DetectorModel::getMatrixSize "pixel grid size", sensor excess and sensor thickness */ virtual ROOT::Math::XYZVector getSensorSize() const { ROOT::Math::XYZVector excess_thickness((sensor_excess_.at(1) + sensor_excess_.at(3)), (sensor_excess_.at(0) + sensor_excess_.at(2)), sensor_thickness_); return getGridSize() + excess_thickness; return getMatrixSize() + excess_thickness; } /** * @brief Get center of the sensor in local coordinates Loading @@ -272,7 +273,7 @@ namespace allpix { virtual ROOT::Math::XYZPoint getSensorCenter() const { ROOT::Math::XYZVector offset( (sensor_excess_.at(1) - sensor_excess_.at(3)) / 2.0, (sensor_excess_.at(0) - sensor_excess_.at(2)) / 2.0, 0); return getCenter() + offset; return getMatrixCenter() + offset; } /** * @brief Set the thickness of the sensor Loading Loading @@ -305,13 +306,13 @@ namespace allpix { * @brief Get size of the chip * @return Size of the chip * * Calculated from \ref DetectorModel::getGridSize "pixel grid size", sensor excess and chip thickness * Calculated from \ref DetectorModel::getMatrixSize "pixel grid size", sensor excess and chip thickness */ virtual ROOT::Math::XYZVector getChipSize() const { ROOT::Math::XYZVector excess_thickness((sensor_excess_.at(1) + sensor_excess_.at(3)), (sensor_excess_.at(0) + sensor_excess_.at(2)), chip_thickness_); return getGridSize() + excess_thickness; return getMatrixSize() + excess_thickness; } /** * @brief Get center of the chip in local coordinates Loading @@ -323,7 +324,7 @@ namespace allpix { ROOT::Math::XYZVector offset((sensor_excess_.at(1) - sensor_excess_.at(3)) / 2.0, (sensor_excess_.at(0) - sensor_excess_.at(2)) / 2.0, getSensorSize().z() / 2.0 + getChipSize().z() / 2.0); return getCenter() + offset; return getMatrixCenter() + offset; } /** * @brief Set the thickness of the sensor Loading Loading @@ -391,7 +392,7 @@ namespace allpix { * @param pixel_index Pixel index to be checked * @return True if pixel_index is within the pixel grid, false otherwise */ virtual bool isWithinPixelGrid(const Pixel::Index& pixel_index) const; virtual bool isWithinMatrix(const Pixel::Index& pixel_index) const; /** * @brief Returns if a set of pixel coordinates is within the grid of pixels defined for the device Loading @@ -399,7 +400,7 @@ namespace allpix { * @param y Y- (or row-) coordinate to be checked * @return True if pixel coordinates are within the pixel grid, false otherwise */ virtual bool isWithinPixelGrid(const int x, const int y) const; virtual bool isWithinMatrix(const int x, const int y) const; /** * @brief Returns a pixel center in local coordinates Loading src/core/geometry/GeometryManager.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,7 @@ ROOT::Math::XYZPoint GeometryManager::getMinimumCoordinate() { std::array<int, 8> offset_z = {{1, -1, 1, -1, 1, -1, 1, -1}}; for(size_t i = 0; i < 8; ++i) { auto point = model->getGeometricalCenter(); auto point = model->getModelCenter(); point.SetX(point.x() + offset_x.at(i) * model->getSize().x() / 2.0); point.SetY(point.y() + offset_y.at(i) * model->getSize().y() / 2.0); point.SetZ(point.z() + offset_z.at(i) * model->getSize().z() / 2.0); Loading Loading @@ -204,7 +204,7 @@ ROOT::Math::XYZPoint GeometryManager::getMaximumCoordinate() { std::array<int, 8> offset_z = {{1, -1, 1, -1, 1, -1, 1, -1}}; for(size_t i = 0; i < 8; ++i) { auto point = model->getGeometricalCenter(); auto point = model->getModelCenter(); point.SetX(point.x() + offset_x.at(i) * model->getSize().x() / 2.0); point.SetY(point.y() + offset_y.at(i) * model->getSize().y() / 2.0); point.SetZ(point.z() + offset_z.at(i) * model->getSize().z() / 2.0); Loading src/core/geometry/HybridPixelDetectorModel.hpp +4 −4 Original line number Diff line number Diff line Loading @@ -63,12 +63,12 @@ namespace allpix { * @brief Get size of the chip * @return Size of the chip * * Calculated from \ref DetectorModel::getGridSize "pixel grid size", chip excess and chip thickness * Calculated from \ref DetectorModel::getMatrixSize "pixel grid size", chip excess and chip thickness */ ROOT::Math::XYZVector getChipSize() const override { ROOT::Math::XYZVector excess_thickness( (chip_excess_.at(1) + chip_excess_.at(3)), (chip_excess_.at(0) + chip_excess_.at(2)), chip_thickness_); return getGridSize() + excess_thickness; return getMatrixSize() + excess_thickness; } /** * @brief Get center of the chip in local coordinates Loading @@ -80,7 +80,7 @@ namespace allpix { ROOT::Math::XYZVector offset((chip_excess_.at(1) - chip_excess_.at(3)) / 2.0, (chip_excess_.at(0) - chip_excess_.at(2)) / 2.0, getSensorSize().z() / 2.0 + getChipSize().z() / 2.0 + getBumpHeight()); return getCenter() + offset; return getMatrixCenter() + offset; } /** Loading Loading @@ -146,7 +146,7 @@ namespace allpix { virtual ROOT::Math::XYZPoint getBumpsCenter() const { ROOT::Math::XYZVector offset( bump_offset_.x(), bump_offset_.y(), getSensorSize().z() / 2.0 + getBumpHeight() / 2.0); return getCenter() + offset; return getMatrixCenter() + offset; } /** * @brief Get the radius of the sphere of every individual bump bond (union solid with cylinder) Loading Loading
src/core/geometry/Detector.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ void Detector::build_transform() { // * The shift from the origin to the detector position ROOT::Math::Transform3D transform_center(rotation_center, translation_center); // Transform from locally centered to local coordinates ROOT::Math::Translation3D translation_local(static_cast<ROOT::Math::XYZVector>(model_->getCenter())); ROOT::Math::Translation3D translation_local(static_cast<ROOT::Math::XYZVector>(model_->getMatrixCenter())); ROOT::Math::Transform3D transform_local(translation_local); // Compute total transform local to global by first transforming local to locally centered and then to global coordinates transform_ = transform_center * transform_local.Inverse(); Loading
src/core/geometry/DetectorModel.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ DetectorModel::DetectorModel(std::string type, ConfigReader reader) : type_(std: } } ROOT::Math::XYZPoint DetectorModel::getGeometricalCenter() const { ROOT::Math::XYZPoint DetectorModel::getModelCenter() const { // Prepare detector assembly stack (sensor, chip, supports) with z-positions and thicknesses: std::vector<std::pair<double, double>> stack = {{getSensorCenter().z(), getSensorSize().z()}, Loading @@ -115,7 +115,7 @@ ROOT::Math::XYZPoint DetectorModel::getGeometricalCenter() const { // half thickness) auto center = ((element_first.first - element_first.second / 2.0) + (element_last.first + element_last.second / 2.0)) / 2.0; return ROOT::Math::XYZPoint(getCenter().x(), getCenter().y(), center); return ROOT::Math::XYZPoint(getMatrixCenter().x(), getMatrixCenter().y(), center); } std::vector<Configuration> DetectorModel::getConfigurations() const { Loading Loading @@ -168,10 +168,10 @@ ROOT::Math::XYZVector DetectorModel::getSize() const { } ROOT::Math::XYZVector size; size.SetX(2 * std::max(max.x() - getCenter().x(), getCenter().x() - min.x())); size.SetY(2 * std::max(max.y() - getCenter().y(), getCenter().y() - min.y())); size.SetZ((max.z() - getCenter().z()) + (getCenter().z() - min.z())); // max.z() is positive (chip side) and min.z() is negative (sensor side) size.SetX(2 * std::max(max.x() - getMatrixCenter().x(), getMatrixCenter().x() - min.x())); size.SetY(2 * std::max(max.y() - getMatrixCenter().y(), getMatrixCenter().y() - min.y())); size.SetZ((max.z() - getMatrixCenter().z()) + (getMatrixCenter().z() - min.z())); // max.z() is positive (chip side) and min.z() is negative (sensor side) return size; } Loading @@ -190,7 +190,7 @@ std::vector<DetectorModel::SupportLayer> DetectorModel::getSupportLayers() const chip_offset += layer.size_.z(); } layer.center_ = getCenter() + offset; layer.center_ = getMatrixCenter() + offset; } return ret_layers; Loading Loading @@ -224,14 +224,14 @@ bool DetectorModel::isWithinImplant(const ROOT::Math::XYZPoint& local_pos) const /** * The definition of the pixel grid size is determined by the detector model */ bool DetectorModel::isWithinPixelGrid(const Pixel::Index& pixel_index) const { bool DetectorModel::isWithinMatrix(const Pixel::Index& pixel_index) const { return !(pixel_index.x() >= number_of_pixels_.x() || pixel_index.y() >= number_of_pixels_.y()); } /** * The definition of the pixel grid size is determined by the detector model */ bool DetectorModel::isWithinPixelGrid(const int x, const int y) const { bool DetectorModel::isWithinMatrix(const int x, const int y) const { return !(x < 0 || x >= static_cast<int>(number_of_pixels_.x()) || y < 0 || y >= static_cast<int>(number_of_pixels_.y())); } Loading @@ -255,7 +255,7 @@ std::set<Pixel::Index> DetectorModel::getNeighbors(const Pixel::Index& idx, cons for(int x = static_cast<int>(idx.x() - distance); x <= static_cast<int>(idx.x() + distance); x++) { for(int y = static_cast<int>(idx.y() - distance); y <= static_cast<int>(idx.y() + distance); y++) { if(!isWithinPixelGrid(x, y)) { if(!isWithinMatrix(x, y)) { continue; } neighbors.insert({static_cast<unsigned int>(x), static_cast<unsigned int>(y)}); Loading
src/core/geometry/DetectorModel.hpp +16 −15 Original line number Diff line number Diff line Loading @@ -182,9 +182,10 @@ namespace allpix { * * The center coordinate corresponds to the \ref Detector::getPosition "position" in the global frame. */ virtual ROOT::Math::XYZPoint getCenter() const { return { getGridSize().x() / 2.0 - getPixelSize().x() / 2.0, getGridSize().y() / 2.0 - getPixelSize().y() / 2.0, 0}; virtual ROOT::Math::XYZPoint getMatrixCenter() const { return {getMatrixSize().x() / 2.0 - getPixelSize().x() / 2.0, getMatrixSize().y() / 2.0 - getPixelSize().y() / 2.0, 0}; } /** Loading @@ -192,15 +193,15 @@ namespace allpix { * @note This returns the center of the geometry model, i.e. including all support layers, passive readout chips et * cetera. */ virtual ROOT::Math::XYZPoint getGeometricalCenter() const; virtual ROOT::Math::XYZPoint getModelCenter() const; /** * @brief Get size of the wrapper box around the model that contains all elements * @return Size of the detector model * * All elements of the model are covered by a box centered around \ref DetectorModel::getGeometricalCenter. This * All elements of the model are covered by a box centered around \ref DetectorModel::getModelCenter. This * means that the extend of the model should be calculated using the geometrical center as reference, not the * position returned by \ref DetectorModel::getCenter. * position returned by \ref DetectorModel::getMatrixCenter. */ virtual ROOT::Math::XYZVector getSize() const; Loading Loading @@ -246,7 +247,7 @@ namespace allpix { * @warning The grid has zero thickness * @note This is basically a 2D method, but provided in 3D because it is primarily used there */ virtual ROOT::Math::XYZVector getGridSize() const { virtual ROOT::Math::XYZVector getMatrixSize() const { return {getNPixels().x() * getPixelSize().x(), getNPixels().y() * getPixelSize().y(), 0}; } Loading @@ -255,13 +256,13 @@ namespace allpix { * @brief Get size of the sensor * @return Size of the sensor * * Calculated from \ref DetectorModel::getGridSize "pixel grid size", sensor excess and sensor thickness * Calculated from \ref DetectorModel::getMatrixSize "pixel grid size", sensor excess and sensor thickness */ virtual ROOT::Math::XYZVector getSensorSize() const { ROOT::Math::XYZVector excess_thickness((sensor_excess_.at(1) + sensor_excess_.at(3)), (sensor_excess_.at(0) + sensor_excess_.at(2)), sensor_thickness_); return getGridSize() + excess_thickness; return getMatrixSize() + excess_thickness; } /** * @brief Get center of the sensor in local coordinates Loading @@ -272,7 +273,7 @@ namespace allpix { virtual ROOT::Math::XYZPoint getSensorCenter() const { ROOT::Math::XYZVector offset( (sensor_excess_.at(1) - sensor_excess_.at(3)) / 2.0, (sensor_excess_.at(0) - sensor_excess_.at(2)) / 2.0, 0); return getCenter() + offset; return getMatrixCenter() + offset; } /** * @brief Set the thickness of the sensor Loading Loading @@ -305,13 +306,13 @@ namespace allpix { * @brief Get size of the chip * @return Size of the chip * * Calculated from \ref DetectorModel::getGridSize "pixel grid size", sensor excess and chip thickness * Calculated from \ref DetectorModel::getMatrixSize "pixel grid size", sensor excess and chip thickness */ virtual ROOT::Math::XYZVector getChipSize() const { ROOT::Math::XYZVector excess_thickness((sensor_excess_.at(1) + sensor_excess_.at(3)), (sensor_excess_.at(0) + sensor_excess_.at(2)), chip_thickness_); return getGridSize() + excess_thickness; return getMatrixSize() + excess_thickness; } /** * @brief Get center of the chip in local coordinates Loading @@ -323,7 +324,7 @@ namespace allpix { ROOT::Math::XYZVector offset((sensor_excess_.at(1) - sensor_excess_.at(3)) / 2.0, (sensor_excess_.at(0) - sensor_excess_.at(2)) / 2.0, getSensorSize().z() / 2.0 + getChipSize().z() / 2.0); return getCenter() + offset; return getMatrixCenter() + offset; } /** * @brief Set the thickness of the sensor Loading Loading @@ -391,7 +392,7 @@ namespace allpix { * @param pixel_index Pixel index to be checked * @return True if pixel_index is within the pixel grid, false otherwise */ virtual bool isWithinPixelGrid(const Pixel::Index& pixel_index) const; virtual bool isWithinMatrix(const Pixel::Index& pixel_index) const; /** * @brief Returns if a set of pixel coordinates is within the grid of pixels defined for the device Loading @@ -399,7 +400,7 @@ namespace allpix { * @param y Y- (or row-) coordinate to be checked * @return True if pixel coordinates are within the pixel grid, false otherwise */ virtual bool isWithinPixelGrid(const int x, const int y) const; virtual bool isWithinMatrix(const int x, const int y) const; /** * @brief Returns a pixel center in local coordinates Loading
src/core/geometry/GeometryManager.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,7 @@ ROOT::Math::XYZPoint GeometryManager::getMinimumCoordinate() { std::array<int, 8> offset_z = {{1, -1, 1, -1, 1, -1, 1, -1}}; for(size_t i = 0; i < 8; ++i) { auto point = model->getGeometricalCenter(); auto point = model->getModelCenter(); point.SetX(point.x() + offset_x.at(i) * model->getSize().x() / 2.0); point.SetY(point.y() + offset_y.at(i) * model->getSize().y() / 2.0); point.SetZ(point.z() + offset_z.at(i) * model->getSize().z() / 2.0); Loading Loading @@ -204,7 +204,7 @@ ROOT::Math::XYZPoint GeometryManager::getMaximumCoordinate() { std::array<int, 8> offset_z = {{1, -1, 1, -1, 1, -1, 1, -1}}; for(size_t i = 0; i < 8; ++i) { auto point = model->getGeometricalCenter(); auto point = model->getModelCenter(); point.SetX(point.x() + offset_x.at(i) * model->getSize().x() / 2.0); point.SetY(point.y() + offset_y.at(i) * model->getSize().y() / 2.0); point.SetZ(point.z() + offset_z.at(i) * model->getSize().z() / 2.0); Loading
src/core/geometry/HybridPixelDetectorModel.hpp +4 −4 Original line number Diff line number Diff line Loading @@ -63,12 +63,12 @@ namespace allpix { * @brief Get size of the chip * @return Size of the chip * * Calculated from \ref DetectorModel::getGridSize "pixel grid size", chip excess and chip thickness * Calculated from \ref DetectorModel::getMatrixSize "pixel grid size", chip excess and chip thickness */ ROOT::Math::XYZVector getChipSize() const override { ROOT::Math::XYZVector excess_thickness( (chip_excess_.at(1) + chip_excess_.at(3)), (chip_excess_.at(0) + chip_excess_.at(2)), chip_thickness_); return getGridSize() + excess_thickness; return getMatrixSize() + excess_thickness; } /** * @brief Get center of the chip in local coordinates Loading @@ -80,7 +80,7 @@ namespace allpix { ROOT::Math::XYZVector offset((chip_excess_.at(1) - chip_excess_.at(3)) / 2.0, (chip_excess_.at(0) - chip_excess_.at(2)) / 2.0, getSensorSize().z() / 2.0 + getChipSize().z() / 2.0 + getBumpHeight()); return getCenter() + offset; return getMatrixCenter() + offset; } /** Loading Loading @@ -146,7 +146,7 @@ namespace allpix { virtual ROOT::Math::XYZPoint getBumpsCenter() const { ROOT::Math::XYZVector offset( bump_offset_.x(), bump_offset_.y(), getSensorSize().z() / 2.0 + getBumpHeight() / 2.0); return getCenter() + offset; return getMatrixCenter() + offset; } /** * @brief Get the radius of the sphere of every individual bump bond (union solid with cylinder) Loading