CbmRoot
Loading...
Searching...
No Matches
trd2d/Unpack.cxx
Go to the documentation of this file.
1/* Copyright (C) 2024-2025 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer], Dominik Smith, Alex Bercuci */
4
5#include "Unpack.h"
6
8
9using namespace cbm::algo::trd2d;
10using fles::Subsystem;
11
12Unpack::Unpack(const ReadoutConfig& readout) : fReadout(readout)
13{
20 constexpr std::array<u8, 2> AlgoVersion = {(u8) eMessageVersion::kMessLegacy, (u8) eMessageVersion::kMess24};
21
22 // Create one algorithm per component for TRD and configure it with parameters
23 auto equipIdsTrd2d = fReadout.GetEquipmentIds();
24 for (auto& equip : equipIdsTrd2d) {
25
26 trd2d::UnpackPar par{};
27 const size_t numAsics = fReadout.GetNumAsics(equip);
28
29 auto asics = fReadout.GetAsicList(equip);
30 for (auto asic : asics) {
32 const size_t numChans = fReadout.GetNumChans(equip, asic);
33
34 for (size_t chan = 0; chan < numChans; chan++) {
36 auto pars = fReadout.ChanMap(equip, asic, chan);
37 chanPar.fPadAddress = pars.padAddress; // Pad address for channel
38 chanPar.fMask = pars.maskFlag; // Flag channel mask
39 chanPar.fDaqOffset = pars.tOffset; // Time calibration parameter
40 chanPar.fSignalThres = pars.lThreshold; // Threshold cut
41 asicPar.fChanParams.push_back(chanPar);
42 }
43 L_(debug) << "--- Configured asic " << (int) asic << " with " << numChans << " channels";
44 auto comppars = fReadout.CompMap(equip);
45 par.fSystemTimeOffset = fReadout.GetSystemTimeOffset();
46 par.fModId = comppars.moduleId;
47 par.fEqAdd = equip;
48 par.fEqId = comppars.fiberId;
49 par.fAsicParams[asic] = asicPar;
50 }
51 L_(debug) << "--- Configured equipment 0x" << std::hex << (int) equip << " with " << std::dec << numAsics
52 << " asics";
53
54 // build all algorithms defined for data unpacking ! Why ?? (AB 25.01.15)
55 std::unique_ptr<UnpackMSBase<CbmTrdDigi, UnpackMonitorData, UnpackAuxData>> algo;
56 for (auto ver : AlgoVersion) {
57 switch (ver) {
59 algo = std::make_unique<UnpackMS<(u8) eMessageVersion::kMessLegacy>>(std::move(par));
60 break;
61 case (int) eMessageVersion::kMess24:
62 algo = std::make_unique<UnpackMS<(u8) eMessageVersion::kMess24>>(std::move(par));
63 break;
64 }
65 // register algorithm
66 L_(debug) << "Register algo for ver=" << (int) ver << " eqId=0x" << std::hex << (int) equip;
67 fAlgos[{equip, ver}] = std::move(algo);
68 }
69 }
70 L_(info) << "--- Configured " << fAlgos.size() << " unpacker algorithms for TRD2D.";
71 // for (const auto& [key, algo] : fAlgos) {
72 // L_(info) << "eq=0x" << std::hex << key.eqId << " ver=" << int(key.sysVer);
73 // if (key.sysVer ==2 ) continue;
74 // (dynamic_cast<const UnpackMS<3>&>(*algo)).DumpParameters();
75 // }
76}
77
78Unpack::Result_t Unpack::operator()(const fles::Timeslice& ts) const { return DoUnpack(Subsystem::TRD2D, ts); }
#define L_(level)
Result_t DoUnpack(const fles::Subsystem subsystem, const fles::Timeslice &ts) const
std::map< UnpackKey, std::unique_ptr< Unpack_t > > fAlgos
Provides the hardware-to-software address mapping for the CBM-TRD2D.
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,...
size_t GetNumAsics(uint16_t equipmentId)
Number of ASICS of a component.
size_t GetNumChans(uint16_t equipmentId, uint16_t asicId)
Number of channels of a component - ASIC pair.
std::vector< uint8_t > GetAsicList(uint16_t equipmentId)
Number of ASICS of a component.
std::vector< uint16_t > GetEquipmentIds()
Equipment in the configuration.
int64_t GetSystemTimeOffset()
Get system time offset.
CompMapping CompMap(uint16_t equipId)
API: Mapping from component to pair (module id, crob id)
Unpack algorithm for TRD2D.
detail::UnpackBase::Result_t Result_t
Unpack(const ReadoutConfig &readout)
Result_t operator()(const fles::Timeslice &) const
@ kMess24
unpacker version for 2-board FASPRO+GETS HW
std::uint8_t u8
Definition Definitions.h:17
TRD2D Unpacking parameters for one Asic.
std::vector< UnpackChannelPar > fChanParams
Parameters for different channels.
TRD2D Unpacking parameters for one Asic channel.
int32_t fPadAddress
Pad address for channel.
uint16_t fSignalThres
Signal threshold to remove ringing channels.
uint8_t fDaqOffset
Time calibration parameter.
bool fMask
Flag for channel masking.
Parameters required for the TRD2D unpacking (specific to one component)