ATLAS Offline Software
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloGpu
src
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
12
void
Rand4Hits::destroyCPUGen
() {
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
}
cpu_randgen_t
#define cpu_randgen_t
Definition
Rand4Hits_cpu.cxx:5
Rand4Hits::destroyCPUGen
void destroyCPUGen()
Definition
Rand4Hits_cpu.cxx:12
Rand4Hits::createCPUGen
void createCPUGen(unsigned long long seed)
Definition
Rand4Hits_cpu.cxx:7
Rand4Hits::m_gen
void * m_gen
Definition
Rand4Hits.h:67
Rand4Hits::m_rnd_cpu
std::vector< float > m_rnd_cpu
Definition
Rand4Hits.h:80
Rand4Hits::genCPU
float * genCPU(size_t num)
Definition
Rand4Hits_cpu.cxx:16
Generated on
for ATLAS Offline Software by
1.14.0