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

47 lines
1.9 KiB
C++
Executable File

#ifndef EVENT_POSITION_DISTRIBUTION_H
#define EVENT_POSITION_DISTRIBUTION_H
#include <memory>
#include <random>
#include "simulation/coordinates.h"
#include "simulation/scalar_field.h"
// structure for storing a minimum and maximum value
struct Limit {
Limit() : min(0), max(0){};
Limit(double min, double max) : min(min), max(max){};
double min;
double max;
};
// class for drawing positions
class EventPositionDistribution {
public:
// Constructor: takes a shared_ptr to a ScalarField used as the distribution to be drawn from
// a Limit density containing the maximum value of the mother_density within the position limits (used for rejection method)
// a Limit r_position defining the region in r-direction, where positions are drawn from
// a Limit z_position defining the region in z-direction, where positions are drawn from
// a Limit phi_position defining the region in phi-direction, where positions are drawn from
EventPositionDistribution(std::shared_ptr<ScalarField> mother_density,
Limit density,
Limit r_position,
Limit phi_position,
Limit z_position);
// draw a position from the ScalarField using the given mt19937 engine pointer as a CylinderCoordinate
// using the rejection method
CylinderCoordinate rollPosition(std::mt19937* engine);
private:
// ScalarField defining the distribution
std::shared_ptr<ScalarField> mother_density_;
// distribution functions drawn to be drawn from in the rejection method
std::uniform_real_distribution<double> r_values;
std::uniform_real_distribution<double> z_values;
std::uniform_real_distribution<double> phi_values;
std::uniform_real_distribution<double> density_values;
};
#endif /* EVENT_POSITION_DISTRIBUTION_H */