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 +
11
12namespace Mantid::Geometry {
13
22bool edgePixel(const Mantid::Geometry::Instrument_const_sptr &inst, const std::string &bankName, int col, int row,
23 int Edge) {
24 if (bankName == "None")
25 return false;
26 std::shared_ptr<const Geometry::IComponent> parent = inst->getComponentByName(bankName);
27 if (parent->type() == "RectangularDetector") {
28 std::shared_ptr<const Geometry::RectangularDetector> RDet =
29 std::dynamic_pointer_cast<const Geometry::RectangularDetector>(parent);
30
31 return col < Edge || col >= (RDet->xpixels() - Edge) || row < Edge || row >= (RDet->ypixels() - Edge);
32 } else {
33 std::vector<Geometry::IComponent_const_sptr> children;
34 std::shared_ptr<const Geometry::ICompAssembly> asmb =
35 std::dynamic_pointer_cast<const Geometry::ICompAssembly>(parent);
36 asmb->getChildren(children, false);
37 int startI = 1;
38 if (children[0]->getName() == "sixteenpack") {
39 startI = 0;
40 parent = children[0];
41 children.clear();
42 asmb = std::dynamic_pointer_cast<const Geometry::ICompAssembly>(parent);
43 asmb->getChildren(children, false);
44 }
45 std::shared_ptr<const Geometry::ICompAssembly> asmb2 =
46 std::dynamic_pointer_cast<const Geometry::ICompAssembly>(children[0]);
47 std::vector<Geometry::IComponent_const_sptr> grandchildren;
48 asmb2->getChildren(grandchildren, false);
49 auto NROWS = static_cast<int>(grandchildren.size());
50 auto NCOLS = static_cast<int>(children.size());
51 // Wish pixels and tubes start at 1 not 0
52 return col - startI < Edge || col - startI >= (NCOLS - Edge) || row - startI < Edge ||
53 row - startI >= (NROWS - Edge);
54 }
55 return false;
56}
57} // namespace Mantid::Geometry
std::string getName(const IMDDimension &self)
MANTID_GEOMETRY_DLL bool edgePixel(const Geometry::Instrument_const_sptr &inst, const std::string &bankName, int col, int row, int Edge)
Function to find peaks near detector edge.
Definition: EdgePixel.cpp:22
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.