39 ss <<
" DATA : fasp=" << std::setw(2) << (int)
fasp <<
" ch=" << std::setw(2) << (int)
ch
40 <<
" t=" << std::setw(3) << (int)
tlab <<
" data=" << std::setw(4) << (int)
data << std::endl;
43 default: ss <<
" MTYPE: unknown" << std::endl;
break;
50 template<std::u
int8_t mess_ver>
57 eMessageType FaspMessage::getType<uint8_t(eMessageVersion::kMess24)>(uint32_t w)
66 template<std::u
int8_t mess_ver>
73 void FaspMessage::readDW<uint8_t(eMessageVersion::kMess24)>(uint32_t w)
78 uint16_t adc_data = (w >> shift) & 0x3fff;
82 uint16_t sign = adc_data >> 13;
87 value_i = (-1) * ((adc_data ^ 0xffff) & 0x1fff);
89 data = (value_i + 0x1fff) >> 2;
91 tlab = (w >> shift) & 0x7f;
93 ch = (w >> shift) & 0xf;
95 fasp = ((w >> shift) & 0x3f);
108 template<std::u
int8_t mess_ver>
115 void FaspMessage::readEW<uint8_t(eMessageVersion::kMess24)>(uint32_t w)
120 epoch = (w >> shift) & 0x1fffff;
122 ch = (w >> shift) & 0xf;
124 fasp = (w >> shift) & 0x3f;
138 L_(debug) <<
"UnpackPar::dump()";
139 L_(debug) <<
"mod=" <<
fModId <<
" elink[" << (int)
fEqId <<
"]=0x" << std::hex << (
int)
fEqAdd
142 L_(debug) <<
" fasp=" << int(fasp) <<
" par=" << std::hex << ∥
144 L_(debug) <<
"UnpackPar::dump(-----------------------)";
148 uint8_t UnpackPar::mapFaspId2Mod<uint8_t(eMessageVersion::kMessLegacy)>(uint8_t fasp_id)
const
153 L_(debug) <<
"<vLegacy> Eq[" << (int) fEqId <<
"] = 0x" << std::hex << fEqAdd;
158 uint8_t UnpackPar::mapFaspId2Mod<uint8_t(eMessageVersion::kMess24)>(uint8_t fasp_id)
const
174 const fles::MicrosliceDescriptor& msDescr,
175 const uint64_t tTimeslice)
const
189 uint64_t time = uint64_t((msDescr.idx - tTimeslice - fParams.fSystemTimeOffset) / 12.5);
195 const uint32_t nwords = msDescr.size / 4;
196 L_(debug) <<
"UnpackMS<kMessLegacy>::op() param.olink[" << (int) fParams.fEqId <<
"]=0x" << std::hex
197 << (
int) fParams.fEqAdd <<
" data.rob=0x" << int(msDescr.eq_id) <<
" words=" << std::dec << nwords;
199 const uint32_t* wd =
reinterpret_cast<const uint32_t*
>(msContent);
201 unsigned char lFaspOld(0xff);
202 std::vector<FaspMessage> vMess;
203 for (uint64_t j = 0; j < nwords; j++, wd++) {
205 uint8_t ch_id = w & 0xf;
206 uint8_t isaux = (w >> 4) & 0x1;
207 uint8_t slice = (w >> 5) & 0x7f;
208 uint16_t data = (w >> 12) & 0x3fff;
209 uint8_t fasp_id = ((w >> 26) & 0x3f);
215 pushDigis(vMess, time, ctx);
224 if (lFaspOld != fasp_id) {
226 pushDigis(vMess, time, ctx);
241 std::get<0>(result) = FinalizeComponent(ctx);
247 template<u
int8_t sys_ver>
250 constexpr uint8_t mLegacy =
252 const uint16_t mod_id = fParams.fModId;
253 const uint8_t fasp_mod_id = fParams.mapFaspId2Mod<mLegacy>(messes[0].fasp);
254 const UnpackAsicPar& asicPar = fParams.fAsicParams.at(fasp_mod_id);
256 for (
auto imess : messes) {
259 const int32_t pad = std::abs(chPar.
fPadAddress) / 2;
260 const bool hasPairingR = bool(chPar.
fPadAddress > 0);
262 const uint64_t lTime = time + tdaqOffset + imess.tlab;
263 const uint16_t lchR = hasPairingR ? imess.data : 0;
264 const uint16_t lchT = hasPairingR ? 0 : imess.data;
265 std::vector<CbmTrdDigi>& digiBuffer = ctx.
fDigiBuffer[pad];
267 if (digiBuffer.size() == 0) {
268 digiBuffer.emplace_back(pad, lchT, lchR, lTime);
269 digiBuffer.back().SetAddressModule(mod_id);
274 auto id = digiBuffer.rbegin();
278 const int32_t dtime = (*id).GetTimeDAQ() - lTime;
281 if (abs(dtime) < 5) {
282 r = (*id).GetCharge(t, dt);
283 if (lchR && r < 0.1) {
284 (*id).SetCharge(t, lchR, -dtime);
287 else if (lchT && t < 0.1) {
288 (*id).SetCharge(lchT, r, +dtime);
289 (*id).SetTimeDAQ(uint64_t((*id).GetTimeDAQ() - dtime));
296 digiBuffer.emplace_back(pad, lchT, lchR, lTime);
297 digiBuffer.back().SetAddressModule(mod_id);
298 id = digiBuffer.rbegin();
302 for (++
id;
id != digiBuffer.rend(); ++id) {
303 r = (*id).GetCharge(t, dt);
304 if (lchR &&
int(r)) {
305 (*id).SetCharge(t, lchR, dt);
309 else if (lchT &&
int(t)) {
310 (*id).SetCharge(lchT, r, dt);
321 template<u
int8_t sys_ver>
324 std::vector<CbmTrdDigi> outputDigis;
332 r = (*id).GetCharge(t, dt);
334 if (((t > 0) != (*id).IsFlagged(0)) || ((r > 0) != (*id).IsFlagged(1))) {
339 (*id).SetFlag(0,
false);
340 (*id).SetFlag(1,
false);
341 outputDigis.emplace_back(std::move((*
id)));
345 if (nIncomplete > 2) {
355 const fles::MicrosliceDescriptor& msDescr,
356 const uint64_t tTimeslice)
const
362 constexpr uint8_t m24 =
371 uint64_t time = uint64_t((msDescr.idx - tTimeslice - fParams.fSystemTimeOffset) * fAsicClockFreq);
374 const uint32_t nwords = msDescr.size / 4;
375 L_(debug) <<
"UnpackMS<kMess24>::op() param.olink[" << (int) fParams.fEqId <<
"]=0x" << std::hex
376 << (
int) fParams.fEqAdd <<
" data.rob=0x" << int(msDescr.eq_id) <<
" words=" << std::dec << nwords;
379 const uint32_t* wd =
reinterpret_cast<const uint32_t*
>(msContent);
381 unsigned char lFaspOld(0xff);
382 std::vector<FaspMessage> vMess;
383 for (uint32_t j = 0; j < nwords; j++, wd++) {
398 pushDigis(vMess, time, ctx);
406 L_(error) <<
"FASP message[Epoch] with wrong signature.";
415 if (vMess.size()) pushDigis(vMess, time, ctx);
423 vMess.emplace_back(ctx.
fMess);
427 std::vector<CbmTrdDigi> outputDigis;
429 if (!ctx.
fRobDigi[ipad].size())
continue;
430 for (
auto id : ctx.
fRobDigi[ipad]) {
432 outputDigis.emplace_back(std::move(
id));
435 std::get<0>(result) = outputDigis;
441 MsContext& ctx)
const
443 constexpr uint8_t m24 =
445 const uint8_t fasp_mod_id = fParams.mapFaspId2Mod<m24>(messes[0].fasp);
446 L_(debug) <<
"pushDigis<v24> fasp=" << (int) messes[0].fasp <<
"/" << (
int) fasp_mod_id;
447 if (fParams.fAsicParams.find(fasp_mod_id) == fParams.fAsicParams.end()) {
448 L_(error) <<
"pushDigis<v24> fasp=" << (int) messes[0].fasp <<
"/" << (
int) fasp_mod_id
449 <<
" not mapped to param.olink[" << (int) fParams.fEqId <<
"]=0x" << std::hex << (
int) fParams.fEqAdd;
452 const UnpackAsicPar& asicPar = fParams.fAsicParams.at(fasp_mod_id);
454 for (
auto imess : messes) {
455 const UnpackChannelPar& chPar = asicPar.fChanParams[imess.ch];
457 if (chPar.fSignalThres && imess.data <= chPar.fSignalThres)
continue;
458 const int32_t pad = std::abs(chPar.fPadAddress) / 2;
459 const bool hasPairingR = bool(chPar.fPadAddress > 0);
460 const uint64_t lTime = time + chPar.fDaqOffset + imess.tlab;
461 const uint16_t lchR = hasPairingR ? imess.data : 0;
462 const uint16_t lchT = hasPairingR ? 0 : imess.data;
463 std::vector<CbmTrdDigi>& digiBuffer = ctx.fRobDigi[pad];
466 if (digiBuffer.size() == 0) {
467 digiBuffer.emplace_back(pad, lchT, lchR, lTime);
468 digiBuffer.back().SetAddressModule(fParams.fModId);
474 auto&
id = digiBuffer.back();
478 const int32_t dtime =
id.GetTimeDAQ() - lTime;
480 if (abs(dtime) < 5) {
481 r =
id.GetCharge(t, dt);
482 if (lchR && r < 0.1) {
483 id.SetCharge(t, lchR, -dtime);
486 else if (lchT && t < 0.1) {
487 id.SetCharge(lchT, r, +dtime);
488 id.SetTimeDAQ(uint64_t(
id.GetTimeDAQ() - dtime));
495 digiBuffer.emplace_back(pad, lchT, lchR, lTime);
496 digiBuffer.back().SetAddressModule(fParams.fModId);
std::tuple< std::vector< Digi_t >, Monitor_t, Aux_t > Result_t
Unpack algorithm for TRD2D.
std::vector< CbmTrdDigi > FinalizeComponent(MsContext &ctx) const
Finalize component (e.g. copy from temp buffers)
bool pushDigis(std::vector< FaspMessage > messages, const uint64_t time, MsContext &ctx) const
@ kMess24
unpacker version for 2-board FASPRO+GETS HW
uint8_t tlab
time of the digi inside the epoch
void readDW(uint32_t w)
Read DATA WORD and store the content locally.
uint32_t epoch
epoch id (not used for the moment)
uint8_t ch
ch id in the FASP
std::string print() const
void readEW(uint32_t w)
Read EPOCH WORD and store the content locally.
uint8_t fasp
FASP id in the module.
eMessageType type
message type 0 = data, 1 = epoch (not used for the moment)
static eMessageType getType(uint32_t w)
Implementation of message type descriptor according to message version.
TRD2D Unpacking parameters for one Asic.
TRD2D Unpacking parameters for one Asic channel.
int32_t fPadAddress
Pad address for channel.
uint8_t fDaqOffset
Time calibration parameter.
UnpackMonitorData fMonitor
Container for monitoring data.
std::array< std::vector< CbmTrdDigi >, NFASPMOD *NFASPCH > fDigiBuffer
FaspMessage fMess
encapsulation of the FASP message.
UnpackMonitorData fMonitor
Container for monitoring data.
std::array< std::vector< CbmTrdDigi >, NFASPMOD *NFASPPAD > fRobDigi
uint32_t fNumSelfTriggeredData
word fulfills data & 0x2000
uint32_t fNumIncompleteDigis
incomplete digis left in pads after finalization
uint32_t fNumErrEndBitSet
Corrupted data with end bit set.
void dump() const
Write to the debug stream the content of the current param object.
uint8_t fEqId
Equipment (optical fiber) ID of component.
uint16_t fModId
Module ID of component.
std::map< uint8_t, UnpackAsicPar > fAsicParams
Parameters for each ASIC.
uint16_t fEqAdd
Equipment (optical fiber) address [HEX].
#define FASP_EPOCH_LENGTH