ATLAS Offline Software
Rand4Hits_cpu.cxx
Go to the documentation of this file.
1 #include <random>
2 #include <vector>
3 #include <algorithm>
4 
5 #define cpu_randgen_t std::mt19937
6 
7 void Rand4Hits::createCPUGen( unsigned long long seed ) {
8  cpu_randgen_t* eng = new cpu_randgen_t( seed );
9  m_gen = (void*)eng;
10 }
11 
13  if ( m_gen ) { delete (cpu_randgen_t*)m_gen; }
14 }
15 
16 float* Rand4Hits::genCPU( size_t num ) {
17  m_rnd_cpu.resize( num );
18 
19  cpu_randgen_t* eng = (cpu_randgen_t*)( m_gen );
20 
21  auto RNG = [eng]( float low, float high ) {
22  auto randomFunc = [distribution_ = std::uniform_real_distribution<float>( low, high ),
23  random_engine_ = *eng]() mutable { return distribution_( random_engine_ ); };
24  return randomFunc;
25  };
26 
27  std::generate_n( m_rnd_cpu.begin(), num, RNG( 0.f, 1.f ) );
28 
29  return m_rnd_cpu.data();
30 }
Rand4Hits::createCPUGen
void createCPUGen(unsigned long long seed)
Definition: Rand4Hits_cpu.cxx:7
Rand4Hits::genCPU
float * genCPU(size_t num)
Definition: Rand4Hits_cpu.cxx:16
cpu_randgen_t
#define cpu_randgen_t
Definition: Rand4Hits_cpu.cxx:5
hist_file_dump.f
f
Definition: hist_file_dump.py:135
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
Rand4Hits::m_rnd_cpu
std::vector< float > m_rnd_cpu
Definition: Rand4Hits.h:80
Rand4Hits::destroyCPUGen
void destroyCPUGen()
Definition: Rand4Hits_cpu.cxx:12
RngCompsConfig.RNG
def RNG(engine="dSFMT", name="AthRNGSvc")
Definition: RngCompsConfig.py:43
Rand4Hits::m_gen
void * m_gen
Definition: Rand4Hits.h:67