1#ifndef TRACKING_RECO_SISTRIPCHANNELMAP_H_
2#define TRACKING_RECO_SISTRIPCHANNELMAP_H_
8namespace tracking::reco {
38inline constexpr int16_t
pchannel(uint8_t apv_id, uint8_t channel) {
39 return static_cast<int16_t
>(
45inline std::string
channelKey(uint8_t feb, uint8_t hybrid, uint8_t apv,
47 return std::to_string(feb) +
":" + std::to_string(hybrid) +
":" +
48 std::to_string(apv) +
":" + std::to_string(channel);
53inline constexpr uint32_t
channelId(uint8_t feb, uint8_t hybrid, uint8_t apv,
55 return (
static_cast<uint32_t
>(feb) << 24) |
56 (
static_cast<uint32_t
>(hybrid) << 16) |
57 (
static_cast<uint32_t
>(apv) << 8) |
static_cast<uint32_t
>(channel);
63 uint8_t& hybrid, uint8_t& apv, uint8_t& channel) {
65 if (std::sscanf(key.c_str(),
"%u:%u:%u:%u", &f, &h, &a, &c) != 4)
67 feb =
static_cast<uint8_t
>(f);
68 hybrid =
static_cast<uint8_t
>(h);
69 apv =
static_cast<uint8_t
>(a);
70 channel =
static_cast<uint8_t
>(c);
75inline constexpr uint32_t
groupKey(uint8_t feb, uint8_t hybrid,
77 return (
static_cast<uint32_t
>(feb) << 24) |
78 (
static_cast<uint32_t
>(hybrid) << 16) |
79 static_cast<uint32_t
>(
static_cast<uint16_t
>(
pchannel));
84 return static_cast<int16_t
>(key & 0xFFFF);
bool parseChannelKey(const std::string &key, uint8_t &feb, uint8_t &hybrid, uint8_t &apv, uint8_t &channel)
Parse a "feb:hybrid:apv:channel" key (as produced by channelKey()) back into its electronics fields.
std::string channelKey(uint8_t feb, uint8_t hybrid, uint8_t apv, uint8_t channel)
Build the per-channel pedestal-map key "feb:hybrid:apv:channel".
constexpr uint32_t channelId(uint8_t feb, uint8_t hybrid, uint8_t apv, uint8_t channel)
Pack the full electronics address (feb, hybrid, apv, channel) into a single 32-bit id,...
constexpr int K_CHANNELS_PER_HYBRID
Number of physical strips per hybrid (kApvsPerHybrid * kChannelsPerApv).
constexpr int K_SAMPLES_PER_APV_TRIGGER
Number of ADC samples the APV25 reads out per channel per trigger.
constexpr int16_t pchannelFromGroupKey(uint32_t key)
Extract the pchannel back out of a key produced by groupKey().
constexpr int K_CHANNELS_PER_APV
Number of readout channels per APV25 chip.
constexpr uint32_t groupKey(uint8_t feb, uint8_t hybrid, int16_t pchannel)
Pack (feb, hybrid, pchannel) into a single 32-bit waveform-grouping key.
constexpr int16_t pchannel(uint8_t apv_id, uint8_t channel)
Convert an (APV id, APV channel) pair into the physical strip number (pchannel) within a hybrid,...
constexpr int K_APVS_PER_HYBRID
Number of APV25 chips per hybrid.