Project
Loading...
Searching...
No Matches
GBTUserLogicEncoder.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
16
18
20
21namespace o2
22{
23namespace mid
24{
25
26void GBTUserLogicEncoder::setConfig(uint16_t gbtUniqueId, const std::vector<ROBoardConfig>& configurations)
27{
29 mCrateId = crateparams::getCrateIdFromGBTUniqueId(gbtUniqueId);
30 mOffset = 8 * crateparams::getGBTIdInCrate(gbtUniqueId);
31 mResponse.set(configurations);
32}
33
34void GBTUserLogicEncoder::addShort(std::vector<char>& buffer, uint16_t shortWord) const
35{
37 buffer.emplace_back((shortWord >> 8) & 0xFF);
38 buffer.emplace_back(shortWord & 0xFF);
39}
40
42{
44 auto& vec = mBoards[ir];
45 auto boards = mResponse.getTriggerResponse(triggerWord);
46 vec.insert(vec.end(), boards.begin(), boards.end());
47}
48
50{
52
53 // Apply zero suppression
54 std::vector<ROBoard> zsLocs;
55 for (auto& loc : data) {
56 if (!mResponse.isZeroSuppressed(loc)) {
57 zsLocs.emplace_back(loc);
58 }
59 }
60
61 auto& vec = mBoards[ir];
62 vec.insert(vec.end(), zsLocs.begin(), zsLocs.end());
63
64 // Get regional response
65 auto irReg = ir;
66 applyElectronicsDelay(irReg.orbit, irReg.bc, mElectronicsDelay.localToReg);
67 auto regs = mResponse.getRegionalResponse(zsLocs);
68 auto& vecReg = mBoards[irReg];
69 vecReg.insert(vecReg.end(), regs.begin(), regs.end());
70}
71
72void GBTUserLogicEncoder::flush(std::vector<char>& buffer, const InteractionRecord& ir)
73{
75 std::map<InteractionRecord, std::vector<ROBoard>> tmpBoards;
76 for (auto& item : mBoards) {
77 if (item.first <= ir) {
78 for (auto& loc : item.second) {
79 buffer.emplace_back(loc.statusWord);
80 buffer.emplace_back(loc.triggerWord);
81 addShort(buffer, item.first.bc);
82 buffer.emplace_back((raw::getLocId(loc.boardId) << 4) | loc.firedChambers);
83 buffer.emplace_back(mCrateId << 4);
84 if (raw::isLoc(loc.statusWord)) {
85 for (int ich = 4; ich >= 0; --ich) {
86 if (loc.firedChambers & (1 << ich)) {
87 addShort(buffer, loc.patternsBP[ich]);
88 addShort(buffer, loc.patternsNBP[ich]);
89 }
90 }
91 }
92 }
93 } else {
94 tmpBoards[item.first] = item.second;
95 }
96 }
97 mBoards.swap(tmpBoards);
98}
99
100} // namespace mid
101} // namespace o2
MID RO crate parameters.
Raw data encoder for MID GBT user logic.
void process(gsl::span< const ROBoard > data, InteractionRecord ir)
void flush(std::vector< char > &buffer, const InteractionRecord &ir)
void processTrigger(const InteractionRecord &ir, uint8_t triggerWord)
void setConfig(uint16_t gbtUniqueId, const std::vector< ROBoardConfig > &configurations)
std::vector< ROBoard > getRegionalResponse(const std::vector< ROBoard > &locs) const
std::vector< ROBoard > getTriggerResponse(uint8_t triggerWord) const
bool isZeroSuppressed(const ROBoard &loc) const
Returns true if the local board has no fired digits after zero suppression.
void set(const std::vector< ROBoardConfig > &configurations)
GLuint buffer
Definition glcorearb.h:655
GLboolean * data
Definition glcorearb.h:298
uint8_t getCrateIdFromGBTUniqueId(uint16_t gbtUniqueId)
Gets the crate ID from the GBT unique ID.
uint8_t getGBTIdInCrate(uint16_t gbtUniqueId)
Gets the link ID in crate from the RO ID.
bool isLoc(uint8_t statusWord)
Definition ROBoard.h:65
uint8_t getLocId(uint8_t uniqueLocId)
Definition ROBoard.h:80
void applyElectronicsDelay(uint32_t &orbit, uint16_t &bc, int16_t delay, uint16_t maxBunches=constants::lhc::LHCMaxBunches)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
int16_t localToReg
Delay between regional board and local board answers.
std::vector< o2::ctf::BufferType > vec
o2::InteractionRecord ir(0, 0)