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 "UnpackMS.h"
8#include "yaml/Property.h"
9#include "yaml/Yaml.h"
10
11#include <map>
12#include <sstream>
13#include <utility>
14#include <vector>
15
16namespace cbm::algo::trd2d
17{
18
19
33
34 public:
35 struct CompMapping {
36 uint16_t moduleId;
37 uint8_t fiberId;
38
39 CBM_YAML_FORMAT(YAML::Flow);
41 yaml::Property(&CompMapping::fiberId, "fiberId", "Optical Fibre ID"));
42 };
43
44 struct ChanMapping {
45 int32_t padAddress;
46 bool maskFlag;
47 int8_t tOffset;
48 uint16_t lThreshold;
49
50 CBM_YAML_FORMAT(YAML::Flow);
52 yaml::Property(&ChanMapping::padAddress, "address", "Pad address"),
53 yaml::Property(&ChanMapping::maskFlag, "mask", "Channel masking flag"),
54 yaml::Property(&ChanMapping::tOffset, "toff", "Channel wise time offset"),
55 yaml::Property(&ChanMapping::lThreshold, "thres", "SW masking by threshold"));
56 };
57
60
61
64
65
69 std::vector<uint16_t> GetEquipmentIds();
70
71
76 size_t GetNumAsics(uint16_t equipmentId);
77
78
83 std::vector<uint8_t> GetAsicList(uint16_t equipmentId);
84
85
91 size_t GetNumChans(uint16_t equipmentId, uint16_t asicId);
92
94
99 CompMapping CompMap(uint16_t equipId);
100
101
108 ChanMapping ChanMap(uint16_t equipId, uint16_t asic, uint16_t chan);
109
110
112 std::string PrintReadoutMap();
113
115 void InitComponentMap(const std::map<uint32_t, std::vector<uint16_t>>& map);
116
118 void InitChannelMap(
119 const std::map<size_t, std::map<size_t, std::map<size_t, std::tuple<int32_t, bool, int16_t, uint16_t>>>>&
120 channelMap);
121
124
126 void SetSystemTimeOffset(int64_t offsetNs) { fSystemTimeOffset = offsetNs; };
127
128 private:
129 // --- System time offset
130 int64_t fSystemTimeOffset = 0;
131
132 // --- TRD2D readout map
133 // --- Map index: (equipment), map value: (module id, crob id)
134 std::map<uint16_t, CompMapping> fReadoutMap = {};
135
136 // --- TRD2D channel map
137 // --- Map index: (equipment, asic, chan), map value: (pad address, mask flag, daq offset)
138 std::map<uint16_t, std::map<uint8_t, std::vector<ChanMapping>>> fChannelMap = {};
139
141 yaml::Property(&ReadoutSetup::fSystemTimeOffset, "timeOffset", "System time offset for TRD2D"),
142 yaml::Property(&ReadoutSetup::fReadoutMap, "readoutMap", "Maps equipment to module and Optical fibre Id", YAML::Hex),
144 "Maps equipment, ASIC and channel to pad address, mask flag and DAQ offset",
145 YAML::Hex));
146 }; // end struct cbm::algo::trd2d::ReadoutSetup
147
149
150 public:
151 struct ChanNoise {
152 uint16_t tDelay;
153 uint16_t tWindow;
154 uint16_t lDThres;
155 uint16_t lSThres;
156
158 yaml::Property(&ChanNoise::tDelay, "delay", "time delay wrt the causing signal"),
159 yaml::Property(&ChanNoise::tWindow, "window", "time window for noise signal search"),
160 yaml::Property(&ChanNoise::lDThres, "dnoise", "Max signal value for cutting dynamic noise signals"),
161 yaml::Property(&ChanNoise::lSThres, "snoise", "Max signal value for cutting static noise signals"));
162 };
164 bool maskFlag;
165 int8_t tOffset;
166 float baseline;
167 float gainfee;
169
170 CBM_YAML_FORMAT(YAML::Flow);
172 yaml::Property(&ChanDescriptor::maskFlag, "mask", "Channel masking flag"),
173 yaml::Property(&ChanDescriptor::tOffset, "toff", "Channel wise time offset"),
174 yaml::Property(&ChanDescriptor::baseline, "bline", "Baseline correction"),
175 yaml::Property(&ChanDescriptor::gainfee, "gainfee", "Gain correction for FEE channel"),
176 yaml::Property(&ChanDescriptor::noise, "noise", "Dynamic noise descriptor"));
177 };
178
180 ReadoutCalib();
181
182
185
191 ChanDescriptor GetChannelFeeCalib(uint16_t modId, uint16_t padId);
192
195
197 std::string PrintCalibMap();
198
199 private:
200 float fSystemCalibSignal = 900.;
201
202 // --- TRD2D-FEE calibration map
203 // --- Map index: (module_id), map value: (array of channel calibration parameters)
204 std::map<uint16_t, std::array<ChanDescriptor, NFASPMOD* NFASPCH>> fCalibMap = {};
205
207 yaml::Property(&ReadoutCalib::fSystemCalibSignal, "sCalib", "System wide calibrating signal for TRD2D"),
209 "Maps of FEE calibration: mask, DAQ time offset, etc.",
210 YAML::Hex));
211 }; // end struct cbm::algo::trd2d::ReadoutCalib
212
213} // namespace cbm::algo::trd2d
214
#define CBM_YAML_EXTERN_DECL(type)
Declare the external instantiation of the Read and Dump functions for a type.
Definition Yaml.h:297
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"))