9#include "MantidGeometry/DllConfig.h"
19#include <unordered_map>
28class InstrumentMetadata;
44 using Entry = std::pair<size_t, std::shared_ptr<Parameter>>;
52 inline bool empty()
const {
return m_parameterInfo->empty(); }
54 inline int size()
const {
return static_cast<int>(m_parameterInfo->size()); }
56 size_t getMemorySize()
const;
58 static const std::string &pos();
59 static const std::string &posx();
60 static const std::string &posy();
61 static const std::string &posz();
62 static const std::string &rot();
63 static const std::string &rotx();
64 static const std::string &roty();
65 static const std::string &rotz();
66 static const std::string &pDouble();
67 static const std::string &pInt();
68 static const std::string &pBool();
69 static const std::string &pString();
70 static const std::string &pV3D();
71 static const std::string &pQuat();
72 static const std::string &scale();
74 const std::string diff(
const ParameterMap &
rhs,
const bool &firstDiffOnly =
false,
const bool relative =
false,
75 const double doubleTolerance = Kernel::Tolerance)
const;
86 m_parameterInfo->clear();
91 m_parameterInfo.swap(other.m_parameterInfo);
92 m_domainIds.swap(other.m_domainIds);
93 m_domainIndices.swap(other.m_domainIndices);
94 m_stagedIndices.swap(other.m_stagedIndices);
95 m_stagedIds.swap(other.m_stagedIds);
98 void clearParametersByName(
const std::string &
name);
101 void clearParametersByName(
const std::string &
name,
const IComponent *comp);
104 void add(
const std::string &type,
const IComponent *comp,
const std::string &
name,
const std::string &
value,
105 const std::string *
const pDescription =
nullptr,
const std::string &visible =
"true");
123 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true") {
125 auto typedParam = std::dynamic_pointer_cast<ParameterType<T>>(param);
127 typedParam->setValue(
value);
128 this->add(comp, param, pDescription);
132 void add(
const IComponent *comp,
const std::shared_ptr<Parameter> &par,
133 const std::string *
const pDescription =
nullptr);
138 void addFittingParameter(
const IComponent *comp,
const std::string &
name,
const std::string &fittingFunction,
139 const std::string &
value,
const std::string *
const pDescription =
nullptr,
140 const std::string &pVisible =
"true");
149 void add(
const std::string &type,
const size_t componentIndex,
const std::string &
name,
const std::string &
value,
150 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
151 void add(
const size_t componentIndex,
const std::shared_ptr<Parameter> &par,
152 const std::string *
const pDescription =
nullptr);
153 void addFittingParameter(
const size_t componentIndex,
const std::string &
name,
const std::string &fittingFunction,
154 const std::string &
value,
const std::string *
const pDescription =
nullptr,
155 const std::string &pVisible =
"true");
160 void addPositionCoordinate(
const IComponent *comp,
const std::string &
name,
const double value,
161 const std::string *
const pDescription =
nullptr);
163 void addRotationParam(
const IComponent *comp,
const std::string &
name,
const double deg,
164 const std::string *
const pDescription =
nullptr);
167 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
170 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
173 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
176 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
179 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
182 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
185 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
188 const std::string *
const pDescription =
nullptr);
191 const std::string *
const pDescription =
nullptr);
194 const std::string *
const pDescription =
nullptr);
200 bool contains(
const IComponent *comp,
const std::string &
name,
const std::string &type =
"")
const;
202 bool contains(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
206 std::shared_ptr<Parameter> get(
const IComponent *comp,
const std::string &
name,
const std::string &type =
"")
const;
208 std::shared_ptr<Parameter> get(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
210 std::shared_ptr<Parameter> getByType(
const IComponent *comp,
const std::string &type)
const;
213 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const std::string &
name,
214 const std::string &type =
"")
const;
217 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
220 std::shared_ptr<Parameter> getRecursiveByType(
const IComponent *comp,
const std::string &type)
const;
225 std::shared_ptr<Parameter> getRecursiveFittingParameter(
const IComponent *comp,
const std::string &
name,
226 const std::string &fittingFunction)
const;
235 template <
class T> std::vector<T>
getType(
const std::string &compName,
const std::string &
name)
const {
236 std::vector<T> retval;
238 for (
auto const &[
index, parameters] : *m_parameterInfo) {
239 static_cast<void>(parameters);
240 if (compName == componentName(
index)) {
241 std::shared_ptr<Parameter>
const param = m_parameterInfo->get(
index,
name);
243 retval.emplace_back(param->value<T>());
250 const std::string getDescription(
const std::string &compName,
const std::string &
name)
const;
252 const std::string getShortDescription(
const std::string &compName,
const std::string &
name)
const;
255 std::string getString(
const IComponent *comp,
const std::string &
name,
bool recursive =
false)
const;
258 std::vector<std::string>
getString(
const std::string &compName,
const std::string &
name)
const {
259 return getType<std::string>(compName,
name);
268 std::vector<double>
getDouble(
const std::string &compName,
const std::string &
name)
const {
269 return getType<double>(compName,
name);
278 std::vector<Kernel::V3D>
getV3D(
const std::string &compName,
const std::string &
name)
const {
279 return getType<Kernel::V3D>(compName,
name);
283 std::set<std::string> names(
const IComponent *comp)
const;
285 std::string asString()
const;
287 static std::string asString(
const std::vector<Entry> &entries,
const ComponentInfo &componentInfo,
290 static std::string asStringEntry(
const std::string &component,
const Parameter ¶meter);
293 static void saveNexus(Nexus::File *file,
const std::string &
group,
const std::string &contents);
299 const std::vector<std::string> &getParameterFilenames()
const;
301 void addParameterFilename(
const std::string &filename);
305 std::vector<Entry> entries()
const;
307 bool hasDetectorInfo(
const Instrument *instrument)
const;
308 bool hasComponentInfo(
const Instrument *instrument)
const;
317 void setInstrument(
const Instrument *instrument);
349 std::shared_ptr<ParameterInfo> rekey(std::shared_ptr<const ComponentIDs> componentIds,
350 std::shared_ptr<const ComponentIndices> componentIndices);
353 std::shared_ptr<Parameter>
create(
const std::string &className,
const std::string &
name,
354 const std::string &visible =
"true")
const;
359 void buildInstrumentMetadata();
361 void seedLogfileParameters();
363 bool relErr(
double x1,
double x2,
double errorVal)
const;
366 size_t domainSize()
const {
return m_domainIds ? m_domainIds->size() : 0; }
373 std::string componentName(
const size_t index)
const;
375 std::string componentFullName(
const size_t index)
const;
const std::vector< double > & rhs
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
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
Parameter map iterator typedef.
std::pair< size_t, std::shared_ptr< Parameter > > Entry
A stored parameter together with the component index of the component it belongs to.
void clear()
Clears the map.
ParameterMap & operator=(ParameterMap *rhs)
Assignment operator.
std::vector< ComponentID > m_stagedIds
std::vector< Kernel::V3D > getV3D(const std::string &compName, const std::string &name) const
Returns a Kernel::V3D parameter as vector's first element if exists and an empty vector if it doesn't...
bool empty() const
Returns true if the map is empty, false otherwise.
std::shared_ptr< ParameterInfo > m_parameterInfo
The parameter store, owner of the parameter info.
size_t domainSize() const
The number of components in the index domain.
std::shared_ptr< Geometry::InstrumentMetadata > m_instrumentMetadata
std::vector< T > getType(const std::string &compName, const std::string &name) const
Get the values of a given parameter of all the components that have the name: compName.
const std::shared_ptr< Geometry::InstrumentMetadata > & sharedInstrumentMetadata() const
const std::shared_ptr< ParameterInfo > & sharedParameterInfo() const
The parameter store this map owns.
const std::shared_ptr< Geometry::DetectorInfo > & sharedDetectorInfo() const
const std::shared_ptr< Geometry::ComponentInfo > & sharedComponentInfo() const
std::vector< std::string > getString(const std::string &compName, const std::string &name) const
Returns a string parameter as vector's first element if exists and an empty vector if it doesn't.
int size() const
Return the size of the map.
std::vector< std::string > m_parameterFileNames
internal list of parameter files loaded
std::vector< Geometry::IComponent * > ComponentIDs
The components of one instrument, by index, as held by its ComponentInfo.
void add(const std::string &type, const IComponent *comp, const std::string &name, const T &value, const std::string *const pDescription=nullptr, const std::string &pVisible="true")
Method for adding a parameter providing its value of a particular type.
std::unordered_map< Geometry::IComponent const *, size_t > m_stagedIndices
Staging indices, for the components of a detached map, which has no component indices yet.
std::shared_ptr< const ComponentIndices > m_domainIndices
std::unordered_map< Geometry::IComponent const *, size_t > ComponentIndices
The reverse of ComponentIDs.
std::vector< double > getDouble(const std::string &compName, const std::string &name) const
Returns a double parameter as vector's first element if exists and an empty vector if it doesn't.
const std::vector< Geometry::ComponentID > & componentIds() const
std::shared_ptr< Geometry::DetectorInfo > m_detectorInfo
The 2.0 instrument layers, co-owned with the ExperimentInfo that built them.
std::shared_ptr< Geometry::ComponentInfo > m_componentInfo
std::shared_ptr< const ComponentIDs > m_domainIds
The index domain: the components of the instrument this map is attached to, shared with that instrume...
void swap(ParameterMap &other)
method swaps two parameter maps contents each other
Base class for parameters of an instrument.
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::shared_ptr< ParameterMap > ParameterMap_sptr
ParameterMap shared pointer typedef.
std::shared_ptr< const ParameterMap > ParameterMap_const_sptr
ParameterMap constant shared pointer typedef.
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)