Mantid
Loading...
Searching...
No Matches
SpatialGrouping.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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 +
7#pragma once
8
11#include "MantidAlgorithms/DllConfig.h"
13
14namespace Mantid {
15namespace Kernel {
16class V3D;
17}
18namespace Geometry {
19class IDetector;
20class BoundingBox;
21} // namespace Geometry
22
23namespace Algorithms {
34class MANTID_ALGORITHMS_DLL SpatialGrouping final : public API::Algorithm {
35public:
37 const std::string name() const override { return "SpatialGrouping"; }
39 const std::string summary() const override {
40 return "This algorithm creates an XML grouping file, which can be used in "
41 "GroupDetectors or ReadGroupsFromFile, which groups the detectors "
42 "of an instrument based on the distance between the detectors. It "
43 "does this by querying the getNeighbours method on the Detector "
44 "object.";
45 }
46
48 int version() const override { return (1); }
49 const std::vector<std::string> seeAlso() const override { return {"GroupDetectors"}; }
51 const std::string category() const override { return "Transforms\\Grouping"; }
52
53private:
55 void init() override;
57 void exec() override;
58
60 bool expandNet(std::map<specnum_t, Mantid::Kernel::V3D> &nearest, specnum_t spec, const size_t noNeighbours,
63 void sortByDistance(std::map<specnum_t, Mantid::Kernel::V3D> &nearest, const size_t noNeighbours);
65 void createBox(const Geometry::IDetector &det, Geometry::BoundingBox &bndbox, double searchDist);
67 void growBox(double &min, double &max, const double factor);
68
70 std::map<specnum_t, Kernel::V3D> m_positions;
72 std::set<specnum_t> m_included;
74 std::vector<std::vector<int>> m_groups;
75
77 std::unique_ptr<API::WorkspaceNearestNeighbourInfo> m_neighbourInfo;
78};
79
80} // namespace Algorithms
81} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
This algorithm creates an XML Grouping File for use in the GroupDetectors (v2) or ReadGroupsFromFile ...
std::map< specnum_t, Kernel::V3D > m_positions
map of detectors in the instrument
const std::string summary() const override
Summary of algorithms purpose.
std::vector< std::vector< int > > m_groups
first and last values for each group
std::unique_ptr< API::WorkspaceNearestNeighbourInfo > m_neighbourInfo
NearestNeighbourInfo used by expandNet()
std::set< specnum_t > m_included
flag which detectors are included in a group already
int version() const override
Algorithm's version.
const std::string category() const override
Algorithm's category for identification.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
const std::string name() const override
Algorithm's name.
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition: BoundingBox.h:34
Interface class for detector objects.
Definition: IDetector.h:43
Helper class which provides the Collimation Length for SANS instruments.
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16