36 std::string IpAddress,
42 ): Type(detectorType_from_int(Type)),
43 ipaddr(std::move(IpAddress)),
48 sender{ipaddr,
static_cast<uint16_t
>(UDPPort)}
51 hp = (PacketHeaderV0*)&buffer[0];
52 auto prev = time - period;
53 setPulseTime(time.high(), time.low(), prev.high(), prev.low());
65 void addReadout(uint8_t Ring, uint8_t FEN,
double tof,
double weight,
const void * data);
81 void setPulseTime(uint32_t PHI, uint32_t PLO, uint32_t PPHI, uint32_t PPLO);
88 if ((now - time) >= &period){
89 now = time + period * ((now - time) / period);
92 if ((now - time) > (period * 5u)) {
96 setPulseTime(now.high(), now.low(), time.high(), time.low());
102 [[nodiscard]] std::pair<uint32_t, uint32_t> lastPulseTime()
const;
103 [[nodiscard]] std::pair<uint32_t, uint32_t> prevPulseTime()
const;
104 [[nodiscard]] std::pair<uint32_t, uint32_t> lastEventTime()
const;
115 case Verbosity::details: verbosity=3;
break;
116 case Verbosity::info: verbosity=2;
break;
117 case Verbosity::warnings: verbosity=1;
break;
118 case Verbosity::errors: verbosity=0;
break;
119 case Verbosity::silent: verbosity=-1;
break;
120 default: verbosity=0;
124 int verbose(
const int v){verbosity = v;
return verbosity;}
127 void dump_to(
const std::string & filename,
const std::string & dataset_name =
"events");
129 void enable_network() {network =
true;}
130 void disable_network() {network =
false;}
132 void set_random_seed(
const uint32_t seed) {
133 random_engine.seed(seed);
136 int random_poisson(
const double mean) {
137 std::poisson_distribution<int> distribution(mean);
138 return distribution(random_engine);
142 HighFive::CompoundType datatype()
const {
143 return ::hdf_compound_type(readoutType_from_detectorType(Type));
146 void check_size_and_send();
162 PacketHeaderV0 *hp{};
164 const int MaxDataSize{8950};
172 std::optional<Writer> writer{std::nullopt};
175 cluon::UDPSender sender;
177 std::mt19937 random_engine{std::default_random_engine{}()};
void addReadout(uint8_t Ring, uint8_t FEN, efu_time t, const void *data)
Add a single readout with an explicit event time.
void addReadout(uint8_t Ring, uint8_t FEN, double tof, double weight, const void *data)
Add a weighted readout: draws n ~ Poisson(weight) and buffers the event n times (weight <= 0 is a noi...
void setPulseTime(uint32_t PHI, uint32_t PLO, uint32_t PPHI, uint32_t PPLO)
Update the pulse and previous pulse times (high/low pairs).
void dump_to(const std::string &filename, const std::string &dataset_name="events")
Also store every added readout to a legacy flat HDF5 file (see Writer).