9#include "MantidGeometry/DllConfig.h"
16#include "MantidTypes/Core/DateAndTime.h"
22#include <unordered_map>
37 std::map<std::pair<std::string, const IComponent *>, std::shared_ptr<XMLInstrumentParameter>>;
50 std::string
type()
const override {
return "Instrument"; }
52 Instrument(
const std::shared_ptr<const Instrument> &instr,
const std::shared_ptr<ParameterMap> &map);
59 bool hasSource()
const;
60 bool hasSample()
const;
68 bool isMonitor(
const detid_t &detector_id)
const;
69 bool isMonitor(
const std::set<detid_t> &detector_ids)
const;
75 std::vector<IDetector_const_sptr> getDetectors(
const std::vector<detid_t> &det_ids)
const;
78 std::vector<IDetector_const_sptr> getDetectors(
const std::set<detid_t> &det_ids)
const;
96 void markAsDetectorIncomplete(
const IDetector *);
97 void markAsDetectorFinalize();
111 std::vector<detid_t> getDetectorIDs(
bool skipMonitors =
false)
const;
113 std::size_t getNumberDetectors(
bool skipMonitors =
false)
const;
117 void getDetectorsInBank(std::vector<IDetector_const_sptr> &dets,
const IComponent &comp)
const;
118 void getDetectorsInBank(std::vector<IDetector_const_sptr> &dets,
const std::string &bankName)
const;
121 std::vector<detid_t> getMonitors()
const;
124 void getBoundingBox(
BoundingBox &assemblyBox)
const override;
127 std::shared_ptr<const std::vector<IObjComponent_const_sptr>> getPlottable()
const;
130 std::shared_ptr<const IComponent> getComponentByID(
const IComponent *
id)
const;
133 std::vector<std::shared_ptr<const IComponent>> getAllComponentsWithName(
const std::string &cname)
const;
151 void setDefaultView(
const std::string &type);
159 using CompAssembly::getChild;
162 std::shared_ptr<const Instrument> baseInstrument()
const;
166 std::shared_ptr<ParameterMap> getParameterMap()
const;
175 void setValidFromDate(
const Types::Core::DateAndTime &val);
183 std::shared_ptr<const Instrument> getPhysicalInstrument()
const;
184 void setPhysicalInstrument(std::unique_ptr<Instrument>);
186 void getInstrumentParameters(
double &l1,
Kernel::V3D &beamline,
double &beamline_norm,
Kernel::V3D &samplePos)
const;
188 void saveNexus(Nexus::File *file,
const std::string &
group)
const;
189 void loadNexus(Nexus::File *file,
const std::string &
group);
191 void setFilename(
const std::string &filename);
192 const std::string &getFilename()
const;
193 void setXmlText(
const std::string &XmlText);
194 const std::string &getXmlText()
const;
197 void setReferenceFrame(std::shared_ptr<ReferenceFrame> frame);
199 std::shared_ptr<const ReferenceFrame> getReferenceFrame()
const;
206 ContainsState containsRectDetectors()
const;
209 return findDetectorsOfType<RectangularDetector>();
211 std::vector<GridDetector_const_sptr>
findGridDetectors()
const {
return findDetectorsOfType<GridDetector>(); }
213 bool isMonitorViaIndex(
const size_t index)
const;
215 std::shared_ptr<ParameterMap> makeLegacyParameterMap()
const;
217 bool isEmptyInstrument()
const;
219 void parseTreeAndCacheBeamline();
220 std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>>
225 void saveDetectorSetInfoToNexus(Nexus::File *file,
const std::vector<detid_t> &detIDs)
const;
229 void addInstrumentChildrenToQueue(std::queue<IComponent_const_sptr> &queue)
const;
230 bool addAssemblyChildrenToQueue(std::queue<IComponent_const_sptr> &queue,
IComponent_const_sptr component)
const;
232 std::queue<IComponent_const_sptr> compQueue;
233 addInstrumentChildrenToQueue(compQueue);
235 std::vector<std::shared_ptr<const T>> detectors;
239 while (!compQueue.empty()) {
240 comp = compQueue.front();
243 if (!validateComponentProperties(comp))
246 if (
auto const detector = std::dynamic_pointer_cast<const T>(comp)) {
247 detectors.push_back(detector);
250 addAssemblyChildrenToQueue(compQueue, comp);
260 void appendPlottable(
const CompAssembly &ca, std::vector<IObjComponent_const_sptr> &lst)
const;
262 std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>>
325 std::shared_ptr<const DetectorInfo> m_detectorInfo{
nullptr};
328 std::shared_ptr<const ComponentInfo> m_componentInfo{
nullptr};
331 bool m_isPhysicalInstrument{
false};
333namespace Conversion {
336 const double offset);
339 const std::vector<detid_t> &detectors,
340 const std::map<detid_t, double> &offsets);
343 const double offset,
const double binWidth);
std::map< DeltaEMode::Type, std::string > index
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Class for Assembly of geometric components.
ComponentInfo : Provides a component centric view on to the instrument.
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
base class for Geometric IComponent
Interface class for detector objects.
std::string m_filename
Path to the original IDF .xml file that was loaded for this instrument.
const InstrumentParameterCache & getLogfileCache() const
std::string m_defaultViewAxis
Stores from which side the instrument will be viewed from, initially in the instrument viewer,...
std::string m_xmlText
Contents of the IDF .xml file that was loaded for this instrument.
std::vector< GridDetector_const_sptr > findGridDetectors() const
ContainsState
To determine whether the instrument contains elements of some type.
std::shared_ptr< const Instrument > m_instr
Pointer to the "real" instrument, for parametrized Instrument.
std::string m_defaultView
Stores the default type of the instrument view: 3D or one of the "unwrapped".
std::map< std::string, std::string > m_logfileUnit
Store units used by users to specify angles in IDFs and associated parameter files.
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.
Instrument & operator=(const Instrument &)
Private copy assignment operator.
std::vector< RectangularDetector_const_sptr > findRectDetectors() const
std::map< std::string, std::string > & getLogfileUnit()
Get information about the units used for parameters described in the IDF and associated parameter fil...
Types::Core::DateAndTime m_ValidTo
the date at which the instrument definition is no longer valid.
const std::string & getDefaultView() const
Get the default type of the instrument view.
const std::string & getDefaultAxis() const
Retrieves from which side the instrument to be viewed from when the instrument viewer first starts,...
std::string type() const override
String description of the type of component.
Types::Core::DateAndTime getValidFromDate() const
std::shared_ptr< const Instrument > m_physicalInstrument
Pointer to the physical instrument, where this differs from the 'neutronic' one (indirect geometry)
std::shared_ptr< ParameterMap > m_map_nonconst
Non-const pointer to the parameter map.
InstrumentParameterCache m_logfileCache
To store info about the parameters defined in IDF.
void setValidToDate(const Types::Core::DateAndTime &val)
Set the date at which the instrument definition is no longer valid.
void setDefaultViewAxis(const std::string &axis)
Retrieves from which side the instrument to be viewed from when the instrument viewer first starts,...
std::vector< std::shared_ptr< const T > > findDetectorsOfType() const
std::shared_ptr< ReferenceFrame > m_referenceFrame
Pointer to the reference frame object.
InstrumentParameterCache & getLogfileCache()
Get information about the parameters described in the instrument definition file and associated param...
Types::Core::DateAndTime m_ValidFrom
the date from which the instrument definition begins to be valid.
Types::Core::DateAndTime getValidToDate() const
ReferenceFrame : Holds reference frame information from the geometry description file.
This class is used to store information about parameters in XML instrument definition files and instr...
MANTID_GEOMETRY_DLL double calculateDIFCCorrection(const double l1, const double l2, const double twoTheta, const double offset, const double binWidth)
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::map< std::pair< std::string, const IComponent * >, std::shared_ptr< XMLInstrumentParameter > > InstrumentParameterCache
Convenience typedef.
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
Helper class which provides the Collimation Length for SANS instruments.
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.