Warning, file /include/DDDigi/DigiRandomEngine.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDDIGI_DIGIRANDOMENGINE_H
0014 #define DDDIGI_DIGIRANDOMENGINE_H
0015 #if 0
0016
0017
0018
0019
0020 #include <random>
0021 #include <functional>
0022
0023
0024 namespace dd4hep {
0025
0026
0027 namespace digi {
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 class DigiRandomEngine {
0039 public:
0040 typedef unsigned int result_type;
0041 std::function<double()> m_generator;
0042 public:
0043
0044 template <typename ENGINE> DigiRandomEngine(ENGINE* engine);
0045
0046 virtual ~DigiRandomEngine();
0047 static constexpr result_type min() { return std::default_random_engine::min(); }
0048 static constexpr result_type max() { return std::default_random_engine::max(); }
0049 static constexpr double range() { return double(max()) - double(min()); }
0050
0051 unsigned int operator()() const { return m_generator(); }
0052 };
0053
0054 template <typename ENGINE> DigiRandomEngine::DigiRandomEngine(ENGINE* engine) {
0055 m_generator = [this,engine]() {
0056 static constexpr double norm =
0057 DigiRandomEngine::range() / (double(ENGINE::max() - ENGINE::min()));
0058 return result_type(double((*engine())) * norm);
0059 };
0060 }
0061 }
0062 }
0063 #endif
0064 #endif