LDMX Software
EventBuilder.h
1#ifndef EVENTBUILDER_EVENTBUILDER_H
2#define EVENTBUILDER_EVENTBUILDER_H
3#include <string>
4#include <chrono>
5#include "FragmentBuffer.h"
6#include "Event/PhysicsEventData.h"
8#include "Framework/Logger.h"
9#include "Packing/Utility/Reader.h"
10
11namespace eventbuilder {
12
14 public:
15
16 EventBuilder(const std::string &name, framework::Process &proc)
17 : framework::Producer(name, proc), m_verbose_parse(false), m_event_id(0) {}
18
19 enableLogging("EventBuilder")
20
21 virtual ~EventBuilder() = default;
22
24
25 void produce(framework::Event &event) override;
26
27 private:
28
29 PhysicsEventData assemble_payload(const std::vector<DataFragment> &fragments);
30 void write_event_binary(const PhysicsEventData &ev, const std::string &path = "events.bin");
31
32 bool m_verbose_parse;
33 unsigned int m_event_id;
34 FragmentBuffer m_event_buffer;
35 std::string m_input_file;
37 std::string m_output_name{"BuilderOutput"};
38 long long m_coherence_window_ns{5000000}; // 5 ms window for collecting fragments
39 // Minimum number of distinct subsystems required to assemble an event.
40 // Configurable (was a hardcoded 3); Run 182 only has ts + tracker, so 2.
41 int m_min_subsystems{2};
42
43 // Performance metrics
44 std::chrono::steady_clock::time_point m_start_time;
45 std::chrono::steady_clock::time_point m_event_start_time;
46 uint64_t m_total_bytes_read{0};
47 uint64_t m_total_events_built{0};
48 unsigned long m_events_since_last_report{0};
49
50 // Windowed metrics for real-time monitoring (DAQ use)
51 static constexpr unsigned int WINDOW_SIZE = 100; // Calculate rates over last 100 events
52 std::chrono::steady_clock::time_point m_window_start_time;
53 uint64_t m_window_events_count{0};
54 uint64_t m_window_bytes_read{0};
55};
56
57} // namespace eventbuilder
58#endif
Base classes for all user event processing components to extend.
void produce(framework::Event &event) override
Process the event and put new data products into it.
void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:37
Base class for a module which produces a data product.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Reading a raw data file.
Definition Reader.h:20