epic-drich-beam-test-analysis
ePIC dRICH beam test analysis framework
Loading...
Searching...
No Matches
config_reader.h
Go to the documentation of this file.
1#pragma once
2
17#include <fstream>
18#include <sstream>
19#include <set>
20#include <map>
21#include <unordered_map>
22#include <vector>
23#include <string>
24#include <optional>
25#include <algorithm>
26#include <iostream>
27#include <cstdint>
28#include <utility.h>
29#include <toml++/toml.h>
30
31// =========================================================================
32// Core tag set
33// =========================================================================
34
36static const std::set<std::string> lightdata_core_tags = {"timing", "tracking", "cherenkov"};
37
38// =========================================================================
39// Readout configuration
40// =========================================================================
41
49{
50 std::string name;
51 std::map<uint16_t, std::vector<uint16_t>> device_chip;
52
53 readout_config_struct() = default;
54
60 readout_config_struct(std::string _name, std::map<uint16_t, std::vector<uint16_t>> _device_chip);
61
67 void add_device_chip(uint16_t device, uint16_t chip);
68
73 void add_device(uint16_t device);
74};
75
76// =========================================================================
77
85{
86public:
87 // -------------------------------------------------------------------------
89
90
91 readout_config_list() = default;
92
94 explicit readout_config_list(std::vector<readout_config_struct> vec);
95
97
98 // -------------------------------------------------------------------------
100
101
103 readout_config_struct *find_by_name(const std::string &name);
104
106 readout_config_struct *find_by_device(uint16_t device);
107
109 std::vector<readout_config_struct *> find_all_by_device(uint16_t device);
110
112 std::vector<std::string> find_by_device_and_chip(uint16_t device, uint16_t chip);
113
115 bool has_name(const std::string &name) const;
116
118
119 // -------------------------------------------------------------------------
121
122
124 bool has_cherenkov();
126 bool has_timing();
128 bool has_tracking();
129
131
132 std::vector<readout_config_struct> configs;
133};
134
135// =========================================================================
136// Free utility functions
137// =========================================================================
138
146std::vector<std::string> find_by_device_and_chip(
147 const std::map<std::string, readout_config_struct> &readout_config_utility,
148 uint16_t device,
149 uint16_t chip);
150
161std::vector<readout_config_struct> readout_config_reader(std::string config_file = "conf/readout_config.toml");
162
163// =========================================================================
164// Run metadata
165// =========================================================================
166
169{
170 std::string type;
171 std::string tag;
172 double refindex;
173 double depth;
174 std::string side;
175};
176
184{
185 // -------------------------------------------------------------------------
187
188 std::string beam_polarity;
191
192 // -------------------------------------------------------------------------
194
195 std::string rdo_firmware;
196 std::string timing_firmware;
202
203 // -------------------------------------------------------------------------
205
206 double temperature;
207 double v_bias;
209
210 // -------------------------------------------------------------------------
212
216
217 // -------------------------------------------------------------------------
219
220 std::vector<radiator_info_struct> radiators;
222};
223
224// =========================================================================
225
236{
237public:
238 // -------------------------------------------------------------------------
240
241
250 static void read_database(std::string filename);
251
253 static void clear_database() { run_info_database.clear(); }
254
260 static const std::optional<run_info_struct> get_run_info(const std::string &run_id);
261
263
264 // -------------------------------------------------------------------------
266
267
276 static void read_runslists(std::string runlist_file);
277
283 static const std::optional<std::vector<std::string>> get_run_list(const std::string &runlist_name);
284
286
287private:
288 // -------------------------------------------------------------------------
290
291
292 static std::unordered_map<std::string, run_info_struct> run_info_database;
293 static std::unordered_map<std::string, std::vector<std::string>> run_list_database;
294
296};
Searchable container of readout_config_struct entries.
Definition config_reader.h:85
bool has_timing()
true if a "timing" role is present.
Definition config_reader.cxx:77
std::vector< std::string > find_by_device_and_chip(uint16_t device, uint16_t chip)
Names of all configs that contain the (device, chip) pair.
Definition config_reader.cxx:53
readout_config_struct * find_by_device(uint16_t device)
First config that contains device, or nullptr.
Definition config_reader.cxx:36
bool has_tracking()
true if a "tracking" role is present.
Definition config_reader.cxx:78
std::vector< readout_config_struct * > find_all_by_device(uint16_t device)
All configs that contain device.
Definition config_reader.cxx:44
readout_config_struct * find_by_name(const std::string &name)
First config whose name matches name, or nullptr.
Definition config_reader.cxx:28
bool has_name(const std::string &name) const
true if any config has name equal to name.
Definition config_reader.cxx:69
bool has_cherenkov()
true if a "cherenkov" role is present.
Definition config_reader.cxx:76
std::vector< readout_config_struct > configs
Ordered list of readout role assignments.
Definition config_reader.h:132
Static database of run metadata and named run lists.
Definition config_reader.h:236
static const std::optional< std::vector< std::string > > get_run_list(const std::string &runlist_name)
Retrieve the ordered run-ID list for runlist_name.
Definition config_reader.cxx:342
static void clear_database()
Clear all entries from the run-info database.
Definition config_reader.h:253
static const std::optional< run_info_struct > get_run_info(const std::string &run_id)
Retrieve the metadata record for run_id.
Definition config_reader.cxx:301
static void read_runslists(std::string runlist_file)
Parse a TOML run-list file and populate the internal list map.
Definition config_reader.cxx:307
static void read_database(std::string filename)
Parse a TOML run-database file and populate the internal map.
Definition config_reader.cxx:214
std::vector< std::string > find_by_device_and_chip(const std::map< std::string, readout_config_struct > &readout_config_utility, uint16_t device, uint16_t chip)
Names of all configs in readout_config_utility containing (device, chip).
Definition config_reader.cxx:82
std::vector< readout_config_struct > readout_config_reader(std::string config_file="conf/readout_config.toml")
Parse a TOML readout configuration file and return the role list.
Definition config_reader.cxx:102
Optical radiator properties for one radiator layer.
Definition config_reader.h:169
std::string side
Detector side ("left" / "right").
Definition config_reader.h:174
double refindex
Refractive index at the nominal beam energy.
Definition config_reader.h:172
std::string tag
Short label used in histogram naming.
Definition config_reader.h:171
double depth
Radiator depth along the beam axis [cm].
Definition config_reader.h:173
std::string type
Radiator material identifier (e.g. "aerogel").
Definition config_reader.h:170
Associates a named readout role with a set of (device, chip) pairs.
Definition config_reader.h:49
void add_device_chip(uint16_t device, uint16_t chip)
Register a single (device, chip) pair.
Definition config_reader.cxx:8
std::map< uint16_t, std::vector< uint16_t > > device_chip
Active chips per device.
Definition config_reader.h:51
std::string name
Human-readable role name (e.g. "cherenkov").
Definition config_reader.h:50
void add_device(uint16_t device)
Register all 8 chips of a device.
Definition config_reader.cxx:15
Complete per-run metadata record.
Definition config_reader.h:184
int beam_energy
Nominal beam momentum [GeV/c].
Definition config_reader.h:189
double temperature
SiPM temperature during the run [°C].
Definition config_reader.h:206
std::string rdo_firmware
RDO firmware version string.
Definition config_reader.h:195
std::string beam_polarity
Beam particle sign ("+" or "-").
Definition config_reader.h:188
bool timing_on_axis
true if the timing channel is on the beam axis.
Definition config_reader.h:198
int aerogel_mirror
Aerogel mirror configuration index.
Definition config_reader.h:213
int gas_mirror
Gas radiator mirror configuration index.
Definition config_reader.h:214
std::vector< radiator_info_struct > radiators
Ordered list of active radiator layers.
Definition config_reader.h:220
int op_mode
ALCOR operational mode index.
Definition config_reader.h:199
double v_bias
SiPM bias voltage [V].
Definition config_reader.h:207
std::string timing_firmware
Timing board firmware version string.
Definition config_reader.h:196
int delta_thr
ALCOR Δ-threshold setting [LSB].
Definition config_reader.h:200
int n_spills
Number of spills in the run.
Definition config_reader.h:197
General-purpose utilities, fitting functions, and ALCOR address decoders.