CbmRoot
Loading...
Searching...
No Matches
trd/Unpack.cxx
Go to the documentation of this file.
1/* Copyright (C) 2024 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer], Dominik Smith */
4
5#include "Unpack.h"
6
8
9using namespace cbm::algo::trd;
10using fles::Subsystem;
11
12Unpack::Unpack(const ReadoutConfig& readout) : fReadout(readout)
13{
14 constexpr std::array<u8, 2> SystemVersion = {0x01, 0x10};
15
16 // Create one algorithm per component for TRD and configure it with parameters
17 auto equipIdsTrd = fReadout.GetEquipmentIds();
18 for (auto& equip : equipIdsTrd) {
19 trd::UnpackPar par{};
20 const size_t numCrobs = fReadout.GetNumCrobs(equip);
21
22 for (size_t crob = 0; crob < numCrobs; crob++) {
23 trd::UnpackCrobPar crobPar;
24 const size_t numElinks = fReadout.GetNumElinks(equip, crob);
25
26 for (size_t elink = 0; elink < numElinks; elink++) {
27 trd::UnpackElinkPar elinkPar;
28 auto addresses = fReadout.Map(equip, crob, elink);
29 elinkPar.fAddress = addresses.first; // Asic address for this elink
30 elinkPar.fChanAddress = addresses.second; // Channel addresses for this elink
32 crobPar.fElinkParams.push_back(elinkPar);
33 }
34 par.fCrobParams.push_back(crobPar);
35 }
36 auto algo_01 = std::make_unique<UnpackMS<SystemVersion[0]>>(std::move(par));
37 auto algo_10 = std::make_unique<UnpackMS<SystemVersion[1]>>(std::move(par));
38 fAlgos[{equip, SystemVersion[0]}] = std::move(algo_01);
39 fAlgos[{equip, SystemVersion[1]}] = std::move(algo_10);
40
41 L_(debug) << "--- Configured equipment " << equip << " with " << numCrobs << " crobs";
42 }
43 L_(info) << "--- Configured " << fAlgos.size() << " unpacker algorithms for TRD.";
44}
45
46Unpack::Result_t Unpack::operator()(const fles::Timeslice& ts) const { return DoUnpack(Subsystem::TRD, 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-TRD.
std::vector< uint16_t > GetEquipmentIds()
Equipment in the configuration.
std::pair< int32_t, std::vector< uint32_t > > Map(uint16_t equipId, uint16_t crob, uint16_t elink)
API: Mapping from component, crob and elink to pair (ASIC address, channel addresses)
int32_t GetElinkTimeOffset(uint32_t criid, uint8_t elinkid)
Get the time offeset to be substracted from the digis which come from a specific CRI.
size_t GetNumCrobs(uint16_t equipmentId)
Number of CROBS of a component.
size_t GetNumElinks(uint16_t equipmentId, uint16_t crobId)
Number of elinks of a component - CROB pair.
int64_t GetSystemTimeOffset()
Get system time offset.
ReadoutConfig fReadout
Definition trd/Unpack.h:31
detail::UnpackBase::Result_t Result_t
Definition trd/Unpack.h:22
Unpack(const ReadoutConfig &readout)
Result_t operator()(const fles::Timeslice &) const
TRD Unpacking parameters for one CROB.
std::vector< UnpackElinkPar > fElinkParams
Parameters for each eLink.
TRD Unpacking parameters for one eLink.
std::vector< uint32_t > fChanAddress
CbmTrdAddress for different channels.
uint32_t fAddress
Asic address.
uint64_t fTimeOffset
Time calibration parameter.
Parameters required for the TRD unpacking (specific to one component)