18 const bool quotedString =
true;
49 }
else if (
name ==
"Symmetries") {
51 }
else if (
name ==
"PhysicalProperties") {
55 if (
name ==
"Temperatures") {
58 }
else if (
name ==
"FWHMs") {
61 auto frontValue =
m_FWHMs.front();
63 m_FWHMs.assign(nSpec, frontValue);
68 for (
size_t i = 0; i < nSpec; ++i) {
73 control.setAttributeValue(
"FWHMX", std::vector<double>());
74 control.setAttributeValue(
"FWHMY", std::vector<double>());
81 }
else if ((
name.compare(0, 5,
"FWHMX") == 0 ||
name.compare(0, 5,
"FWHMY") == 0) && !attr.
asVector().empty()) {
93 std::vector<std::string> &cache) {
102 attrCopy.setString(attrValue);
117 for (
size_t i = 0; i < nSpec; ++i) {
119 auto fwhmX = control.getAttribute(
"FWHMX").asVector();
120 auto fwhmY = control.getAttribute(
"FWHMY").asVector();
130 throw std::runtime_error(
"No ions are set.");
133 throw std::runtime_error(
"Number of ions is different from number of symmetries.");
143 throw std::logic_error(
"Too few spectrum functions.");
147 bool allXYEmpty =
true;
148 bool someXYEmpty =
false;
149 for (
size_t i = 0; i < nSpec; ++i) {
153 throw std::logic_error(
"CrystalFieldSpectrumControl function expected");
157 throw std::runtime_error(
"Vectors in each pair of (FWHMX, FWHMY) "
158 "attributes must have the same size");
160 someXYEmpty = someXYEmpty ||
m_fwhmX[i].empty() ||
m_fwhmY[i].empty();
161 allXYEmpty = allXYEmpty &&
m_fwhmX[i].empty() &&
m_fwhmY[i].empty();
166 throw std::runtime_error(
"No peak width settings (FWHMs and FWHMX and "
167 "FWHMY attributes not set).");
168 }
else if (someXYEmpty) {
170 throw std::runtime_error(
"FWHMX, FWHMY attributes are not given for all spectra.");
172 }
else if (
m_FWHMs.size() != nSpec) {
178 throw std::runtime_error(
"Vector of FWHMs must either have same size as "
182 }
else if (!allXYEmpty) {
184 throw std::runtime_error(
"Either FWHMs or (FWHMX and FWHMY) can be set but not all.");
187 throw std::runtime_error(
"No temperatures are set.");
204 for (
size_t i = 0; i < nSpec; ++i) {
262 throw std::runtime_error(
"No tmperature was set.");
265 source->setAttributeValue(
"Ion",
m_ions[0]);
276 source->setAttributeValue(
"Ion",
m_ions[0]);
286 auto nSites =
m_ions.size();
289 for (
size_t i = 0; i < nSites; ++i) {
291 source->addFunction(peakSource);
292 peakSource->setAttributeValue(
"Ion",
m_ions[i]);
293 peakSource->setAttributeValue(
"Symmetry",
m_symmetries[i]);
296 peakSource->setAttributeValue(
"Temperature", temperature);
304 auto nSites =
m_ions.size();
305 for (
size_t i = 0; i < nSites; ++i) {
307 source->addFunction(peakSource);
308 peakSource->setAttributeValue(
"Ion",
m_ions[i]);
309 peakSource->setAttributeValue(
"Symmetry",
m_symmetries[i]);
322 declareParameter(
"IntensityScaling", 1.0,
"Scales intensities of peaks in a spectrum.");
double value
The value of the point.
A composite function is a function containing other functions.
virtual size_t addFunction(IFunction_sptr f)
Add a function at the back of the internal function list.
void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Declare a single attribute.
std::size_t nFunctions() const override
Number of functions.
Attribute getAttribute(const std::string &name) const override
Return a value of attribute attName.
std::string name() const override
Returns the function's name.
IFunction_sptr getFunction(std::size_t i) const override
Returns the pointer to i-th function.
Base class that represents the domain of a function.
A class to store values calculated by a function.
Attribute is a non-fitting parameter.
std::string asUnquotedString() const
Returns a string value that is guarenteed to be unquoted.
std::vector< double > asVector() const
Returns vector<double> if attribute is vector<double>, throws exception otherwise.
std::string asString() const
Returns string value if attribute is a string, throws exception otherwise.
virtual Attribute getAttribute(const std::string &name) const
Return a value of attribute attName.
void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Declare a single attribute.
virtual void setAttribute(const std::string &name, const Attribute &)
Set a value to attribute attName.
void setAttributeValue(const std::string &attName, const T &value)
Set an attribute value.
Implements the part of IFunction interface dealing with parameters.
void declareParameter(const std::string &name, double initValue=0, const std::string &description="") override
Declare a new parameter.
void setAttribute(const std::string &name, const Attribute &) override
Set a value to attribute.
API::IFunction_sptr buildSingleSiteSingleSpectrum()
Build the source function in a single site - single spectrum case.
void cacheAttributes()
Cache the attributes.
const std::vector< double > & temperatures() const
void buildPhysPropControls()
Build control functions for phys properties.
API::IFunction_sptr buildSource()
Build the source function.
std::vector< std::string > m_physProps
The physical properties.
std::vector< std::vector< double > > m_fwhmY
void checkConsistent()
Check that everything is consistent.
API::IFunction_sptr buildMultiSiteSingleSpectrum()
Build the source function in a multi site - single spectrum case.
API::IFunction_sptr buildSingleSiteMultiSpectrum()
Build the source function in a single site - multi spectrum case.
void buildControls()
Build control functions for individual spectra.
const std::vector< std::string > & physProps() const
API::IFunction_sptr buildSingleSite()
Build the source function in a single site case.
std::vector< double > m_temperatures
The temperatures.
void parseStringListAttribute(const std::string &attName, const std::string &value, std::vector< std::string > &cache)
Parse a comma-separated list attribute.
std::vector< std::string > m_ions
const std::vector< double > & FWHMs() const
API::IFunction_sptr buildMultiSiteMultiSpectrum()
Build the source function in a multi site - multi spectrum case.
bool hasPhysProperties() const
Check if there are any phys. properties.
bool isMultiSpectrum() const
Is it a multi-spectrum case?
bool isMultiSite() const
Are there multiple ions?
std::vector< double > m_FWHMs
Cache the default peak FWHMs.
std::vector< std::string > m_symmetries
The symmetries.
bool hasPeaks() const
Any peaks defined?
API::IFunction_sptr buildMultiSite()
Build the source function in a multi site case.
std::vector< std::vector< double > > m_fwhmX
Caches of the width functions.
CrystalFieldPeaks is a function that calculates crystal field peak positions and intensities.
CrystalFieldPhysPropControl()
std::string name() const override
Returns the function's name.
void function(const API::FunctionDomain &, API::FunctionValues &) const override
Evaluates the function for all arguments in the domain.
void function(const API::FunctionDomain &, API::FunctionValues &) const override
Evaluates the function for all arguments in the domain.
CrystalFieldSpectrumControl()
std::string name() const override
Returns the function's name.
Marks code as not implemented yet.
Iterator begin()
Iterator referring to first element in the container.
@ TOK_TRIM
remove leading and trailing whitespace from tokens
Iterator end()
Iterator referring to the past-the-end element in the container.
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Mantid::Kernel::StringTokenizer tokenizer
std::shared_ptr< CompositeFunction > CompositeFunction_sptr
shared pointer to the composite function base class
DLLExport std::string join(ITERATOR_TYPE begin, ITERATOR_TYPE end, const std::string &separator, typename std::enable_if<!(std::is_same< typename std::iterator_traits< ITERATOR_TYPE >::iterator_category, std::random_access_iterator_tag >::value)>::type *=nullptr)
Join a set or vector of (something that turns into a string) together into one string,...
std::string to_string(const wide_integer< Bits, Signed > &n)