19Kernel::Logger
g_log(
"DetectorGroup");
38 g_log.
error(
"Illegal attempt to create an empty DetectorGroup");
39 throw std::invalid_argument(
"Empty DetectorGroup objects are not allowed");
41 std::vector<IDetector_const_sptr>::const_iterator it;
42 for (it = dets.begin(); it != dets.end(); ++it) {
59 m_detectors.insert(DetCollection::value_type(det->getID(), det));
76 DetCollection::const_iterator it;
78 newPos += (*it).second->getPos();
89 return newPos /=
static_cast<double>(
m_detectors.size());
95 DetCollection::const_iterator it;
97 result += (*it).second->getDistance(comp);
99 return result /
static_cast<double>(
m_detectors.size());
106 DetCollection::const_iterator it;
108 const V3D sampleDetVec = (*it).second->getPos() - observer;
109 result += sampleDetVec.
angle(axis);
111 return result /
static_cast<double>(
m_detectors.size());
127 DetCollection::const_iterator it;
129 const V3D sampleDetVec = it->second->getPos() - observer;
130 double angle = sampleDetVec.
angle(axis);
139 return result /
static_cast<double>(
m_detectors.size());
145 double phi(0.0), dummy1(0.0), dummy2(0.0);
147 return phi * M_PI / 180.0;
153 return avgPos < 0 ? -(offset + avgPos) : offset - avgPos;
161 std::vector<detid_t> result;
163 DetCollection::const_iterator it;
165 result.emplace_back((*it).first);
175 std::vector<IDetector_const_sptr> result;
177 DetCollection::const_iterator it;
179 result.emplace_back((*it).second);
194 [&observer](
double angle,
const auto &det) { return angle + det.second->solidAngle(observer); });
202 DetCollection::const_iterator it;
204 if ((*it).second->isParametrized())
216 DetCollection::const_iterator it;
218 if ((*it).second->isValid(point))
230 DetCollection::const_iterator it;
232 if ((*it).second->isOnSide(point))
246 DetCollection::const_iterator it;
250 return (*
m_detectors.begin()).second->getPointInObject(point);
261 return std::set<std::string>();
271 return std::map<std::string, ComponentID>();
315 detector.second->getBoundingBox(memberBox);
316 boundingBox.
grow(memberBox);
334 return std::string(
"");
339 return std::vector<double>(0);
344 return std::vector<V3D>(0);
349 return std::vector<Quat>(0);
354 return std::vector<std::string>(0);
359 return std::vector<int>(0);
364 return std::vector<bool>(0);
401 spFirstDet->getBoundingBox(bbox);
405 for (
int i = 0; i < 6; i++) {
407 int is = (i % 2 == 0) ? -1 : 1;
409 cs[ic] += is * width[ic] / 4;
424 DetCollection::const_iterator it;
433 DetCollection::const_iterator it;
444 throw std::runtime_error(
"A DetectorGroup cannot have a ParameterMap");
451 throw std::runtime_error(
"DetectorGroup::registerContents. This should not "
452 "be called. DetectorGroups are not part of the "
453 "instrument. On-the-fly only.");
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
std::vector< Kernel::V3D > const & getCoordSystem() const
returns the coordinate system to which BB is alighned to;
Kernel::V3D width() const
Returns the width of the box.
bool isAxisAligned() const
Check if it is normal axis aligned bounding box or not.
void grow(const BoundingBox &other)
Grow the bounding box so that it also encompasses the given box.
void realign(std::vector< Kernel::V3D > const *const pCS=nullptr)
reallign the BB according to new coordinate system, provided earlier or specified as parameter;
ComponentVisitor : Visitor for IComponents.
std::string getParameterAsString(const std::string &pname, bool recursive=true) const override
Get a string representation of a parameter.
std::string getFullName() const override
Get the IComponent full path name.
std::vector< Kernel::Quat > getRotationParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a Kernel::Quaternion.
const Kernel::Material material() const override
Returns the material of the Object.
bool hasParameter(const std::string &name, bool recursive=true) const override
Returns a boolean indicating whether the parameter exists or not.
double getTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis) const override
Gives the average angle of a group of detectors from the observation point, relative to the axis give...
DetCollection m_detectors
The collection of grouped detectors.
virtual size_t registerContents(class ComponentVisitor &visitor) const override
double solidAngle(const Kernel::V3D &observer) const override
Gives the total solid angle subtended by a group of detectors by summing the contributions from the i...
detid_t getID() const override
Get the detector ID.
Kernel::V3D groupCentre
group centre is the geometrical centre of the detectors group calculated when the calculate group top...
std::string getName() const override
Get the IComponent name.
std::map< std::string, ComponentID > getParameterNamesByComponent() const override
return the parameter names and the component they are from
std::vector< double > getNumberParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a double.
bool isParametrized() const override
Return true if any detector in the group is parametrized.
void addDetector(const IDetector_const_sptr &det)
Add a detector to the collection.
void getBoundingBox(BoundingBox &boundingBox) const override
Get the bounding box for this component and store it in the given argument.
std::vector< std::string > getStringParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a string.
std::vector< bool > getBoolParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as an integer.
std::string getNameSeparator() const
Return separator for list of names of detectors.
std::vector< detid_t > getDetectorIDs() const
What detectors are contained in the group?
std::string getParameterType(const std::string &name, bool recursive=true) const override
Detectors group assumed to be non-parameterized.
double getPhi() const override
Computes the average position and returns the phi value.
std::vector< Kernel::V3D > getPositionParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a Kernel::V3D.
std::set< std::string > getParameterNames(bool recursive=true) const override
Return the parameter names.
double getDistance(const IComponent &comp) const override
Gives the average distance of a group of detectors from the given component.
void calculateGroupTopology() const
function calculates the detectors arrangement (topology)
DetectorGroup()
Default constructor.
std::vector< IDetector_const_sptr > getDetectors() const
What detectors are contained in the group?
double getSignedTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis, const Kernel::V3D &instrumentUp) const override
Gives the signed angle of this detector object with respect to an axis.
bool isOnSide(const Kernel::V3D &point) const override
Does the point given lie on the surface of one of the detectors.
double getPhiOffset(const double &offset) const override
Computes the average position and returns the phi value.
const ParameterMap & parameterMap() const override
Helper for legacy access mode. Always throws for DetectorGroup.
std::vector< int > getIntParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as an integer.
det_topology getTopology(Kernel::V3D ¢er) const override
returns the detector's group topology if it has been calculated before or invokes the procedure of ca...
Kernel::V3D getPos() const override
Returns the position of the DetectorGroup.
std::size_t nDets() const override
Get the number of physical detectors this object represents.
bool getParameterVisible(const std::string &pname, bool recursive=true) const override
Get a visibility attribute of a parameter.
int m_id
The ID of this effective detector.
size_t index() const override
Helper for legacy access mode. Always throws for DetectorGroup.
int getPointInObject(Kernel::V3D &point) const override
Try to find a point that lies within (or on) the object.
bool isValid(const Kernel::V3D &point) const override
isValid() is true if the point is inside any of the detectors, i.e.
det_topology group_topology
the parameter describes the topology of the detector's group namely if detectors form a box or a ring...
base class for Geometric IComponent
Interface class for detector objects.
void error(const std::string &msg)
Logs at error level.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr V3D cross_prod(const V3D &v) const noexcept
Cross product (this * argument)
double angle(const V3D &) const
Angle between this and another vector.
void getSpherical(double &R, double &theta, double &phi) const noexcept
Return the vector's position in spherical coordinates.
Mantid::Kernel::Logger g_log("Goniometer")
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
det_topology
Describes the topology of a detectors group used to calculate angular position and angular measures f...
constexpr double Tolerance
Standard tolerance value.
int32_t detid_t
Typedef for a detector ID.