Project
Loading...
Searching...
No Matches
RUDecodeData.h
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
14#ifndef ALICEO2_ITSMFT_RUDECODEDATA_H_
15#define ALICEO2_ITSMFT_RUDECODEDATA_H_
16
17#include <array>
18#include <memory>
24
25namespace o2
26{
27namespace itsmft
28{
29struct GBTLink;
30
32
33 static constexpr int MaxCablesPerRU = 28; // max number of cables RU can readout
34 static constexpr int MaxChipsPerRU = 196; // max number of chips the RU can readout
35 static constexpr int MaxLinksPerRU = 3; // max number of GBT links per RU
36
37 std::array<PayLoadCont, MaxCablesPerRU> cableData{}; // cable data in compressed ALPIDE format
38 std::vector<o2::itsmft::ChipPixelData> chipsData{}; // fully decoded data in 1st nChipsFired chips
39 std::map<int, ChipPixelData*> seenChips{}; // Map that records chip data by global ID
40 std::vector<uint16_t> seenChipIDsInCable{}; // IDs of chips seen in the current cable
41 std::vector<uint16_t> seenChipIDs{}; // IDs of all chips seen during ROF decoding, including empty ones
42 std::array<int, MaxLinksPerRU> links{}; // link entry RSTODO: consider removing this and using pointer
43 std::array<uint8_t, MaxCablesPerRU> cableHWID{}; // HW ID of cable whose data is in the corresponding slot of cableData
44 std::array<uint8_t, MaxCablesPerRU> cableLinkID{}; // ID of the GBT link transmitting this cable data
45 std::array<GBTLink*, MaxCablesPerRU> cableLinkPtr{}; // Ptr of the GBT link transmitting this cable data
46 std::unordered_map<uint64_t, uint32_t> linkHBFToDump{}; // FEEID<<32+hbfEntry to dump in case of error
47 int ruSWID = -1; // SW (stave) ID
48 int nChipsFired = 0; // number of chips with data or with errors
49 int lastChipChecked = 0; // last chips checked among nChipsFired
50 int nNonEmptyLinks = 0; // number of non-empty links for current ROF
51 int nLinks = 0; // number of links seen for this TF
52 int nLinksDone = 0; // number of links finished for this TF
53 int verbosity = 0; // verbosity level, for -1,0 print only summary data, for 1: print once every error
54 bool ROFRampUpStage = false; // flag that the data come from the ROF rate ramp-up stage
55 GBTCalibData calibData{}; // calibration info from GBT calibration word
56 std::unordered_map<uint32_t, std::pair<uint32_t, uint32_t>> chipErrorsTF{}; // vector of chip decoding errors seen in the given TF
57 std::vector<ErrorMessage> errMsgVecTF; // Specific errors info collected for sending for the whole TF
58
59 const RUInfo* ruInfo = nullptr;
60
62 {
63 memset(&links[0], -1, MaxLinksPerRU * sizeof(int));
64 }
65 void clear();
67 {
68 seenChipIDs.clear();
69 }
70 void setROFInfo(ChipPixelData* chipData, const GBTLink* lnk);
71 template <class Mapping>
72 int decodeROF(const Mapping& mp, const o2::InteractionRecord ir, bool verifyDecoder);
73 void fillChipStatistics(int icab, const ChipPixelData* chipData);
74 void dumpcabledata(int icab);
75 bool checkLinkInSync(int icab, const o2::InteractionRecord ir);
77};
78
81template <class Mapping>
82int RUDecodeData::decodeROF(const Mapping& mp, const o2::InteractionRecord ir, bool verifyDecoder)
83{
84 nChipsFired = 0;
86 int ntot = 0;
87 // poll majority ROF IR to detect desynchronization between the liks
88
89 std::array<bool, Mapping::getNChips()> doneChips{};
90 auto* chipData = &chipsData[0];
91 seenChipIDs.clear();
92 for (int icab = 0; icab < ruInfo->nCables; icab++) { // cableData is ordered in such a way to have chipIDs in increasing order
93 if (!cableData[icab].getSize()) {
94 continue;
95 }
96 if (!checkLinkInSync(icab, ir)) { // apparently there was desynchronization
97 continue;
98 }
99 auto cabHW = cableHWID[icab];
100 auto chIdGetter = [this, &mp, cabHW](int cid) {
101 // return mp.getGlobalChipID(cid, cabHW, *this->ruInfo);
102 auto chip = mp.getGlobalChipID(cid, cabHW, *this->ruInfo);
103 return chip;
104 };
105 auto localChipIdGetter = [this, &mp, cabHW](int gid) {
106 auto localID = mp.getLocalChipID(gid, cabHW, *this->ruInfo);
107 return localID;
108 };
109
110 int ret = 0;
111 // dumpcabledata(icab);
112
113 std::vector<uint16_t>* seenChipIDsPtr = &seenChipIDs;
114 if (verifyDecoder) {
115 seenChipIDsInCable.clear();
116 seenChipIDsPtr = &seenChipIDsInCable;
117 seenChips.clear();
118 }
119 while ((ret = AlpideCoder::decodeChip(*chipData, cableData[icab], *seenChipIDsPtr, chIdGetter)) || chipData->isErrorSet()) { // we register only chips with hits or errors flags set
120 setROFInfo(chipData, cableLinkPtr[icab]);
121 if (verifyDecoder) {
122 auto ID = chipData->getChipID();
123 // Since the errored chips are not recorded, we need to add them
124 // separately
125 if (seenChipIDsInCable.empty() || seenChipIDsInCable.back() != ID) {
126 seenChipIDsInCable.push_back(ID);
127 }
128 seenChips[ID] = chipData;
129 }
130 auto nhits = chipData->getData().size();
131 if (nhits && doneChips[chipData->getChipID()]) {
132 if (chipData->getChipID() == chipsData[nChipsFired - 1].getChipID()) {
133 LOGP(debug, "re-entry into the data of the chip {} after previously detector error", chipData->getChipID());
134 }
135#ifdef ALPIDE_DECODING_STAT
136 else {
137 chipData->setError(ChipStat::InterleavedChipData);
138 }
139#endif
140 ret = -1; // discard decoded data
141 nhits = 0;
142 }
143#ifdef ALPIDE_DECODING_STAT
144 fillChipStatistics(icab, chipData);
145#endif
146 if (nhits && chipData->getChipID() < Mapping::getNChips()) {
147 doneChips[chipData->getChipID()] = true;
148 ntot += nhits;
149 if (++nChipsFired < chipsData.size()) { // fetch next free chip
150 chipData = &chipsData[nChipsFired];
151 } else {
152 break; // last chip decoded
153 }
154 }
155 if (ret < 0) {
156 break; // negative code was returned by decoder: abandon cable data
157 }
158 }
159 if (verifyDecoder) {
161 seenChipIDsInCable, localChipIdGetter,
162 chIdGetter);
163 seenChipIDs.insert(seenChipIDs.end(), seenChipIDsInCable.begin(), seenChipIDsInCable.end());
164 }
165 cableData[icab].clear();
166 }
167 return ntot;
168}
169
170} // namespace itsmft
171} // namespace o2
172
173#endif
class for the ALPIDE data decoding/encoding
std::ostringstream debug
Calibration data from GBT data.
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc bool
Declaration of class for continuos buffer of ALPIDE data.
Transient data classes for single pixel and set of pixels from current chip.
Checks validity of hardware address (HW) and transform it to digit AbsId index.
static bool verifyDecodedCable(std::map< int, ChipPixelData * > &seenChips, PayLoadCont &buffer, std::vector< uint16_t > &seenChipIDs, LG lidGetter, CG cidGetter)
static int decodeChip(ChipPixelData &chipData, T &buffer, std::vector< uint16_t > &seenChips, CG cidGetter)
decode alpide data for the next non-empty chip from the buffer
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< o2::itsmft::ChipPixelData > chipsData
std::unordered_map< uint64_t, uint32_t > linkHBFToDump
void dumpcabledata(int icab)
std::unordered_map< uint32_t, std::pair< uint32_t, uint32_t > > chipErrorsTF
std::vector< uint16_t > seenChipIDsInCable
void setROFInfo(ChipPixelData *chipData, const GBTLink *lnk)
std::map< int, ChipPixelData * > seenChips
static constexpr int MaxChipsPerRU
std::array< int, MaxLinksPerRU > links
std::array< PayLoadCont, MaxCablesPerRU > cableData
static constexpr int MaxCablesPerRU
static constexpr int MaxLinksPerRU
std::array< uint8_t, MaxCablesPerRU > cableHWID
ClassDefNV(RUDecodeData, 2)
std::array< GBTLink *, MaxCablesPerRU > cableLinkPtr
std::vector< ErrorMessage > errMsgVecTF
bool checkLinkInSync(int icab, const o2::InteractionRecord ir)
int decodeROF(const Mapping &mp, const o2::InteractionRecord ir, bool verifyDecoder)
std::vector< uint16_t > seenChipIDs
std::array< uint8_t, MaxCablesPerRU > cableLinkID
void fillChipStatistics(int icab, const ChipPixelData *chipData)
uint8_t nCables
Definition RUInfo.h:36
o2::InteractionRecord ir(0, 0)