Skip to content

Commit

Permalink
feat: Add num-vertex option to PG, error check (#939)
Browse files Browse the repository at this point in the history
Add a `--gen-nvertex` option to `ActsExampleParticleGun` which allows setting the event multiplicity. Also adds functionality to `Acts::MultiIndex` to retrieve the number of bits per level, and use this to do error checks on the input parameters in `ActsExampleParticleGun`.
  • Loading branch information
paulgessinger committed Aug 16, 2021
1 parent b47fe06 commit 42a362c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Core/include/Acts/Utilities/MultiIndex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class MultiIndex {
return (m_value & ~maskLower) | maskLower;
}

/// Get the number of bits for the associated level
static constexpr std::size_t bits(std::size_t lvl) {
assert((lvl < NumLevels) and "Index level outside allowed range");
return s_bits[lvl];
}

private:
// per-level mask and right-most bit position for shifting
static constexpr std::array<std::size_t, NumLevels> s_bits{BitsPerLevel...};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ void ActsExamples::Options::addParticleGunOptions(Description& desc) {
opt("gen-randomize-charge", bool_switch(),
"Flip the charge and change the PDG number accordingly.");
opt("gen-nparticles", value<size_t>()->default_value(1u),
"Number of generated particles");
"Number of generated particles per vertex");
opt("gen-nvertices", value<size_t>()->default_value(1u),
"Number of generated vertices");
}

ActsExamples::EventGenerator::Config
Expand Down Expand Up @@ -80,9 +82,20 @@ ActsExamples::Options::readParticleGunOptions(const Variables& vars) {
pgCfg.randomizeCharge = vars["gen-randomize-charge"].template as<bool>();
pgCfg.numParticles = vars["gen-nparticles"].as<size_t>();

if (pgCfg.numParticles > std::pow(2, ActsFatras::Barcode::bits(2))) {
throw std::runtime_error{
"Too many particles per vertex requested for Fatras Barcode"};
}

size_t nVertices = vars["gen-nvertices"].as<size_t>();

if (nVertices > std::pow(2, ActsFatras::Barcode::bits(0))) {
throw std::runtime_error{"Too many vertices requested for Fatras Barcode"};
}

EventGenerator::Config cfg;
cfg.generators = {
{FixedMultiplicityGenerator{1}, std::move(vertexGen),
{FixedMultiplicityGenerator{nVertices}, std::move(vertexGen),
ParametricParticleGenerator(pgCfg)},
};

Expand Down

0 comments on commit 42a362c

Please sign in to comment.