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};
47 std::string m_binary_file_{"events.bin"};
49 std::string m_performance_file_{"event_performance.csv"};
50
51 // Performance metrics
52 std::chrono::steady_clock::time_point m_start_time_;
53 std::chrono::steady_clock::time_point m_event_start_time_;
54 uint64_t m_total_bytes_read_{0};
55 uint64_t m_total_events_built_{0};
56 unsigned long m_events_since_last_report_{0};
57
58 // Windowed metrics for real-time monitoring (DAQ use)
59 static constexpr unsigned int WINDOW_SIZE =
60 100; // Calculate rates over last 100 events
61 std::chrono::steady_clock::time_point m_window_start_time_;
62 uint64_t m_window_events_count_{0};
63 uint64_t m_window_bytes_read_{0};
64};
65
66} // namespace eventbuilder
67#endif
Base classes for all user event processing components to extend.
std::string m_performance_file_
performance metrics CSV, empty to disable
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.
std::string m_binary_file_
binary event output, empty to disable
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