Project
Loading...
Searching...
No Matches
RawDataStats.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
12// Cru raw data reader, this is the part that parses the raw data
13// it runs on the flp(pre compression) or on the epn(pre tracklet64 array generation)
14// it hands off blocks of cru pay load to the parsers.
15
16#ifndef O2_TRD_RAWDATASTATS
17#define O2_TRD_RAWDATASTATS
18
19#include "Rtypes.h"
20#include <string>
21#include <cstdint>
22#include <array>
23#include <unordered_map>
26
27namespace o2::trd
28{
29
32 DigitEndMarkerWrongState, // read a end marker but we were expecting something else
33 DigitMCMHeaderSanityCheckFailure, // the checked bits in the DigitMCMHeader were not correctly set
34 DigitMCMNotIncreasing, // sequential headers must have increasing mcm number
35 DigitMCMDuplicate, // we saw two DigitMCMHeaders for the same MCM in one trigger
36 DigitADCMaskInvalid, // mask adc count does not match # of 1s in bitpattern or the check bits are wrongly set
37 DigitSanityCheck, // adc failed sanity check based on current channel (odd/even) and check bits DigitMCMData.f
38 DigitParsingExitInWrongState, // exiting parsing in the wrong state ... got to the end of the buffer in wrong state.
39 DigitParsingNoSecondEndmarker, // we found a single digit end marker not followed by a second one
40 DigitHCHeaderMismatch, // the half-chamber ID from the digit HC header is not consistent with the one expected from the link ID
41 TrackletHCHeaderFailure, // either reserved bit not set or HCID is not what was expected from RDH
42 TrackletMCMHeaderSanityCheckFailure, // MCMHeader sanity check failure, LSB or MSB not set
43 TrackletDataWrongOrdering, // the tracklet data is not arriving in increasing MCM order
44 TrackletDataDuplicateMCM, // we see more than one TrackletMCMHeader for the same MCM
45 TrackletNoTrackletEndMarker, // got to the end of the buffer with out finding a tracklet end marker.
46 TrackletNoSecondEndMarker, // we expected to see a second tracklet end marker, but found something else instead
47 TrackletMCMDataFailure, // invalid word for TrackletMCMData detected
48 TrackletDataMissing, // we expected tracklet data but got an endmarker instead
49 TrackletExitingNoTrackletEndMarker, // got to the end of the buffer exiting tracklet parsing with no tracklet end marker
50 UnparsedTrackletDataRemaining, // the tracklet parsing has finished correctly, but there is still data left on the link (CRU puts incorrect link size or corrupt data?)
51 UnparsedDigitDataRemaining, // the digit parsing has finished correctly, but there is still data left on the link (CRU puts incorrect link size or corrupt data? RDH > 8kByte before?)
52 DigitHeaderCountGT3, // digital half chamber header had more than 3 additional words expected by header. most likely corruption above somewhere.
53 DigitHeaderWrongType, // expected digit header, but could not determine type
54 HalfCRUSumLength, // if the HalfCRU headers summed lengths wont fit into the buffer, implies corruption, its a faster check than the next one.
55 BadRDHMemSize, // RDH memory size is supposedly zero
56 BadRDHFEEID, // RDH parsing failure for reasons in the word
57 BadRDHEndPoint, // RDH parsing failure for reasons in the word
58 BadRDHOrbit, // RDH parsing failure for reasons in the word
59 BadRDHCRUID, // RDH parsing failure for reasons in the word
60 BadRDHPacketCounter, // RDH packet counter not incrementing
61 HalfCRUCorrupt, // if the HalfCRU headers has values out of range, corruption is assumed.
62 DigitHCHeader1Problem, // multiple instances of Digit HC Header 1
63 DigitHCHeader2Problem, // multiple instances of Digit HC Header 2
64 DigitHCHeader3Problem, // multiple instances of Digit HC Header 3
65 DigitHCHeaderSVNMismatch, // svn version information has changed in the DigitHCHeader3.
66 TrackletsReturnedMinusOne, // trackletparsing returned -1, data was dumped;
67 FEEIDIsFFFF, // RDH is in error, the FEEID is 0xffff
68 FEEIDBadSector, // RDH is in error, the FEEID.supermodule is not a valid value.
69 HalfCRUBadBC, // the BC in the half-CRU header is so low that the BC shift would make it negative
70 TRDLastParsingError // This is to keep QC happy until we can change it there as well.
71};
72
73static const std::unordered_map<int, std::string> ParsingErrorsString = {
74 {NoError, "NoError"},
75 {DigitEndMarkerWrongState, "DigitEndMarkerWrongState"},
76 {DigitMCMHeaderSanityCheckFailure, "DigitMCMHeaderSanityCheckFailure"},
77 {DigitMCMNotIncreasing, "DigitMCMNotIncreasing"},
78 {DigitMCMDuplicate, "DigitMCMDuplicate"},
79 {DigitADCMaskInvalid, "DigitADCMaskInvalid"},
80 {DigitSanityCheck, "DigitSanityCheck"},
81 {DigitParsingExitInWrongState, "DigitParsingExitInWrongState"},
82 {DigitParsingNoSecondEndmarker, "DigitParsingNoSecondEndmarker"},
83 {DigitHCHeaderMismatch, "DigitHCHeaderMismatch"},
84 {TrackletHCHeaderFailure, "TrackletHCHeaderFailure"},
85 {TrackletMCMHeaderSanityCheckFailure, "TrackletMCMHeaderSanityCheckFailure"},
86 {TrackletDataWrongOrdering, "TrackletDataWrongOrdering"},
87 {TrackletDataDuplicateMCM, "TrackletDataDuplicateMCM"},
88 {TrackletNoTrackletEndMarker, "TrackletNoTrackletEndMarker"},
89 {TrackletNoSecondEndMarker, "TrackletNoSecondEndMarker"},
90 {TrackletMCMDataFailure, "TrackletMCMDataFailure"},
91 {TrackletDataMissing, "TrackletDataMissing"},
92 {TrackletExitingNoTrackletEndMarker, "TrackletExitingNoTrackletEndMarker"},
93 {UnparsedTrackletDataRemaining, "UnparsedTrackletDataRemaining"},
94 {UnparsedDigitDataRemaining, "UnparsedDigitDataRemaining"},
95 {DigitHeaderCountGT3, "DigitHeaderCountGT3"},
96 {DigitHeaderWrongType, "DigitHeaderWrongType"},
97 {HalfCRUSumLength, "HalfCRUSumLength"},
98 {BadRDHMemSize, "BadRDHMemSize"},
99 {BadRDHFEEID, "BadRDHFEEID"},
100 {BadRDHEndPoint, "BadRDHEndPoint"},
101 {BadRDHOrbit, "BadRDHOrbit"},
102 {BadRDHCRUID, "BadRDHCRUID"},
103 {BadRDHPacketCounter, "BadRDHPacketCounter"},
104 {HalfCRUCorrupt, "HalfCRUCorrupt"},
105 {DigitHCHeader1Problem, "DigitHCHeader1Problem"},
106 {DigitHCHeader2Problem, "DigitHCHeader2Problem"},
107 {DigitHCHeader3Problem, "DigitHCHeader3Problem"},
108 {DigitHCHeaderSVNMismatch, "DigitHCHeaderSVNMismatch"},
109 {TrackletsReturnedMinusOne, "TrackletsReturnedMinusOne"},
110 {FEEIDIsFFFF, "FEEIDIsFFFF"},
111 {FEEIDBadSector, "FEEIDBadSector"},
112 {HalfCRUBadBC, "HalfCRUBadBC"},
113 {TRDLastParsingError, "TRDLastParsingError"}};
114
115//enumerations for the options, saves on having a long parameter list.
124}; // this is currently 16 options, the array is 16, if you add here you need to change the 16;
125
127 std::array<uint16_t, constants::MAXHALFCHAMBER> mLinkWords{};
128 std::array<uint8_t, constants::MAXHALFCHAMBER> mLinkErrorFlag{};
130};
131
132//Data to be stored on a timeframe basis to then be sent as a message to be ultimately picked up by qc.
133//Some countes include a average over the numbers stored on a per event basis, e.g. digits per event.
135{
136 public:
137 std::array<uint8_t, constants::MAXHALFCHAMBER> mLinkErrorFlag{}; // status of the error flags for this timeframe, 8bit values from cru halfchamber header.
138 std::array<uint16_t, constants::MAXHALFCHAMBER> mLinkNoData{}; // Link had no data or was not present.
139 std::array<uint16_t, constants::MAXHALFCHAMBER> mLinkWords{}; // units of 256bits, read from the cru half chamber header
140 std::array<uint16_t, constants::MAXHALFCHAMBER> mLinkWordsRead{}; // units of 32 bits the data words read before dumping or finishing
141 std::array<uint16_t, constants::MAXHALFCHAMBER> mLinkWordsRejected{}; // units of 32 bits the data dumped due to some or other error
142 std::array<uint16_t, constants::MAXHALFCHAMBER> mParsingOK{}; // count how often given link could be parsed without any errors
143 std::array<uint16_t, TRDLastParsingError> mParsingErrors{}; // errors in parsing, indexed by enum above of ParsingErrors
144 std::vector<uint32_t> mParsingErrorsByLink{}; // each entry is for a single parsing error on a given link (HCID * number of Errors + error index)
145 float mTimeTaken; // time taken to process all half-CRU data blocks combined [us].
146 float mTimeTakenForDigits; // time take to process tracklet data blocks [us].
147 float mTimeTakenForTracklets; // time take to process digit data blocks [us].
148 uint32_t mDigitsFound; // digits found in the time frame.
149 uint32_t mTrackletsFound; // tracklets found in the time frame.
150 uint16_t mNTriggersCalib; // number of triggers with digit readout
151 uint16_t mNTriggersTotal; // total number of triggers
152 std::array<int, 256> mDataFormatRead{}; // We just keep the major version number
153 o2::dataformats::TFIDInfo mTFIDInfo; // keep track of TF ID
154 void clear()
155 {
156 mLinkNoData.fill(0);
157 mLinkWords.fill(0);
158 mLinkWordsRead.fill(0);
159 mLinkWordsRejected.fill(0);
160 mParsingOK.fill(0);
161 mParsingErrors.fill(0);
162 mParsingErrorsByLink.clear();
163 mTimeTaken = 0;
166 mDigitsFound = 0;
167 mTrackletsFound = 0;
168 mNTriggersCalib = 0;
169 mNTriggersTotal = 0;
170 mDataFormatRead.fill(0);
171 };
172 ClassDefNV(TRDDataCountersPerTimeFrame, 3); // primarily for serialisation so we can send this as a message in o2
173};
174
175} // namespace o2::trd
176
177#endif
Global TRD definitions and constants.
ClassDefNV(TRDDataCountersPerTimeFrame, 3)
std::array< uint16_t, constants::MAXHALFCHAMBER > mParsingOK
std::array< int, 256 > mDataFormatRead
std::array< uint16_t, constants::MAXHALFCHAMBER > mLinkWordsRead
std::array< uint16_t, TRDLastParsingError > mParsingErrors
std::array< uint16_t, constants::MAXHALFCHAMBER > mLinkWords
o2::dataformats::TFIDInfo mTFIDInfo
std::array< uint16_t, constants::MAXHALFCHAMBER > mLinkNoData
std::array< uint8_t, constants::MAXHALFCHAMBER > mLinkErrorFlag
std::vector< uint32_t > mParsingErrorsByLink
std::array< uint16_t, constants::MAXHALFCHAMBER > mLinkWordsRejected
@ TrackletNoSecondEndMarker
@ TrackletDataWrongOrdering
@ DigitHCHeaderSVNMismatch
@ DigitHeaderWrongType
@ TrackletDataMissing
@ TrackletExitingNoTrackletEndMarker
@ TrackletNoTrackletEndMarker
@ DigitSanityCheck
@ DigitEndMarkerWrongState
@ TrackletDataDuplicateMCM
@ DigitParsingNoSecondEndmarker
@ DigitMCMDuplicate
@ DigitHCHeader1Problem
@ DigitMCMHeaderSanityCheckFailure
@ TrackletsReturnedMinusOne
@ DigitHCHeaderMismatch
@ DigitParsingExitInWrongState
@ TrackletHCHeaderFailure
@ BadRDHPacketCounter
@ DigitADCMaskInvalid
@ BadRDHEndPoint
@ TRDLastParsingError
@ HalfCRUSumLength
@ DigitHCHeader2Problem
@ FEEIDBadSector
@ DigitHCHeader3Problem
@ BadRDHMemSize
@ DigitHeaderCountGT3
@ HalfCRUCorrupt
@ TrackletMCMDataFailure
@ DigitMCMNotIncreasing
@ UnparsedTrackletDataRemaining
@ UnparsedDigitDataRemaining
@ TrackletMCMHeaderSanityCheckFailure
@ TRDVerboseErrorsBit
@ TRDGenerateStats
@ TRDOnlyCalibrationTriggerBit
@ TRDIgnore2StageTrigger
ClassDefNV(DataCountersPerTrigger, 1)
std::array< uint16_t, constants::MAXHALFCHAMBER > mLinkWords
std::array< uint8_t, constants::MAXHALFCHAMBER > mLinkErrorFlag