BornAgain  1.18.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 scattering at grazing incidence
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 {
23 //! Returns list of all angle related parameters used in Core library.
24 std::vector<std::string> angleRelatedParameters()
25 {
26  std::vector<std::string> result{
27  "InclinationAngle", "AzimuthalAngle", "Alpha", "Beta", "Gamma", "Angle"};
28  return result;
29 }
30 } // namespace
31 
32 bool ParameterUtils::isAngleRelated(const std::string& par_name)
33 {
34  static std::vector<std::string> angleRelated = angleRelatedParameters();
35 
36  for (const auto& par : angleRelated) {
37  if (par_name.find(par) != std::string::npos)
38  return true;
39  }
40  return false;
41 }
42 
44  const std::string& parName)
45 {
46  std::unique_ptr<ParameterPool> pool{node.createParameterTree()};
47  return pool->getUniqueMatch(parName)->unit();
48 }
Defines class IParameterized.
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
bool isAngleRelated(const std::string &par_name)
Returns true if given parameter name is related to angles.
std::string poolParameterUnits(const IParameterized &node, const std::string &parName)
Returns units of main parameter.
std::vector< std::string > angleRelatedParameters()
Returns list of all angle related parameters used in Core library.