CbmRoot
Loading...
Searching...
No Matches
trd2d/ReadoutConfig.h
Go to the documentation of this file.
1/* Copyright (C) 2023-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese, Dominik Smith [committer], Alex Bercuci */
4
5#pragma once
6
7#include "CbmYaml.h"
9
10#include <map>
11#include <sstream>
12#include <utility>
13#include <vector>
14
15namespace cbm::algo::trd2d
16{
17
18
30
32
33 public:
34 struct CompMapping {
35 uint16_t moduleId;
36 uint8_t fiberId;
37
38 CBM_YAML_FORMAT(YAML::Flow);
39 CBM_YAML_PROPERTIES(yaml::Property(&CompMapping::moduleId, "moduleId", "Module ID"),
40 yaml::Property(&CompMapping::fiberId, "fiberId", "Optical Fibre ID"));
41 };
42
43 struct ChanMapping {
44 int32_t padAddress;
45 bool maskFlag;
46 int8_t tOffset;
47 uint16_t lThreshold;
48
49 CBM_YAML_FORMAT(YAML::Flow);
51 yaml::Property(&ChanMapping::padAddress, "address", "Pad address"),
52 yaml::Property(&ChanMapping::maskFlag, "mask", "Channel masking flag"),
53 yaml::Property(&ChanMapping::tOffset, "toff", "Channel wise time offset"),
54 yaml::Property(&ChanMapping::lThreshold, "thres", "SW masking by threshold"));
55 };
56
59
60
63
64
68 std::vector<uint16_t> GetEquipmentIds();
69
70
75 size_t GetNumAsics(uint16_t equipmentId);
76
77
82 std::vector<uint8_t> GetAsicList(uint16_t equipmentId);
83
84
90 size_t GetNumChans(uint16_t equipmentId, uint16_t asicId);
91
93
98 CompMapping CompMap(uint16_t equipId);
99
100
107 ChanMapping ChanMap(uint16_t equipId, uint16_t asic, uint16_t chan);
108
109
111 std::string PrintReadoutMap();
112
114 void InitComponentMap(const std::map<uint32_t, std::vector<uint16_t>>& map);
115
117 void InitChannelMap(
118 const std::map<size_t, std::map<size_t, std::map<size_t, std::tuple<int32_t, bool, int16_t, uint16_t>>>>&
119 channelMap);
120
123
125 void SetSystemTimeOffset(int64_t offsetNs) { fSystemTimeOffset = offsetNs; };
126
127 private:
128 // --- System time offset
129 int64_t fSystemTimeOffset = 0;
130
131 // --- TRD2D readout map
132 // --- Map index: (equipment), map value: (module id, crob id)
133 std::map<uint16_t, CompMapping> fReadoutMap = {};
134
135 // --- TRD2D channel map
136 // --- Map index: (equipment, asic, chan), map value: (pad address, mask flag, daq offset)
137 std::map<uint16_t, std::map<uint8_t, std::vector<ChanMapping>>> fChannelMap = {};
138
140 yaml::Property(&ReadoutSetup::fSystemTimeOffset, "timeOffset", "System time offset for TRD2D"),
141 yaml::Property(&ReadoutSetup::fReadoutMap, "readoutMap", "Maps equipment to module and Optical fibre Id", YAML::Hex),
142 yaml::Property(&ReadoutSetup::fChannelMap, "channelMap",
143 "Maps equipment, ASIC and channel to pad address, mask flag and DAQ offset",
144 YAML::Hex));
145 }; // end struct cbm::algo::trd2d::ReadoutSetup
146
148
149 public:
150 struct ChanNoise {
151 uint16_t tDelay;
152 uint16_t tWindow;
153 uint16_t lDThres;
154 uint16_t lSThres;
155
157 yaml::Property(&ChanNoise::tDelay, "delay", "time delay wrt the causing signal"),
158 yaml::Property(&ChanNoise::tWindow, "window", "time window for noise signal search"),
159 yaml::Property(&ChanNoise::lDThres, "dnoise", "Max signal value for cutting dynamic noise signals"),
160 yaml::Property(&ChanNoise::lSThres, "snoise", "Max signal value for cutting static noise signals"));
161 };
163 bool maskFlag;
164 int8_t tOffset;
165 float baseline;
166 float gainfee;
168
169 CBM_YAML_FORMAT(YAML::Flow);
171 yaml::Property(&ChanDescriptor::maskFlag, "mask", "Channel masking flag"),
172 yaml::Property(&ChanDescriptor::tOffset, "toff", "Channel wise time offset"),
173 yaml::Property(&ChanDescriptor::baseline, "bline", "Baseline correction"),
174 yaml::Property(&ChanDescriptor::gainfee, "gainfee", "Gain correction for FEE channel"),
175 yaml::Property(&ChanDescriptor::noise, "noise", "Dynamic noise descriptor"));
176 };
177
179 ReadoutCalib();
180
181
184
190 ChanDescriptor GetChannelFeeCalib(uint16_t modId, uint16_t padId);
191
194
196 std::string PrintCalibMap();
197
198 private:
199 float fSystemCalibSignal = 900.;
200
201 // --- TRD2D-FEE calibration map
202 // --- Map index: (module_id), map value: (array of channel calibration parameters)
203 std::map<uint16_t, std::array<ChanDescriptor, NFASPMOD* NFASPCH>> fCalibMap = {};
204
206 yaml::Property(&ReadoutCalib::fSystemCalibSignal, "sCalib", "System wide calibrating signal for TRD2D"),
207 yaml::Property(&ReadoutCalib::fCalibMap, "calibMap",
208 "Maps of FEE calibration: mask, DAQ time offset, etc.",
209 YAML::Hex));
210 }; // end struct cbm::algo::trd2d::ReadoutCalib
211
212} // namespace cbm::algo::trd2d
213
#define CBM_YAML_EXTERN_DECL(type)
Declare the external instantiation of the Read and Dump functions for a type.
Definition CbmYaml.h:342
std::string PrintCalibMap()
Debug output of readout map.
std::map< uint16_t, std::array< ChanDescriptor, NFASPMOD *NFASPCH > > fCalibMap
reference signal [ADU] to which the FEE gain is refereed
CBM_YAML_PROPERTIES(yaml::Property(&ReadoutCalib::fSystemCalibSignal, "sCalib", "System wide calibrating signal for TRD2D"), yaml::Property(&ReadoutCalib::fCalibMap, "calibMap", "Maps of FEE calibration: mask, DAQ time offset, etc.", YAML::Hex))
ChanDescriptor GetChannelFeeCalib(uint16_t modId, uint16_t padId)
Retrieve calibration for one channel.
float GetSystemCalibSignal()
Get system reference signal for calibration.
std::vector< uint8_t > GetAsicList(uint16_t equipmentId)
Number of ASICS of a component.
ChanMapping ChanMap(uint16_t equipId, uint16_t asic, uint16_t chan)
API: Mapping from component, asic and channel to tuple (pad address, R pairing flag,...
std::map< uint16_t, CompMapping > fReadoutMap
std::map< uint16_t, std::map< uint8_t, std::vector< ChanMapping > > > fChannelMap
std::string PrintReadoutMap()
Debug output of readout map.
std::vector< uint16_t > GetEquipmentIds()
Equipment in the configuration.
void InitComponentMap(const std::map< uint32_t, std::vector< uint16_t > > &map)
Initialisation of readout map.
void SetSystemTimeOffset(int64_t offsetNs)
Get system time offset.
size_t GetNumAsics(uint16_t equipmentId)
Number of ASICS of a component.
CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::fSystemTimeOffset, "timeOffset", "System time offset for TRD2D"), yaml::Property(&ReadoutSetup::fReadoutMap, "readoutMap", "Maps equipment to module and Optical fibre Id", YAML::Hex), yaml::Property(&ReadoutSetup::fChannelMap, "channelMap", "Maps equipment, ASIC and channel to pad address, mask flag and DAQ offset", YAML::Hex))
void InitChannelMap(const std::map< size_t, std::map< size_t, std::map< size_t, std::tuple< int32_t, bool, int16_t, uint16_t > > > > &channelMap)
Initialisation of channel map.
size_t GetNumChans(uint16_t equipmentId, uint16_t asicId)
Number of channels of a component - ASIC pair.
int64_t GetSystemTimeOffset()
Get system time offset.
CompMapping CompMap(uint16_t equipId)
API: Mapping from component to pair (module id, crob id)
CBM_YAML_PROPERTIES(yaml::Property(&ChanDescriptor::maskFlag, "mask", "Channel masking flag"), yaml::Property(&ChanDescriptor::tOffset, "toff", "Channel wise time offset"), yaml::Property(&ChanDescriptor::baseline, "bline", "Baseline correction"), yaml::Property(&ChanDescriptor::gainfee, "gainfee", "Gain correction for FEE channel"), yaml::Property(&ChanDescriptor::noise, "noise", "Dynamic noise descriptor"))
CBM_YAML_FORMAT(YAML::Flow)
noise descriptor [ChanNoise]
ChanNoise noise
ASIC gain deviation for channel.
float gainfee
Baseline correction for channel.
uint16_t lSThres
Threshold [ADU] for dynamic channel noise.
CBM_YAML_PROPERTIES(yaml::Property(&ChanNoise::tDelay, "delay", "time delay wrt the causing signal"), yaml::Property(&ChanNoise::tWindow, "window", "time window for noise signal search"), yaml::Property(&ChanNoise::lDThres, "dnoise", "Max signal value for cutting dynamic noise signals"), yaml::Property(&ChanNoise::lSThres, "snoise", "Max signal value for cutting static noise signals"))
threshold [ADU] for static channel noise (happens independently)
uint16_t lDThres
time [clk] window to search for noisy signal
uint16_t tWindow
time [clk] delay wrt to causing primary signal
bool maskFlag
map pad and pairing to FASP channel
CBM_YAML_FORMAT(YAML::Flow)
SW threshold for ringing channels.
CBM_YAML_PROPERTIES(yaml::Property(&ChanMapping::padAddress, "address", "Pad address"), yaml::Property(&ChanMapping::maskFlag, "mask", "Channel masking flag"), yaml::Property(&ChanMapping::tOffset, "toff", "Channel wise time offset"), yaml::Property(&ChanMapping::lThreshold, "thres", "SW masking by threshold"))
CBM_YAML_PROPERTIES(yaml::Property(&CompMapping::moduleId, "moduleId", "Module ID"), yaml::Property(&CompMapping::fiberId, "fiberId", "Optical Fibre ID"))