Skip to content

Commit fd1f139

Browse files
shahor02sawenzel
authored andcommitted
Fix in InteractionSampler for mu>100
For very large per-BC interaction rate (>100, i.e. IR > 1e9 with default bunch filling) the interacting BC sampling was stuck due to the numerical limitations of truncated Poisson generation algo.
1 parent 1a3e8be commit fd1f139

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Steer/include/Steer/InteractionSampler.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,14 @@ inline int InteractionSampler::genPoissonZT()
107107
// generate 0-truncated poisson number
108108
// https://en.wikipedia.org/wiki/Zero-truncated_Poisson_distribution
109109
int k = 1;
110-
double t = mMuBCZTRed, u = gRandom->Rndm(), s = t;
111-
while (s < u) {
112-
s += t *= mMuBC / (++k);
110+
if (mMuBCZTRed > 0) {
111+
double t = mMuBCZTRed, u = gRandom->Rndm(), s = t;
112+
while (s < u) {
113+
s += t *= mMuBC / (++k);
114+
}
115+
} else { // need to generate explicitly since the prob of
116+
while (!(k = gRandom->Poisson(mMuBC))) {
117+
};
113118
}
114119
return k;
115120
}

0 commit comments

Comments
 (0)