6#include <magic_enum/magic_enum.hpp>
7#include <range/v3/view/zip.hpp>
15 inline auto check_if_within_range(
double value, std::pair<double, double> min_max) ->
bool
18 if (min_max.first == min_max.second)
22 if (min_max.first < min_max.second)
24 return (value > min_max.first) and (value < min_max.second);
26 return (value > min_max.first) or (value < min_max.second);
32 if (options.particle_names.size() != options.energy_range_maxs.size())
35 "Number of particle types specified (={}) is not equal to the number of range maximum (={}).",
36 options.particle_names.size(),
37 options.energy_range_maxs.size()));
39 if (options.particle_names.size() != options.energy_range_mins.size())
42 "Number of particle types specified (={}) is not equal to the number of range minimum (={}).",
43 options.particle_names.size(),
44 options.energy_range_mins.size()));
48 filter.SetMaxEnergy(options.global_max_energy);
49 filter.SetMinEnergy(options.global_min_energy);
51 for (
auto [type, range_min, range_max] :
52 ranges::views::zip(options.particle_names, options.energy_range_mins, options.energy_range_maxs))
54 filter.AddParticle(type, range_min, range_max);
62 if (not check_if_within_range(neuland_point.GetEnergyLoss(),
63 std::pair{ minimum_allowed_energy_, maximum_allowed_energy_ }))
85 list_.emplace(pid, std::pair{ min_energy, max_energy });
89 list_.at(pid) = std::pair{ min_energy, max_energy };
95 const auto particle_pid = neuland_point.GetPID();
98 return check_if_within_range(neuland_point.GetEnergyLoss(),
list_.at(particle_pid));
105 const auto particle_pid = neuland_point.GetPID();
108 return not check_if_within_range(neuland_point.GetEnergyLoss(),
list_.at(particle_pid));
115 return fmt::format(
"Filter Content: \n"
116 "=============================\n"
118 "-- Global minimun energy:{}\n"
119 "-- Global maximum energy: {}\n"
121 "=============================",
122 magic_enum::enum_name(
mode_),
Mode mode_
Filtering mode.
double maximum_allowed_energy_
global maximum engergy in GeV
ParticleFilter()=default
Default constructor.
auto IsPointAllowed(const R3BNeulandPoint &neuland_point) -> bool
Check if the neuland point is allowed.
auto Print() -> std::string
Print the configuration of the current filter.
auto is_allowed_with_whitelist(const R3BNeulandPoint &neuland_point) -> bool
static auto Create(const Options &options) -> ParticleFilter
Generator for the filter object from the configuration.
std::unordered_map< int32_t, std::pair< double, double > > list_
Whitelist with min energy values [GeV].
void AddParticle(const std::string &particle_name, double min_energy=0., double max_energy=0.)
Add particle to the list.
double minimum_allowed_energy_
global minimum engergy in GeV
auto is_allowed_with_blacklist(const R3BNeulandPoint &neuland_point) -> bool
PDGConverter pdg_converter_
Simulation of NeuLAND Bar/Paddle.
Option structure to create a filter.