epic-drich-beam-test-analysis
ePIC dRICH beam test analysis framework
Loading...
Searching...
No Matches
parallel_streaming_framer.h
1#pragma once
2
3#include <iostream>
4#include <vector>
5#include <string>
6#include <map>
7#include <unordered_map>
8#include <variant>
9#include "TFile.h"
10#include "TTree.h"
11#include "TH1.h"
12#include "TH2.h"
13#include "TSystem.h"
14#include <filesystem>
15#include "alcor_spilldata.h"
16#include "alcor_data_streamer.h"
17
20
22#define _FRAME_SIZE_ 1024
23
25#define _FRAME_LENGTH_NS_ (_FRAME_SIZE_ * 3.125)
26
28#define _FIRST_FRAMES_TRIGGER_ 2500
29
31#define _AFTERPULSE_DEADTIME_ 64
32
34
48{
49public:
50 // -------------------------------------------------------------------------
51 // Constructors
52 // -------------------------------------------------------------------------
53
56
62 parallel_streaming_framer(std::vector<std::string> filenames, uint16_t frame_size = _FRAME_SIZE_)
63 : parallel_streaming_framer(filenames, "", "", frame_size) {}
64
71 parallel_streaming_framer(std::vector<std::string> filenames, std::string trigger_config_file, uint16_t frame_size = _FRAME_SIZE_)
72 : parallel_streaming_framer(filenames, trigger_config_file, "", frame_size) {}
73
81 parallel_streaming_framer(std::vector<std::string> filenames, std::string trigger_config_file, std::string readout_config_file, uint16_t frame_size = _FRAME_SIZE_);
82
83 // -------------------------------------------------------------------------
84 // Getters
85 // -------------------------------------------------------------------------
86
92
98
105
111
112 // -------------------------------------------------------------------------
113 // Setters
114 // -------------------------------------------------------------------------
115
121
127
132 void set_parallel_cores(uint16_t v);
133
134 // -------------------------------------------------------------------------
135 // Progress bar assignment
136 // -------------------------------------------------------------------------
137
146 void assign_bar(mist::logger::progress_bar &bar);
147
158 void assign_bar(mist::logger::subtask_progress_bar &bar);
159
166 void clear_bar();
167
168 // -------------------------------------------------------------------------
169 // I/O Operations
170 // -------------------------------------------------------------------------
171
176 bool next_spill();
177
183 void process(alcor_data_streamer &current_stream, int _frame_size);
184
185private:
186 // -------------------------------------------------------------------------
187 // Internal progress helpers
188 // -------------------------------------------------------------------------
189
199 void _update_bar(int64_t current, int64_t total);
200
203
205 uint16_t n_threads_requested;
206
208 std::mutex frame_mutexes_access;
209
211 std::mutex triggers_map_mutex;
212
214 std::mutex spilldata_masks_mutex;
215
217
220
222 uint8_t _current_spill;
223
228 std::map<std::string, uint32_t> _next_spill;
229
240 std::variant<std::monostate,
241 mist::logger::progress_bar *,
242 mist::logger::subtask_progress_bar *>
243 assigned_bar_;
244
246 alcor_spilldata spilldata;
247
249 std::vector<alcor_data_streamer> data_streams;
250
252
255
257 std::vector<trigger_config> triggers;
258
260 std::unordered_map<uint8_t, trigger_config> triggers_map;
261
263 readout_config_list readout_config;
264
266 uint16_t _frame_size;
267
269
272
274 TH2F *h2_fine_tune_distribution;
275
277};
Sequential cursor-based reader for ALCOR hit-level data in a ROOT TTree.
Definition alcor_data_streamer.h:18
High-level accessor class for one beam-spill worth of ALCOR data.
Definition alcor_spilldata.h:99
Frames raw ALCOR data streams from multiple input files in parallel.
Definition parallel_streaming_framer.h:48
TH2F * get_fine_tune_distribution()
Returns the fine tune distribution per tdc index.
Definition parallel_streaming_framer.cxx:47
void set_spilldata_link(alcor_spilldata &v)
Sets the spill data by reference.
Definition parallel_streaming_framer.cxx:51
void process(alcor_data_streamer &current_stream, int _frame_size)
Processes a single data stream and returns the framed spill data.
Definition parallel_streaming_framer.cxx:72
parallel_streaming_framer(std::vector< std::string > filenames, uint16_t frame_size=_FRAME_SIZE_)
Construct a framer from a list of input files.
Definition parallel_streaming_framer.h:62
alcor_spilldata get_spilldata() const
Returns a copy of the current spill data.
Definition parallel_streaming_framer.cxx:44
parallel_streaming_framer(std::vector< std::string > filenames, std::string trigger_config_file, uint16_t frame_size=_FRAME_SIZE_)
Construct a framer with trigger configuration.
Definition parallel_streaming_framer.h:71
void set_spilldata(alcor_spilldata v)
Sets the spill data by value.
Definition parallel_streaming_framer.cxx:50
void assign_bar(mist::logger::progress_bar &bar)
Assign a standalone progress bar for reporting streaming progress.
Definition parallel_streaming_framer.cxx:55
parallel_streaming_framer()=default
Default constructor.
bool next_spill()
Advances all data streams to the next spill.
Definition parallel_streaming_framer.cxx:201
void clear_bar()
Detach the currently assigned bar without finishing it.
Definition parallel_streaming_framer.cxx:57
int get_registered_triggers()
Returns the number of triggers registered from the configuration file.
Definition parallel_streaming_framer.cxx:46
void set_parallel_cores(uint16_t v)
Sets the number of parallel processing threads.
Definition parallel_streaming_framer.cxx:52
alcor_spilldata & get_spilldata_link()
Returns a reference to the current spill data.
Definition parallel_streaming_framer.cxx:45
Searchable container of readout_config_struct entries.
Definition config_reader.h:85
#define _FRAME_SIZE_
Number of clock cycles per frame.
Definition parallel_streaming_framer.h:22