BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleLabelHandler.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Export/SampleLabelHandler.cpp
6 //! @brief Implement class SampleLabelHandler.
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 
24 #include <set>
25 
27 {
28  return m_CrystalLabel[cr];
29 }
30 
32 {
33  return m_FormFactorLabel[ff];
34 }
35 
37 {
38  return m_InterferenceFunctionLabel[iff];
39 }
40 
41 std::string SampleLabelHandler::labelLayer(const Layer* layer)
42 {
43  return m_LayerLabel[layer];
44 }
45 
46 std::string SampleLabelHandler::labelLayout(const ILayout* layout)
47 {
48  return m_ILayoutLabel[layout];
49 }
50 
52 {
53  return m_MaterialLabel[mat];
54 }
55 
57 {
58  return m_LatticeLabel[lat];
59 }
60 
62 {
63  return m_MultiLayerLabel[ml];
64 }
65 
67 {
68  if (const auto core_shell_particle = dynamic_cast<const ParticleCoreShell*>(absparticle))
69  return m_ParticleCoreShellLabel[core_shell_particle];
70  if (const auto particle = dynamic_cast<const Particle*>(absparticle))
71  return m_ParticleLabel[particle];
72  if (const auto particle = dynamic_cast<const ParticleDistribution*>(absparticle))
73  return m_ParticleDistributionLabel[particle];
74  if (const auto lattice_basis = dynamic_cast<const ParticleComposition*>(absparticle))
75  return m_ParticleCompositionLabel[lattice_basis];
76  if (const auto mesocrystal = dynamic_cast<const MesoCrystal*>(absparticle))
77  return m_MesoCrystalLabel[mesocrystal];
79  "SampleLabelHandler::getLabel: called for unknown IParticle type");
80 }
81 
83 {
84  return m_RotationsLabel[rot];
85 }
86 
88 {
89  return m_LayerRoughnessLabel[roughness];
90 }
91 
93 {
94  std::string label = "crystal_" + std::to_string(m_CrystalLabel.size() + 1);
95  m_CrystalLabel.insert(sample, label);
96 }
97 
99 {
100  std::string label = "formFactor_" + std::to_string(m_FormFactorLabel.size() + 1);
101  m_FormFactorLabel.insert(sample, label);
102 }
103 
105 {
106  std::string label = "interference_" + std::to_string(m_InterferenceFunctionLabel.size() + 1);
107  m_InterferenceFunctionLabel.insert(sample, label);
108 }
109 
111 {
112  std::string label = "layer_" + std::to_string(m_LayerLabel.size() + 1);
113  m_LayerLabel.insert(sample, label);
114 }
115 
117 {
118  std::string label = "layout_" + std::to_string(m_ILayoutLabel.size() + 1);
119  m_ILayoutLabel.insert(sample, label);
120 }
121 
123 {
124  for (auto it = m_MaterialLabel.begin(); it != m_MaterialLabel.end(); ++it) {
125  if (*(it->first) == *mat) {
126  m_MaterialLabel.insert(mat, it->second);
127  return;
128  }
129  }
130  // material not found => create new label
131  std::set<std::string> unique_labels;
132  for (auto it = m_MaterialLabel.begin(); it != m_MaterialLabel.end(); ++it)
133  unique_labels.insert(it->second);
134 
135  std::string label = "material_" + std::to_string(unique_labels.size() + 1);
136  m_MaterialLabel.insert(mat, label);
137 }
138 
140 {
141  std::string label = "lattice_" + std::to_string(m_LatticeLabel.size() + 1);
142  m_LatticeLabel.insert(sample, label);
143 }
144 
146 {
147  std::string label = "mesocrystal_" + std::to_string(m_MesoCrystalLabel.size() + 1);
148  m_MesoCrystalLabel.insert(sample, label);
149 }
150 
152 {
153  std::string label = "multiLayer_" + std::to_string(m_MultiLayerLabel.size() + 1);
154  m_MultiLayerLabel.insert(sample, label);
155 }
156 
158 {
159  std::string label =
160  "particleComposition_" + std::to_string(m_ParticleCompositionLabel.size() + 1);
161  m_ParticleCompositionLabel.insert(sample, label);
162 }
163 
165 {
166  std::string label =
167  "particleDistribution_" + std::to_string(m_ParticleDistributionLabel.size() + 1);
168  m_ParticleDistributionLabel.insert(sample, label);
169 }
170 
172 {
173  std::string label = "particle_" + std::to_string(m_ParticleLabel.size() + 1);
174  m_ParticleLabel.insert(sample, label);
175 }
176 
178 {
179  std::string label = "particleCoreShell_" + std::to_string(m_ParticleCoreShellLabel.size() + 1);
180  m_ParticleCoreShellLabel.insert(sample, label);
181 }
182 
184 {
185  std::string label = "rotation_" + std::to_string(m_RotationsLabel.size() + 1);
186  m_RotationsLabel.insert(sample, label);
187 }
188 
190 {
191  if (sample->getSigma() != 0 && sample->getHurstParameter() != 0
192  && sample->getLatteralCorrLength() != 0) {
193  std::string label = "layerRoughness_" + std::to_string(m_LayerRoughnessLabel.size() + 1);
194  m_LayerRoughnessLabel.insert(sample, label);
195  }
196 }
Defines and implements the interface class IInterferenceFunction.
Defines class LayerRoughness.
Defines class MesoCrystal.
Defines class MultiLayer.
Defines class ParticleComposition.
Defines ParticleCoreShell.
Defines class ParticleDistribution.
Defines class Particle.
Defines classes LabelMap and SampleLabelHandler.
A crystal structure with a ParticleComposition as a basis.
Definition: Crystal.h:26
Interface for a generic particle.
Pure virtual base class for all form factors.
Definition: IFormFactor.h:40
Pure virtual base class of interference functions.
Pure virtual interface class to equip a sample layer with scattering properties.
Definition: ILayout.h:32
Pure virtual interface for rotations.
Definition: Rotations.h:27
A lattice with three basis vectors.
Definition: Lattice.h:28
A roughness of interface between two layers.
double getSigma() const
Returns rms of roughness.
double getLatteralCorrLength() const
Returns lateral correlation length.
double getHurstParameter() const
Returns hurst parameter.
A layer, with thickness (in nanometer) and material.
Definition: Layer.h:28
A wrapper for underlying material implementation.
Definition: Material.h:29
A particle with an internal structure of smaller particles.
Definition: MesoCrystal.h:26
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:42
const_iterator end() const
Definition: OrderedMap.h:47
size_t size() const
Definition: OrderedMap.h:51
void insert(const Key &key, const Object &object)
Definition: OrderedMap.h:59
const_iterator begin() const
Definition: OrderedMap.h:46
A composition of particles at fixed positions.
A particle with a core/shell geometry.
A particle type that is a parametric distribution of IParticle's.
A particle with a form factor and refractive index.
Definition: Particle.h:26
void insertRotation(const IRotation *sample)
std::string labelLayer(const Layer *sample)
void insertInterferenceFunction(const IInterferenceFunction *sample)
void insertFormFactor(const IFormFactor *sample)
particledistributions_t m_ParticleDistributionLabel
std::string labelParticle(const IAbstractParticle *sample)
std::string labelRotation(const IRotation *sample)
void insertRoughness(const LayerRoughness *sample)
void insertMesoCrystal(const MesoCrystal *sample)
particlecompositions_t m_ParticleCompositionLabel
std::string labelInterferenceFunction(const IInterferenceFunction *sample)
std::string labelMultiLayer(const MultiLayer *sample)
void insertMultiLayer(const MultiLayer *sample)
mesocrystals_t m_MesoCrystalLabel
particlescoreshell_t m_ParticleCoreShellLabel
void insertParticleCoreShell(const ParticleCoreShell *sample)
rotations_t m_RotationsLabel
std::string labelLattice(const Lattice *sample)
roughnesses_t m_LayerRoughnessLabel
std::string labelLayout(const ILayout *sample)
formfactors_t m_FormFactorLabel
void insertLattice(const Lattice *sample)
std::string labelCrystal(const Crystal *sample)
void insertParticle(const Particle *sample)
void insertCrystal(const Crystal *sample)
std::string labelRoughness(const LayerRoughness *sample)
void insertMaterial(const Material *sample)
interferences_t m_InterferenceFunctionLabel
void insertParticleComposition(const ParticleComposition *sample)
void insertParticleDistribution(const ParticleDistribution *sample)
void insertLayout(const ILayout *sample)
multilayers_t m_MultiLayerLabel
std::string labelMaterial(const Material *sample)
std::string labelFormFactor(const IFormFactor *sample)
void insertLayer(const Layer *sample)