00001 #ifndef HZZ2L2NU_INCLUDE_TABULATEDRANDOMGENERATOR_H_ 00002 #define HZZ2L2NU_INCLUDE_TABULATEDRANDOMGENERATOR_H_ 00003 00004 #include <limits> 00005 #include <vector> 00006 00007 #include <TTreeReaderValue.h> 00008 00009 #include <Dataset.h> 00010 00011 00027 class TabulatedRngEngine { 00028 public: 00029 using value_t = uint32_t; 00030 00032 TabulatedRngEngine(Dataset &dataset); 00033 00035 constexpr value_t MaxValue() const { 00036 return std::numeric_limits<value_t>::max(); 00037 } 00038 00046 value_t Read(int channel) const; 00047 00060 int Register(int numChannels = 1); 00061 00062 private: 00064 int numChannelsRegistered_; 00065 00067 int const kSeed_ = 1439; 00068 00070 int const kVolume_ = 100'000; 00071 00073 std::vector<value_t> table_; 00074 00076 mutable TTreeReaderValue<ULong64_t> event_; 00077 }; 00078 00079 00089 class TabulatedRandomGenerator { 00090 public: 00098 TabulatedRandomGenerator( 00099 TabulatedRngEngine &engine, int numChannels = 1); 00100 00102 double Gaus(int channel, double mean = 0., double sigma = 1.) const; 00103 00105 double Rndm(int channel) const; 00106 00107 private: 00109 TabulatedRngEngine &engine_; 00110 00112 int numChannels_; 00113 00115 int offset_; 00116 }; 00117 00118 #endif // HZZ2L2NU_INCLUDE_TABULATEDRANDOMGENERATOR_H_ 00119