12#include "CLHEP/Random/RandomEngine.h"
13#include "CLHEP/Random/RandGeneral.h"
21 : base_class(name,svc)
31 declareProperty(
"MaxBunchCrossingPerOrbit",
m_maxBunchCrossingPerOrbit,
"The number of slots in each LHC beam. Default: 3564.");
33 "An array of floats containing the beam intensity distribution as a function of time in bins of 25ns. ArrayBM normalizes the distribution and uses it as a stencil to determine the relative intensity at each beam xing in the simulated range"
35 declareProperty(
"EmptyBunchOption",
m_emptyBunches=0,
"Option for empty bunches. 0: normal treatment. Positive N: first N BCIDs after filled. Negative N: any empty BCID is allowed.");
55 std::vector<float>::const_iterator pBegin(rProp.begin());
56 std::vector<float>::const_iterator pEnd(rProp.end());
62 return StatusCode::FAILURE;
82 if (rProp[i]>0) sinceFilled=0;
104 float nonZeroElementCount(
static_cast<float>(std::count_if(pBegin, pEnd,
IsNonZero)));
105 if(nonZeroElementCount<1.0)
108 return StatusCode::FAILURE;
110 float elementSum(
static_cast<float>(std::accumulate(pBegin, pEnd,0.0)));
111 float denominator(elementSum/nonZeroElementCount);
114 float maxElement(*(std::max_element(pBegin, pEnd)));
115 float inv_maxElement = maxElement != 0 ? 1. / maxElement : 1;
124 ATH_MSG_ERROR(
"All IntensityPattern elements must be >=0. Please fix element #" << i );
125 return StatusCode::FAILURE;
136 if (denominator != 0) {
151 std::make_unique<std::discrete_distribution<unsigned int>>(
154 return StatusCode::SUCCESS;
161 const EventContext& ctx =
162 Gaudi::Hive::currentContext();
165 m_rngWrapper->setSeed(
"BEAMINT", ctx.slot(), event,
run, ctx.evt());
166 CLHEP::HepRandomEngine* rndmEngine = m_rngWrapper->getEngine(ctx);
185 <<
" index " <<
index
A IBeamIntensity service configured with an intensity array The Gaudi::Property<std::vector<float>> d...
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Holds helper functions used by FixedArrayBM and ArrayBM.
static bool IsNonZero(float lumi)
double * m_intensityPattern
normalized intensity pattern. C array to make clhep RandGeneral happy
virtual StatusCode initialize() override final
int m_emptyBunches
Empty bunch option.
Gaudi::Property< std::uint64_t > m_seed
seed for FastReseededPRNG. Non-zero switches to using FastReseededPRNG.
CLHEP::RandGeneral * m_biRandom
shoot random number proportionally to m_intensityPattern
float m_largestElementInPattern
The largest value in the pattern assuming that the pattern has mean value 1.0.
unsigned int m_maxBunchCrossingPerOrbit
max bunch crossings per orbit
virtual float normFactor(int iXing) const override final
ArrayBM(const std::string &name, ISvcLocator *svc)
virtual void selectT0(unsigned int run, unsigned long long event) override final
Gaudi::Property< std::vector< float > > m_intensityPatternProp
user-defined intensity pattern
Gaudi::Hive::ContextSpecificData< unsigned int > m_t0Offset
offset of the t0 wrto our intensity pattern
unsigned int m_ipLength
length of the intensity pattern
std::unique_ptr< std::discrete_distribution< unsigned int > > m_t0Dist
as with m_biRandom, but for FastReseededPRNG
double * m_signalPattern
Additional array for keeping the locations we want signal in By default, will match the intensity pat...
ServiceHandle< IAthRNGSvc > m_randomSvc
the service managing our random seeds/sequences