Project
Loading...
Searching...
No Matches
DigitPayloadEncoder.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
17#include "Framework/Logger.h"
22#include <cstdint>
23#include <fmt/printf.h>
24#include <functional>
25#include <gsl/span>
26#include <memory>
27#include "Framework/Logger.h"
28
29namespace o2::mch::raw
30{
32{
33 return fmt::format("DetID {:4d} PadId {:10d} ADC {:10d} TFtime {:10d} NofSamples {:5d} {}",
34 d.getDetID(), d.getPadID(), d.getADC(), d.getTime(), d.getNofSamples(),
35 d.isSaturated() ? "(S)" : "");
36}
37
39 PayloadEncoder& encoder)
40 : mDigit2ElecMapper{digit2elec}, mEncoder{encoder}
41{
42}
43
44void DigitPayloadEncoder::encodeDigits(gsl::span<o2::mch::Digit> digits,
47 std::vector<std::byte>& buffer)
48{
49 mEncoder.startHeartbeatFrame(orbit, bc);
50 for (auto d : digits) {
51 auto optElecId = mDigit2ElecMapper(d);
52 if (!optElecId.has_value()) {
53 LOGP(warning, "could not get elecId for digit {}", asString(d));
54 continue;
55 }
56 auto elecId = optElecId.value().first;
57 int dualSampaChannelId = optElecId.value().second;
58 // FIXME : what to put as rel time ?
59 uint10_t ts = 0;
61 uint20_t bxCount = sampaBunchCrossingCounter(orbit, bc, firstIR.orbit);
62 auto clusters = {raw::SampaCluster(ts, bxCount, d.getADC(), d.getNofSamples())};
63 mEncoder.addChannelData(elecId, dualSampaChannelId, clusters);
64 }
65 mEncoder.moveToBuffer(buffer);
66}
67} // namespace o2::mch::raw
uint64_t orbit
Definition RawEventData.h:6
uint64_t bc
Definition RawEventData.h:5
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
MCH digit implementation.
Definition Digit.h:31
DigitPayloadEncoder(Digit2ElecMapper digit2elec, PayloadEncoder &encoder)
void encodeDigits(gsl::span< o2::mch::Digit > digits, uint32_t orbit, uint16_t bc, std::vector< std::byte > &buffer)
A PayloadEncoder builds MCH raw data (payload part only)
virtual void startHeartbeatFrame(uint32_t orbit, uint16_t bunchCrossing)=0
virtual void addChannelData(DsElecId dsId, DualSampaChannelId chId, const std::vector< SampaCluster > &data)=0
virtual size_t moveToBuffer(std::vector< std::byte > &buffer)=0
uint16_t uint10_t
Definition DataFormats.h:67
std::function< std::optional< std::pair< DsElecId, int > >(const o2::mch::Digit &digit)> Digit2ElecMapper
uint20_t sampaBunchCrossingCounter(uint32_t orbit, uint16_t bc, uint32_t firstOrbit)
std::string asString(const SampaCluster &sc)
Piece of data for one Sampa channel.
IR getFirstSampledTFIR() const
get TF and HB (abs) for this IR
Definition HBFUtils.h:74
std::vector< Cluster > clusters
std::vector< Digit > digits