Files
karl/include/simulation/scattering_angle_distribution.h
2024-12-04 17:15:04 +01:00

66 lines
2.3 KiB
C++
Executable File

#ifndef SCATTERING_ANGLE_DISTRIBUTION_H
#define SCATTERING_ANGLE_DISTRIBUTION_H
#include <map>
#include <memory>
#include <random>
#include <string>
#include <vector>
#include "simulation/energy_binning.h"
// class defining the minimum requirements of a scattering angle distribution
class ScatteringAngleDistribution {
public:
// draw a value for the scattering angle depending on the energy (in eV) and
// the random engine
virtual double roll(std::mt19937* engine, double energy_eV) = 0;
};
// class for an isotropic scattering angle distribution
class IsotropicAngleDistribution : public ScatteringAngleDistribution {
public:
// Constructor: initializes a uniform distribution between (o,2pi)
IsotropicAngleDistribution();
// draw from a uniform distribution
double roll(std::mt19937* engine, double energy_eV = 0.);
private:
std::uniform_real_distribution<double> distribution_;
};
// class for drawing from a piecewise linear scattering angle distribution
class AngleDistributionFromFile : public ScatteringAngleDistribution {
public:
// Constructor: takes string containing the absolute path (including the file)
// that contains the data of the scattering angle distribution
AngleDistributionFromFile(std::string absolute_filepath);
// draw a value from the distribution
double roll(std::mt19937* engine, double energy_eV);
private:
std::shared_ptr<EnergyBinning> energy_binning_;
std::vector<std::piecewise_linear_distribution<double>> angle_distributions_;
};
// class for a composition of two scattering angle distibutions
class CompositeAngleDistribution : public ScatteringAngleDistribution {
public:
// Constructor: takes two ScatteringAngleDistributions and a decider energy (eV)
// if energy_eV < decider energy use lower_distribution
// otherwise use the higher_distribution
CompositeAngleDistribution(
std::shared_ptr<ScatteringAngleDistribution> lower_distribution,
std::shared_ptr<ScatteringAngleDistribution> higher_distribution,
double decider_energy);
// draw a value from the distribution
double roll(std::mt19937* engine, double energy_eV);
private:
std::shared_ptr<ScatteringAngleDistribution> lower_distribution_;
std::shared_ptr<ScatteringAngleDistribution> higher_distribution_;
const double decider_energy_;
};
#endif /* SCATTERING_ANGLE_DISTRIBUTION_H */