8 #include "CLHEP/Random/RandFlat.h"
9 #include "CLHEP/Random/RandomEngine.h"
15 CLHEP::HepRandomEngine* rndmEngine)
const {
16 const double injectionAngle = std::atan2(std::abs(localDir.z()), std::abs(localDir.x())) /
Gaudi::Units::deg;
21 <<
", bin i: "<<ithAngle<<
", bin j: "<<jthAngle);
24 double jitter{0.},
prob{1.}, probRef{0.};
25 const std::vector<double>& ith_probs{
m_bins[ithAngle].timeProbs};
26 const std::vector<double>& jth_probs{
m_bins[jthAngle].timeProbs};
27 unsigned int trials{0};
28 while (
prob > probRef) {
29 prob = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0);
30 jitter = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0) *
m_timeInterval;
31 size_t ithJitter =
static_cast<size_t>(jitter);
34 probRef = (1. - wAngle) * (ithJitter < ith_probs.size() ? ith_probs[ithJitter] : 0.) +
35 wAngle * (ithJitter < jth_probs.size() ? jth_probs[ithJitter] : 0.);
37 <<
", probRef: "<<probRef);
42 m_bins.emplace_back(minAngle, std::move(timeProbs));
47 return StatusCode::FAILURE;
50 for (
size_t b = 0 ;
b <
m_bins.size() - 1; ++
b) {
55 std::numeric_limits<double>::epsilon()) {
57 <<
" to "<<
m_bins[
b].maxAngle<<
" is outside of the fixed interval "
59 return StatusCode::FAILURE;
61 if (
m_bins[
b].timeProbs.empty()) {
62 ATH_MSG_FATAL(
"The angular bin "<<
b<<
" has no probabilities associated.");
63 return StatusCode::FAILURE;
67 return StatusCode::SUCCESS;