Skip to content

Commit 16b64de

Browse files
authored
Merge pull request #52 from rest-for-physics/jgalan_random_review
Reviewing how the random seed is recovered
2 parents 70a32d1 + d6c1468 commit 16b64de

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/TRestAxionDeviationProcess.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ void TRestAxionDeviationProcess::InitProcess() {
119119
fRandom = nullptr;
120120
}
121121

122+
if (fRandom != nullptr) {
123+
delete fRandom;
124+
fRandom = nullptr;
125+
}
122126
fRandom = new TRandom3(fSeed);
123-
if (fSeed == 0) fSeed = fRandom->GetSeed();
127+
fSeed = fRandom->TRandom::GetSeed();
124128
}
125129

126130
///////////////////////////////////////////////

src/TRestAxionGeneratorProcess.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,12 @@ void TRestAxionGeneratorProcess::InitProcess() {
115115
fRandom = nullptr;
116116
}
117117

118+
if (fRandom != nullptr) {
119+
delete fRandom;
120+
fRandom = nullptr;
121+
}
118122
fRandom = new TRandom3(fSeed);
119-
if (fSeed == 0) fSeed = fRandom->GetSeed();
123+
fSeed = fRandom->TRandom::GetSeed();
120124
}
121125

122126
///////////////////////////////////////////////

src/TRestAxionSolarFlux.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,12 @@ void TRestAxionSolarFlux::LoadTables() {
267267
fRandom = nullptr;
268268
}
269269

270+
if (fRandom != nullptr) {
271+
delete fRandom;
272+
fRandom = nullptr;
273+
}
270274
fRandom = new TRandom3(fSeed);
271-
if (fSeed == 0) fSeed = fRandom->GetSeed();
275+
fSeed = fRandom->TRandom::GetSeed();
272276

273277
fTablesLoaded = true;
274278
}

src/TRestAxionTransmissionProcess.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ void TRestAxionTransmissionProcess::InitProcess() {
123123
fXrayWindows.push_back(w);
124124
}
125125
}
126-
127-
// fRandom = new TRandom3(fSeed);
128-
// if (fSeed == 0) fSeed = fRandom->GetSeed();
129126
}
130127

131128
///////////////////////////////////////////////

0 commit comments

Comments
 (0)