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 Config& config) : fConfig(config)
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
25 auto equipIdsTrd2d = setup.GetEquipmentIds();
26 for (auto& equip : equipIdsTrd2d) {
27 trd2d::UnpackPar par{};
28 auto comppars = setup.CompMap(equip);
29 par.fSystemTimeOffset = setup.GetSystemTimeOffset();
30 par.fModId = comppars.moduleId;
31 par.fEqAdd = equip;
32 par.fEqId = comppars.fiberId;
33 par.fRefSignal = calib.GetSystemCalibSignal();
34
35 const size_t numAsics = setup.GetNumAsics(equip);
36 auto asics = setup.GetAsicList(equip);
37 for (auto asic : asics) {
39 const size_t numChans = setup.GetNumChans(equip, asic);
40
41 for (size_t chan = 0; chan < numChans; chan++) {
43 auto pars = setup.ChanMap(equip, asic, chan);
44 chanPar.fPadAddress = pars.padAddress; // Pad address for channel
45 uint16_t ch = std::abs(pars.padAddress);
46 auto calCh = calib.GetChannelFeeCalib(par.fModId, ch);
47 par.fCalibParams[ch] = {calCh.maskFlag,
48 calCh.tOffset,
49 calCh.baseline,
50 calCh.gainfee,
51 {calCh.noise.tDelay, calCh.noise.tWindow, calCh.noise.lDThres, calCh.noise.lSThres}};
52 chanPar.fMask = pars.maskFlag; // Flag channel mask
53 chanPar.fDaqOffset = pars.tOffset; // Time calibration parameter
54 par.toff[ch / 2] = pars.tOffset;
55 chanPar.fSignalThres = pars.lThreshold; // Threshold cut
56 asicPar.fChanParams.push_back(chanPar);
57 }
58 L_(debug) << "--- Configured asic " << (int) asic << " with " << numChans << " channels";
59 par.fAsicParams[asic] = asicPar;
60 }
61 L_(debug) << "--- Configured equipment 0x" << std::hex << (int) equip << " with " << std::dec << numAsics
62 << " asics";
63
64 // build all algorithms defined for data unpacking ! Why ?? (AB 25.01.15)
65 std::unique_ptr<UnpackMSBase<CbmTrdDigi, UnpackMonitorData, UnpackAuxData>> algo;
66 for (auto ver : AlgoVersion) {
67 switch (ver) {
69 algo = std::make_unique<UnpackMS<(u8) eMessageVersion::kMessLegacy>>(std::move(par));
70 break;
71 case (int) eMessageVersion::kMess24:
72 algo = std::make_unique<UnpackMS<(u8) eMessageVersion::kMess24>>(std::move(par));
73 break;
74 }
75 // register algorithm
76 L_(debug) << "Register algo for ver=" << (int) ver << " eqId=0x" << std::hex << (int) equip;
77 fAlgos[{equip, ver}] = std::move(algo);
78 }
79 }
80 L_(info) << "--- Configured " << fAlgos.size() << " unpacker algorithms for TRD2D.";
81 // for (const auto& [key, algo] : fAlgos) {
82 // L_(info) << "eq=0x" << std::hex << key.eqId << " ver=" << int(key.sysVer);
83 // if (key.sysVer ==2 ) continue;
84 // (dynamic_cast<const UnpackMS<3>&>(*algo)).DumpParameters();
85 // }
86}
87
88Unpack::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
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::vector< uint16_t > GetEquipmentIds()
Equipment in the configuration.
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.
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 Config &config)
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.
bool fMask
Flag for channel masking.
int8_t fDaqOffset
Time calibration parameter.
Parameters required for the TRD2D unpacking (specific to one component)