ATLAS Offline Software
PixelRodDecoder.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef PIXELRAWDATABYTESTREAM_PIXEL_RODDECODER_H
6 #define PIXELRAWDATABYTESTREAM_PIXEL_RODDECODER_H
7 
8 
11 
12 #include "GaudiKernel/ServiceHandle.h"
13 #include "eformat/SourceIdentifier.h"
14 
20 #include <atomic>
21 class PixelID;
22 
23 class PixelRodDecoder : virtual public IPixelRodDecoder, public AthAlgTool {
24 
25  public:
26 
27  // Collection type
28  typedef Pixel1RawData RDO;
30 
31  // constructor
32  PixelRodDecoder(const std::string& type, const std::string& name,
33  const IInterface* parent ) ;
34 
35  // destructor
37 
38  StatusCode initialize() override;
39  StatusCode finalize() override;
40 
42  IPixelRDO_Container* rdoIdc,
43  IDCInDetBSErrContainer& decodingErrors,
44  std::vector<IdentifierHash>* vecHash, const EventContext& ctx) const override;
45 
46  uint32_t getDataType(unsigned int rawDataWord, bool link_start) const; // determine module word type
47 
49  uint32_t decodeBCID_IBL(const uint32_t word) const; // decode IBL BCID from header word
50  uint32_t decodeL1ID_IBL(const uint32_t word) const; // decode IBL L1ID from header word
51  uint32_t decodeFeI4Bflag_IBL(const uint32_t word) const; // decode IBL FeI4 flag bit
52  uint32_t decodeModule_IBL(const uint32_t word) const; // decode IBL module link number from header word
53 
55  uint32_t decodeBCID(const uint32_t word) const; // decode BCID from header word
56  uint32_t decodeL1ID(const uint32_t word) const; // decode L1ID from header word
57  uint32_t decodeL1IDskip(const uint32_t word) const; // decode L1ID skips from header word
58  uint32_t decodeModule(const uint32_t word) const; // decode module link number from header word
59  uint32_t decodeHeaderErrors(const uint32_t word) const; // decode header errors from header word
60 
61 
63  uint32_t decodeRow(const uint32_t word, bool isIBLorDBM ) const; // decode row number from hit word
64  uint32_t decodeColumn(const uint32_t word, bool isIBLorDBM) const; // decode column number from hit word
65  uint32_t decodeToT(const uint32_t word, bool isIBLorDBM ) const; // decode TimeOverThreshold value from hit word
66 
67 
69  uint32_t decodeLinkNumHit_IBL(const uint32_t word) const; // decode Link Number in the IBL not-condensed Hit word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014)
70 
71 
73  uint32_t decodeFE(const uint32_t word) const; // decode FE number from hit word
74 
75 
77  uint32_t decodeSkippedTrigTrailer_IBL(const uint32_t word) const; // decode the skipped trigger counter in the IBL trailer
78  uint32_t decodeTrailerErrors_IBL (const uint32_t word) const; // decode IBL trailer errors, all together
79  uint32_t decodeLinkNumTrailer_IBL(const uint32_t word) const; // decode the link number in the IBL trailer // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014)
80  uint32_t decodeCondensedModeBit_IBL(const uint32_t word) const; // decode the Condensed mode bit in the IBL trailer
81 
82 
84  uint32_t decodeTrailerErrors(const uint32_t word) const; // decode trailer errors from trailer word
85  uint32_t decodeTrailerBitflips(const uint32_t word) const; // search for bitflips in wordparts supposed to be empty
86  uint32_t decodeBcidTrailer_IBL(const uint32_t word) const;
87 
88 
90  uint32_t decodeFEFlags2(const uint32_t word) const; // decode FE flags from flag type 2 word
91  uint32_t decodeMCCFlags(const uint32_t word) const; // decode MCC flags from flag type 2 word
92 
93 
95  uint32_t decodeServiceCodeCounter_IBL(const uint32_t word) const; // decode the Service Code Counter from the "non-short" IBL FE flag word
96  uint32_t decodeServiceCode_IBL(const uint32_t word) const; // decode the Service code from the "non-short" IBL FE Flag word
97  uint32_t decodeLinkNumFEFlag_IBL(const uint32_t word) const; // decode the Link Number present in the IBL FE Flag word // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014)
98  // uint32_t decodeFEFlagBitFlips_IBL(const uint32_t word); // search for bitflips in word partes supposed to be empty // At least temporarily not used, because IBL data format is not clear (Franconi, 17.06.2014)
99 
100 
102  uint32_t decodeRawData(const uint32_t word) const; // decode raw data word for IBL and Pixel
103 
104  uint32_t extractFefromLinkNum (const uint32_t linkNum) const;
105  uint32_t extractSLinkfromLinkNum (const uint32_t linkNum) const;
106 
107  bool CheckLinkStart(const bool Link_start, const int rodId, const unsigned int mLink, const unsigned int mBCID, const unsigned int mLVL1ID, const int LVL1A);
108 
109  uint32_t treatmentFEFlagInfo(unsigned int serviceCode, unsigned int serviceCodeCounter) const;
110 
111  constexpr static size_t ERROR_CONTAINER_MAX = 56506; // see explanation in PixelRawDataProviderTool.cxx. Increased to accommodate space for the SvcCounter
112  private:
113  mutable std::atomic_uint m_masked_errors{};
114  mutable std::atomic_uint m_numGenWarnings{};
115  mutable std::atomic_uint m_numDuplicatedPixels{0};
116 
117  const unsigned m_maxNumGenWarnings{200}; // Maximum number of general warnings to print
118  mutable std::atomic_uint m_numBCIDWarnings{};
119  const unsigned m_maxNumBCIDWarnings{50}; // Maximum number of BCID and LVL1ID warnings to print
120  BooleanProperty m_checkDuplicatedPixel{this, "CheckDuplicatedPixel", true, "Check duplicated pixels in fillCollection method"};
121 
122  mutable std::atomic_uint m_numInvalidIdentifiers{0};
123  mutable std::atomic_uint m_numPreambleErrors{0};
124  mutable std::atomic_uint m_numTimeOutErrors{0};
125  mutable std::atomic_uint m_numLVL1IDErrors{0};
126  mutable std::atomic_uint m_numBCIDErrors{0};
127  mutable std::atomic_uint m_numFlaggedErrors{0};
128  mutable std::atomic_uint m_numTrailerErrors{0};
129  mutable std::atomic_uint m_numDisabledFEErrors{0};
130  mutable std::atomic_uint m_numDecodingErrors{0};
131  mutable std::atomic_uint m_numRODErrors{0};
132  mutable std::atomic_uint m_numLinkMaskedByPPC{0};
133  mutable std::atomic_uint m_numLimitError{0};
134 
135  const PixelID* m_pixel_id=nullptr;
136 
138  {this, "PixelReadoutManager", "PixelReadoutManager", "Pixel readout manager" };
139 
141  {this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"};
142 
144  {this, "PixelHitDiscCnfgData", "PixelHitDiscCnfgData", "Pixel FEI4 HitDiscConfig key"};
145 
147  bool checkDataWordsCorruption( uint32_t word ) const;
148 
153 
155  StatusCode updateEventInfoIfEventCorrupted( bool isCorrupted ) const;
156 
158  void checkUnequalNumberOfHeaders( const unsigned int nFragmentsPerFE[8], uint32_t robId ) const;
159 
161  inline bool thisRdoIsUnique(const Identifier & pixelRdo, std::unordered_set<Identifier> & pixelRdosSeenSoFar) const;
162 
164  unsigned int getLocalFEI4(const uint32_t fe, const uint64_t onlineId) const;
165 
167  void propagateROBErrorsToModules(const PixelCablingCondData *pixCabling,
168  uint32_t robId,
169  std::array<uint64_t, PixelRodDecoder::ERROR_CONTAINER_MAX> &bsErrWord,
170  IDCInDetBSErrContainer& decodingErrors,
172  const char *error_description) const;
173 };
174 
175 bool
176 PixelRodDecoder::thisRdoIsUnique(const Identifier & pixelRdo, std::unordered_set<Identifier> & pixelRdosSeenSoFar) const{
177  //The 'second' element of the pair returned by a set insert indicates whether the insert was successful.
178  //If the element is NOT already in the set (has not been seen already), then this element is true.
179  return (m_checkDuplicatedPixel and pixelRdosSeenSoFar.insert(pixelRdo).second);
180 }
181 
182 
183 #endif
PixelRodDecoder::decodeL1ID_IBL
uint32_t decodeL1ID_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1035
PixelRodDecoder::m_numFlaggedErrors
std::atomic_uint m_numFlaggedErrors
Definition: PixelRodDecoder.h:127
PixelRodDecoder::m_is_ibl_module
bool m_is_ibl_module
Definition: PixelRodDecoder.h:151
PixelRodDecoder::decodeFeI4Bflag_IBL
uint32_t decodeFeI4Bflag_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1043
PixelCablingCondData.h
PixelRodDecoder::m_numBCIDWarnings
std::atomic_uint m_numBCIDWarnings
Definition: PixelRodDecoder.h:118
PixelRodDecoder::m_numDecodingErrors
std::atomic_uint m_numDecodingErrors
Definition: PixelRodDecoder.h:130
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
PixelRodDecoder::checkUnequalNumberOfHeaders
void checkUnequalNumberOfHeaders(const unsigned int nFragmentsPerFE[8], uint32_t robId) const
if the check duplicated RDO flag is true, check that this RDO is unique (returns true if unique)
Definition: PixelRodDecoder.cxx:1456
PixelRodDecoder::ERROR_CONTAINER_MAX
constexpr static size_t ERROR_CONTAINER_MAX
Definition: PixelRodDecoder.h:111
PixelRodDecoder::PixelRawCollection
InDetRawDataCollection< PixelRDORawData > PixelRawCollection
Definition: PixelRodDecoder.h:29
PixelRodDecoder::m_numTrailerErrors
std::atomic_uint m_numTrailerErrors
Definition: PixelRodDecoder.h:128
IDCInDetBSErrContainer
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
Definition: IDCInDetBSErrContainer.h:19
PixelRodDecoder::m_pixelReadout
ServiceHandle< InDetDD::IPixelReadoutManager > m_pixelReadout
Definition: PixelRodDecoder.h:138
PixelRodDecoder::decodeFE
uint32_t decodeFE(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1148
PixelRodDecoder::CheckLinkStart
bool CheckLinkStart(const bool Link_start, const int rodId, const unsigned int mLink, const unsigned int mBCID, const unsigned int mLVL1ID, const int LVL1A)
PixelRodDecoder::decodeL1ID
uint32_t decodeL1ID(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1067
PixelRodDecoder::decodeFEFlags2
uint32_t decodeFEFlags2(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1241
PixelRodDecoder::extractSLinkfromLinkNum
uint32_t extractSLinkfromLinkNum(const uint32_t linkNum) const
Definition: PixelRodDecoder.cxx:1016
PixelRodDecoder::m_condHitDiscCnfgKey
SG::ReadCondHandleKey< PixelHitDiscCnfgData > m_condHitDiscCnfgKey
Definition: PixelRodDecoder.h:144
PixelRodDecoder::decodeToT
uint32_t decodeToT(const uint32_t word, bool isIBLorDBM) const
Definition: PixelRodDecoder.cxx:1128
PixelByteStreamErrors::PixelErrorsEnum
PixelErrorsEnum
< Possible errors in pixel data decoding
Definition: PixelByteStreamErrors.h:13
PixelRodDecoder::initialize
StatusCode initialize() override
Definition: PixelRodDecoder.cxx:64
PixelRodDecoder::decodeModule
uint32_t decodeModule(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1083
PixelRodDecoder::decodeColumn
uint32_t decodeColumn(const uint32_t word, bool isIBLorDBM) const
Definition: PixelRodDecoder.cxx:1116
EventContainers::IIdentifiableCont
Definition: IIdentifiableCont.h:13
PixelRodDecoder::m_masked_errors
std::atomic_uint m_masked_errors
Definition: PixelRodDecoder.h:113
PixelRodDecoder::m_numDuplicatedPixels
std::atomic_uint m_numDuplicatedPixels
Definition: PixelRodDecoder.h:115
PixelRodDecoder::m_numPreambleErrors
std::atomic_uint m_numPreambleErrors
Definition: PixelRodDecoder.h:123
PixelRodDecoder::finalize
StatusCode finalize() override
Definition: PixelRodDecoder.cxx:83
PixelRodDecoder::getDataType
uint32_t getDataType(unsigned int rawDataWord, bool link_start) const
Definition: PixelRodDecoder.cxx:1255
PixelRodDecoder::m_numBCIDErrors
std::atomic_uint m_numBCIDErrors
Definition: PixelRodDecoder.h:126
PixelRodDecoder::decodeServiceCode_IBL
uint32_t decodeServiceCode_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1226
PixelRodDecoder::~PixelRodDecoder
~PixelRodDecoder()
Definition: PixelRodDecoder.cxx:57
PixelRodDecoder::decodeMCCFlags
uint32_t decodeMCCFlags(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1248
PixelRodDecoder::m_numTimeOutErrors
std::atomic_uint m_numTimeOutErrors
Definition: PixelRodDecoder.h:124
eformat::ROBFragment
Definition: L1CaloBsDecoderUtil.h:12
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PixelRodDecoder::decodeTrailerBitflips
uint32_t decodeTrailerBitflips(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1202
PixelRodDecoder::decodeSkippedTrigTrailer_IBL
uint32_t decodeSkippedTrigTrailer_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1157
PixelRodDecoder::decodeRow
uint32_t decodeRow(const uint32_t word, bool isIBLorDBM) const
Definition: PixelRodDecoder.cxx:1104
AthAlgTool.h
PixelRodDecoder::decodeBcidTrailer_IBL
uint32_t decodeBcidTrailer_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1179
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
PixelRodDecoder::m_numRODErrors
std::atomic_uint m_numRODErrors
Definition: PixelRodDecoder.h:131
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PixelRodDecoder::RDO
Pixel1RawData RDO
Definition: PixelRodDecoder.h:28
Pixel1RawData
Definition: Pixel1RawData.h:23
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
PixelCablingCondData
Definition: PixelCablingCondData.h:26
PixelRodDecoder::decodeModule_IBL
uint32_t decodeModule_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1051
IPixelRodDecoder.h
IPixelReadoutManager.h
PixelRodDecoder::decodeLinkNumTrailer_IBL
uint32_t decodeLinkNumTrailer_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1171
PixelRodDecoder::decodeL1IDskip
uint32_t decodeL1IDskip(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1075
ReadCondHandleKey.h
PixelRodDecoder::decodeBCID_IBL
uint32_t decodeBCID_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1027
PixelRodDecoder::extractFefromLinkNum
uint32_t extractFefromLinkNum(const uint32_t linkNum) const
Definition: PixelRodDecoder.cxx:1008
PixelRodDecoder::m_numLimitError
std::atomic_uint m_numLimitError
Definition: PixelRodDecoder.h:133
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
PixelRodDecoder::m_is_ibl_present
bool m_is_ibl_present
Definition: PixelRodDecoder.h:150
PixelRodDecoder::m_numDisabledFEErrors
std::atomic_uint m_numDisabledFEErrors
Definition: PixelRodDecoder.h:129
PixelRodDecoder::decodeHeaderErrors
uint32_t decodeHeaderErrors(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1091
IPixelRodDecoder
Definition: IPixelRodDecoder.h:14
PixelRodDecoder::thisRdoIsUnique
bool thisRdoIsUnique(const Identifier &pixelRdo, std::unordered_set< Identifier > &pixelRdosSeenSoFar) const
get local FEI4
Definition: PixelRodDecoder.h:176
PixelRodDecoder::m_numLVL1IDErrors
std::atomic_uint m_numLVL1IDErrors
Definition: PixelRodDecoder.h:125
PixelRodDecoder::m_numInvalidIdentifiers
std::atomic_uint m_numInvalidIdentifiers
Definition: PixelRodDecoder.h:122
PixelRodDecoder::m_numGenWarnings
std::atomic_uint m_numGenWarnings
Definition: PixelRodDecoder.h:114
PixelRodDecoder::treatmentFEFlagInfo
uint32_t treatmentFEFlagInfo(unsigned int serviceCode, unsigned int serviceCodeCounter) const
Definition: PixelRodDecoder.cxx:1285
PixelRodDecoder::decodeLinkNumFEFlag_IBL
uint32_t decodeLinkNumFEFlag_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1233
PixelRodDecoder::m_pixel_id
const PixelID * m_pixel_id
Definition: PixelRodDecoder.h:135
SG::ReadCondHandleKey< PixelCablingCondData >
PixelRodDecoder::propagateROBErrorsToModules
void propagateROBErrorsToModules(const PixelCablingCondData *pixCabling, uint32_t robId, std::array< uint64_t, PixelRodDecoder::ERROR_CONTAINER_MAX > &bsErrWord, IDCInDetBSErrContainer &decodingErrors, PixelByteStreamErrors::PixelErrorsEnum error_code, const char *error_description) const
Definition: PixelRodDecoder.cxx:111
PixelRodDecoder::decodeServiceCodeCounter_IBL
uint32_t decodeServiceCodeCounter_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1219
PixelRodDecoder::m_is_dbm_module
bool m_is_dbm_module
if the flag is set to true appropriate bits are set in event info
Definition: PixelRodDecoder.h:152
PixelRodDecoder::updateEventInfoIfEventCorrupted
StatusCode updateEventInfoIfEventCorrupted(bool isCorrupted) const
checks if all FEs have sent the same number of headers, if not, generate warning message
Definition: PixelRodDecoder.cxx:1440
PixelHitDiscCnfgData.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArHVGainsPredictor.error_code
error_code
Definition: LArHVGainsPredictor.py:229
PixelRodDecoder::decodeBCID
uint32_t decodeBCID(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1059
PixelRodDecoder::m_condCablingKey
SG::ReadCondHandleKey< PixelCablingCondData > m_condCablingKey
Definition: PixelRodDecoder.h:141
PixelByteStreamErrors.h
PixelRodDecoder::getLocalFEI4
unsigned int getLocalFEI4(const uint32_t fe, const uint64_t onlineId) const
in case of invalid ROB fragments set corresponding error flags in all linked modules.
Definition: PixelRodDecoder.cxx:1484
AthAlgTool
Definition: AthAlgTool.h:26
PixelRodDecoder
Definition: PixelRodDecoder.h:23
PixelRodDecoder::decodeCondensedModeBit_IBL
uint32_t decodeCondensedModeBit_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1187
PixelRodDecoder::m_checkDuplicatedPixel
BooleanProperty m_checkDuplicatedPixel
Definition: PixelRodDecoder.h:120
PixelID
Definition: PixelID.h:67
PixelRodDecoder::decodeLinkNumHit_IBL
uint32_t decodeLinkNumHit_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1141
PixelRodDecoder::decodeRawData
uint32_t decodeRawData(const uint32_t word) const
PixelRodDecoder::decodeTrailerErrors_IBL
uint32_t decodeTrailerErrors_IBL(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1164
PixelRodDecoder::checkDataWordsCorruption
bool checkDataWordsCorruption(uint32_t word) const
checks if data words do not look like header & trailer markers, return true if so,...
Definition: PixelRodDecoder.cxx:1269
PixelRodDecoder::m_maxNumBCIDWarnings
const unsigned m_maxNumBCIDWarnings
Definition: PixelRodDecoder.h:119
PixelRodDecoder::fillCollection
StatusCode fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, IPixelRDO_Container *rdoIdc, IDCInDetBSErrContainer &decodingErrors, std::vector< IdentifierHash > *vecHash, const EventContext &ctx) const override
Definition: PixelRodDecoder.cxx:133
PixelRodDecoder::m_numLinkMaskedByPPC
std::atomic_uint m_numLinkMaskedByPPC
Definition: PixelRodDecoder.h:132
PixelRodDecoder::m_maxNumGenWarnings
const unsigned m_maxNumGenWarnings
Definition: PixelRodDecoder.h:117
PixelRodDecoder::decodeTrailerErrors
uint32_t decodeTrailerErrors(const uint32_t word) const
Definition: PixelRodDecoder.cxx:1195
PixelRodDecoder::PixelRodDecoder
PixelRodDecoder(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PixelRodDecoder.cxx:49
ServiceHandle< InDetDD::IPixelReadoutManager >
Identifier
Definition: IdentifierFieldParser.cxx:14