forked from WCSim/WCSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWCSimRandomParameters.hh
76 lines (69 loc) · 1.94 KB
/
WCSimRandomParameters.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef WCSimRandomParameters_h
#define WCSimRandomParameters_h 1
#include "WCSimRandomMessenger.hh"
#include "WCSimRootOptions.hh"
#include "CLHEP/Random/Random.h"
#include "CLHEP/Random/RanluxEngine.h"
#include "CLHEP/Random/JamesRandom.h"
#include "CLHEP/Random/RanecuEngine.h"
class WCSimRandomParameters
{
public:
WCSimRandomParameters()
{
seed=31415;
generator=RANDOM_E_HEPJAMES;
RandomMessenger = new WCSimRandomMessenger(this);
}
~WCSimRandomParameters() {delete RandomMessenger;}
WCSimRandomGenerator_t GetGenerator() {return generator; }
void SetGenerator(WCSimRandomGenerator_t rng)
{
switch (rng)
{
case RANDOM_E_RANLUX:
{
printf("Setting the random number generator to RANLUX\n");
CLHEP::RanluxEngine *newluxengine = new CLHEP::RanluxEngine(31415,4); // highest luxury level
CLHEP::HepRandom::setTheEngine(newluxengine);
}
break;
case RANDOM_E_RANECU:
{
printf("Setting the random number generator to RANECU\n");
CLHEP::RanecuEngine *newecuengine = new CLHEP::RanecuEngine();
CLHEP::HepRandom::setTheEngine(newecuengine);
}
break;
case RANDOM_E_HEPJAMES:
{
printf("Setting the random number generator to HEPJAMES\n");
CLHEP::HepJamesRandom *newjamesengine = new CLHEP::HepJamesRandom();
CLHEP::HepRandom::setTheEngine(newjamesengine);
}
break;
default:
{
printf("Random number generator type not understood: %d\n",rng);
exit(0);
}
}
};
int GetSeed() {return CLHEP::HepRandom::getTheSeed();}
void SetSeed(int iseed)
{
CLHEP::HepRandom::setTheSeed(iseed);
printf("Setting the Random Seed to: %d\n",iseed);
seed = iseed;
}
void SaveOptionsToOutput(WCSimRootOptions * wcopt)
{
wcopt->SetRandomSeed(seed);
wcopt->SetRandomGenerator(generator);
}
private:
WCSimRandomGenerator_t generator;
int seed;
WCSimRandomMessenger *RandomMessenger;
};
#endif