CbmRoot
Loading...
Searching...
No Matches
sts/ReadoutConfig.h
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], Felix Weiglhofer */
4#ifndef CBM_ALGO_DETECTOR_STS_READOUT_CONFIG_H
5#define CBM_ALGO_DETECTOR_STS_READOUT_CONFIG_H
6
7#include "Definitions.h"
8#include "yaml/Property.h"
9#include "yaml/Yaml.h"
10
11#include <map>
12#include <string>
13#include <vector>
14
15namespace cbm::algo::sts
16{
17
18 struct ChannelMaskSet;
19
20 enum class FEBType
21 {
22 FEB8_1,
23 FEB8_5
24 };
25
30 struct ReadoutSetup {
31
32 struct Module {
35
37 yaml::Property(&Module::address, "address", "HW address of module", YAML::Hex),
39 "Type 0 had the connector at the right side, type 1 at the left side. For type 0, the mapping "
40 "of FEB to module side as above applies, for type 1, it has to be inverted."));
41 };
42
43 struct Component {
45 std::vector<std::vector<i16>> feb2module;
46 std::vector<std::vector<i16>> feb2moduleSide;
47 std::vector<std::vector<bool>> febIsPulser;
48
49 FEBType GetFEBType() const;
50 size_t FEBsPerCrob() const { return feb2module.at(0).size(); }
51
54 "Equipment ID of component. Written to the data stream (MicrosliceDescriptor).", YAML::Hex),
56 "Mapping of FEB within CROB to module index (-1 = inactive)"),
58 "Mapping of FEB within CROB to module side (0 = left, 1 = right)"),
59 yaml::Property(&Component::febIsPulser, "febIsPulser", "Flag if FEB is pulser (true) or not (false)"));
60 };
61
62 struct Elink {
66
68 yaml::Property(&Elink::toFeb, "toFeb", "Mapping of elink to FEB within CROB (-1 = inactive)"),
69 yaml::Property(&Elink::toAsicFebA, "toAsicFebA", "Mapping of eLink to ASIC for FEB Type A", YAML::Hex),
70 yaml::Property(&Elink::toAsicFebB, "toAsicFebB", "Mapping of eLink to ASIC for FEB Type B", YAML::Hex));
71 };
72
74 std::vector<Module> modules;
75 std::vector<Component> components;
76 std::vector<Elink> elinksFeb8_1;
77 std::vector<Elink> elinksFeb8_5;
78
79 const std::vector<Elink>& GetElinks(FEBType type) const;
80
81 CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::numAsicsPerFeb, "numAsicsPerFeb", "Number of ASICs per FEB"),
82 yaml::Property(&ReadoutSetup::modules, "modules", "Modules", {}, YAML::Flow),
83 yaml::Property(&ReadoutSetup::components, "components", "Components", {}, YAML::Flow),
85 "Elinks for FEB8_1 (1:1 elink:ASIC, 5 FEB / ROB)", {}, YAML::Flow),
87 "Elinks for FEB8_5 (5:1 elink:ASIC, 1 FEB / ROB)", {}, YAML::Flow));
88 };
89
101
102 public:
108
110 ReadoutConfig() = default;
111
114
118 std::vector<u16> GetEquipmentIds();
119
124 size_t GetNumElinks(u16 equipmentId);
125
129 size_t GetNumElinks();
130
136 Entry Map(u16 equipId, u16 elink);
137
143 std::vector<bool> MaskMap(uint16_t equipId, uint16_t elink);
144
150 uint32_t AdcCutMap(uint16_t equipId, uint16_t elink);
151
152
154 std::string PrintReadoutMap();
155
156 private:
157 // --- STS readout map
158 // --- Map index: (equipment, elink)
159 std::map<u16, std::vector<Entry>> fReadoutConfig = {};
160
161 // --- STS adc cut map
162 // --- Map index: (equipment, elink), map value: adc cut
163 std::map<uint16_t, std::map<size_t, uint32_t>> fAdcCutMap = {};
164
165 // --- STS channel mask map
166 // --- Map index: (equipment, elink), map value: (vector of mask flags for channels per asic)
167 std::map<uint16_t, std::map<size_t, std::vector<bool>>> fMaskMap = {};
168
169
171 void Init(const ReadoutSetup&, const ChannelMaskSet&);
172 };
173
174} // namespace cbm::algo::sts
175
177
178#endif // CBM_ALGO_DETECTOR_STS_READOUT_CONFIG_H
#define CBM_YAML_EXTERN_DECL(type)
Declare the external instantiation of the Read and Dump functions for a type.
Definition Yaml.h:297
Provides the hardware-to-software address mapping for the CBM-STS.
void Init(const ReadoutSetup &, const ChannelMaskSet &)
Initialisation of readout map.
std::map< uint16_t, std::map< size_t, std::vector< bool > > > fMaskMap
std::string PrintReadoutMap()
Debug output of readout map.
ReadoutConfig()=default
Empty mapping.
std::map< uint16_t, std::map< size_t, uint32_t > > fAdcCutMap
std::vector< bool > MaskMap(uint16_t equipId, uint16_t elink)
API: Mapping from component and elink to channel mask flags.
std::map< u16, std::vector< Entry > > fReadoutConfig
Entry Map(u16 equipId, u16 elink)
API: Mapping from component and elink to address / ASIC number + pulser flag.
std::vector< u16 > GetEquipmentIds()
Equipment in the configuration.
size_t GetNumElinks()
Total number of elinks for STS.
uint32_t AdcCutMap(uint16_t equipId, uint16_t elink)
API: Mapping from component and elink to minimum adc cut.
Property(T Class::*member, std::string_view key, std::string_view description) -> Property< Class, T >
std::int32_t i32
Definition Definitions.h:20
std::uint32_t u32
Definition Definitions.h:21
std::int16_t i16
Definition Definitions.h:18
std::uint16_t u16
Definition Definitions.h:19
CBM_YAML_PROPERTIES(yaml::Property(&Component::equipmentId, "equipmentId", "Equipment ID of component. Written to the data stream (MicrosliceDescriptor).", YAML::Hex), yaml::Property(&Component::feb2module, "feb2module", "Mapping of FEB within CROB to module index (-1 = inactive)"), yaml::Property(&Component::feb2moduleSide, "feb2moduleSide", "Mapping of FEB within CROB to module side (0 = left, 1 = right)"), yaml::Property(&Component::febIsPulser, "febIsPulser", "Flag if FEB is pulser (true) or not (false)"))
std::vector< std::vector< i16 > > feb2module
std::vector< std::vector< bool > > febIsPulser
std::vector< std::vector< i16 > > feb2moduleSide
CBM_YAML_PROPERTIES(yaml::Property(&Module::address, "address", "HW address of module", YAML::Hex), yaml::Property(&Module::type, "type", "Type 0 had the connector at the right side, type 1 at the left side. For type 0, the mapping " "of FEB to module side as above applies, for type 1, it has to be inverted."))
Readout setup / Hardware cabling for STS Used to create the hardware mapping for the STS unpacker.
std::vector< Module > modules
const std::vector< Elink > & GetElinks(FEBType type) const
std::vector< Elink > elinksFeb8_5
CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::numAsicsPerFeb, "numAsicsPerFeb", "Number of ASICs per FEB"), yaml::Property(&ReadoutSetup::modules, "modules", "Modules", {}, YAML::Flow), yaml::Property(&ReadoutSetup::components, "components", "Components", {}, YAML::Flow), yaml::Property(&ReadoutSetup::elinksFeb8_1, "elinksFeb8_1", "Elinks for FEB8_1 (1:1 elink:ASIC, 5 FEB / ROB)", {}, YAML::Flow), yaml::Property(&ReadoutSetup::elinksFeb8_5, "elinksFeb8_5", "Elinks for FEB8_5 (5:1 elink:ASIC, 1 FEB / ROB)", {}, YAML::Flow))
std::vector< Elink > elinksFeb8_1
std::vector< Component > components