7 #ifndef ICARUSALG_UTILITIES_FASTANDPOORGAUSS_H
8 #define ICARUSALG_UTILITIES_FASTANDPOORGAUSS_H
15 #include <type_traits>
21 namespace util::details {
28 static_assert(std::is_integral_v<T>);
29 if constexpr(std::is_signed_v<T>)
if (value < 0)
return false;
31 if (value & 1)
return (value == 1);
32 }
while (value >>= 1);
45 template <std::
size_t N,
typename T>
93 template <std::
size_t N,
typename T =
double>
135 template <
typename T>
160 {
return mean + z * stddev; }
191 template <
typename T =
double>
211 unsigned int const fN;
227 template <std::
size_t N,
typename T>
233 template <std::
size_t N,
typename T>
235 return static_cast<std::size_t
>(u * NPoints);
240 template <std::
size_t N,
typename T>
244 std::array<Data_t, NPoints> samples;
246 double const V2 = std::sqrt(2.0);
251 value =
static_cast<Data_t>(TMath::ErfInverse(extract() * 2.0 - 1.0) * V2);
260 template <
typename T>
262 unsigned int i = fNext;
263 if (++fNext == fN) reset();
271 #endif // ICARUSALG_UTILITIES_FASTANDPOORGAUSS_H
T Data_t
Type of data to deal with.
Data_t transform(Data_t const u) const
Returns the Gaussian distributed value corresponding to u.
process_name opflash particleana ie ie ie z
static std::array< Data_t, N > const fSamples
Sampled points of inverse Gaussian.
std::size_t indexOf(Data_t u) const
Returns the index of the precomputed table serving the value u.
Translates a number u uniformly distributed between 0 and 1 into a Gaussian distributed one z...
Data_t operator()(Data_t const u) const
constexpr bool isPowerOfTwo(T value)
Returns whether the integral type value is a power of 2.
static constexpr std::size_t NPoints
Number of sampled points.
static std::array< Data_t, NPoints > makeSamples()
Fills the pre-sampling table.
process_name largeant stream1 can override from command line with o or output physics producers generator N