8#include "MantidBeamline/ComponentInfo.h"
9#include "MantidBeamline/DetectorInfo.h"
27#include <nexus/NeXusFile.hpp>
40void raiseDuplicateDetectorError(
const size_t detectorId) {
41 std::stringstream sstream;
42 sstream <<
"Instrument Definition corrupt. Detector with ID " << detectorId <<
" already exists.";
49 :
CompAssembly(), m_detectorCache(), m_sourceCache(nullptr), m_sampleCache(nullptr), m_defaultView(
"3D"),
54 :
CompAssembly(name), m_detectorCache(), m_sourceCache(nullptr), m_sampleCache(nullptr), m_defaultView(
"3D"),
62 :
CompAssembly(instr.get(), map.get()), m_sourceCache(instr->m_sourceCache), m_sampleCache(instr->m_sampleCache),
63 m_defaultView(instr->m_defaultView), m_defaultViewAxis(instr->m_defaultViewAxis), m_instr(instr),
64 m_map_nonconst(map), m_ValidFrom(instr->m_ValidFrom), m_ValidTo(instr->m_ValidTo),
77 :
CompAssembly(instr), m_sourceCache(nullptr), m_sampleCache(nullptr),
78 m_logfileCache(instr.m_logfileCache), m_logfileUnit(instr.m_logfileUnit), m_defaultView(instr.m_defaultView),
79 m_defaultViewAxis(instr.m_defaultViewAxis), m_instr(), m_map_nonconst(),
80 m_ValidFrom(instr.m_ValidFrom), m_ValidTo(instr.m_ValidTo), m_referenceFrame(instr.m_referenceFrame) {
87 std::vector<IComponent_const_sptr> children;
89 std::vector<IComponent_const_sptr>::const_iterator it;
90 for (it = children.begin(); it != children.end(); ++it) {
103 if (
const auto *
obj =
dynamic_cast<const Component *
>(it->get())) {
104 const std::string objName =
obj->getName();
128 throw std::runtime_error(
"Instrument::baseInstrument() called for a "
129 "non-parametrized instrument.");
141 throw std::runtime_error(
"Instrument::getParameterMap() called for a "
142 "non-parametrized instrument.");
153 if (
m_instr->getPhysicalInstrument()) {
175 physInst->m_isPhysicalInstrument =
true;
178 throw std::runtime_error(
"Instrument::setPhysicalInstrument() called on a "
179 "parametrized instrument.");
190 const auto &in_dets =
m_instr->m_detectorCache;
192 for (
const auto &in_det : in_dets) {
193 out_map.emplace(std::get<0>(in_det),
getDetector(std::get<0>(in_det)));
199 out_map.emplace(std::get<0>(in_det), std::get<1>(in_det));
206 std::vector<detid_t> out;
208 const auto &in_dets =
m_instr->m_detectorCache;
209 for (
const auto &in_det : in_dets)
210 if (!skipMonitors || !std::get<2>(in_det))
211 out.emplace_back(std::get<0>(in_det));
214 for (
const auto &in_det : in_dets)
215 if (!skipMonitors || !std::get<2>(in_det))
216 out.emplace_back(std::get<0>(in_det));
223 std::size_t numDetIDs(0);
226 numDetIDs =
m_instr->m_detectorCache.size();
233 std::size_t monitors(0);
235 const auto &in_dets =
m_instr->m_detectorCache;
236 for (
const auto &in_det : in_dets)
237 if (std::get<2>(in_det))
241 for (
const auto &in_det : in_dets)
242 if (std::get<2>(in_det))
245 return (numDetIDs - monitors);
259 if (in_dets->empty())
260 throw std::runtime_error(
"No detectors on this instrument. Can't find min/max ids");
262 min = std::get<0>(*in_dets->begin());
263 max = std::get<0>(*in_dets->rbegin());
276 const auto bank =
dynamic_cast<const ICompAssembly *
>(&comp);
279 std::vector<std::shared_ptr<const IComponent>> children;
281 std::vector<std::shared_ptr<const IComponent>>::iterator it;
282 for (it = children.begin(); it != children.end(); ++it) {
285 dets.emplace_back(det);
324 g_log.
warning(
"In Instrument::getSource(). No source has been set.");
330 else if (
dynamic_cast<const CompAssembly *
>(sourceCache))
332 else if (
dynamic_cast<const Component *
>(sourceCache))
335 g_log.
error(
"In Instrument::getSource(). Source is not a recognised "
337 g_log.
error(
"Try to assume it is a Component.");
350 g_log.
warning(
"In Instrument::getSamplePos(). No SamplePos has been set.");
356 else if (
dynamic_cast<const CompAssembly *
>(sampleCache))
358 else if (
dynamic_cast<const Component *
>(sampleCache))
361 g_log.
error(
"In Instrument::getSamplePos(). SamplePos is not a "
362 "recognised component type.");
363 g_log.
error(
"Try to assume it is a Component.");
400 std::shared_ptr<const IComponent> node = std::shared_ptr<const IComponent>(
this,
NoDeleting());
401 std::vector<std::shared_ptr<const IComponent>> retVec;
403 if (this->
getName() == cname) {
404 retVec.emplace_back(node);
407 std::deque<std::shared_ptr<const IComponent>> nodeQueue;
409 nodeQueue.emplace_back(node);
410 while (!nodeQueue.empty()) {
411 node = nodeQueue.front();
412 nodeQueue.pop_front();
414 std::shared_ptr<const ICompAssembly> asmb = std::dynamic_pointer_cast<const ICompAssembly>(node);
416 nchildren = asmb->nelements();
418 for (
int i = 0; i < nchildren; ++i) {
419 std::shared_ptr<const IComponent> comp = (*asmb)[i];
420 if (comp->getName() == cname) {
421 retVec.emplace_back(comp);
423 nodeQueue.emplace_back(comp);
436template <
class T>
auto lower_bound(T &map,
const detid_t key) ->
decltype(map.begin()) {
437 return std::lower_bound(map.begin(), map.end(), std::make_tuple(key,
IDetector_const_sptr(
nullptr),
false),
438 [](
const typename T::value_type &a,
const typename T::value_type &b) ->
bool {
439 return std::get<0>(a) < std::get<0>(b);
443template <
class T>
auto find(T &map,
const detid_t key) ->
decltype(map.begin()) {
444 auto it = lower_bound(map, key);
445 if ((it != map.end()) && (std::get<0>(*it) == key))
463 const auto it = find(baseInstr.m_detectorCache, detector_id);
464 if (it == baseInstr.m_detectorCache.end()) {
465 std::stringstream readInt;
466 readInt << detector_id;
484 auto it = find(
m_instr->m_detectorCache, detector_id);
485 if (it ==
m_instr->m_detectorCache.end()) {
488 return std::get<1>(*it).get();
493 const auto it = find(baseInstr.m_detectorCache, detector_id);
494 if (it == baseInstr.m_detectorCache.end())
496 return std::get<2>(*it);
500 if (detector_ids.empty())
503 return std::any_of(detector_ids.cbegin(), detector_ids.cend(),
504 [
this](
const auto detector_id) { return isMonitor(detector_id); });
514 const size_t ndets(det_ids.size());
518 std::shared_ptr<DetectorGroup> det_group = std::make_shared<DetectorGroup>();
519 for (
const auto detID : det_ids) {
531 std::vector<IDetector_const_sptr> dets_ptr;
532 dets_ptr.reserve(det_ids.size());
533 std::vector<detid_t>::const_iterator it;
534 for (it = det_ids.begin(); it != det_ids.end(); ++it) {
545 std::vector<IDetector_const_sptr> dets_ptr;
546 dets_ptr.reserve(det_ids.size());
547 std::set<detid_t>::const_iterator it;
548 for (it = det_ids.begin(); it != det_ids.end(); ++it) {
566 throw std::runtime_error(
"Instrument::markAsSamplePos() called on a "
567 "parametrized Instrument object.");
571 throw std::runtime_error(
"Instrument::markAsSamplePos() called on an IObjComponent "
572 "object that supports shape definition. Sample is prevented from "
573 "being this type because the shape must only be stored in "
574 "ExperimentInfo::m_sample.");
583 g_log.
warning(
"Have already added samplePos component to the _sampleCache.");
599 throw std::runtime_error(
"Instrument::markAsSource() called on a "
600 "parametrized Instrument object.");
608 g_log.
warning(
"Have already added source component to the _sourceCache.");
622 throw std::runtime_error(
"Instrument::markAsDetector() called on a "
623 "parametrized Instrument object.");
630 raiseDuplicateDetectorError(det->
getID());
640 throw std::runtime_error(
"Instrument::markAsDetector() called on a "
641 "parametrized Instrument object.");
656 [](
const std::tuple<detid_t, IDetector_const_sptr, bool> &a,
657 const std::tuple<detid_t, IDetector_const_sptr, bool> &b) ->
bool { return std::get<0>(a) < std::get<0>(b); });
660 [](
const std::tuple<detid_t, IDetector_const_sptr, bool> &a,
661 const std::tuple<detid_t, IDetector_const_sptr, bool> &b) ->
bool {
662 return std::get<0>(a) == std::get<0>(b);
665 raiseDuplicateDetectorError(std::get<0>(*resultIt));
679 throw std::runtime_error(
"Instrument::markAsMonitor() called on a "
680 "parametrized Instrument object.");
687 std::get<2>(*it) =
true;
696 throw std::runtime_error(
"Instrument::removeDetector() called on a "
697 "parameterized Instrument object.");
709 parentAssembly->
remove(det);
721 std::vector<detid_t> mons;
723 if (std::get<2>(item))
724 mons.emplace_back(std::get<0>(item));
745 for (
int i = 0; i < nchildren; ++i) {
747 if (comp && comp->getComponentID() != sourceID) {
749 comp->getBoundingBox(compBox);
750 assemblyBox.
grow(compBox);
761 if (component && component->getComponentID() != sourceID) {
762 component->getBoundingBox(compBox);
775 std::shared_ptr<const std::vector<IObjComponent_const_sptr>> objs =
m_instr->getPlottable();
780 auto &res =
const_cast<std::vector<IObjComponent_const_sptr> &
>(*objs);
781 const std::vector<IObjComponent_const_sptr>::size_type total = res.size();
782 for (std::vector<IObjComponent_const_sptr>::size_type i = 0; i < total; ++i) {
789 auto res = std::make_shared<std::vector<IObjComponent_const_sptr>>();
797 for (
int i = 0; i < ca.
nelements(); i++) {
828 if (sourceObj ==
nullptr) {
833 beamline = samplePos - sourcePos;
834 beamline_norm = 2.0 * beamline.
norm();
839 l1 = this->
getSource()->getDistance(*sample);
850 m_instr->m_filename = filename;
890 file->makeGroup(group,
"NXinstrument",
true);
891 file->putAttr(
"version", 1);
893 file->writeData(
"name",
getName());
896 file->makeGroup(
"instrument_xml",
"NXnote",
true);
899 g_log.
warning() <<
"Saving Instrument with no XML data. If this was "
900 "instrument data you may not be able to load this data "
901 "back into Mantid, for fitted/analysed data this "
902 "warning can be ignored.\n";
903 file->writeData(
"data", xmlText);
904 file->writeData(
"type",
"text/xml");
905 file->writeData(
"description",
"XML contents of the instrument IDF file.");
912 params->saveNexus(file,
"instrument_parameter_map");
918 if (!detmonIDs.empty()) {
920 file->makeGroup(
"physical_detectors",
"NXdetector",
true);
921 file->writeData(
"number_of_detectors", uint64_t(detectorIDs.size()));
926 std::vector<detid_t> monitorIDs;
927 for (
size_t i = 0; i < detmonIDs.size(); i++) {
929 monitorIDs.emplace_back(detmonIDs[i]);
933 file->makeGroup(
"physical_monitors",
"NXmonitor",
true);
934 file->writeData(
"number_of_monitors", uint64_t(monitorIDs.size()));
951 size_t nDets = detIDs.size();
959 sample_pos = sample->getPos();
961 std::vector<double> a_angles(nDets);
962 std::vector<double> p_angles(nDets);
963 std::vector<double> distances(nDets);
965 for (
size_t i = 0; i < nDets; i++) {
967 Kernel::V3D pos = detectors[i]->getPos() - sample_pos;
968 pos.
getSpherical(distances[i], p_angles[i], a_angles[i]);
970 a_angles[i] = detectors[i]->getPhi() * 180.0 / M_PI;
973 file->writeData(
"detector_number", detIDs);
974 file->writeData(
"azimuthal_angle", a_angles);
975 file->openData(
"azimuthal_angle");
976 file->putAttr(
"units",
"degree");
979 file->writeData(
"polar_angle", p_angles);
980 file->openData(
"polar_angle");
981 file->putAttr(
"units",
"degree");
983 file->writeData(
"distance", distances);
984 file->openData(
"distance");
985 file->putAttr(
"units",
"metre");
996 file->openGroup(group,
"NXinstrument");
1012 return m_instr->getReferenceFrame();
1027 std::string typeUC(
type);
1028 std::transform(typeUC.begin(), typeUC.end(), typeUC.begin(), toupper);
1029 if (typeUC ==
"3D" || typeUC ==
"CYLINDRICAL_X" || typeUC ==
"CYLINDRICAL_Y" || typeUC ==
"CYLINDRICAL_Z" ||
1030 typeUC ==
"SPHERICAL_X" || typeUC ==
"SPHERICAL_Y" || typeUC ==
"SPHERICAL_Z") {
1034 g_log.
warning() <<
type <<
" is not allowed as an instrument view type. Default to \"3D\"" <<
'\n';
1043 Types::Core::DateAndTime earliestAllowedDate(
"1900-01-31 23:59:01");
1044 if (val < earliestAllowedDate) {
1046 "The valid-from <instrument> tag date must be from 1900-01-31 23:59:01 "
1054 std::queue<IComponent_const_sptr> compQueue;
1057 bool foundRect =
false;
1058 bool foundNonRect =
false;
1062 while (!compQueue.empty() && !(foundRect && foundNonRect)) {
1063 comp = compQueue.front();
1073 foundNonRect =
true;
1078 if (foundRect && foundNonRect)
1089 std::queue<IComponent_const_sptr> compQueue;
1092 std::vector<RectangularDetector_const_sptr> detectors;
1096 while (!compQueue.empty()) {
1097 comp = compQueue.front();
1103 if (
auto const detector = std::dynamic_pointer_cast<const RectangularDetector>(comp)) {
1104 detectors.push_back(detector);
1124 if (detector &&
isMonitor(detector->getID()))
1128 const auto &name = component->getName();
1129 if (name ==
"chopper-position" || name.substr(0, 4) ==
"slit" || name ==
"supermirror") {
1146 if (
auto const assembly = std::dynamic_pointer_cast<const ICompAssembly>(component)) {
1147 for (
int i = 0; i < assembly->nelements(); i++)
1148 queue.push(assembly->getChild(i));
1172 const auto it = find(baseInstr.m_detectorCache, detID);
1173 return std::distance(baseInstr.m_detectorCache.cbegin(), it);
1183 pmap->setInstrument(
nullptr);
1192 constexpr double d_max = 1e-9;
1193 constexpr double L = 1000.0;
1194 constexpr double safety_factor = 2.0;
1195 const double imag_norm_max = sin(d_max / (2.0 * L * safety_factor));
1197 Eigen::Affine3d transformation;
1198 int64_t oldParentIndex = -1;
1202 for (
size_t i = 0; i < componentInfo.size(); ++i) {
1204 const int64_t parentIndex = componentInfo.parent(i);
1205 const bool makeTransform = parentIndex != oldParentIndex;
1206 bool isDetFixedInBank =
false;
1208 if (makeTransform) {
1209 oldParentIndex = parentIndex;
1210 const auto parentPos =
toVector3d(componentInfo.position(parentIndex));
1211 const auto invParentRot =
toQuaterniond(componentInfo.rotation(parentIndex)).conjugate();
1213 transformation = invParentRot;
1214 transformation.translate(-parentPos);
1217 if (componentInfo.isDetector(i)) {
1219 const std::shared_ptr<const IDetector> &baseDet = std::get<1>(baseInstr.m_detectorCache[i]);
1222 if (detectorInfo.isMasked(i)) {
1223 pmap->forceUnsafeSetMasked(baseDet.get(),
true);
1226 if (makeTransform) {
1228 if (isDetFixedInBank) {
1230 size_t panelIndex = componentInfo.parent(parentIndex);
1231 const auto panelID = componentInfo.componentID(panelIndex);
1233 Eigen::Vector3d scale(1, 1, 1);
1234 if (
auto scalex =
pmap->get(panelID,
"scalex"))
1235 scale[0] = 1.0 /
scalex->value<
double>();
1236 if (
auto scaley =
pmap->get(panelID,
"scaley"))
1237 scale[1] = 1.0 /
scaley->value<
double>();
1238 transformation.prescale(scale);
1243 const auto componentId = componentInfo.componentID(i);
1252 Eigen::Vector3d relPos = transformation *
toVector3d(componentInfo.position(i));
1253 Eigen::Quaterniond relRot =
toQuaterniond(componentInfo.relativeRotation(i));
1257 if (isDetFixedInBank) {
1258 throw std::runtime_error(
"Cannot create legacy ParameterMap: Position "
1259 "parameters for GridDetectorPixel are "
1280 throw std::logic_error(
"Instrument::parseTreeAndCacheBeamline must be "
1281 "called with the base instrument, not a "
1282 "parametrized instrument");
1291std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>>
1304std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>>
1308 auto detInfo = std::make_unique<DetectorInfo>(detectorInfo);
1309 compInfo->m_componentInfo->setDetectorInfo(detInfo->m_detectorInfo.get());
1312 detInfo->m_instrument = parInstrument;
1313 return {std::move(compInfo), std::move(detInfo)};
1316namespace Conversion {
std::map< DeltaEMode::Type, std::string > index
double obj
the value of the quadratic function
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
void grow(const BoundingBox &other)
Grow the bounding box so that it also encompasses the given box.
Class for Assembly of geometric components.
std::vector< IComponent * > m_children
the group of child components
void getChildren(std::vector< IComponent_const_sptr > &outVector, bool recursive) const override
Returns a vector of all children contained.
BoundingBox * m_cachedBoundingBox
A cached bounding box.
int add(IComponent *) override
Add a component to the assembly.
std::shared_ptr< const IComponent > getComponentByName(const std::string &cname, int nlevels=0) const override
Returns a pointer to the first component of assembly encountered with the given name.
int remove(IComponent *)
Remove a component from the assembly.
Kernel::V3D getPos() const override
Gets the absolute position of the Parametrized CompAssembly This attempts to read the cached position...
CompAssembly()
Empty constructor.
int nelements() const override
Return the number of elements in the assembly.
ComponentInfo : Provides a component centric view on to the instrument.
BoundingBox boundingBox(const size_t componentIndex, const BoundingBox *reference=nullptr, const bool excludeMonitors=false) const
Compute the bounding box for the component with componentIndex taking into account all sub components...
std::unique_ptr< ComponentInfo > cloneWithoutDetectorInfo() const
Clone current instance but not the DetectorInfo non-owned parts.
Component is a wrapper for a Component which can modify some of its parameters, e....
const ParameterMap * m_map
A pointer to const ParameterMap containing the parameters.
size_t index() const
Helper for legacy access mode. Returns the index of the component.
bool hasComponentInfo() const
const IComponent * base() const
Returns the address of the base component.
bool isParametrized() const override
Return true if the Component is, in fact, parametrized (that is - it has a valid parameter map)
std::string getName() const override
Get the IComponent name.
const Component * m_base
The base component - this is the unmodified component (without the parameters).
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
This class represents a detector - i.e.
Class for Assembly of geometric components.
virtual void getChildren(std::vector< IComponent_const_sptr > &outVector, bool recursive) const =0
Get all children.
base class for Geometric IComponent
virtual IComponent const * getBaseComponent() const =0
Returns const pointer to base component if this component is parametrized.
virtual Kernel::V3D getScaleFactor() const
Gets the scaling factor of the object for the Object Component.
virtual ComponentID getComponentID() const =0
Returns the ComponentID - a unique identifier of the component.
virtual Kernel::Quat getRelativeRot() const =0
Get the relative Orientation.
virtual Kernel::V3D getRelativePos() const =0
Get the position relative to the parent IComponent (absolute if no parent)
virtual const IComponent * getBareParent() const =0
Returns the bare pointer to the IComponent parent.
virtual std::string getName() const =0
Get the IComponent name.
Interface class for detector objects.
virtual detid_t getID() const =0
Get the detector ID.
Object Component class, this class brings together the physical attributes of the component to the po...
std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > makeWrappers() const
ContainsState containsRectDetectors() const
Check whether instrument contains rectangular detectors.
std::string m_filename
Path to the original IDF .xml file that was loaded for this instrument.
std::vector< std::shared_ptr< const IComponent > > getAllComponentsWithName(const std::string &cname) const
Returns pointers to all components encountered with the given name.
void markAsSamplePos(const IComponent *)
mark a Component which has already been added to the Instrument (as a child comp.) to be 'the' sample...
std::size_t getNumberDetectors(bool skipMonitors=false) const
IComponent_const_sptr getSource() const
Gets a pointer to the source.
std::string m_xmlText
Contents of the IDF .xml file that was loaded for this instrument.
std::shared_ptr< const IComponent > getComponentByID(const IComponent *id) const
Returns a shared pointer to a component.
bool validateComponentProperties(IComponent_const_sptr component) const
const IComponent * m_sampleCache
Purpose to hold copy of samplePos component.
void getInstrumentParameters(double &l1, Kernel::V3D &beamline, double &beamline_norm, Kernel::V3D &samplePos) const
Get several instrument parameters used in tof to D-space conversion.
std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > makeWrappers(ParameterMap &pmap, const ComponentInfo &componentInfo, const DetectorInfo &detectorInfo) const
Sets up links between m_detectorInfo, m_componentInfo, and m_instrument.
const IDetector * getBaseDetector(const detid_t &detector_id) const
Gets a pointer to the base (non-parametrized) detector from its ID returns null if the detector has n...
std::shared_ptr< const Instrument > baseInstrument() const
Pointer to the 'real' instrument, for parametrized instruments.
Instrument()
Default constructor.
ContainsState
To determine whether the instrument contains elements of some type.
void parseTreeAndCacheBeamline()
Parse the instrument tree and create ComponentInfo and DetectorInfo.
std::shared_ptr< const Instrument > getPhysicalInstrument() const
INDIRECT GEOMETRY INSTRUMENTS ONLY: Returns the physical instrument, if one has been specified as dis...
std::shared_ptr< const Instrument > m_instr
Pointer to the "real" instrument, for parametrized Instrument.
void markAsDetector(const IDetector *)
mark a Component which has already been added to the Instrument (as a child comp.) to be a Detector c...
std::string m_defaultView
Stores the default type of the instrument view: 3D or one of the "unwrapped".
void loadNexus(::NeXus::File *file, const std::string &group)
Load the object from an open NeXus file.
std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > makeBeamline(ParameterMap &pmap, const ParameterMap *source=nullptr) const
Return ComponentInfo and DetectorInfo for instrument given by pmap.
std::shared_ptr< const DetectorInfo > m_detectorInfo
Pointer to the DetectorInfo object. May be NULL.
std::vector< IDetector_const_sptr > getDetectors(const std::vector< detid_t > &det_ids) const
Returns a list of Detectors for the given detectors ids.
std::shared_ptr< ParameterMap > makeLegacyParameterMap() const
Returns a legacy ParameterMap, containing information that is now stored in DetectorInfo (masking,...
std::vector< std::tuple< detid_t, IDetector_const_sptr, bool > > m_detectorCache
Map which holds detector-IDs and pointers to detector components, and monitor flags.
size_t detectorIndex(const detid_t detID) const
Returns the index for a detector ID. Used for accessing DetectorInfo.
void setValidFromDate(const Types::Core::DateAndTime &val)
Set the date from which the instrument definition begins to be valid.
void setXmlText(const std::string &XmlText)
Set the Contents of the IDF .xml file that was loaded for this instrument.
void saveNexus(::NeXus::File *file, const std::string &group) const
Save the instrument to an open NeXus file.
Instrument * clone() const override
Virtual copy constructor.
std::vector< RectangularDetector_const_sptr > findRectDetectors() const
bool isMonitor(const detid_t &detector_id) const
const std::string & getFilename() const
bool isMonitorViaIndex(const size_t index) const
Temporary helper for refactoring. Argument is index, not ID!
void setPhysicalInstrument(std::unique_ptr< Instrument >)
INDIRECT GEOMETRY INSTRUMENTS ONLY: Sets the physical instrument.
std::shared_ptr< ParameterMap > getParameterMap() const
Pointer to the NOT const ParameterMap holding the parameters of the modified instrument components.
void saveDetectorSetInfoToNexus(::NeXus::File *file, const std::vector< detid_t > &detIDs) const
Save information about a set of detectors to Nexus.
std::shared_ptr< IComponent > getChild(const int i) const override
Get a pointer to the ith component within the assembly. Easier to use than.
bool hasSample() const
Checks to see if the Instrument has a sample.
Kernel::V3D getBeamDirection() const
Gets the beam direction (i.e.
const IComponent * m_sourceCache
Purpose to hold copy of source component.
std::vector< detid_t > getMonitors() const
Returns a list containing the detector ids of monitors.
void appendPlottable(const CompAssembly &ca, std::vector< IObjComponent_const_sptr > &lst) const
Add a plottable component.
std::string type() const override
String description of the type of component.
void markAsDetectorIncomplete(const IDetector *)
As markAsDetector but without the required sorting.
const std::string & getXmlText() const
std::vector< detid_t > getDetectorIDs(bool skipMonitors=false) const
Return a vector of detector IDs in this instrument.
void getBoundingBox(BoundingBox &assemblyBox) const override
Get the bounding box for this component and store it in the given argument.
std::shared_ptr< const ComponentInfo > m_componentInfo
Pointer to the ComponentInfo object. May be NULL.
std::shared_ptr< const Instrument > m_physicalInstrument
Pointer to the physical instrument, where this differs from the 'neutronic' one (indirect geometry)
bool isEmptyInstrument() const
virtual int add(IComponent *component) override
Add a component to the instrument.
std::shared_ptr< const std::vector< IObjComponent_const_sptr > > getPlottable() const
Get pointers to plottable components.
IDetector_const_sptr getDetectorG(const std::set< detid_t > &det_ids) const
Returns a pointer to the geometrical object for the given set of IDs.
void markAsMonitor(const IDetector *)
mark a Component which has already been added to the Instrument (as a child comp.) to be a monitor an...
void getDetectorsInBank(std::vector< IDetector_const_sptr > &dets, const IComponent &comp) const
Fill a vector with all the detectors contained (at any depth) in a named component.
void markAsSource(const IComponent *)
mark a Component which has already been added to the Instrument (as a child comp.) to be 'the' source...
bool hasSource() const
Checks to see if the Instrument has a source.
void setReferenceFrame(std::shared_ptr< ReferenceFrame > frame)
Set reference Frame.
void getMinMaxDetectorIDs(detid_t &min, detid_t &max) const
Get the minimum and maximum (inclusive) detector IDs.
std::shared_ptr< ParameterMap > m_map_nonconst
Non-const pointer to the parameter map.
void setDefaultView(const std::string &type)
Set the default type of the instrument view.
std::shared_ptr< const ReferenceFrame > getReferenceFrame() const
Get refernce Frame.
void markAsDetectorFinalize()
Sorts the detector cache.
bool addAssemblyChildrenToQueue(std::queue< IComponent_const_sptr > &queue, IComponent_const_sptr component) const
If component is a ComponentAssembly, we add its children to the queue to check if they're Rectangular...
std::shared_ptr< ReferenceFrame > m_referenceFrame
Pointer to the reference frame object.
IDetector_const_sptr getDetector(const detid_t &detector_id) const
Gets a pointer to the detector from its ID Note that for getting the detector associated with a spect...
Types::Core::DateAndTime m_ValidFrom
the date from which the instrument definition begins to be valid.
void setFilename(const std::string &filename)
Set the path to the original IDF .xml file that was loaded for this instrument.
IComponent_const_sptr getSample() const
Gets a pointer to the Sample Position.
void addInstrumentChildrenToQueue(std::queue< IComponent_const_sptr > &queue) const
void removeDetector(IDetector *)
Remove a detector from the instrument.
Void deleter for shared pointers.
Object Component class, this class brings together the physical attributes of the component to the po...
static std::shared_ptr< IComponent > create(const std::shared_ptr< const IComponent > &base, const ParameterMap *map)
Create a parameterized component from the given base component and ParameterMap.
static std::shared_ptr< Instrument > createInstrument(const std::shared_ptr< const Instrument > &base, const std::shared_ptr< ParameterMap > &map)
Create a parameterized instrument from the given base and ParameterMap.
static std::shared_ptr< IDetector > createDetector(const IDetector *base, const ParameterMap *map)
Create a parameterized detector from the given base component and ParameterMap and return a shared_pt...
const Geometry::DetectorInfo & detectorInfo() const
Only for use by ExperimentInfo. Returns a reference to the DetectorInfo.
static const std::string & scale()
static const std::string & rot()
static const std::string & pos()
Return string to be used in the map.
bool hasComponentInfo(const Instrument *instrument) const
Only for use by ExperimentInfo.
const Geometry::ComponentInfo & componentInfo() const
Only for use by ExperimentInfo. Returns a reference to the ComponentInfo.
RectangularDetector is a type of CompAssembly, an assembly of components.
ReferenceFrame : Holds reference frame information from the geometry description file.
Exception for errors associated with the instrument definition.
Exception for when an item is not found in a collection.
The Logger class is in charge of the publishing messages from the framework through various channels.
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
double norm() const noexcept
void getSpherical(double &R, double &theta, double &phi) const noexcept
Return the vector's position in spherical coordinates.
MANTID_GEOMETRY_DLL bool isDetectorFixedInBank(const ComponentInfo &compInfo, const size_t detIndex)
Tests whether or not the detector is within a fixed bank.
MANTID_GEOMETRY_DLL double tofToDSpacingFactor(const double l1, const double l2, const double twoTheta, const double offset)
Calculate and return conversion factor from tof to d-spacing.
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
std::shared_ptr< IComponent > IComponent_sptr
Typedef of a shared pointer to a IComponent.
Mantid::Kernel::Logger g_log("Goniometer")
std::shared_ptr< const IObjComponent > IObjComponent_const_sptr
Shared pointer to IObjComponent (const version)
std::shared_ptr< ParameterMap > ParameterMap_sptr
ParameterMap shared pointer typedef.
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
MANTID_KERNEL_DLL double tofToDSpacingFactor(const double l1, const double l2, const double twoTheta, const double offset)
Calculate and return conversion factor from tof to d-spacing.
Kernel::Quat toQuat(const Eigen::Quaterniond &quat)
Converts Eigen::Quaterniond to Kernel::Quat.
Eigen::Vector3d toVector3d(const Kernel::V3D &vec)
Converts Kernel::V3D to Eigen::Vector3d.
Kernel::V3D toV3D(const Eigen::Vector3d &vec)
This header provides conversion helpers between vector and rotation types in MantidKernel and equival...
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
Eigen::Quaterniond toQuaterniond(const Kernel::Quat &quat)
Converts Kernel::Quat to Eigen::Quaterniond.
int32_t detid_t
Typedef for a detector ID.
std::map< detid_t, Geometry::IDetector_const_sptr > detid2det_map
Typedef of a map from detector ID to detector shared pointer.
Generate a tableworkspace to store the calibration results.
adjust instrument component position and orientation
: detector size scale at y-direction