Mantid
Loading...
Searching...
No Matches
EdgePixel.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
13
14namespace Mantid::Geometry {
15
24bool edgePixel(ComponentInfo const &compInfo, const std::string &bankName, int col, int row, int Edge) {
25 if (bankName == "None") {
26 return false;
27 }
28 size_t parentIndex = compInfo.indexOfAny(bankName);
29 if (compInfo.componentType(parentIndex) == Beamline::ComponentType::Rectangular) {
30 auto RDet = dynamic_cast<Geometry::RectangularDetector const *const>(compInfo.componentID(parentIndex));
31
32 return col < Edge || col >= (RDet->xpixels() - Edge) || row < Edge || row >= (RDet->ypixels() - Edge);
33 } else {
34
35 // get the children and grandchildren from the component info
36 auto children = compInfo.children(parentIndex);
37 int startI = 1;
38 if (!children.empty() && compInfo.name(children[0]) == "sixteenpack") {
39 startI = 0;
40 children = compInfo.children(children[0]);
41 }
42 auto grandchildren = compInfo.children(children[0]);
43
44 // calculate if the pixel is on the edge of the bank
45 auto NROWS = static_cast<int>(grandchildren.size());
46 auto NCOLS = static_cast<int>(children.size());
47 // Wish pixels and tubes start at 1 not 0
48 return col - startI < Edge || col - startI >= (NCOLS - Edge) || row - startI < Edge ||
49 row - startI >= (NROWS - Edge);
50 }
51}
52} // namespace Mantid::Geometry
ComponentInfo : Provides a component centric view on to the instrument.
size_t indexOfAny(const std::string &name) const
const std::vector< size_t > & children(size_t componentIndex) const
const IComponent * componentID(const size_t componentIndex) const
const std::string & name(const size_t componentIndex) const
Beamline::ComponentType componentType(const size_t componentIndex) const
RectangularDetector is a type of CompAssembly, an assembly of components.
MANTID_GEOMETRY_DLL bool edgePixel(ComponentInfo const &info, const std::string &bankName, int col, int row, int Edge)
Function to find peaks near detector edge.
Definition EdgePixel.cpp:24