BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ParameterUtils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Param/Varia/ParameterUtils.cpp
6 //! @brief Implements namespace ParameterUtils
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
19 #include <memory>
20 
21 namespace {
22 //! Returns list of all angle related parameters used in Core library.
23 std::vector<std::string> angleRelatedParameters()
24 {
25  std::vector<std::string> result{
26  "InclinationAngle", "AzimuthalAngle", "Alpha", "Beta", "Gamma", "Angle"};
27  return result;
28 }
29 } // namespace
30 
31 bool ParameterUtils::isAngleRelated(const std::string& par_name)
32 {
33  static std::vector<std::string> angleRelated = angleRelatedParameters();
34 
35  for (const auto& par : angleRelated) {
36  if (par_name.find(par) != std::string::npos)
37  return true;
38  }
39  return false;
40 }
41 
43  const std::string& parName)
44 {
45  std::unique_ptr<ParameterPool> pool{node.createParameterTree()};
46  return pool->getUniqueMatch(parName)->unit();
47 }
Defines interface IParametricComponent.
Defines class ParameterPool.
Defines namespace ParameterUtils.
Defines class RealParameter.
Manages a local parameter pool, and a tree of child pools.
virtual ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.
RealParameter * getUniqueMatch(const std::string &pattern) const
Returns the one parameter that matches the pattern (wildcards '*' allowed), or throws.
std::string unit() const
std::string poolParameterUnits(const IParametricComponent &node, const std::string &parName)
Returns units of main parameter.
bool isAngleRelated(const std::string &par_name)
Returns true if given parameter name is related to angles.