3#include <mist/ring_finding/hough_transform.h>
8#include <unordered_map>
67 uint32_t global_index_,
369 static void set_param0(
int global_tdc_index,
float value) { calibration_parameters[global_tdc_index][0] = value; }
376 static void set_param1(
int global_tdc_index,
float value) { calibration_parameters[global_tdc_index][1] = value; }
383 static void set_param2(
int global_tdc_index,
float value) { calibration_parameters[global_tdc_index][2] = value; }
448 void read_calib_from_file(
const std::string &filename,
bool clear_first =
true,
bool overwrites =
true);
485 mist::ring_finding::hough_transform &ht,
486 std::vector<alcor_finedata> &alcor_hits,
487 float threshold_fraction,
491 float collection_radius = 6.f);
509 inline static std::unordered_map<int, std::array<float, 3>> calibration_parameters = {};
516 void set_standard_function();
Data structures and utilities for ALCOR hit-level data handling.
hit_mask
Bit positions used inside alcor_data_struct::hit_mask.
Definition alcor_data.h:97
Represents a single calibrated ALCOR TDC hit with fine-time correction.
Definition alcor_finedata.h:103
alcor_finedata()
Default constructor. Initialises all fields to zero.
Definition alcor_finedata.cxx:23
alcor_finedata_struct get_data_struct() const
Returns a copy of the underlying alcor_finedata_struct.
Definition alcor_finedata.h:138
int get_fifo() const
Returns the FIFO number decoded from the calibration index.
Definition alcor_finedata.h:208
void read_calib_from_file(const std::string &filename, bool clear_first=true, bool overwrites=true)
Loads calibration parameters from a plain-text file.
Definition alcor_finedata.cxx:85
float get_hit_x() const
Returns the x-axis position from mapping.
Definition alcor_finedata.h:153
void set_data_struct(const alcor_finedata_struct &d)
Replaces the underlying data struct.
Definition alcor_finedata.h:320
bool has_mask_bit(hit_mask bit) const
Checks whether a single bit is set in the hit mask.
Definition alcor_finedata.h:287
float get_hit_y() const
Returns the y-axis position from mapping.
Definition alcor_finedata.h:156
void add_mask_bit(hit_mask bit)
Sets a single bit in the hit mask.
Definition alcor_finedata.h:274
uint8_t get_fine() const
Returns the fine timestamp (TDC bin within a clock cycle).
Definition alcor_finedata.h:150
uint32_t get_mask() const
Returns the hit bitmask.
Definition alcor_finedata.h:159
bool is_cross_talk() const
Checks whether the hit is flagged as cross-talk.
Definition alcor_finedata.h:296
void set_global_index(uint32_t calib)
Sets the calibration index.
Definition alcor_finedata.h:326
int get_global_channel_index() const
Returns the global channel index stripped of TDC info.
Definition alcor_finedata.h:226
void set_rollover(uint32_t r)
Sets the rollover counter.
Definition alcor_finedata.h:332
int get_column() const
Returns the column address decoded from the calibration index.
Definition alcor_finedata.h:217
int get_tdc() const
Returns the TDC index decoded from the calibration index.
Definition alcor_finedata.h:202
bool operator<(const alcor_finedata &v) const
Less-than comparison against an alcor_finedata hit.
Definition alcor_finedata.h:396
void generate_calibration(TH2F *calibration_histogram, bool overwrite_calibration)
Derives calibration parameters from a 2D fine-time histogram.
Definition alcor_finedata.cxx:105
bool is_ring_tag_second() const
Checks whether the hit is tagged as part of a ring (second pass).
Definition alcor_finedata.h:293
int get_device_index() const
Returns the per-device TDC index.
Definition alcor_finedata.h:223
float get_hit_y_rnd() const
Returns the pixel-randomised y-coordinate, uniform within ±1.5 mm of the hit position.
Definition alcor_finedata.h:241
bool is_ring_tag_first() const
Checks whether the hit is tagged as part of a ring (first pass).
Definition alcor_finedata.h:290
bool operator>(const alcor_finedata &v) const
Greater-than comparison against an alcor_finedata hit.
Definition alcor_finedata.h:402
uint32_t get_global_index() const
Returns the calibration index identifying the TDC channel.
Definition alcor_finedata.h:141
bool is_dead_lane() const
Checks whether the hit originates from a dead lane.
Definition alcor_finedata.h:305
static void set_param2(int global_tdc_index, float value)
Sets calibration parameter 2 for a given TDC channel.
Definition alcor_finedata.h:383
void set_streaming_ring_trigger_mask()
Flags the hit as a streaming ring trigger participant.
Definition alcor_finedata.h:353
static std::vector< mist::ring_finding::ring_result > alcor_find_rings_hough(mist::ring_finding::hough_transform &ht, std::vector< alcor_finedata > &alcor_hits, float threshold_fraction, int min_hits, int min_active, int max_rings=2, float collection_radius=6.f)
Convert a vector of alcor_finedata hits into hough_hit, run the Hough-transform ring finder,...
Definition alcor_finedata.cxx:181
int get_eo_channel() const
Returns the even/odd channel index decoded from the calibration index.
Definition alcor_finedata.h:214
bool operator>=(const alcor_finedata &v) const
Greater-than-or-equal comparison against an alcor_finedata hit.
Definition alcor_finedata.h:405
float get_time_ns() const
Returns the calibrated hit time in nanoseconds.
Definition alcor_finedata.h:190
uint16_t get_coarse() const
Returns the coarse timestamp (clock-cycle count).
Definition alcor_finedata.h:147
int get_chip() const
Returns the chip ID decoded from the calibration index.
Definition alcor_finedata.h:211
void update_calibration(TH2F *h)
Updates calibration without overwriting existing entries. Alias for generate_calibration with overwri...
Definition alcor_finedata.h:434
void set_coarse(uint16_t c)
Sets the coarse timestamp.
Definition alcor_finedata.h:338
float get_hit_phi_rnd() const
Returns the azimuthal angle from the origin using a freshly randomised position [rad].
Definition alcor_finedata.h:247
bool operator<=(const alcor_finedata &v) const
Less-than-or-equal comparison against an alcor_finedata hit.
Definition alcor_finedata.h:399
int get_device() const
Returns the readout device ID decoded from the calibration index.
Definition alcor_finedata.h:205
int get_pixel() const
Returns the pixel address decoded from the calibration index.
Definition alcor_finedata.h:220
float get_hit_r_rnd() const
Returns the radial distance from the origin using a freshly randomised position.
Definition alcor_finedata.h:244
bool is_afterpulse() const
Checks whether the hit is flagged as an afterpulse.
Definition alcor_finedata.h:299
void write_calib_to_file(const std::string &filename)
Writes the current calibration parameters to a plain-text file.
Definition alcor_finedata.cxx:76
void set_fine(uint8_t f)
Sets the fine timestamp.
Definition alcor_finedata.h:344
float get_hit_x_rnd() const
Returns the pixel-randomised x-coordinate, uniform within ±1.5 mm of the hit position.
Definition alcor_finedata.h:238
bool is_part_lane() const
Checks whether the hit originates from a partially active lane.
Definition alcor_finedata.h:302
float get_time() const
Returns the calibrated hit time in clock cycles. Combines rollover, coarse, and the fine-time phase c...
Definition alcor_finedata.h:182
static void set_param0(int global_tdc_index, float value)
Sets calibration parameter 0 for a given TDC channel.
Definition alcor_finedata.h:369
static void set_param1(int global_tdc_index, float value)
Sets calibration parameter 1 for a given TDC channel.
Definition alcor_finedata.h:376
uint32_t get_rollover() const
Returns the rollover counter.
Definition alcor_finedata.h:144
void set_mask(uint32_t mask)
Sets the hit bitmask.
Definition alcor_finedata.h:350
float get_phase() const
Returns the calibrated fine-time phase in clock cycles. Computed from the 3-parameter calibration sto...
Definition alcor_finedata.cxx:38
void clear_mask_bit(hit_mask bit)
Clears a single bit in the hit mask.
Definition alcor_finedata.h:280
Plain data container for a single ALCOR hit.
Definition alcor_data.h:60
Raw decoded hit data from an ALCOR TDC channel.
Definition alcor_finedata.h:24
uint16_t coarse
Coarse timestamp (clock-cycle counter).
Definition alcor_finedata.h:32
uint8_t fine
Fine timestamp (TDC interpolation bin within a clock cycle).
Definition alcor_finedata.h:35
alcor_finedata_struct()=default
Default constructor.
float hit_x
X-axis position from mapping.
Definition alcor_finedata.h:38
uint32_t hit_mask
Bitmask encoding hit channel/pixel information.
Definition alcor_finedata.h:52
alcor_finedata_struct(uint32_t rollover_, uint16_t coarse_, uint8_t fine_, float hit_x_, float hit_y_, uint32_t global_index_, uint32_t hit_mask_)
Constructor from individual values.
Definition alcor_finedata.h:62
float hit_y
Y-axis position from mapping.
Definition alcor_finedata.h:41
uint32_t rollover
Rollover counter (most-significant timing word).
Definition alcor_finedata.h:29
uint32_t global_index
Global calibration index identifying the TDC channel.
Definition alcor_finedata.h:49
std::uniform_real_distribution _rnd_(0.0, 1.0)
Uniform float distribution in [0, 1).
std::mt19937 _global_gen_(_global_rd_())
Mersenne-Twister 19937 engine seeded from _global_rd_.