Project
Loading...
Searching...
No Matches
DecodedDataAggregator.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
19#include "Framework/Logger.h"
22
23namespace o2
24{
25namespace mid
26{
27
28ColumnData& DecodedDataAggregator::FindColumnData(uint8_t deId, uint8_t columnId, size_t firstEntry, size_t evtTypeIdx)
29{
32 for (auto colIt = mData[evtTypeIdx].begin() + firstEntry, end = mData[evtTypeIdx].end(); colIt != end; ++colIt) {
33 if (colIt->deId == deId && colIt->columnId == columnId) {
34 return *colIt;
35 }
36 }
37 mData[evtTypeIdx].push_back({deId, columnId});
38 return mData[evtTypeIdx].back();
39}
40
41void DecodedDataAggregator::addData(const ROBoard& loc, size_t firstEntry, size_t evtTypeIdx)
42{
44 uint8_t uniqueLocId = loc.boardId;
45 uint8_t crateId = raw::getCrateId(uniqueLocId);
47 try {
48 uint16_t deBoardId = mCrateMapper.roLocalBoardToDE(uniqueLocId);
49 auto rpcLineId = detparams::getRPCLine(detparams::getDEIdFromFEEId(deBoardId));
50 auto columnId = detparams::getColumnIdFromFEEId(deBoardId);
51 auto lineId = detparams::getLineIdFromFEEId(deBoardId);
52 for (int ich = 0; ich < 4; ++ich) {
53 if (((loc.firedChambers >> ich) & 0x1) == 0) {
54 continue;
55 }
56 uint8_t deId = detparams::getDEId(isRightSide, ich, rpcLineId);
57 auto& col = FindColumnData(deId, columnId, firstEntry, evtTypeIdx);
58 col.setBendPattern(loc.patternsBP[ich], lineId);
59 col.setNonBendPattern(col.getNonBendPattern() | loc.patternsNBP[ich]);
60 }
61 } catch (const std::exception& except) {
62 LOG(alarm) << except.what();
63 }
64}
65
66void DecodedDataAggregator::process(gsl::span<const ROBoard> localBoards, gsl::span<const ROFRecord> rofRecords)
67{
69
70 // First clear the output
71 for (auto& data : mData) {
72 data.clear();
73 }
74 for (auto& rof : mROFRecords) {
75 rof.clear();
76 }
77
78 // Fill the map with ordered events
79 for (auto rofIt = rofRecords.begin(); rofIt != rofRecords.end(); ++rofIt) {
80 mEventIndexes[static_cast<int>(rofIt->eventType)][rofIt->interactionRecord.toLong()].emplace_back(rofIt - rofRecords.begin());
81 }
82
83 const ROFRecord* rof = nullptr;
84 for (size_t ievtType = 0; ievtType < mEventIndexes.size(); ++ievtType) {
85 for (auto& item : mEventIndexes[ievtType]) {
86 size_t firstEntry = mData[ievtType].size();
87 for (auto& idx : item.second) {
88 // In principle all of these ROF records have the same timestamp
89 rof = &rofRecords[idx];
90 for (size_t iloc = rof->firstEntry; iloc < rof->firstEntry + rof->nEntries; ++iloc) {
91 addData(localBoards[iloc], firstEntry, ievtType);
92 }
93 }
94 auto nEntries = mData[ievtType].size() - firstEntry;
95 if (nEntries > 0) {
96 mROFRecords[ievtType].emplace_back(rof->interactionRecord, rof->eventType, firstEntry, nEntries);
97 }
98 }
99 // Clear the inner objects when the computation is done
100 mEventIndexes[ievtType].clear();
101 } // loop on event types
102}
103
104} // namespace mid
105} // namespace o2
MID RO crate parameters.
MID decoded raw data aggregator.
Useful detector parameters for MID.
uint32_t col
Definition RawData.h:4
uint16_t roLocalBoardToDE(uint8_t uniqueLocId) const
Converts the LOC ID expressed in readout convention into the LOC ID in MT11 right in the offline conv...
void process(gsl::span< const ROBoard > localBoards, gsl::span< const ROFRecord > rofRecords)
GLuint GLuint end
Definition glcorearb.h:469
GLboolean * data
Definition glcorearb.h:298
uint8_t itsSharedClusterMap uint8_t
bool isRightSide(uint8_t crateId)
Tests if the crate is in the right side.
int getColumnIdFromFEEId(uint16_t uniqueFEEId)
bool isRightSide(int deId)
int getDEIdFromFEEId(uint16_t uniqueFEEId)
int getLineIdFromFEEId(uint16_t uniqueFEEId)
int getDEId(bool isRight, int chamber, int rpc)
uint8_t getCrateId(uint8_t uniqueLocId)
Definition ROBoard.h:75
Enum< T >::Iterator begin(Enum< T >)
Definition Defs.h:173
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
o2::InteractionRecord interactionRecord
Definition ROFRecord.h:44
EventType eventType
Definition ROFRecord.h:45
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"