-
Notifications
You must be signed in to change notification settings - Fork 1
/
CustomRand.cxx
109 lines (72 loc) · 2.2 KB
/
CustomRand.cxx
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "CustomRand.hxx"
#include "TF1.h"
#include "TMath.h"
#include "TRandom3.h"
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
CustomRand::CustomRand(const char * fname,
double ERange[2],
double ThetaRange[2],
double PhiRange[2])
{
extern int Gen_seed;
PartSet = true;
int seed = 0;
cout << "Seed setting: " << Gen_seed << endl;
// exit(0);
if(gRandom) delete gRandom;
gRandom = new TRandom3(0);
gRandom -> SetSeed(seed);
char PhiName[100] = "Phi_";
strcat(PhiName, fname);
PhiRand = new TF1(PhiName, "1", PhiRange[0], PhiRange[1]);
char ThetaName[100] = "Theta_";
strcat(ThetaName, fname);
// ThetaRand = new TF1(ThetaName, "1",
// TMath::Cos(ThetaRange[0]),
// TMath::Cos(ThetaRange[1]));
ThetaRand = new TF1(ThetaName, "0.5*sin(x)", ThetaRange[0], ThetaRange[1]);
char EName[100] = "E_%c";
std::sprintf(EName, EName, fname);
ERand = new TF1(EName, "1", ERange[0], ERange[1]);
}
/*--------------------------------------------------*/
CustomRand::CustomRand(const char * fname,
double ERange[2],
double ThetaRange[2],
double PhiRange[2],
int demp_seed)
{
PartSet = true;
int seed = demp_seed;
if(gRandom) delete gRandom;
gRandom = new TRandom3(0);
gRandom -> SetSeed(seed);
char PhiName[100] = "Phi_";
strcat(PhiName, fname);
PhiRand = new TF1(PhiName, "1", PhiRange[0], PhiRange[1]);
char ThetaName[100] = "Theta_";
strcat(ThetaName, fname);
// ThetaRand = new TF1(ThetaName, "1",
// TMath::Cos(ThetaRange[0]),
// TMath::Cos(ThetaRange[1]));
ThetaRand = new TF1(ThetaName, "0.5*sin(x)", ThetaRange[0], ThetaRange[1]);
char EName[100] = "E_%c";
std::sprintf(EName, EName, fname);
ERand = new TF1(EName, "1", ERange[0], ERange[1]);
}
/*--------------------------------------------------*/
double CustomRand::Phi()
{
return PhiRand->GetRandom();
}
double CustomRand::Theta()
{
return ThetaRand->GetRandom();
}
double CustomRand::E()
{
return ERand->GetRandom();
}