Loading README.md +2 −1 Original line number Diff line number Diff line Loading @@ -103,9 +103,10 @@ The following authors, in alphabetical order, have developed or contributed to A * Moritz Kiehn, Université de Genève, @msmk * Stephan Lachnit, Heidelberg University, @stephanlachnit * Salman Maqbool, CERN Summer Student, @smaqbool * Stefano Mersi, CERN, @mersi * Ryuji Moriya, CERN Summer Student, University of Glasgow, @rmoriya * Sebastien Murphy, ETHZ, @smurphy * Andreas Matthias Nürnberg, KIT, @nurnberg * Stefano Mersi, CERN, @mersi * Sebastian Pape, TU Dortmund University, @spape * Marko Petric, CERN, @mpetric * Radek Privara, Palacky University Olomouc, @rprivara Loading doc/usermanual/chapters/acknowledgements.tex +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ The following authors, in alphabetical order, have developed or contributed to \ \item Stephan Lachnit, Heidelberg University \item Salman Maqbool, CERN Summer Student \item Stefano Mersi, CERN \item Ryuji Moriya, CERN Summer Student, University of Glasgow \item Sebastien Murphy, ETHZ \item Andreas Matthias Nürnberg, KIT \item Sebastian Pape, TU Dortmund University Loading src/core/geometry/DetectorModel.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -225,3 +225,23 @@ std::pair<int, int> DetectorModel::getPixelIndex(const ROOT::Math::XYZPoint& pos auto pixel_y = static_cast<int>(std::round(position.y() / pixel_size_.y())); return {pixel_x, pixel_y}; } std::set<Pixel::Index> DetectorModel::getNeighbors(const Pixel::Index& idx, const size_t distance) const { std::set<Pixel::Index> neighbors; 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)) { continue; } neighbors.insert({static_cast<unsigned int>(x), static_cast<unsigned int>(y)}); } } return neighbors; } bool DetectorModel::areNeighbors(const Pixel::Index& seed, const Pixel::Index& entrant, const size_t distance) const { auto pixel_distance = [](unsigned int lhs, unsigned int rhs) { return (lhs > rhs ? lhs - rhs : rhs - lhs); }; return (pixel_distance(seed.x(), entrant.x()) <= distance && pixel_distance(seed.y(), entrant.y()) <= distance); } src/core/geometry/DetectorModel.hpp +20 −1 Original line number Diff line number Diff line Loading @@ -238,7 +238,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 */ ROOT::Math::XYZVector getGridSize() const { virtual ROOT::Math::XYZVector getGridSize() const { return {getNPixels().x() * getPixelSize().x(), getNPixels().y() * getPixelSize().y(), 0}; } Loading Loading @@ -410,6 +410,25 @@ namespace allpix { */ virtual std::pair<int, int> getPixelIndex(const ROOT::Math::XYZPoint& position) const; /** * @brief Return a set containing all pixels neighboring the given one with a configurable maximum distance * @param idx Index of the pixel in question * @param distance Distance for pixels to be considered neighbors * @return Set of neighboring pixel indices, including the initial pixel * * @note The returned set should always also include the initial pixel indices the neighbors are calculated for */ virtual std::set<Pixel::Index> getNeighbors(const Pixel::Index& idx, const size_t distance) const; /** * @brief Check if two pixel indices are neighbors to each other * @param seed Initial pixel index * @param entrant Entrant pixel index to be tested * @param distance Distance for pixels to be considered neighbors * @return Boolean whether pixels are neighbors or not */ virtual bool areNeighbors(const Pixel::Index& seed, const Pixel::Index& entrant, const size_t distance) const; protected: std::string type_; Loading src/modules/DetectorHistogrammer/DetectorHistogrammerModule.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -615,7 +615,7 @@ void DetectorHistogrammerModule::finalize() { /** * @brief Perform a sparse clustering on the PixelHits */ std::vector<Cluster> DetectorHistogrammerModule::doClustering(std::shared_ptr<PixelHitMessage>& pixels_message) { std::vector<Cluster> DetectorHistogrammerModule::doClustering(std::shared_ptr<PixelHitMessage>& pixels_message) const { std::vector<Cluster> clusters; std::map<const PixelHit*, bool> usedPixel; Loading @@ -634,13 +634,8 @@ std::vector<Cluster> DetectorHistogrammerModule::doClustering(std::shared_ptr<Pi LOG(TRACE) << "Creating new cluster with seed: " << pixel_hit->getPixel().getIndex(); auto touching = [&](const PixelHit* pixel) { auto pxi1 = pixel->getIndex(); for(const auto& cluster_pixel : cluster.getPixelHits()) { auto distance = [](unsigned int lhs, unsigned int rhs) { return (lhs > rhs ? lhs - rhs : rhs - lhs); }; auto pxi2 = cluster_pixel->getIndex(); if(distance(pxi1.x(), pxi2.x()) <= 1 && distance(pxi1.y(), pxi2.y()) <= 1) { if(detector_->getModel()->areNeighbors(cluster_pixel->getIndex(), pixel->getIndex(), 1)) { return true; } } Loading Loading
README.md +2 −1 Original line number Diff line number Diff line Loading @@ -103,9 +103,10 @@ The following authors, in alphabetical order, have developed or contributed to A * Moritz Kiehn, Université de Genève, @msmk * Stephan Lachnit, Heidelberg University, @stephanlachnit * Salman Maqbool, CERN Summer Student, @smaqbool * Stefano Mersi, CERN, @mersi * Ryuji Moriya, CERN Summer Student, University of Glasgow, @rmoriya * Sebastien Murphy, ETHZ, @smurphy * Andreas Matthias Nürnberg, KIT, @nurnberg * Stefano Mersi, CERN, @mersi * Sebastian Pape, TU Dortmund University, @spape * Marko Petric, CERN, @mpetric * Radek Privara, Palacky University Olomouc, @rprivara Loading
doc/usermanual/chapters/acknowledgements.tex +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ The following authors, in alphabetical order, have developed or contributed to \ \item Stephan Lachnit, Heidelberg University \item Salman Maqbool, CERN Summer Student \item Stefano Mersi, CERN \item Ryuji Moriya, CERN Summer Student, University of Glasgow \item Sebastien Murphy, ETHZ \item Andreas Matthias Nürnberg, KIT \item Sebastian Pape, TU Dortmund University Loading
src/core/geometry/DetectorModel.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -225,3 +225,23 @@ std::pair<int, int> DetectorModel::getPixelIndex(const ROOT::Math::XYZPoint& pos auto pixel_y = static_cast<int>(std::round(position.y() / pixel_size_.y())); return {pixel_x, pixel_y}; } std::set<Pixel::Index> DetectorModel::getNeighbors(const Pixel::Index& idx, const size_t distance) const { std::set<Pixel::Index> neighbors; 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)) { continue; } neighbors.insert({static_cast<unsigned int>(x), static_cast<unsigned int>(y)}); } } return neighbors; } bool DetectorModel::areNeighbors(const Pixel::Index& seed, const Pixel::Index& entrant, const size_t distance) const { auto pixel_distance = [](unsigned int lhs, unsigned int rhs) { return (lhs > rhs ? lhs - rhs : rhs - lhs); }; return (pixel_distance(seed.x(), entrant.x()) <= distance && pixel_distance(seed.y(), entrant.y()) <= distance); }
src/core/geometry/DetectorModel.hpp +20 −1 Original line number Diff line number Diff line Loading @@ -238,7 +238,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 */ ROOT::Math::XYZVector getGridSize() const { virtual ROOT::Math::XYZVector getGridSize() const { return {getNPixels().x() * getPixelSize().x(), getNPixels().y() * getPixelSize().y(), 0}; } Loading Loading @@ -410,6 +410,25 @@ namespace allpix { */ virtual std::pair<int, int> getPixelIndex(const ROOT::Math::XYZPoint& position) const; /** * @brief Return a set containing all pixels neighboring the given one with a configurable maximum distance * @param idx Index of the pixel in question * @param distance Distance for pixels to be considered neighbors * @return Set of neighboring pixel indices, including the initial pixel * * @note The returned set should always also include the initial pixel indices the neighbors are calculated for */ virtual std::set<Pixel::Index> getNeighbors(const Pixel::Index& idx, const size_t distance) const; /** * @brief Check if two pixel indices are neighbors to each other * @param seed Initial pixel index * @param entrant Entrant pixel index to be tested * @param distance Distance for pixels to be considered neighbors * @return Boolean whether pixels are neighbors or not */ virtual bool areNeighbors(const Pixel::Index& seed, const Pixel::Index& entrant, const size_t distance) const; protected: std::string type_; Loading
src/modules/DetectorHistogrammer/DetectorHistogrammerModule.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -615,7 +615,7 @@ void DetectorHistogrammerModule::finalize() { /** * @brief Perform a sparse clustering on the PixelHits */ std::vector<Cluster> DetectorHistogrammerModule::doClustering(std::shared_ptr<PixelHitMessage>& pixels_message) { std::vector<Cluster> DetectorHistogrammerModule::doClustering(std::shared_ptr<PixelHitMessage>& pixels_message) const { std::vector<Cluster> clusters; std::map<const PixelHit*, bool> usedPixel; Loading @@ -634,13 +634,8 @@ std::vector<Cluster> DetectorHistogrammerModule::doClustering(std::shared_ptr<Pi LOG(TRACE) << "Creating new cluster with seed: " << pixel_hit->getPixel().getIndex(); auto touching = [&](const PixelHit* pixel) { auto pxi1 = pixel->getIndex(); for(const auto& cluster_pixel : cluster.getPixelHits()) { auto distance = [](unsigned int lhs, unsigned int rhs) { return (lhs > rhs ? lhs - rhs : rhs - lhs); }; auto pxi2 = cluster_pixel->getIndex(); if(distance(pxi1.x(), pxi2.x()) <= 1 && distance(pxi1.y(), pxi2.y()) <= 1) { if(detector_->getModel()->areNeighbors(cluster_pixel->getIndex(), pixel->getIndex(), 1)) { return true; } } Loading