R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
NeulandPointFilter.h
Go to the documentation of this file.
1#pragma once
2#include "R3BNeulandPoint.h"
3#include <bitset>
4
5namespace R3B::Neuland
6{
7 enum class BitSetParticle : uint32_t
8 {
9 none = 0x0000,
10 proton = 0x0001,
11 neutron = 0x0002,
12 electron = 0x0004,
13 positron = 0x0008,
14 alpha = 0x0010,
15 gamma = 0x0020,
16 meson = 0x0040,
17 other = 0x40000000
18 };
19
20 const std::unordered_map<int, BitSetParticle> PidToBitSetParticleHash = {
24 };
25
26 constexpr auto ParticleBitsetSize = 32U;
27
28 using ParticleUType = std::underlying_type_t<BitSetParticle>;
29
30 constexpr auto ParticleToBitSet(BitSetParticle particle)
31 {
32 return std::bitset<ParticleBitsetSize>{ static_cast<ParticleUType>(particle) };
33 }
34
35 inline auto BitSetToParticle(std::bitset<ParticleBitsetSize> bits) -> BitSetParticle
36 {
37 return static_cast<BitSetParticle>(static_cast<uint32_t>(bits.to_ulong()));
38 }
39
40 inline auto CheckCriteria(BitSetParticle particle, BitSetParticle criteria) -> bool
41 {
42 return (ParticleToBitSet(particle) & ParticleToBitSet(criteria)) == ParticleToBitSet(particle);
43 }
44
46 {
47 auto left_bitset = ParticleToBitSet(left);
48 auto right_bitset = ParticleToBitSet(right);
49 return BitSetToParticle(left_bitset | right_bitset);
50 }
51
53 {
54 auto left_bitset = ParticleToBitSet(left);
55 auto right_bitset = ParticleToBitSet(right);
56 return BitSetToParticle(left_bitset & right_bitset);
57 }
58
59 inline auto operator~(BitSetParticle particle) -> BitSetParticle
60 {
61 return BitSetToParticle(~ParticleToBitSet(particle));
62 }
63
64 inline auto PidToBitSetParticle(int pid) -> BitSetParticle
65 {
66 if (pid > 99 and pid < 1000) // NOLINT mesons have three digit pdgs
67 {
69 }
70 auto pid_to_bitset_hash_iterator = PidToBitSetParticleHash.find(pid);
71
72 if (pid_to_bitset_hash_iterator == PidToBitSetParticleHash.end())
73 {
75 }
76
77 return pid_to_bitset_hash_iterator->second;
78 }
79
80} // namespace R3B::Neuland
82{
83 public:
84 NeulandPointFilter() = default;
85 void SetFilter(R3B::Neuland::BitSetParticle filtered_particles);
86 void SetFilter(R3B::Neuland::BitSetParticle filtered_particles, double minimum_allowed_energy);
87 [[nodiscard]] auto GetFilter() const -> R3B::Neuland::BitSetParticle { return filtered_particles_; }
88 [[nodiscard]] auto GetMinimumAllowedEnergy() const -> double { return minimum_allowed_energy_; }
89 auto CheckFiltered(const R3BNeulandPoint& neuland_point) -> bool;
90
91 private:
93 double minimum_allowed_energy_ = 0; // engergy in GeV
94};
NeulandPointFilter()=default
void SetFilter(R3B::Neuland::BitSetParticle filtered_particles)
auto GetMinimumAllowedEnergy() const -> double
auto GetFilter() const -> R3B::Neuland::BitSetParticle
auto CheckFiltered(const R3BNeulandPoint &neuland_point) -> bool
Simulation of NeuLAND Bar/Paddle.
constexpr auto ParticleToBitSet(BitSetParticle particle)
const std::unordered_map< int, BitSetParticle > PidToBitSetParticleHash
auto BitSetToParticle(std::bitset< ParticleBitsetSize > bits) -> BitSetParticle
auto operator~(BitSetParticle particle) -> BitSetParticle
constexpr auto ParticleBitsetSize
auto operator|(BitSetParticle left, BitSetParticle right) -> BitSetParticle
auto PidToBitSetParticle(int pid) -> BitSetParticle
auto CheckCriteria(BitSetParticle particle, BitSetParticle criteria) -> bool
auto operator&(BitSetParticle left, BitSetParticle right) -> BitSetParticle
std::underlying_type_t< BitSetParticle > ParticleUType