CbmRoot
Loading...
Searching...
No Matches
tof/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: Dominik Smith [committer] */
4
5#pragma once
6
7#include "Definitions.h"
8#include "yaml/Property.h"
9#include "yaml/Yaml.h"
10
11#include <cstddef>
12#include <cstdint>
13#include <map>
14#include <vector>
15
16namespace cbm::algo::tof
17{
18
23 struct ReadoutSetup {
24
25 struct CROB {
31
33 yaml::Property(&CROB::moduleId, "moduleId", "Unique ID of module the CROB resides in"),
34 yaml::Property(&CROB::rpcType, "rpcType", "add explanation."),
35 yaml::Property(&CROB::rpcSide, "rpcSide", "add explanation."),
36 yaml::Property(&CROB::nRPC, "nRPC", "number of RPCs."),
37 yaml::Property(&CROB::timeOffset, "timeOffset", "time offset for CROB"));
38 };
39
45 std::vector<CROB> crobs;
46 std::vector<u16> eqIds;
47 std::vector<i32> elink2Asic;
48 std::vector<i32> elink2AsicInner;
49 std::vector<i32> asic2PadI;
50
51 CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::timeOffset, "timeOffset", "Time offset for TOF"),
52 yaml::Property(&ReadoutSetup::nFebsPerComponent, "nFebsPerComponent", "Number of FEBs per component"),
53 yaml::Property(&ReadoutSetup::nAsicsPerFeb, "nAsicsPerFeb", "Number of ASICs per FEB"),
54 yaml::Property(&ReadoutSetup::nChannelsPerAsic, "nChannelsPerAsic", "Number of channels per ASIC"),
55 yaml::Property(&ReadoutSetup::nCrobPerComponent, "nCrobPerComponent", "Number of CROBs per component"),
56 yaml::Property(&ReadoutSetup::crobs, "crobs", "Crobs", {}, YAML::Flow),
57 yaml::Property(&ReadoutSetup::eqIds, "eqIds", "Array to hold the unique IDs (equipment ID) for all TOF DPBs" , YAML::Flow, YAML::Hex),
58 yaml::Property(&ReadoutSetup::elink2Asic, "elink2Asic", "Mapping to eLink to ASIC number within CROB. Mapping is the same for each CROB. (size: nElinksPerCrob)" , YAML::Flow),
59 yaml::Property(&ReadoutSetup::elink2AsicInner, "elink2AsicInner", "add explanation" , YAML::Flow),
60 yaml::Property(&ReadoutSetup::asic2PadI, "asic2PadI", "Mapping in Readout chain PCBs; Map from GET4 channel to PADI channel (size: nChansPerFeb)" , YAML::Flow));
61
62 size_t NComponents() const { return eqIds.size(); }
63 size_t NCrobs() const { return crobs.size(); }
70
71 bool CheckBmonComp(uint32_t uCompId) const { return ((uCompId & 0xFFF0) == 0xABF0); }
72 bool CheckInnerComp(uint32_t uCompId) const { return ((uCompId & 0xFFF0) == 0xBBC0); }
73 };
74
75
77
79
80 public:
82 ReadoutConfig(const ReadoutSetup& pars);
83
86
91
95 std::vector<uint16_t> GetEquipmentIds();
96
101 size_t GetNumElinks(uint16_t equipmentId);
102
108 std::vector<uint32_t> Map(uint16_t equipId, uint16_t elink);
109
115 int32_t GetElinkTimeOffset(uint16_t equipId, uint16_t elink);
116
117 private:
118 // --- BMon system time offset
119 int32_t fTimeOffset = 0;
120
121 // --- TOF elink time offsets
122 // --- Map index: (equipment, elink), map value: (time offset)
123 std::map<uint16_t, std::vector<uint64_t>> fTimeOffsetMap = {};
124
125 // --- TOF readout map
126 // --- Map index: (equipment, elink, channel), map value: (TOF address)
127 std::map<uint16_t, std::vector<std::vector<uint32_t>>> fReadoutMap = {};
128
130 void Init(const ReadoutSetup& pars);
131
133 int32_t ElinkIdxToGet4Idx(uint32_t elink, const ReadoutSetup& pars);
135 int32_t ElinkIdxToGet4IdxInner(uint32_t elink, const ReadoutSetup& pars);
136
137 int32_t Get4ChanToPadiChan(uint32_t channelInFee, const ReadoutSetup& pars);
138
139 std::vector<int32_t> fviRpcChUId = {}; // UID/address for each channel, build from type, side and module
140
141 void BuildChannelsUidMap(const ReadoutSetup& pars);
142 void BuildChannelsUidMapCbm(uint32_t& uCh, const CROB& crob);
143 void BuildChannelsUidMapStar(uint32_t& uCh, const CROB& crob);
144 void BuildChannelsUidMapCern(uint32_t& uCh, const CROB& crob);
145 void BuildChannelsUidMapCera(uint32_t& uCh, const CROB& crob);
146 void BuildChannelsUidMapStar2(uint32_t& uCh, const CROB& crob);
147 void BuildChannelsUidMapStar2Inner(uint32_t& uCh, const CROB& crob);
148 void BuildChannelsUidMapBuc(uint32_t& uCh, const CROB& crob);
149 };
150
151} // namespace cbm::algo::tof
152
#define CBM_YAML_EXTERN_DECL(type)
Declare the external instantiation of the Read and Dump functions for a type.
Definition Yaml.h:297
void BuildChannelsUidMapStar(uint32_t &uCh, const CROB &crob)
void BuildChannelsUidMapCern(uint32_t &uCh, const CROB &crob)
void BuildChannelsUidMapStar2Inner(uint32_t &uCh, const CROB &crob)
int32_t ElinkIdxToGet4Idx(uint32_t elink, const ReadoutSetup &pars)
Mapping to eLink to ASIC number within DPB. Mapping is the same for each DPB.
std::map< uint16_t, std::vector< std::vector< uint32_t > > > fReadoutMap
void BuildChannelsUidMapStar2(uint32_t &uCh, const CROB &crob)
void BuildChannelsUidMapCera(uint32_t &uCh, const CROB &crob)
std::vector< int32_t > fviRpcChUId
int32_t GetElinkTimeOffset(uint16_t equipId, uint16_t elink)
API: Mapping from component and elink to time offset.
void BuildChannelsUidMapCbm(uint32_t &uCh, const CROB &crob)
std::map< uint16_t, std::vector< uint64_t > > fTimeOffsetMap
void BuildChannelsUidMap(const ReadoutSetup &pars)
void Init(const ReadoutSetup &pars)
Initialisation of readout map.
std::vector< uint32_t > Map(uint16_t equipId, uint16_t elink)
API: Mapping from component and elink to addresses per channel.
int32_t ElinkIdxToGet4IdxInner(uint32_t elink, const ReadoutSetup &pars)
Mapping to eLink to ASIC number within DPB for 2024 inner TOF FEBs. Mapping is the same for each DPB.
ReadoutConfig(const ReadoutSetup &pars)
Constructor.
std::vector< uint16_t > GetEquipmentIds()
Equipment in the configuration.
i32 GetSystemTimeOffset() const
System time offset for TOF.
void BuildChannelsUidMapBuc(uint32_t &uCh, const CROB &crob)
int32_t Get4ChanToPadiChan(uint32_t channelInFee, const ReadoutSetup &pars)
size_t GetNumElinks(uint16_t equipmentId)
Number of elinks of a component.
Property(T Class::*member, std::string_view key, std::string_view description) -> Property< Class, T >
std::int32_t i32
Definition Definitions.h:20
CBM_YAML_PROPERTIES(yaml::Property(&CROB::moduleId, "moduleId", "Unique ID of module the CROB resides in"), yaml::Property(&CROB::rpcType, "rpcType", "add explanation."), yaml::Property(&CROB::rpcSide, "rpcSide", "add explanation."), yaml::Property(&CROB::nRPC, "nRPC", "number of RPCs."), yaml::Property(&CROB::timeOffset, "timeOffset", "time offset for CROB"))
Readout setup / Hardware cabling for TOF Used to create the hardware mapping for the TOF unpacker.
CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::timeOffset, "timeOffset", "Time offset for TOF"), yaml::Property(&ReadoutSetup::nFebsPerComponent, "nFebsPerComponent", "Number of FEBs per component"), yaml::Property(&ReadoutSetup::nAsicsPerFeb, "nAsicsPerFeb", "Number of ASICs per FEB"), yaml::Property(&ReadoutSetup::nChannelsPerAsic, "nChannelsPerAsic", "Number of channels per ASIC"), yaml::Property(&ReadoutSetup::nCrobPerComponent, "nCrobPerComponent", "Number of CROBs per component"), yaml::Property(&ReadoutSetup::crobs, "crobs", "Crobs", {}, YAML::Flow), yaml::Property(&ReadoutSetup::eqIds, "eqIds", "Array to hold the unique IDs (equipment ID) for all TOF DPBs", YAML::Flow, YAML::Hex), yaml::Property(&ReadoutSetup::elink2Asic, "elink2Asic", "Mapping to eLink to ASIC number within CROB. Mapping is the same for each CROB. (size: nElinksPerCrob)", YAML::Flow), yaml::Property(&ReadoutSetup::elink2AsicInner, "elink2AsicInner", "add explanation", YAML::Flow), yaml::Property(&ReadoutSetup::asic2PadI, "asic2PadI", "Mapping in Readout chain PCBs; Map from GET4 channel to PADI channel (size: nChansPerFeb)", YAML::Flow))
bool CheckBmonComp(uint32_t uCompId) const
std::vector< i32 > elink2AsicInner
bool CheckInnerComp(uint32_t uCompId) const