20 throw std::invalid_argument(
"Missing output collection");
23 throw std::invalid_argument(
"No generators are configured");
26 throw std::invalid_argument(
"Missing random numbers service");
31 return "EventGenerator";
35 return {0
u, SIZE_MAX};
39 std::vector<SimVertex> event;
41 auto rng = m_cfg.randomNumbers->spawnGenerator(ctx);
43 size_t nPrimaryVertices = 0;
45 size_t nSecondaryVertices = 0;
47 size_t nParticlesVertex = 0;
49 size_t nParticles = 0;
51 for (
size_t iGenerate = 0; iGenerate < m_cfg.generators.size(); ++iGenerate) {
52 auto&
generate = m_cfg.generators[iGenerate];
55 for (
size_t n =
generate.multiplicity(rng); 0 <
n; --
n) {
56 nPrimaryVertices += 1;
57 nSecondaryVertices = 0;
65 auto processVertices =
generate.process(rng);
67 for (
auto& processVertex : processVertices) {
68 nSecondaryVertices += 1;
70 processVertex.position4 += vertex;
78 .setVertexPrimary(nPrimaryVertices);
80 const auto pos4 = (vertex +
particle.position4()).eval();
85 for (
auto&
particle : processVertex.incoming) {
87 nParticlesVertex += 1;
89 for (
auto&
particle : processVertex.outgoing) {
91 nParticlesVertex += 1;
94 nParticles += nParticlesVertex;
97 std::move(processVertices.begin(), processVertices.end(),
98 std::back_inserter(event));
101 <<
" primary_vertex=" << nPrimaryVertices
102 <<
" n_secondary_vertices=" << nSecondaryVertices
103 <<
" n_particles=" << nParticlesVertex);
109 std::shuffle(event.begin(),
event.end(), rng);
113 <<
" n_primary_vertices=" << nPrimaryVertices
114 <<
" n_secondary_vertices=" << event.size()
115 <<
" n_particles=" << nParticles);