Project
Loading...
Searching...
No Matches
BareELinkDecoder.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
12#include "BareElinkDecoder.h"
13
14namespace o2::mch::raw
15{
16template <>
17void BareElinkDecoder<ChargeSumMode>::sendCluster()
18{
19 SampaChannelHandler handler = mDecodedDataHandlers.sampaChannelHandler;
20 if (handler) {
21 handler(mDsId, getDualSampaChannelId(mSampaHeader),
22 SampaCluster(mTimestamp, mSampaHeader.bunchCrossingCounter(), mClusterSum, mClusterSize));
23 }
24}
25
26template <>
27void BareElinkDecoder<SampleMode>::sendCluster()
28{
29 SampaChannelHandler handler = mDecodedDataHandlers.sampaChannelHandler;
30 if (handler) {
31 handler(mDsId, getDualSampaChannelId(mSampaHeader),
32 SampaCluster(mTimestamp, mSampaHeader.bunchCrossingCounter(), mSamples));
33 }
34 mSamples.clear();
35}
36template <>
37void BareElinkDecoder<ChargeSumMode>::changeToReadingData()
38{
39 changeState(State::ReadingClusterSum, 20);
40}
41
42template <>
43void BareElinkDecoder<SampleMode>::changeToReadingData()
44{
45 changeState(State::ReadingSample, 10);
46}
47
48std::string bitBufferString(const std::bitset<50>& bs, int imax)
49{
50 std::string s;
51 for (int i = 0; i < 64; i++) {
52 if ((static_cast<uint64_t>(1) << i) > imax) {
53 break;
54 }
55 if (bs.test(i)) {
56 s += "1";
57 } else {
58 s += "0";
59 }
60 }
61 return s;
62}
63
64} // namespace o2::mch::raw
int32_t i
DualSampaChannelId getDualSampaChannelId(const SampaHeader &sh)
Return channel number (0..63)
std::string bitBufferString(const std::bitset< 50 > &bs, int imax)
std::function< void(DsElecId dsId, DualSampaChannelId channel, SampaCluster)> SampaChannelHandler