LDMX Software
EventBuilder.h
1#ifndef EVENTBUILDER_EVENTBUILDER_H
2#define EVENTBUILDER_EVENTBUILDER_H
3#include <chrono>
4#include <string>
5
6#include "Event/PhysicsEventData.h"
7#include "FragmentBuffer.h"
9#include "Framework/Logger.h"
10#include "Packing/Utility/Reader.h"
11
12namespace eventbuilder {
13
15 public:
16 EventBuilder(const std::string& name, framework::Process& proc)
17 : framework::Producer(name, proc),
18 m_verbose_parse_(false),
19 m_event_id_(0) {}
20
21 // trailing ';' keeps clang-format from indenting what follows
22 enableLogging("EventBuilder");
23
24 virtual ~EventBuilder() = default;
25
27
28 void produce(framework::Event& event) override;
29
30 private:
31 PhysicsEventData assemblePayload(const std::vector<DataFragment>& fragments);
32 void writeEventBinary(const PhysicsEventData& ev,
33 const std::string& path = "events.bin");
34
35 bool m_verbose_parse_;
36 unsigned int m_event_id_;
37 FragmentBuffer m_event_buffer_;
38 std::string m_input_file_;
40 std::string m_output_name_{"BuilderOutput"};
41 long long m_coherence_window_ns_{
42 5000000}; // 5 ms window for collecting fragments
43 // Minimum number of distinct subsystems required to assemble an event.
44 // Configurable (was a hardcoded 3); Run 182 only has ts + tracker, so 2.
45 int m_min_subsystems_{2};
46
47 // Performance metrics
48 std::chrono::steady_clock::time_point m_start_time_;
49 std::chrono::steady_clock::time_point m_event_start_time_;
50 uint64_t m_total_bytes_read_{0};
51 uint64_t m_total_events_built_{0};
52 unsigned long m_events_since_last_report_{0};
53
54 // Windowed metrics for real-time monitoring (DAQ use)
55 static constexpr unsigned int WINDOW_SIZE =
56 100; // Calculate rates over last 100 events
57 std::chrono::steady_clock::time_point m_window_start_time_;
58 uint64_t m_window_events_count_{0};
59 uint64_t m_window_bytes_read_{0};
60};
61
62} // namespace eventbuilder
63#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:40
Class which represents the process under execution.
Definition Process.h:34
Base class for a module which produces a data product.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Reading a raw data file.
Definition Reader.h:20