epic-drich-beam-test-analysis
ePIC dRICH beam test analysis framework
Loading...
Searching...
No Matches
alcor_data.h
Go to the documentation of this file.
1#pragma once
2
29#include "TTree.h"
30#include "utility.h"
31
38#define _ALCOR_CC_TO_NS_ 3.125
45#define _ALCOR_ROLLOVER_TO_CC_ 32768
46
60{
61 int device;
62 int fifo;
63 int type;
64 int counter;
65 int column;
66 int pixel;
67 int tdc;
69 int coarse;
70 int fine;
71 uint32_t hit_mask;
72
73 alcor_data_struct() = default;
74};
75
83{
84 alcor_hit = 1,
85 trigger_tag = 9,
86 start_spill = 7,
87 end_spill = 15
88};
89
97{
98 _HITMASK_streaming_ring_trigger_ = 1,
99 _HITMASK_ring_tag_first = 2,
100 _HITMASK_ring_tag_second = 3,
101 _HITMASK_hough_ring_tag_first = 11,
102 _HITMASK_hough_ring_tag_second = 12,
103 _HITMASK_cross_talk = 28,
104 _HITMASK_afterpulse = 29,
105 _HITMASK_part_lane = 30,
106 _HITMASK_dead_lane = 31
107};
108
124{
125private:
127 static constexpr int rollover_to_clock = _ALCOR_ROLLOVER_TO_CC_;
128 static constexpr double coarse_to_ns = _ALCOR_CC_TO_NS_;
129 static constexpr int rollover_to_ns = rollover_to_clock * coarse_to_ns;
130
131public:
134 alcor_data() = default;
135
137 explicit alcor_data(const alcor_data_struct &data_struct) : data(data_struct) {}
138
140 explicit alcor_data(int device, int fifo, int type, int counter,
141 int column, int pixel, int tdc, int rollover,
142 int coarse, int fine, uint32_t mask)
143 {
144 data.device = device;
145 data.fifo = fifo;
146 data.type = type;
147 data.counter = counter;
148 data.column = column;
149 data.pixel = pixel;
150 data.tdc = tdc;
151 data.rollover = rollover;
152 data.coarse = coarse;
153 data.fine = fine;
154 data.hit_mask = mask;
155 }
157
160 alcor_data_struct get_data_struct() const { return data; }
161 int get_device() const { return data.device; }
162 int get_fifo() const { return data.fifo; }
163 int get_type() const { return data.type; }
164 int get_counter() const { return data.counter; }
165 int get_column() const { return data.column; }
166 int get_pixel() const { return data.pixel; }
167 int get_tdc() const { return data.tdc; }
168 int get_rollover() const { return data.rollover; }
169 int get_coarse() const { return data.coarse; }
170 int get_fine() const { return data.fine; }
171 uint32_t get_mask() const { return data.hit_mask; }
173
177 int get_chip() const { return data.fifo / 4; }
178 int get_eo_channel() const { return data.pixel + 4 * data.column + 32 * (get_chip() % 2); }
179 int get_calib_index() const { return data.tdc + 4 * get_eo_channel() + 128 * get_chip(); }
180 int get_device_index() const { return get_eo_channel() + 64 * (get_chip() / 2); }
181 int get_global_index() const { return get_device_index() + 256 * (get_device() - 192); }
182 int get_global_tdc_index() const { return 4 * get_global_index() + get_tdc(); }
187 uint64_t get_coarse_global_time() const { return get_coarse() + get_rollover() * rollover_to_clock; }
189
192 void set_data_struct_copy(alcor_data_struct input_data) { data = input_data; }
193 void set_data_struct_linked(alcor_data_struct &input_data) { data = input_data; }
194 void set_device(int val) { data.device = val; }
195 void set_fifo(int val) { data.fifo = val; }
196 void set_type(int val) { data.type = val; }
197 void set_counter(int val) { data.counter = val; }
198 void set_column(int val) { data.column = val; }
199 void set_pixel(int val) { data.pixel = val; }
200 void set_tdc(int val) { data.tdc = val; }
201 void set_rollover(int val) { data.rollover = val; }
202 void set_coarse(int val) { data.coarse = val; }
203 void set_fine(int val) { data.fine = val; }
204 void set_fine(uint32_t val) { data.fine = static_cast<int>(val); }
205 void set_mask(uint32_t val) { data.hit_mask = val; }
207
211 bool operator<(const alcor_data &c) const { return coarse_time_ns() < c.coarse_time_ns(); }
212 bool operator<=(const alcor_data &c) const { return coarse_time_ns() <= c.coarse_time_ns(); }
213 bool operator>(const alcor_data &c) const { return coarse_time_ns() > c.coarse_time_ns(); }
214 bool operator>=(const alcor_data &c) const { return coarse_time_ns() >= c.coarse_time_ns(); }
216
219 bool is_alcor_hit() const { return get_type() == alcor_hit; }
220 bool is_trigger_tag() const { return get_type() == trigger_tag; }
221 bool is_start_spill() const { return get_type() == start_spill; }
222 bool is_end_spill() const { return get_type() == end_spill; }
224
227 int coarse_time_clock() const { return get_coarse() + get_rollover() * rollover_to_clock; }
228 double coarse_time_ns() const { return get_coarse() * coarse_to_ns + get_rollover() * rollover_to_ns; }
230
233 void add_mask(uint32_t new_mask) { data.hit_mask |= new_mask; }
234 void add_mask_bit(int new_mask) { add_mask(encode_bit(new_mask)); }
236
239
243 void link_to_tree(TTree *input_tree);
248 void write_to_tree(TTree *output_tree);
250};
hit_mask
Bit positions used inside alcor_data_struct::hit_mask.
Definition alcor_data.h:97
alcor_hit_struct
Encodes the logical type of an ALCOR hit.
Definition alcor_data.h:83
First-level I/O helper class from the ALCOR decoder.
Definition alcor_data.h:124
int coarse_time_clock() const
Coarse time in clock counts (rollover × 32 768 + coarse)
Definition alcor_data.h:227
bool is_trigger_tag() const
True if this is a trigger-tag word.
Definition alcor_data.h:220
int get_chip() const
Chip number on the device (FIFO / 4)
Definition alcor_data.h:177
void write_to_tree(TTree *output_tree)
Write current data as branches to an output TTree.
Definition alcor_data.cxx:21
void set_counter(int val)
Set event counter.
Definition alcor_data.h:197
int get_column() const
Column address (0–7)
Definition alcor_data.h:165
void set_type(int val)
Set hit type.
Definition alcor_data.h:196
alcor_data(int device, int fifo, int type, int counter, int column, int pixel, int tdc, int rollover, int coarse, int fine, uint32_t mask)
Construct field-by-field.
Definition alcor_data.h:140
void add_mask_bit(int new_mask)
Set a single bit at position new_mask in the hit mask.
Definition alcor_data.h:234
alcor_data()=default
Default constructor — all fields left uninitialised.
void set_data_struct_copy(alcor_data_struct input_data)
Copy input_data into internal storage.
Definition alcor_data.h:192
bool is_start_spill() const
True if this marks the start of a spill.
Definition alcor_data.h:221
void set_fine(uint32_t val)
Set fine-time bin (unsigned overload)
Definition alcor_data.h:204
void set_mask(uint32_t val)
Replace the hit mask.
Definition alcor_data.h:205
void link_to_tree(TTree *input_tree)
Link internal members to branches of an input TTree.
Definition alcor_data.cxx:3
alcor_data_struct get_data_struct() const
Return a copy of the underlying storage struct.
Definition alcor_data.h:160
bool is_alcor_hit() const
True if this is a normal TDC hit.
Definition alcor_data.h:219
int get_coarse() const
Coarse timestamp (cc within rollover)
Definition alcor_data.h:169
int get_rollover() const
Rollover count.
Definition alcor_data.h:168
void set_tdc(int val)
Set TDC sub-channel.
Definition alcor_data.h:200
int get_fine() const
Raw fine-time bin.
Definition alcor_data.h:170
uint64_t get_coarse_global_time() const
Global coarse time including rollovers.
Definition alcor_data.h:187
void set_device(int val)
Set device ID.
Definition alcor_data.h:194
void set_fine(int val)
Set fine-time bin (signed)
Definition alcor_data.h:203
alcor_data(const alcor_data_struct &data_struct)
Construct from a pre-filled storage struct.
Definition alcor_data.h:137
int get_pixel() const
Pixel address (0–3)
Definition alcor_data.h:166
void set_fifo(int val)
Set FIFO number.
Definition alcor_data.h:195
int get_type() const
Hit type — see alcor_hit_struct.
Definition alcor_data.h:163
bool is_end_spill() const
True if this marks the end of a spill.
Definition alcor_data.h:222
void set_coarse(int val)
Set coarse timestamp.
Definition alcor_data.h:202
int get_global_tdc_index() const
Alias for get_global_index(); preferred in new code.
Definition alcor_data.h:182
int get_calib_index() const
Calibration look-up index (TDC + channel + chip encoding)
Definition alcor_data.h:179
int get_eo_channel() const
Even/odd channel index within the chip.
Definition alcor_data.h:178
void set_rollover(int val)
Set rollover count.
Definition alcor_data.h:201
int get_device_index() const
Flat per-device pixel index used for mapping.
Definition alcor_data.h:180
void set_pixel(int val)
Set pixel address.
Definition alcor_data.h:199
int get_counter() const
Event counter.
Definition alcor_data.h:164
int get_fifo() const
FIFO number.
Definition alcor_data.h:162
int get_global_index() const
Packed global index encoding device, chip, channel, and TDC.
Definition alcor_data.h:181
double coarse_time_ns() const
Coarse time converted to nanoseconds (× 3.125 ns/cc)
Definition alcor_data.h:228
uint32_t get_mask() const
Processing flag bit-mask — see hit_mask.
Definition alcor_data.h:171
void add_mask(uint32_t new_mask)
OR new_mask into the current hit mask.
Definition alcor_data.h:233
int get_device() const
Device ID (192+)
Definition alcor_data.h:161
void set_column(int val)
Set column address.
Definition alcor_data.h:198
void set_data_struct_linked(alcor_data_struct &input_data)
Link internal storage to an external struct (no copy)
Definition alcor_data.h:193
int get_tdc() const
TDC sub-channel (0–3)
Definition alcor_data.h:167
Plain data container for a single ALCOR hit.
Definition alcor_data.h:60
int device
Readout device ID (192–207 for known PDUs)
Definition alcor_data.h:61
int counter
Event counter from the DAQ stream.
Definition alcor_data.h:64
int tdc
TDC sub-channel index (0–3)
Definition alcor_data.h:67
int fifo
FIFO number within the device.
Definition alcor_data.h:62
int pixel
Pixel address within the column (0–3)
Definition alcor_data.h:66
int rollover
Coarse-clock rollover count (each rollover = 32 768 cc)
Definition alcor_data.h:68
int column
Column address within the ALCOR chip (0–7)
Definition alcor_data.h:65
int fine
Fine-time bin from the TDC (converted to ns via calibration)
Definition alcor_data.h:70
int type
Hit type code — see alcor_hit_struct.
Definition alcor_data.h:63
int coarse
Coarse timestamp within the current rollover (cc)
Definition alcor_data.h:69
uint32_t hit_mask
Bit-field of processing flags — see hit_mask.
Definition alcor_data.h:71
General-purpose utilities, fitting functions, and ALCOR address decoders.
uint32_t encode_bit(uint8_t active_bit)
Encode a single bit into a 32-bit mask.
Definition utility.h:52