ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PHRandomSeed.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHRandomSeed.cc
1
#include "
PHRandomSeed.h
"
2
#include "
recoConsts.h
"
3
4
#include <iostream>
5
#include <queue>
6
#include <random>
7
8
using namespace
std;
9
10
static
queue<unsigned int>
seedqueue
;
11
static
std::mt19937
fRandomGenerator
;
12
static
std::uniform_int_distribution<unsigned int>
fDistribution
;
13
14
bool
PHRandomSeed::fInitialized
(
false
);
15
bool
PHRandomSeed::fFixed
(
false
);
16
int
PHRandomSeed::verbose
(1);
17
18
unsigned
int
PHRandomSeed::GetSeed
()
19
{
20
unsigned
int
iseed;
21
if
(!
seedqueue
.empty())
22
{
23
iseed =
seedqueue
.front();
24
seedqueue
.pop();
25
}
26
else
27
{
28
if
(!fInitialized)
29
{
30
InitSeed();
31
}
32
if
(fFixed)
33
{
34
iseed =
fDistribution
(
fRandomGenerator
);
35
}
36
else
37
{
38
std::random_device rdev;
39
iseed = rdev();
40
}
41
}
42
if
(verbose)
43
{
44
cout <<
"PHRandomSeed::GetSeed() seed: "
<< iseed << endl;
45
}
46
return
iseed;
47
}
48
49
void
PHRandomSeed::InitSeed
()
50
{
51
recoConsts
*rc =
recoConsts::instance
();
52
if
(rc->
FlagExist
(
"RANDOMSEED"
))
53
{
54
// fixed init seed
55
const
unsigned
int
seed
= rc->
get_IntFlag
(
"RANDOMSEED"
);
56
cout <<
"PHRandomSeed: using fixed seed "
<< seed << endl;
57
fRandomGenerator
.seed(seed);
58
fFixed =
true
;
59
fInitialized =
true
;
60
}
61
}
62
63
void
PHRandomSeed::LoadSeed
(
const
unsigned
int
iseed)
64
{
65
seedqueue
.push(iseed);
66
}
67
68
void
PHRandomSeed::Verbosity
(
const
int
iverb)
69
{
70
verbose = iverb;
71
}
coresoftware
blob
master
offline
framework
phool
PHRandomSeed.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:34
using
1.8.2 with
ECCE GitHub integration