epic-drich-beam-test-analysis
ePIC dRICH beam test analysis framework
Loading...
Searching...
No Matches
mapping.h
Go to the documentation of this file.
1#pragma once
2
3#include "utility.h"
4#include "alcor_finedata.h"
5#include <toml++/toml.h>
6
27{
28public:
29 // -------------------------------------------------------------------------
31
32
39 explicit mapping(std::string conf_file_name);
40
54 void load_calib(std::string filename, bool verbose = false);
55
57
58 // -------------------------------------------------------------------------
65
66
78 std::optional<int> get_do_channel(int matrix, int eo_channel) const;
79
86 std::optional<std::array<int, 2>> get_pdu_matrix(int device, int chip) const;
87
101 std::optional<std::array<float, 2>> get_position_from_pdu_column_row(int pdu, int column, int row) const;
102
115 std::optional<std::array<float, 2>> get_position_from_pdu_matrix_eoch(int pdu, int matrix, int eo_channel) const;
116
128 std::optional<std::array<float, 2>> get_position_from_device_chip_eoch(int device, int chip, int eo_channel) const;
129
135 std::optional<std::array<float, 2>> get_position_from_finedata(alcor_finedata entry) const;
136
146 std::optional<std::array<float, 2>> get_position_from_global_index(int global_index) const;
147
156
158
159 // -------------------------------------------------------------------------
169
170
188 void build_index_to_position_cache(float origin_cut = 5.f);
189
208 void build_position_to_index_cache(std::string collision_policy = "first");
209
215 std::optional<std::array<float, 2>> get_cached_position(int global_index) const;
216
223 std::optional<int> get_cached_index(float x, float y) const;
224
233 const std::map<int, std::array<float, 2>> &get_index_to_position_map() const;
234
240 const std::map<std::array<float, 2>, int> &get_position_to_index_map() const;
241
243
244private:
245 // -------------------------------------------------------------------------
247
248
251 static std::map<int, std::vector<int>> matrix_to_do_channel;
252
254
255 // -------------------------------------------------------------------------
257
258
260 static std::map<int, std::array<float, 2>> pdu_xy_position;
261
264 static std::map<int, bool> pdu_rotation;
265
267 static std::map<std::array<int, 2>, std::array<int, 2>> device_chip_to_pdu_matrix;
268
270
271 // -------------------------------------------------------------------------
273
274
277 std::map<int, std::array<float, 2>> index_to_hit_xy;
278
281 std::map<std::array<float, 2>, int> hit_xy_to_index;
282
284 bool cache_index_to_xy_built{false};
285
287 bool cache_xy_to_index_built{false};
288
290};
Represents a single calibrated ALCOR TDC hit with fine-time correction.
Definition alcor_finedata.h:103
Definition mapping.h:27
std::optional< std::array< float, 2 > > get_position_from_device_chip_eoch(int device, int chip, int eo_channel) const
Compute the physical position from an ALCOR (device, chip, EO channel) triplet.
Definition mapping.cxx:57
void load_calib(std::string filename, bool verbose=false)
Load (or reload) calibration data from a TOML file.
Definition mapping.cxx:82
std::optional< std::array< float, 2 > > get_cached_position(int global_index) const
Query the index→position cache built by build_index_to_position_cache().
Definition mapping.cxx:233
const std::map< std::array< float, 2 >, int > & get_position_to_index_map() const
Read-only access to the full position→index cache map.
Definition mapping.cxx:254
std::optional< std::array< float, 2 > > get_position_from_pdu_column_row(int pdu, int column, int row) const
Compute the physical (x, y) position from a PDU grid address.
Definition mapping.cxx:23
std::optional< std::array< float, 2 > > get_position_from_pdu_matrix_eoch(int pdu, int matrix, int eo_channel) const
Compute the physical position from a (PDU, matrix, EO channel) triplet.
Definition mapping.cxx:44
void build_index_to_position_cache(float origin_cut=5.f)
Build the index → position cache.
Definition mapping.cxx:154
void assign_position(alcor_finedata_struct &entry)
Fill the hit_x / hit_y fields of a fine-data struct in-place.
Definition mapping.cxx:69
std::optional< int > get_cached_index(float x, float y) const
Query the position→index cache built by build_position_to_index_cache().
Definition mapping.cxx:241
std::optional< std::array< int, 2 > > get_pdu_matrix(int device, int chip) const
Retrieve the (PDU, matrix) pair for a given ALCOR (device, chip).
Definition mapping.cxx:16
void build_position_to_index_cache(std::string collision_policy="first")
Build the position → index reverse cache.
Definition mapping.cxx:188
const std::map< int, std::array< float, 2 > > & get_index_to_position_map() const
Read-only access to the full index→position cache map.
Definition mapping.cxx:249
std::optional< int > get_do_channel(int matrix, int eo_channel) const
Translate an EO (even/odd) channel index to a DO (data-out) channel index for the given matrix quadra...
Definition mapping.cxx:7
std::optional< std::array< float, 2 > > get_position_from_global_index(int global_index) const
Compute the physical position from a global TDC channel index.
Definition mapping.cxx:68
std::optional< std::array< float, 2 > > get_position_from_finedata(alcor_finedata entry) const
Compute the physical position directly from a decoded ALCOR fine-data word.
Definition mapping.cxx:67
Raw decoded hit data from an ALCOR TDC channel.
Definition alcor_finedata.h:24
General-purpose utilities, fitting functions, and ALCOR address decoders.