16 #include "Base/Const/Units.h"
17 #include "Base/Util/Assert.h"
18 #include "Device/Beam/Beam.h"
19 #include "Device/Beam/IFootprintFactor.h"
31 #include "Param/Distrib/RangedDistributions.h"
32 #include "Resample/Options/SimulationOptions.h"
33 #include "Sample/Multilayer/MultiLayer.h"
34 #include "Sim/Background/IBackground.h"
35 #include "Sim/Scan/AlphaScan.h"
36 #include "Sim/Scan/ScanResolution.h"
37 #include "Sim/Simulation/includeSimulations.h"
44 void setParameterDistributionToSimulation(ParameterDistribution::WhichParameter which,
47 const auto*
const parameter_item =
dynamic_cast<const T*
>(item);
48 ASSERT(parameter_item);
50 auto par_distr = parameter_item->getParameterDistributionForName(which);
52 simulation.addParameterDistribution(*par_distr);
56 void addDistributionParametersToSimulation(
const BeamItem& item, ScatteringSimulation& simulation)
60 setParameterDistributionToSimulation<BeamWavelengthItem>(ParameterDistribution::BeamWavelength,
62 setParameterDistributionToSimulation<BeamInclinationAngleItem>(
64 setParameterDistributionToSimulation<BeamAzimuthalAngleItem>(
68 void addBackgroundToSimulation(
const InstrumentItem& item, ISimulation& simulation)
71 simulation.setBackground(*background);
84 auto ranged_distr = distr_item->createIRangedDistribution(scale);
88 const double deviation = distr_item->deviation(scale);
89 return std::unique_ptr<ScanResolution>(
90 ScanResolution::scanAbsoluteResolution(*ranged_distr, deviation));
102 ScatteringSimulation* createScatteringSimulation(std::unique_ptr<MultiLayer> sample,
107 addDistributionParametersToSimulation(*item->
beamItem(), *result);
109 addBackgroundToSimulation(*item, *result);
114 OffspecSimulation* createOffspecSimulation(std::unique_ptr<MultiLayer> sample,
120 const auto axis = item->alphaAxis().createAxis(Units::deg);
121 result->setBeamParameters(beamItem->wavelength(), *axis, beamItem->getAzimuthalAngle());
123 addBackgroundToSimulation(*item, *result);
128 SpecularSimulation* createSpecularSimulation(std::unique_ptr<MultiLayer> sample,
133 auto*
const footprint_item = beam_item->footprint();
135 AlphaScan scan(beam_item->wavelength(), *axis_item->createAxis(Units::deg));
136 scan.setFootprintFactor(footprint_item->createFootprint().get());
138 if (
const auto resolution = createScanResolution(beam_item->wavelengthItem()))
139 scan.setWavelengthResolution(*resolution);
140 if (
const auto resolution = createScanResolution(beam_item->inclinationAngleItem()))
141 scan.setAngleResolution(*resolution);
143 auto* result =
new SpecularSimulation(scan, *sample);
146 addBackgroundToSimulation(*item, *result);
151 DepthProbeSimulation* createDepthProbeSimulation(std::unique_ptr<MultiLayer> sample,
160 std::unique_ptr<ISimulation>
166 ASSERT(instrumentItem);
169 std::unique_ptr<ISimulation> result;
171 if (
const auto* gisasInstrument =
dynamic_cast<const GISASInstrumentItem*
>(instrumentItem))
172 result.reset(createScatteringSimulation(std::move(sample), gisasInstrument));
173 else if (
const auto* offspecInstrument =
175 result.reset(createOffspecSimulation(std::move(sample), offspecInstrument));
176 else if (
const auto* specular_instrument =
178 result.reset(createSpecularSimulation(std::move(sample), specular_instrument));
180 result.reset(createDepthProbeSimulation(std::move(sample), penetrator));
184 setSimulationOptions(result.get(), optionsItem);
Defines various axis items.
Defines BackgroundItem classes.
Defines class BeamAngleItems.
Defines class BeamWavelengthItem.
Defines class InstrumentItem and all its children.
Defines class Instrument.
Defines class MultiLayerItem.
Defines namespace GUI::Transform::ToCore.
Defines class SimulationOptionsItem.
Defines namespace GUI::Transform::ToCore.
virtual std::unique_ptr< IBackground > createBackground() const =0
The BeamDistributionItem handles wavelength, inclination and azimuthal parameter distribution for Bea...
DistributionItem * distribution() const
virtual double scaleFactor() const
virtual BeamDistributionItem * inclinationAngleItem() const
BeamAzimuthalAngleItem * azimuthalAngleItem() const
BeamWavelengthItem * wavelengthItem() const
DepthProbeSimulation * createSimulation(const MultiLayer &sample) const
ScatteringSimulation * createScatteringSimulation(const MultiLayer &sample) const
OffspecSimulation * createOffspecSimulation(const MultiLayer &sample) const
Abstract base class for instrument-specific item classes.
virtual BeamItem * beamItem() const
BackgroundItem * backgroundItem() const
The SimulationOptionsItem class holds simulation status (run policy, number of threads,...
bool includeSpecularPeak() const
unsigned numberOfThreads() const
bool useAverageMaterials() const
unsigned numberOfMonteCarloPoints() const
bool useMonteCarloIntegration() const
BasicAxisItem * inclinationAxis() const
SpecularBeamItem * beamItem() const override