diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx index 54f8eb4e6ddc22df170ac7c9597daa3ca681de4d..dc7386c78135d3f940884a1b68736e419d1876f1 100755 --- a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx +++ b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx @@ -358,7 +358,7 @@ StatusCode NoiseMapBuilder::execute ATLAS_NOT_THREAD_SAFE (){ // Thread unsafe D } // exclude module if containg FE synch errors - if (m_pixelConditionsTool->isBSError(modHash)) { + if (m_pixelConditionsTool->hasBSError(modHash)) { ATH_MSG_VERBOSE("Module excluded as containing FE synch errors"); continue; } @@ -582,7 +582,7 @@ StatusCode NoiseMapBuilder::finalize() { else if(layer == 3) { cut=m_layer2Cut; nhitsNoNoisePlot=nhitsNoNoisePlotB2; comp="Layer2"; } } - if (!m_pixelConditionsTool->isBSActive(modHash) && m_hitMaps[modHash]->GetEntries()==0) { + if (!m_pixelConditionsTool->hasBSError(modHash) && m_hitMaps[modHash]->GetEntries()==0) { if(bec == 0) { if(layer == 0) { disablePlotBI->Fill(modEta, modPhi, -1); } else if(layer == 1) { disablePlotB0->Fill(modEta, modPhi, -1); } diff --git a/InnerDetector/InDetConditions/InDetConditionsSummaryService/InDetConditionsSummaryService/IInDetConditionsTool.h b/InnerDetector/InDetConditions/InDetConditionsSummaryService/InDetConditionsSummaryService/IInDetConditionsTool.h index eb1110a0e5d69eb884303e934517b6c06a7d630c..70a80995c9ea4071502365ae17f3ca676f5dbfc0 100644 --- a/InnerDetector/InDetConditions/InDetConditionsSummaryService/InDetConditionsSummaryService/IInDetConditionsTool.h +++ b/InnerDetector/InDetConditions/InDetConditionsSummaryService/InDetConditionsSummaryService/IInDetConditionsTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** @@ -10,6 +10,7 @@ #define IInDetConditionsTool_h //Gaudi Includes #include "GaudiKernel/IInterface.h" +#include "Identifier/IdContext.h" //Local includes #include "InDetConditionsSummaryService/InDetHierarchy.h" @@ -27,27 +28,31 @@ public: /// Creates the InterfaceID and interfaceID() method DeclareInterfaceID(IInDetConditionsTool, 1, 0); - //@name isActive methods reveal whether the element should return data - //@{ - virtual bool isActive(const Identifier & elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const =0; - virtual bool isActive(const IdentifierHash & elementHash) const =0; - virtual bool isActive(const IdentifierHash & elementHash, const Identifier & elementId) const =0; - //@} - ///activeFraction method gives the fraction of active elements in the range of identifiers - virtual double activeFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd) const =0; - //@{ - - //@name isGood methods reveal whether the data are reliable - //@{ - virtual bool isGood(const Identifier & elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const =0; - virtual bool isGood(const IdentifierHash & elementHash) const =0; - virtual bool isGood(const IdentifierHash & elementHash, const Identifier & elementId) const =0; - //@} - ///goodFraction method gives the fraction of good elements in the range of identifiers - virtual double goodFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd) const =0; - - virtual bool isBSActive(const IdentifierHash & moduleHash) const =0; - virtual bool isBSError(const IdentifierHash & moduleHash) const =0; + virtual bool isActive(const Identifier& elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const =0; + virtual bool isActive(const IdentifierHash& elementHash) const =0; + virtual bool isActive(const IdentifierHash& elementHash, const Identifier& elementId) const =0; + virtual double activeFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd) const =0; + + virtual bool isActive(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const =0; + virtual bool isActive(const IdentifierHash& elementHash, const EventContext& ctx) const =0; + virtual bool isActive(const IdentifierHash& elementHash, const Identifier& elementId, const EventContext& ctx) const =0; + virtual double activeFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd, const EventContext& ctx) const =0; + + virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const =0; + virtual bool isGood(const IdentifierHash& elementHash) const =0; + virtual bool isGood(const IdentifierHash& elementHash, const Identifier& elementId) const =0; + virtual double goodFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd) const =0; + + virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const =0; + virtual bool isGood(const IdentifierHash& elementHash, const EventContext& ctx) const =0; + virtual bool isGood(const IdentifierHash& elementHash, const Identifier& elementId, const EventContext& ctx) const =0; + virtual double goodFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd, const EventContext& ctx) const =0; + + virtual bool hasBSError(const IdentifierHash& elementHash) const =0; + virtual bool hasBSError(const IdentifierHash& elementHash, Identifier elementId) const =0; + virtual bool hasBSError(const IdentifierHash& elementHash, const EventContext& ctx) const =0; + virtual bool hasBSError(const IdentifierHash& elementHash, Identifier elementId, const EventContext& ctx) const =0; + virtual uint64_t getBSErrorWord(const IdentifierHash& elementHash, const EventContext& ctx) const =0; }; diff --git a/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt b/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt index bedb6e10aca4b3db45ffe7f4517f93e72590d489..f2a96745d492124ff188454ea8694041d9da66fa 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt +++ b/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt @@ -12,6 +12,7 @@ atlas_depends_on_subdirs( DetectorDescription/Identifier DetectorDescription/GeoPrimitives Database/AthenaPOOL/AthenaPoolUtilities + InnerDetector/InDetConditions/InDetByteStreamErrors InnerDetector/InDetConditions/PixelCoralClientUtils PRIVATE Control/AthenaKernel diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h index 904d182bc227362fe3eb3efada63dd4820dcf860..7d0a6b326fd11b5fdc62ef3fee98efa0ed8b9ad6 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h +++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h @@ -22,6 +22,8 @@ namespace PixelByteStreamErrors { //!< @brief helper to set the error: @example errors[hashId] = addError( errors[hashId], PixelByteStreamErrors::Invalid ) inline void addError(IDCInDetBSErrContainer::ErrorCode& errWord, PixelErrorsEnum errType ) { errWord |= makeError( errType ); } + inline void addServiceRecords(IDCInDetBSErrContainer::ErrorCode& errWord, uint64_t errorCount ) { errWord = errorCount; } + } diff --git a/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.cxx b/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.cxx index 1ee7f24ed8b7865b46a09ba1bd829dacf4e74719..987cbe69384186acefc94c0036ab882cccedd421 100644 --- a/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.cxx @@ -26,7 +26,7 @@ StatusCode PixelConditionsSummaryTool::initialize(){ ATH_CHECK(m_condDCSStateKey.initialize()); ATH_CHECK(m_condDCSStatusKey.initialize()); - ATH_CHECK(m_BSErrContReadKey.initialize(m_useByteStream && !m_BSErrContReadKey.empty())); + ATH_CHECK(m_BSErrContReadKey.initialize(SG::AllowEmpty)); ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID")); @@ -62,191 +62,271 @@ StatusCode PixelConditionsSummaryTool::initialize(){ return StatusCode::SUCCESS; } -bool PixelConditionsSummaryTool::isBSError([[maybe_unused]] const IdentifierHash & moduleHash) const { - if (!m_useByteStream) { - return false; - } - SG::ReadHandle<InDetBSErrContainer> errCont(m_BSErrContReadKey); - if (!errCont.isValid()) { - ATH_MSG_ERROR("BSErrContainer is not valid!"); - return true; - } - if (m_pixelID->wafer_hash_max()==2048) { // RUN-2 setup - if ((m_pixelID->barrel_ec(m_pixelID->wafer_id(moduleHash))==0 && m_pixelID->layer_disk(m_pixelID->wafer_id(moduleHash))==0) - || m_pixelID->is_dbm(m_pixelID->wafer_id(moduleHash))) { - for (const auto* elt : *errCont) { - IdentifierHash myHash=elt->first; - if (myHash-m_pixelID->wafer_hash_max()==moduleHash) { return false; } - } - return true; - } - } +const IDCInDetBSErrContainer* PixelConditionsSummaryTool::getContainer(const EventContext& ctx) const { + SG::ReadHandle<IDCInDetBSErrContainer> idcErrCont(m_BSErrContReadKey, ctx); + if (not idcErrCont.isValid()) { return nullptr; } + ATH_MSG_VERBOSE("PixelConditionsSummaryTool IDC Container fetched " << m_BSErrContReadKey.key()); + return idcErrCont.cptr(); +} - int errorcode = 0; - for (const auto* elt : *errCont) { - IdentifierHash myHash=elt->first; - if (myHash==moduleHash) { errorcode = elt->second; break; } - } - if ((errorcode & 0xFFF1F00F) == 0) { // Mask FE errors - for (const auto* elt : *errCont) { - IdentifierHash myHash=elt->first; - if (myHash-m_pixelID->wafer_hash_max()==moduleHash) { return false; } +PixelConditionsSummaryTool::IDCCacheEntry* PixelConditionsSummaryTool::getCacheEntry(const EventContext& ctx) const { + IDCCacheEntry* cacheEntry = m_eventCache.get(ctx); + if (cacheEntry->needsUpdate(ctx)) { + auto idcErrContPtr = getContainer(ctx); + if (idcErrContPtr==nullptr) { // missing or not, the cache needs to be reset + cacheEntry->reset(ctx.evt(), nullptr); } - return true; - } - else if (errorcode) { - return false; + else { + cacheEntry->reset(ctx.evt(), idcErrContPtr->cache()); + } + ATH_MSG_VERBOSE("PixelConditionsSummaryTool Cache for the event reset " << cacheEntry->eventId << " with IDC container" << idcErrContPtr); } - return true; + return cacheEntry; } -bool PixelConditionsSummaryTool::isBSActive([[maybe_unused]] const IdentifierHash & moduleHash) const { - SG::ReadHandle<InDetBSErrContainer> errCont(m_BSErrContReadKey); - for (const auto* elt : *errCont) { - IdentifierHash myHash=elt->first; - if (myHash-m_pixelID->wafer_hash_max()==moduleHash) { return false; } +uint64_t PixelConditionsSummaryTool::getBSErrorWord(const IdentifierHash& moduleHash, const EventContext& ctx) const { + if (!m_useByteStream) { return 0; } + + std::lock_guard<std::mutex> lock{m_cacheMutex}; + auto idcCachePtr = getCacheEntry(ctx)->IDCCache; + if (idcCachePtr==nullptr) { + ATH_MSG_ERROR("PixelConditionsSummaryTool No cache! " ); } - return true; + uint64_t word = (uint64_t)idcCachePtr->retrieve(moduleHash); + return word<m_missingErrorInfo ? word : 0; } -bool PixelConditionsSummaryTool::isActive(const Identifier & /*elementId*/, - const InDetConditions::Hierarchy /*h*/) const -{ +bool PixelConditionsSummaryTool::hasBSError(const IdentifierHash& moduleHash) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return hasBSError(moduleHash, ctx); +} + +bool PixelConditionsSummaryTool::hasBSError(const IdentifierHash& moduleHash, Identifier pixid) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return hasBSError(moduleHash, pixid, ctx); +} + +bool PixelConditionsSummaryTool::hasBSError(const IdentifierHash& moduleHash, const EventContext& ctx) const { + if (!m_useByteStream) { return false; } + uint64_t word = getBSErrorWord(moduleHash,ctx); + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::TimeOut)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::BCID)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::LVL1ID)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Preamble)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Trailer)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Decoding)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Invalid)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::LinkMaskedByPPC)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Limit)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::TruncatedROB)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::MaskedROB)) { return true; } + + return false; +} + +bool PixelConditionsSummaryTool::hasBSError(const IdentifierHash& moduleHash, Identifier pixid, const EventContext& ctx) const { + if (!m_useByteStream) { return false; } + + if (hasBSError(moduleHash, ctx)) { return true; } + + int maxHash = m_pixelID->wafer_hash_max(); + Identifier moduleID = m_pixelID->wafer_id(pixid); + int chFE = m_pixelCabling->getFE(&pixid,moduleID); + + int indexFE = (1+chFE)*maxHash+(int)moduleHash; // (FE_channel+1)*2048 + moduleHash + uint64_t word = getBSErrorWord(indexFE,ctx); + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::TimeOut)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::BCID)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::LVL1ID)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Preamble)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Trailer)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Decoding)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Invalid)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::LinkMaskedByPPC)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::Limit)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::TruncatedROB)) { return true; } + if (PixelByteStreamErrors::hasError(word,PixelByteStreamErrors::MaskedROB)) { return true; } + + return false; +} + +bool PixelConditionsSummaryTool::isActive(const Identifier& elementId, const InDetConditions::Hierarchy h) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return isActive(elementId, h, ctx); +} + +bool PixelConditionsSummaryTool::isActive(const IdentifierHash& moduleHash) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return isActive(moduleHash, ctx); +} + +bool PixelConditionsSummaryTool::isActive(const IdentifierHash& moduleHash, const Identifier& elementId) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return isActive(moduleHash, elementId, ctx); +} + +bool PixelConditionsSummaryTool::isActive(const Identifier& /*elementId*/, const InDetConditions::Hierarchy /*h*/, const EventContext& /*ctx*/) const { return true; } -bool PixelConditionsSummaryTool::isActive(const IdentifierHash & moduleHash) const { +bool PixelConditionsSummaryTool::isActive(const IdentifierHash& moduleHash, const EventContext& ctx) const { - if (m_useByteStream && !isBSActive(moduleHash)) { return false; } + if (m_useByteStream && hasBSError(moduleHash, ctx)) { return false; } - SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey); + SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey,ctx); bool isDCSActive = false; for (unsigned int istate=0; istate<m_activeState.size(); istate++) { if (m_activeState[istate]==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=true; } } if (!isDCSActive) { return false; } - if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey)->getModuleStatus(moduleHash)) { return false; } + if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey,ctx)->getModuleStatus(moduleHash)) { return false; } - if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey)->getModuleStatus(moduleHash)) { return false; } + if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey,ctx)->getModuleStatus(moduleHash)) { return false; } return true; } -bool PixelConditionsSummaryTool::isActive(const IdentifierHash & moduleHash, const Identifier & elementId) const { +bool PixelConditionsSummaryTool::isActive(const IdentifierHash& moduleHash, const Identifier& elementId, const EventContext& ctx) const { - if (m_useByteStream && !isBSActive(moduleHash)) { return false; } + if (m_useByteStream && hasBSError(moduleHash, ctx)) { return false; } - SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey); + SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey,ctx); bool isDCSActive = false; for (unsigned int istate=0; istate<m_activeState.size(); istate++) { if (m_activeState[istate]==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=true; } } if (!isDCSActive) { return false; } - if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey)->getModuleStatus(moduleHash)) { return false; } + if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey,ctx)->getModuleStatus(moduleHash)) { return false; } - if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey)->getModuleStatus(moduleHash)) { return false; } + if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey,ctx)->getModuleStatus(moduleHash)) { return false; } return checkChipStatus(moduleHash, elementId); } -double PixelConditionsSummaryTool::activeFraction(const IdentifierHash & /*moduleHash*/, - const Identifier & /*idStart*/, - const Identifier & /*idEnd*/) const -{ +double PixelConditionsSummaryTool::activeFraction(const IdentifierHash & /*moduleHash*/, const Identifier & /*idStart*/, const Identifier & /*idEnd*/) const { return 1.0; } -bool PixelConditionsSummaryTool::isGood(const Identifier & elementId, - const InDetConditions::Hierarchy h)const -{ +double PixelConditionsSummaryTool::activeFraction(const IdentifierHash & /*moduleHash*/, const Identifier & /*idStart*/, const Identifier & /*idEnd*/, const EventContext& /*ctx*/) const { + return 1.0; +} + +bool PixelConditionsSummaryTool::isGood(const IdentifierHash & moduleHash) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return isGood(moduleHash, ctx); +} + +bool PixelConditionsSummaryTool::isGood(const Identifier& elementId, const InDetConditions::Hierarchy h) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return isGood(elementId, h, ctx); +} + +bool PixelConditionsSummaryTool::isGood(const IdentifierHash & moduleHash, const Identifier &elementId) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return isGood(moduleHash, elementId, ctx); +} + +bool PixelConditionsSummaryTool::isGood(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const { Identifier moduleID = m_pixelID->wafer_id(elementId); IdentifierHash moduleHash = m_pixelID->wafer_hash(moduleID); - if (m_useByteStream && !isBSError(moduleHash)) { return false; } + if (m_useByteStream && hasBSError(moduleHash, ctx)) { return false; } - SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey); + SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey, ctx); bool isDCSActive = false; for (unsigned int istate=0; istate<m_activeState.size(); istate++) { if (m_activeState[istate]==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=true; } } if (!isDCSActive) { return false; } - SG::ReadCondHandle<PixelDCSStatusData> dcsstatus_data(m_condDCSStatusKey); + SG::ReadCondHandle<PixelDCSStatusData> dcsstatus_data(m_condDCSStatusKey, ctx); bool isDCSGood = false; for (unsigned int istatus=0; istatus<m_activeStatus.size(); istatus++) { if (m_activeStatus[istatus]==dcsstatus_data->getModuleStatus(moduleHash)) { isDCSGood=true; } } if (!isDCSGood) { return false; } - if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey)->getModuleStatus(moduleHash)) { return false; } + if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey,ctx)->getModuleStatus(moduleHash)) { return false; } - if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey)->getModuleStatus(moduleHash)) { return false; } + if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey, ctx)->getModuleStatus(moduleHash)) { return false; } if (h==InDetConditions::PIXEL_CHIP) { - return checkChipStatus(moduleHash, elementId); + if (!checkChipStatus(moduleHash, elementId)) { return false; } + if (m_useByteStream && hasBSError(moduleHash, elementId, ctx)) { return false; } } return true; } -bool PixelConditionsSummaryTool::isGood(const IdentifierHash & moduleHash) const { +bool PixelConditionsSummaryTool::isGood(const IdentifierHash& moduleHash, const EventContext& ctx) const { - if (m_useByteStream && !isBSError(moduleHash)) { return false; } + if (m_useByteStream && hasBSError(moduleHash, ctx)) { return false; } - SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey); + SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey, ctx); bool isDCSActive = false; for (unsigned int istate=0; istate<m_activeState.size(); istate++) { if (m_activeState[istate]==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=true; } } if (!isDCSActive) { return false; } - SG::ReadCondHandle<PixelDCSStatusData> dcsstatus_data(m_condDCSStatusKey); + SG::ReadCondHandle<PixelDCSStatusData> dcsstatus_data(m_condDCSStatusKey, ctx); bool isDCSGood = false; for (unsigned int istatus=0; istatus<m_activeStatus.size(); istatus++) { if (m_activeStatus[istatus]==dcsstatus_data->getModuleStatus(moduleHash)) { isDCSGood=true; } } if (!isDCSGood) { return false; } - if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey)->getModuleStatus(moduleHash)) { return false; } + if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey,ctx)->getModuleStatus(moduleHash)) { return false; } - if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey)->getModuleStatus(moduleHash)) { return false; } + if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey, ctx)->getModuleStatus(moduleHash)) { return false; } return true; } -bool PixelConditionsSummaryTool::isGood(const IdentifierHash & moduleHash, const Identifier &elementId) const { +bool PixelConditionsSummaryTool::isGood(const IdentifierHash & moduleHash, const Identifier &elementId, const EventContext& ctx) const { - if (m_useByteStream && !isBSError(moduleHash)) { return false; } + if (m_useByteStream && hasBSError(moduleHash, ctx)) { return false; } - SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey); + SG::ReadCondHandle<PixelDCSStateData> dcsstate_data(m_condDCSStateKey, ctx); bool isDCSActive = false; for (unsigned int istate=0; istate<m_activeState.size(); istate++) { if (m_activeState[istate]==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=true; } } if (!isDCSActive) { return false; } - SG::ReadCondHandle<PixelDCSStatusData> dcsstatus_data(m_condDCSStatusKey); + SG::ReadCondHandle<PixelDCSStatusData> dcsstatus_data(m_condDCSStatusKey, ctx); bool isDCSGood = false; for (unsigned int istatus=0; istatus<m_activeStatus.size(); istatus++) { if (m_activeStatus[istatus]==dcsstatus_data->getModuleStatus(moduleHash)) { isDCSGood=true; } } if (!isDCSGood) { return false; } - if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey)->getModuleStatus(moduleHash)) { return false; } + if (!m_condTDAQKey.empty() && SG::ReadCondHandle<PixelTDAQData>(m_condTDAQKey,ctx)->getModuleStatus(moduleHash)) { return false; } - if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey)->getModuleStatus(moduleHash)) { return false; } + if (SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey, ctx)->getModuleStatus(moduleHash)) { return false; } - return checkChipStatus(moduleHash, elementId); + if (!checkChipStatus(moduleHash, elementId)) { return false; } + + if (m_useByteStream && hasBSError(moduleHash, elementId, ctx)) { return false; } + + return true; } -double PixelConditionsSummaryTool::goodFraction(const IdentifierHash & moduleHash, - const Identifier & idStart, - const Identifier & idEnd) const -{ +bool PixelConditionsSummaryTool::checkChipStatus(IdentifierHash moduleHash, Identifier pixid) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return checkChipStatus(moduleHash, pixid, ctx); +} + +double PixelConditionsSummaryTool::goodFraction(const IdentifierHash & moduleHash, const Identifier & idStart, const Identifier & idEnd) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return goodFraction(moduleHash, idStart, idEnd, ctx); +} + +double PixelConditionsSummaryTool::goodFraction(const IdentifierHash & moduleHash, const Identifier & idStart, const Identifier & idEnd, const EventContext& ctx) const { - if (!isGood(moduleHash)) { return 0.0; } + if (!isGood(moduleHash, ctx)) { return 0.0; } Identifier moduleID = m_pixelID->wafer_id(moduleHash); @@ -261,7 +341,14 @@ double PixelConditionsSummaryTool::goodFraction(const IdentifierHash & moduleHas double nGood = 0.0; for (int i=std::min(phiStart,phiEnd); i<=std::max(phiStart,phiEnd); i++) { for (int j=std::min(etaStart,etaEnd); j<=std::max(etaStart,etaEnd); j++) { - if (checkChipStatus(moduleHash, m_pixelID->pixel_id(moduleID,i,j))) { nGood++; } + if (checkChipStatus(moduleHash, m_pixelID->pixel_id(moduleID,i,j), ctx)) { + if (m_useByteStream) { + if (!hasBSError(moduleHash, m_pixelID->pixel_id(moduleID,i,j), ctx)) { nGood++; } + } + else { + nGood++; + } + } } } return nGood/nTotal; diff --git a/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.h b/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.h index a1a17a44d89fae147b08e2d63cc92ac7233ddef2..cd02679876eb8e2830c4e2180dcd02b3635bd5fb 100644 --- a/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.h +++ b/InnerDetector/InDetConditions/PixelConditionsTools/src/PixelConditionsSummaryTool.h @@ -16,8 +16,9 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ServiceHandle.h" #include "InDetConditionsSummaryService/IInDetConditionsTool.h" +#include "AthenaKernel/SlotSpecificObj.h" -#include "InDetByteStreamErrors/InDetBSErrContainer.h" +#include "InDetByteStreamErrors/IDCInDetBSErrContainer.h" #include "Identifier/Identifier.h" #include "Identifier/IdentifierHash.h" #include "InDetIdentifier/PixelID.h" @@ -27,6 +28,7 @@ #include "PixelConditionsData/PixelDCSStateData.h" #include "PixelConditionsData/PixelDCSStatusData.h" #include "PixelConditionsData/PixelTDAQData.h" +#include "PixelConditionsData/PixelByteStreamErrors.h" #include "StoreGate/ReadCondHandleKey.h" #include "PixelCabling/IPixelCablingSvc.h" @@ -38,20 +40,34 @@ class PixelConditionsSummaryTool: public AthAlgTool, public IInDetConditionsTool virtual ~PixelConditionsSummaryTool(); virtual StatusCode initialize() override; - virtual bool isActive(const Identifier & elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override final; - virtual bool isActive(const IdentifierHash & moduleHash) const override final; - virtual bool isActive(const IdentifierHash & moduleHash, const Identifier & elementId) const override final; - virtual double activeFraction(const IdentifierHash & moduleHash, const Identifier & idStart, const Identifier & idEnd) const override final; + virtual bool isActive(const Identifier& elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override final; + virtual bool isActive(const IdentifierHash& moduleHash) const override final; + virtual bool isActive(const IdentifierHash& moduleHash, const Identifier& elementId) const override final; + virtual double activeFraction(const IdentifierHash& moduleHash, const Identifier & idStart, const Identifier & idEnd) const override final; + + virtual bool isActive(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const override final; + virtual bool isActive(const IdentifierHash& moduleHash, const EventContext& ctx) const override final; + virtual bool isActive(const IdentifierHash& moduleHash, const Identifier& elementId, const EventContext& ctx) const override final; + virtual double activeFraction(const IdentifierHash& moduleHash, const Identifier & idStart, const Identifier & idEnd, const EventContext& ctx) const override final; virtual bool isGood(const Identifier & elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override final; virtual bool isGood(const IdentifierHash & moduleHash) const override final; virtual bool isGood(const IdentifierHash & moduleHash, const Identifier & elementId) const override final; virtual double goodFraction(const IdentifierHash & moduleHash, const Identifier & idStart, const Identifier & idEnd) const override final; - virtual bool isBSActive(const IdentifierHash & moduleHash) const override final; - virtual bool isBSError(const IdentifierHash & moduleHash) const override final; + virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const override final; + virtual bool isGood(const IdentifierHash& moduleHash, const EventContext& ctx) const override final; + virtual bool isGood(const IdentifierHash& moduleHash, const Identifier& elementId, const EventContext& ctx) const override final; + virtual double goodFraction(const IdentifierHash & moduleHash, const Identifier & idStart, const Identifier & idEnd, const EventContext& ctx) const override final; + + virtual bool hasBSError(const IdentifierHash& moduleHash) const override final; + virtual bool hasBSError(const IdentifierHash& moduleHash, Identifier pixid) const override final; + virtual bool hasBSError(const IdentifierHash& moduleHash, const EventContext& ctx) const override final; + virtual bool hasBSError(const IdentifierHash& moduleHash, Identifier pixid, const EventContext& ctx) const override final; + virtual uint64_t getBSErrorWord(const IdentifierHash& moduleHash, const EventContext& ctx) const override final; bool checkChipStatus(IdentifierHash moduleHash, Identifier pixid) const; + bool checkChipStatus(IdentifierHash moduleHash, Identifier pixid, const EventContext& ctx) const; private: const PixelID* m_pixelID; @@ -81,9 +97,41 @@ class PixelConditionsSummaryTool: public AthAlgTool, public IInDetConditionsTool ServiceHandle<IPixelCablingSvc> m_pixelCabling {this, "PixelCablingSvc", "PixelCablingSvc", "Pixel cabling service"}; - SG::ReadHandleKey<InDetBSErrContainer> m_BSErrContReadKey + SG::ReadHandleKey<IDCInDetBSErrContainer> m_BSErrContReadKey {this, "PixelByteStreamErrs", "PixelByteStreamErrs", "PixelByteStreamErrs container key"}; + const uint64_t m_missingErrorInfo{std::numeric_limits<uint64_t>::max()-3000000000}; + + mutable std::mutex m_cacheMutex{}; + + struct IDCCacheEntry { + EventContext::ContextEvt_t eventId = EventContext::INVALID_CONTEXT_EVT; // invalid event ID for the start + const IDCInDetBSErrContainer_Cache* IDCCache = nullptr; + + void reset( EventContext::ContextEvt_t evtId, const IDCInDetBSErrContainer_Cache* cache) { + eventId = evtId; + IDCCache = cache; + } + + bool needsUpdate( const EventContext& ctx) const { + return eventId != ctx.evt() or eventId == EventContext::INVALID_CONTEXT_EVT; + } + + }; + mutable SG::SlotSpecificObj<IDCCacheEntry> m_eventCache ATLAS_THREAD_SAFE; // Guarded by m_cacheMutex + + /** + * Obtains container form the SG, if it is missing it will complain (hard-coded 3 times per job) and return nullptr + **/ + [[nodiscard]] const IDCInDetBSErrContainer* getContainer(const EventContext& ctx) const; + + /** + * Return cache for the current event + * If, for current slot, the cache is outdated it is retrieved from the IDC collection. + * If the IDC is missing nullptr is returned. + **/ + [[nodiscard]] IDCCacheEntry* getCacheEntry(const EventContext& ctx) const; + }; inline InterfaceID& PixelConditionsSummaryTool::interfaceID(){ @@ -91,8 +139,8 @@ inline InterfaceID& PixelConditionsSummaryTool::interfaceID(){ return IID_PixelConditionsSummaryTool; } -inline bool PixelConditionsSummaryTool::checkChipStatus(IdentifierHash moduleHash, Identifier pixid) const { - std::bitset<16> chipStatus(SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey)->getChipStatus(moduleHash)); +inline bool PixelConditionsSummaryTool::checkChipStatus(IdentifierHash moduleHash, Identifier pixid, const EventContext& ctx) const { + std::bitset<16> chipStatus(SG::ReadCondHandle<PixelModuleData>(m_condDeadMapKey, ctx)->getChipStatus(moduleHash)); if (chipStatus.any()) { Identifier moduleID = m_pixelID->wafer_id(pixid); std::bitset<16> circ; circ.set(m_pixelCabling->getFE(&pixid,moduleID)); diff --git a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.cxx b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.cxx index 82344fbb421c073d81102c0afc633eba91476fa6..573fee4b9c084bfecf2e9ac2052eb04dd88ce94f 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.cxx @@ -60,6 +60,26 @@ SCT_ConditionsSummaryTool::activeFraction(const IdentifierHash& elementHash, con return goodFraction(elementHash, idStart, idEnd); } +double +SCT_ConditionsSummaryTool::activeFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd, const EventContext& ctx) const { + return goodFraction(elementHash, idStart, idEnd, ctx); +} + +bool +SCT_ConditionsSummaryTool::isActive(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const { + return isGood(elementId, h, ctx); +} + +bool +SCT_ConditionsSummaryTool::isActive(const IdentifierHash& elementHash, const EventContext& ctx) const { + return isGood(elementHash, ctx); +} + +bool +SCT_ConditionsSummaryTool::isActive(const IdentifierHash& elementHash, const Identifier& elementId, const EventContext& ctx) const { + return isGood(elementHash, elementId, ctx); +} + bool SCT_ConditionsSummaryTool::isGood(const Identifier& elementId, const InDetConditions::Hierarchy h) const { if (not m_noReports) { @@ -97,6 +117,40 @@ SCT_ConditionsSummaryTool::isGood(const IdentifierHash& /*elementHash*/, const I return true; } +bool +SCT_ConditionsSummaryTool::isGood(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const { + if (not m_noReports) { + for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) { + if (tool->canReportAbout(h) and (not tool->isGood(elementId, ctx, h))) return false; + } + } + return true; +} + +bool +SCT_ConditionsSummaryTool::isGood(const IdentifierHash& elementHash, const EventContext& ctx) const { + if (not m_noReports) { + for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) { + if ((tool->canReportAbout(InDetConditions::SCT_SIDE) or + tool->canReportAbout(InDetConditions::SCT_MODULE)) and + (not tool->isGood(elementHash, ctx))) { + return false; + } + } + } + return true; +} + +bool +SCT_ConditionsSummaryTool::isGood(const IdentifierHash& /*elementHash*/, const Identifier& elementId, const EventContext& ctx) const { + if (not m_noReports) { + for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) { + if (tool->canReportAbout(InDetConditions::SCT_STRIP) and (not tool->isGood(elementId, ctx))) return false; + } + } + return true; +} + double SCT_ConditionsSummaryTool::goodFraction(const IdentifierHash& /*elementHash*/, const Identifier& /*idStart*/, const Identifier& /*idEnd*/) const { double result{1.0}; @@ -104,14 +158,40 @@ SCT_ConditionsSummaryTool::goodFraction(const IdentifierHash& /*elementHash*/, c return result; } +double +SCT_ConditionsSummaryTool::goodFraction(const IdentifierHash& /*elementHash*/, const Identifier& /*idStart*/, const Identifier& /*idEnd*/, const EventContext& /*ctx*/) const { + double result{1.0}; + ATH_MSG_WARNING("goodFraction is a deprecated function always returning 1.0 "); + return result; +} + bool -SCT_ConditionsSummaryTool::isBSActive(const IdentifierHash& /*elementHash*/) const { - ATH_MSG_WARNING("isBSActive() is not implemented for SCT_ConditionsSummaryTool"); +SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/) const { + ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool"); return true; } bool -SCT_ConditionsSummaryTool::isBSError(const IdentifierHash& /*elementHash*/) const { - ATH_MSG_WARNING("isBSError() is not implemented for SCT_ConditionsSummaryTool"); - return false; +SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/, Identifier /*elementId*/) const { + ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool"); + return true; } + +bool +SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/, const EventContext& /*ctx*/) const { + ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool"); + return true; +} + +bool +SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/, Identifier /*elementId*/, const EventContext& /*ctx*/) const { + ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool"); + return true; +} + +uint64_t +SCT_ConditionsSummaryTool::getBSErrorWord(const IdentifierHash& /*moduleHash*/, const EventContext& /*ctx*/) const { + ATH_MSG_WARNING("getBSErrorWord() is not implemented for SCT_ConditionsSummaryTool"); + return 0; +} + diff --git a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.h b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.h index b018ce8351ee810a807b1a9147801b235337e020..e22a2630e6d2d5448d9d621231bc8e0cd62f95c0 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.h +++ b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ConditionsSummaryTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** @@ -45,12 +45,27 @@ public: virtual bool isActive(const IdentifierHash& elementHash) const override; virtual bool isActive(const IdentifierHash& elementHash, const Identifier& elementId) const override; virtual double activeFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd) const override; + + virtual bool isActive(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const override; + virtual bool isActive(const IdentifierHash& elementHash, const EventContext& ctx) const override; + virtual bool isActive(const IdentifierHash& elementHash, const Identifier& elementId, const EventContext& ctx) const override; + virtual double activeFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd, const EventContext& ctx) const override; + virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override; virtual bool isGood(const IdentifierHash& elementHash) const override; virtual bool isGood(const IdentifierHash& elementHash, const Identifier& elementId) const override; virtual double goodFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd) const override; - virtual bool isBSActive(const IdentifierHash& elementHash) const override; - virtual bool isBSError(const IdentifierHash& elementHash) const override; + + virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const override; + virtual bool isGood(const IdentifierHash& elementHash, const EventContext& ctx) const override; + virtual bool isGood(const IdentifierHash& elementHash, const Identifier& elementId, const EventContext& ctx) const override; + virtual double goodFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd, const EventContext& ctx) const override; + + virtual bool hasBSError(const IdentifierHash& elementHash) const override; + virtual bool hasBSError(const IdentifierHash& elementHash, Identifier elementId) const override; + virtual bool hasBSError(const IdentifierHash& elementHash, const EventContext& ctx) const override; + virtual bool hasBSError(const IdentifierHash& elementHash, Identifier elementId, const EventContext& ctx) const override; + virtual uint64_t getBSErrorWord(const IdentifierHash& moduleHash, const EventContext& ctx) const override; //@} private: StringArrayProperty m_reportingTools; //!< list of tools to be used diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx index a5aee3a459b6bca6f939d470e779756fc66374b5..61940ed2132cd0fe6ced69c1680b238d1c397d7b 100644 --- a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx +++ b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx @@ -265,7 +265,7 @@ StatusCode PixelPrepDataToxAOD::execute() // Add information for each contributing hit if(m_writeRDOinformation) { IdentifierHash moduleHash = clusterCollection->identifyHash(); - AUXDATA(xprd,int,isBSError) = (int)m_pixelSummary->isBSError(moduleHash); + AUXDATA(xprd,int,hasBSError) = (int)m_pixelSummary->hasBSError(moduleHash); AUXDATA(xprd,int,DCSState) = dcsState->getModuleStatus(moduleHash); float deplVoltage = 0.0; diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRawDataProviderTool.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRawDataProviderTool.h index 9b47e86b95b2bc391ab5586d457ac8e78f6f77a0..e5fe7767fce11c77964f358cfd901f0d7acbb4a1 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRawDataProviderTool.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRawDataProviderTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef IPIXELRAWDATABYTESTREAMCNV_PIXELRAWDATAPROVIDERTOOL_H @@ -27,6 +27,9 @@ class IPixelRawDataProviderTool : virtual public IAlgTool IDCInDetBSErrContainer& decodingErrors ) const = 0; + //! Size of IDCInDetBSErrContainer + virtual int SizeOfIDCInDetBSErrContainer() const =0; + }; inline const InterfaceID& IPixelRawDataProviderTool::interfaceID(){ diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRodDecoder.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRodDecoder.h index 6589e59b9663814f8e48bada73680ba1f2df4ad0..7a3bd2993729842511e063f723bea3f6e161922a 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRodDecoder.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/PixelRawDataByteStreamCnv/IPixelRodDecoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef IPIXELRAWDATABYTESTREAM_PIXEL_RODDECODER_H @@ -24,7 +24,6 @@ class IPixelRodDecoder : virtual public IAlgTool{ IDCInDetBSErrContainer& decodingErrors, std::vector<IdentifierHash>* vecHash = NULL) const = 0; - virtual StatusCode StoreBSError() const =0; }; inline const InterfaceID& IPixelRodDecoder::interfaceID(){ diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx index e8d3d7414d984991d3aee66958fb5e00a2454072..d50b392fd753ce2f1e4f0acb3636b0d4bf01d574 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx @@ -53,7 +53,6 @@ StatusCode PixelRawDataProvider::initialize() { ATH_CHECK( m_bsErrorsKey.initialize() ); ATH_CHECK( m_bsErrorsCacheKey.initialize( SG::AllowEmpty ) ); - if (m_roiSeeded) { ATH_CHECK( m_roiCollectionKey.initialize() ); ATH_CHECK(m_regionSelector.retrieve()); @@ -140,16 +139,13 @@ StatusCode PixelRawDataProvider::execute(const EventContext& ctx) const { SG::UpdateHandle<IDCInDetBSErrContainer_Cache> bsErrorsCacheHandle( m_bsErrorsCacheKey, ctx); decodingErrors = std::make_unique<IDCInDetBSErrContainer>( bsErrorsCacheHandle.ptr() ); } else { - decodingErrors = std::make_unique<IDCInDetBSErrContainer>( m_pixel_id->wafer_hash_max(), std::numeric_limits<IDCInDetBSErrContainer::ErrorCode>::min() ); + decodingErrors = std::make_unique<IDCInDetBSErrContainer>( m_rawDataTool->SizeOfIDCInDetBSErrContainer(), std::numeric_limits<int>::min() ); } - // ask PixelRawDataProviderTool to decode it and to fill the IDC if (m_rawDataTool->convert(listOfRobf, containerInterface, *decodingErrors).isFailure()) ATH_MSG_ERROR("BS conversion into RDOs failed"); - - if(tempcont) ATH_CHECK(tempcont->MergeToRealContainer(rdoContainer.ptr())); SG::WriteHandle<IDCInDetBSErrContainer> bsErrorsHandle(m_bsErrorsKey, ctx); diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h index 888a96778f02652497832757efcdb87e3de22c48..b9f4c5605c38d706c1662e3f0e6a648398ba2557 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h @@ -56,7 +56,7 @@ private: SG::ReadHandleKey<TrigRoiDescriptorCollection> m_roiCollectionKey { this, "RoIs", "", "If RoI driven unpacking to be used, this is the key"}; SG::WriteHandleKey<PixelRDO_Container> m_rdoContainerKey { this, "RDOKey", "PixelRDOs"}; SG::UpdateHandleKey<PixelRDO_Cache> m_rdoCacheKey; - SG::WriteHandleKey<IDCInDetBSErrContainer> m_bsErrorsKey { this, "BSErrorsKey", "PixBSErr"}; + SG::WriteHandleKey<IDCInDetBSErrContainer> m_bsErrorsKey { this, "BSErrorsKey", "PixelByteStreamErrs"}; SG::UpdateHandleKey<IDCInDetBSErrContainer_Cache> m_bsErrorsCacheKey; SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey { this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"}; diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx index a49c6afa43d1a4af751a6d69e695b18fed06ee50..1462f149d26661ebd08f20f2210e19242be06351 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelRawDataProviderTool.h" @@ -44,7 +44,6 @@ StatusCode PixelRawDataProviderTool::convert(std::vector<const ROBFragment*>& ve IDCInDetBSErrContainer& decodingErrors ) const { if (vecRobs.size()==0) { return StatusCode::SUCCESS; } - std::vector<const ROBFragment*>::const_iterator rob_it = vecRobs.begin(); #ifdef PIXEL_DEBUG @@ -111,8 +110,6 @@ StatusCode PixelRawDataProviderTool::convert(std::vector<const ROBFragment*>& ve // using 1 container per event and subdetector StatusCode sc = m_decoder->fillCollection(&**rob_it, rdoIdc, decodingErrors); - - const int issuesMessageCountLimit = 100; if (sc==StatusCode::FAILURE) { if (m_DecodeErrCount < issuesMessageCountLimit) { @@ -125,8 +122,28 @@ StatusCode PixelRawDataProviderTool::convert(std::vector<const ROBFragment*>& ve } } } - if (isNewEvent) { - ATH_CHECK(m_decoder->StoreBSError()); - } return StatusCode::SUCCESS; } + +int PixelRawDataProviderTool::SizeOfIDCInDetBSErrContainer() const { + //========================================================= + // Size of Pixel BS Error container + // + // The error would be stored not only for module but also each FE (x16) per module. + // In addition, IBL FEI4 provides error counter between trigger, this also extends + // the size beyond nominal module + FE ID. These numbers come from the hardware + // specification so that there is no easy way to document in the header file. + // Rather, put the hardcoded number here. + // + // Total number of pixel modules: 2048 + // Number of FE chips per module: 16 + // ------------------------------------- + // 2048 x 17 (module + FE) = 34816 + // + // IBL extra error information : + // 280(module) x 2(FE) x 32(error counter) = 35840 + // ------------------------------------- + // Total : 70656 + //========================================================= + return 70656; +} diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h index 8fa60a092dd7863cf51aaf29e58a56e78f28eccc..31c98e90fd99fb905eafdbe59fa2c11f09dfde07 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef PIXELRAWDATABYTESTREAMCNV_PIXELRAWDATAPROVIDERTOOL_H @@ -41,6 +41,8 @@ class PixelRawDataProviderTool : virtual public IPixelRawDataProviderTool, publi IPixelRDO_Container* rdoIdc, IDCInDetBSErrContainer& decodingErrors) const final; + //! Size of IDCInDetBSErrContainer + int SizeOfIDCInDetBSErrContainer() const final; private: diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx index 3ac603e2f67413dd34fdee32df31c87b3aa31f13..2aaca3f3d617cb7df50331e2c23bd7d00f8223c7 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.cxx @@ -77,7 +77,6 @@ StatusCode PixelRodDecoder::initialize() { ATH_MSG_DEBUG( "m_is_ibl_present = " << m_is_ibl_present ); // Retrieve Pixel Errors Service - ATH_CHECK(m_errors.retrieve()); ATH_CHECK(m_condCablingKey.initialize()); ATH_CHECK(m_condHitDiscCnfgKey.initialize(m_is_ibl_present)); @@ -97,15 +96,27 @@ StatusCode PixelRodDecoder::finalize() { ATH_MSG_INFO("General (corruption / illegal value)\t" << m_numGenWarnings << " (" << m_maxNumGenWarnings << ")"); ATH_MSG_INFO("Unexpected BCID / LVL1ID \t" << m_numBCIDWarnings << " (" << m_maxNumBCIDWarnings << ")"); + ATH_MSG_INFO(" --- Summary from PixelRodDecoder --- "); + ATH_MSG_INFO(" - Number of invalid Identifiers Errors: " << m_numInvalidIdentifiers); + ATH_MSG_INFO(" - Number of Preamble Errors: " << m_numPreambleErrors); + ATH_MSG_INFO(" - Number of TimeOut Errors: " << m_numTimeOutErrors); + ATH_MSG_INFO(" - Number of LVL1ID Errors: " << m_numLVL1IDErrors); + ATH_MSG_INFO(" - Number of BCID Errors: " << m_numBCIDErrors); + ATH_MSG_INFO(" - Number of Flagged Errors: " << m_numFlaggedErrors); + ATH_MSG_INFO(" - Number of Trailer Errors: " << m_numTrailerErrors); + ATH_MSG_INFO(" - Number of Disabled FE Errors: " << m_numDisabledFEErrors); + ATH_MSG_INFO(" - Number of ROD Errors: " << m_numRODErrors); + ATH_MSG_INFO(" - Number of links masked by PPC: " << m_numLinkMaskedByPPC); + ATH_MSG_INFO(" - Number of header/trailer limit errors: " << m_numLimitError); + ATH_MSG_INFO(" - Number of Unknown word Errors: " << m_numDecodingErrors); + ATH_MSG_INFO(" --------------------------------------------- "); + return StatusCode::SUCCESS; } //---------------------------------------------------------------------------------------------------- fillCixollection -StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRDO_Container* rdoIdc, - IDCInDetBSErrContainer& decodingErrors, - std::vector<IdentifierHash>* vecHash) const -{ +StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRDO_Container* rdoIdc, IDCInDetBSErrContainer& decodingErrors, std::vector<IdentifierHash>* vecHash) const { #ifdef PIXEL_DEBUG ATH_MSG_VERBOSE( "-------------------------------------------------------------------------------------------------------------"); ATH_MSG_DEBUG("Entering PixelRodDecoder"); @@ -126,18 +137,50 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD } SG::ReadCondHandle<PixelCablingCondData> pixCabling(m_condCablingKey); - //SG::ReadCondHandle<PixelHitDiscCnfgData> pixHitDiscCnfg(m_condHitDiscCnfgKey); std::unique_ptr<SG::ReadCondHandle<PixelHitDiscCnfgData> > pixHitDiscCnfg; - { - StatusCode sc = checkRODStatus( robFrag, decodingErrors ); - if ( not sc.isSuccess() ) - return sc; - } - unsigned int errorcode = 0; uint64_t bsErrCode = 0; // new BS Errors handling - // m_errors->reset(); // reset the collection of errors + + uint32_t serviceCodeCounter = 0; // frequency of the serviceCode (with the exceptions of serviceCode = 14,15 or 16) + uint32_t serviceCode = 0; // is a code. the corresponding meaning is listed in the table in the FE-I4 manual, pag. 105 + + // Check ROD status + if (robFrag->nstatus()!=0) { + const uint32_t* rob_status; + robFrag->status(rob_status); + // check the ROD status for truncation + if (ATH_UNLIKELY((*rob_status)!=0)) { + ATH_MSG_DEBUG( "ROB status word for robid 0x"<< std::hex << robId << " is non-zero 0x" << (*rob_status) << std::dec); + + /* + Definition of the status words in a ROB fragment header is found in + https://twiki.cern.ch/twiki/bin/view/Atlas/ROBINFragmentErrors#Definition_of_the_first_status_e + */ + if (((*rob_status) >> 27) & 0x1) { + const std::deque<Identifier> offlineIdList = pixCabling->find_entry_offlineList(robId); + for (const Identifier& id: offlineIdList) { + PixelByteStreamErrors::addError(bsErrCode,PixelByteStreamErrors::TruncatedROB); + IdentifierHash idHash = m_pixel_id->wafer_hash(id); + decodingErrors.setOrDrop(idHash,bsErrCode); + } + ATH_MSG_DEBUG("ROB status word for robid 0x"<< std::hex << robId << std::dec <<" indicates data truncation."); + return StatusCode::RECOVERABLE; + } + + if (((*rob_status) >> 31) & 0x1) { + const std::deque<Identifier> offlineIdList = pixCabling->find_entry_offlineList(robId); + for (const Identifier& id: offlineIdList) { + PixelByteStreamErrors::addError(bsErrCode,PixelByteStreamErrors::MaskedROB); + IdentifierHash idHash = m_pixel_id->wafer_hash(id); + decodingErrors.setOrDrop(idHash,bsErrCode); + } + ATH_MSG_DEBUG( "ROB status word for robid 0x"<< std::hex << robId<< std::dec <<" indicates resource was masked off."); + return StatusCode::RECOVERABLE; + } + + } + } StatusCode sc = StatusCode::SUCCESS; @@ -201,13 +244,11 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD int hitDiscCnfg = 3; // FE-I4 hit discrimination setting - // Do a check on IBL Slink ID eformat::helper::SourceIdentifier sid_rob(robId); sLinkSourceId = (sid_rob.module_id()) & 0x000F; // retrieve S-Link number from the source Identifier (0xRRRL, L = Slink number) if ( isIBL( robId ) && sLinkSourceId>0x3) { // Check if SLink number for the IBL is correct! - generalwarning("In ROB 0x" << std::hex << robId << ": IBL/DBM SLink number not in correct range (0-3): SLink = " - << std::dec << sLinkSourceId); + generalwarning("In ROB 0x" << std::hex << robId << ": IBL/DBM SLink number not in correct range (0-3): SLink = " << std::dec << sLinkSourceId); } // Store length of module fragments, for monitoring @@ -227,758 +268,705 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD ++nwords_in_module_fragment; + errorcode = 0; + bsErrCode = 0; + + serviceCodeCounter = 0; + serviceCode = 0; switch (word_type) { // depending on type of word call the right decoding method //-------------------------------------------------------------------------------------------- HEADER WORD FOUND - case PRB_LINKHEADER: // link (module) header found + case PRB_LINKHEADER: // link (module) header found - ATH_MSG_DEBUG("Header word found"); + ATH_MSG_DEBUG("Header word found"); - if (link_start) { // if header found before last header was closed by a trailer -> error - generalwarning("In ROB 0x" << std::hex << robId << ": Unexpected link header found: 0x" << std::hex << rawDataWord - << ", data corruption" << std::dec); - m_errors->addDecodingError(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); - } - else { - ATH_MSG_DEBUG( "Header decoding starts" ); - } + if (link_start) { // if header found before last header was closed by a trailer -> error + generalwarning("In ROB 0x" << std::hex << robId << ": Unexpected link header found: 0x" << std::hex << rawDataWord << ", data corruption" << std::dec); + m_numDecodingErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); + } + else { + ATH_MSG_DEBUG( "Header decoding starts" ); + } - link_start = true; // setting link (module) header found flag - are_4condensed_words = false; - receivedCondensedWords = false; - isIBLModule = false; - isDBMModule = false; - countHitCondensedWords = 0; - nwords_in_module_fragment = 1; - - if (m_is_ibl_present) { - isIBLModule = isIBL(robId); - isDBMModule = isDBM(robId); - } + link_start = true; // setting link (module) header found flag + are_4condensed_words = false; + receivedCondensedWords = false; + isIBLModule = false; + isDBMModule = false; + countHitCondensedWords = 0; + nwords_in_module_fragment = 1; + + if (m_is_ibl_present) { + isIBLModule = isIBL(robId); + isDBMModule = isDBM(robId); + } - errorcode = 0; // reset errorcode - // Keep track of IDs for previous fragment before decoding the new values - prevLVL1ID = mLVL1ID; - prevBCID = mBCID; - prevLinkNum = mLink; - prevOffsetBCID_ROB_FE = offsetBCID_ROB_FE; + errorcode = 0; // reset errorcode + // Keep track of IDs for previous fragment before decoding the new values + prevLVL1ID = mLVL1ID; + prevBCID = mBCID; + prevLinkNum = mLink; + prevOffsetBCID_ROB_FE = offsetBCID_ROB_FE; - if (isIBLModule || isDBMModule) { // decode IBL/DBM header word. + if (isIBLModule || isDBMModule) { // decode IBL/DBM header word. #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "Decoding the IBL/DBM header word: 0x" << std::hex << rawDataWord << std::dec ); + ATH_MSG_VERBOSE( "Decoding the IBL/DBM header word: 0x" << std::hex << rawDataWord << std::dec ); #endif - // IBL header data format: 001nnnnnFLLLLLLLLLLLLLBBBBBBBBBB - mBCID = decodeBCID_IBL(rawDataWord); // decode IBL BCID: B - mLVL1ID = decodeL1ID_IBL(rawDataWord); // decode IBL LVL1ID: L - linkNum_IBLheader = decodeModule_IBL(rawDataWord); // decode IBL FE number on the S-Link (range [0,7], as 8 FEs are connected to 1 S-Link in IBL) and the S-Link number itself: n - - - if (decodeFeI4Bflag_IBL(rawDataWord)) { - m_errors->addFlaggedError(); // decode FeI4B flag bit: F - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Flagged ); - } - - - fe_IBLheader = extractFefromLinkNum(linkNum_IBLheader); - mLink = fe_IBLheader; // this is used to retrieve the onlineId. It contains only the 3 LSBs of the nnnnn, indicating the number of FE w.r.t. the SLink - sLinkHeader = extractSLinkfromLinkNum(linkNum_IBLheader); // this is used to check that the (redundant) info is correctly transmitted - - if (sLinkHeader != sLinkSourceId) { - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": SLink discrepancy: Slink number from SourceId = 0x" << std::hex << sLinkSourceId - << ", number from link header = 0x" << sLinkHeader << std::dec); - } - - // If decoding fragment from same FE as previous one, do LVL1ID and BCID checks - if (mLink == prevLinkNum) { - - // Check that L1ID is the same for all fragments - if (mLVL1ID != prevLVL1ID && prevLVL1ID != 0x3FFF) { - lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink - << ": frame header LVL1ID differs from previous one (current frame LVL1ID = 0x" - << mLVL1ID << ", previous frame LVL1ID = 0x" << prevLVL1ID << ")" << std::dec); - } - // Check that BCIDs are consecutive - if ((mBCID != prevBCID + 1) && prevBCID != 0x3FFF && prevBCID != mBCID_max_IBL) { - lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink - << ": frame header with non-consecutive BCID (current BCID = 0x" - << mBCID << ", previous BCID = 0x" << prevBCID << ")" << std::dec); - } - } - else { // If decoding new FE, check BCID offset - offsetBCID_ROB_FE = static_cast<int>(mBCID) - robBCID; - if (offsetBCID_ROB_FE != prevOffsetBCID_ROB_FE && (offsetBCID_ROB_FE != 0x3FFF && prevOffsetBCID_ROB_FE != 0x3FFF)) { - lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << std::dec << ": FE header with unexpected BCID offset" - << " wrt to ROB header (offset = " << offsetBCID_ROB_FE << ", expected " << prevOffsetBCID_ROB_FE << " from ROB)"); - } - // Check that first fragment from each FE starts at the same BCID - if (mBCID != prevStartingBCID && prevStartingBCID != 0x3FFF) { - lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink - << ": FE BCID starts at different value than in previous FE (current BCID = 0x" - << mBCID << ", prev starting BCID = 0x" << prevStartingBCID << ")" << std::dec); - } - prevStartingBCID = mBCID; - } - - // Count number of headers received - if (mLink < 0x8) ++nFragmentsPerFE[mLink]; + // IBL header data format: 001nnnnnFLLLLLLLLLLLLLBBBBBBBBBB + mBCID = decodeBCID_IBL(rawDataWord); // decode IBL BCID: B + mLVL1ID = decodeL1ID_IBL(rawDataWord); // decode IBL LVL1ID: L + linkNum_IBLheader = decodeModule_IBL(rawDataWord); // decode IBL FE number on the S-Link (range [0,7], as 8 FEs are connected to 1 S-Link in IBL) and the S-Link number itself: n - } - else { // this is Pixels detector decode header word. Data format: 001PtlbxdnnnnnnnMMMMLLLLBBBBBBBB (NOT IBL OR PIXEL) + if (decodeFeI4Bflag_IBL(rawDataWord)) { + m_numFlaggedErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Flagged ); + } - ATH_MSG_VERBOSE( "Decoding Pixel header word: 0x" << std::hex << rawDataWord << std::dec ); + fe_IBLheader = extractFefromLinkNum(linkNum_IBLheader); + mLink = fe_IBLheader; // this is used to retrieve the onlineId. It contains only the 3 LSBs of the nnnnn, indicating the number of FE w.r.t. the SLink + sLinkHeader = extractSLinkfromLinkNum(linkNum_IBLheader); // this is used to check that the (redundant) info is correctly transmitted - mBCID = decodeBCID(rawDataWord); // decode Pixel BCID: B - mLVL1ID = decodeL1ID(rawDataWord); // decode Pixel LVL1ID: L - mLink = decodeModule(rawDataWord); // decode Pixel link (module): n - //mLVL1IDskip = decodeL1IDskip(rawDataWord); // decode Pixel skipped LVL1ID: M -- temporarily removed + if (sLinkHeader != sLinkSourceId) { + generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": SLink discrepancy: Slink number from SourceId = 0x" << std::hex << sLinkSourceId << ", number from link header = 0x" << sLinkHeader << std::dec); + } - const uint32_t headerError = decodeHeaderErrors(rawDataWord); // get link (module) header errors - if ( headerError != 0 ) { - sc = StatusCode::RECOVERABLE; - errorcode = errorcode | (headerError << 20); //encode error as HHHHMMMMMMMMFFFFFFFFTTTT for header, flagword, trailer errors - checkHeaderErrors( bsErrCode, headerError ); - } - } // end of detector type decoding + // If decoding fragment from same FE as previous one, do LVL1ID and BCID checks + if (mLink == prevLinkNum) { + + // Check that L1ID is the same for all fragments + if (mLVL1ID != prevLVL1ID && prevLVL1ID != 0x3FFF) { + lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << ": frame header LVL1ID differs from previous one (current frame LVL1ID = 0x" << mLVL1ID << ", previous frame LVL1ID = 0x" << prevLVL1ID << ")" << std::dec); + } + // Check that BCIDs are consecutive + if ((mBCID != prevBCID + 1) && prevBCID != 0x3FFF && prevBCID != mBCID_max_IBL) { + lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << ": frame header with non-consecutive BCID (current BCID = 0x" << mBCID << ", previous BCID = 0x" << prevBCID << ")" << std::dec); + } + } + else { // If decoding new FE, check BCID offset + offsetBCID_ROB_FE = static_cast<int>(mBCID) - robBCID; + if (offsetBCID_ROB_FE != prevOffsetBCID_ROB_FE && (offsetBCID_ROB_FE != 0x3FFF && prevOffsetBCID_ROB_FE != 0x3FFF)) { + lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << std::dec << ": FE header with unexpected BCID offset" << " wrt to ROB header (offset = " << offsetBCID_ROB_FE << ", expected " << prevOffsetBCID_ROB_FE << " from ROB)"); + } + // Check that first fragment from each FE starts at the same BCID + if (mBCID != prevStartingBCID && prevStartingBCID != 0x3FFF) { + lvl1id_bcid_warning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << ": FE BCID starts at different value than in previous FE (current BCID = 0x" << mBCID << ", prev starting BCID = 0x" << prevStartingBCID << ")" << std::dec); + } + prevStartingBCID = mBCID; + } - // Get onlineId - onlineId = pixCabling->getOnlineIdFromRobId(robId, mLink); + // Count number of headers received + if (mLink < 0x8) ++nFragmentsPerFE[mLink]; - if (onlineId == 0) { - generalwarning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink - << ": Got invalid onlineId (= 0) in FE header - dataword = 0x" << rawDataWord); - } + } + else { // this is Pixels detector decode header word. Data format: 001PtlbxdnnnnnnnMMMMLLLLBBBBBBBB (NOT IBL OR PIXEL) + + ATH_MSG_VERBOSE( "Decoding Pixel header word: 0x" << std::hex << rawDataWord << std::dec ); + + mBCID = decodeBCID(rawDataWord); // decode Pixel BCID: B + mLVL1ID = decodeL1ID(rawDataWord); // decode Pixel LVL1ID: L + mLink = decodeModule(rawDataWord); // decode Pixel link (module): n + //mLVL1IDskip = decodeL1IDskip(rawDataWord); // decode Pixel skipped LVL1ID: M -- temporarily removed + + const uint32_t headerError = decodeHeaderErrors(rawDataWord); // get link (module) header errors + if ( headerError != 0 ) { + sc = StatusCode::RECOVERABLE; + errorcode = errorcode | (headerError << 20); //encode error as HHHHMMMMMMMMFFFFFFFFTTTT for header, flagword, trailer errors + checkHeaderErrors( bsErrCode, headerError ); + } + } // end of detector type decoding + + // Get onlineId + onlineId = pixCabling->getOnlineIdFromRobId(robId, mLink); + + if (onlineId == 0) { + generalwarning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << ": Got invalid onlineId (= 0) in FE header - dataword = 0x" << rawDataWord); + } #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE("In decoder: got onlineId 0x" << std::hex << onlineId ); + ATH_MSG_VERBOSE("In decoder: got onlineId 0x" << std::hex << onlineId ); #endif - offlineIdHash = m_pixel_id->wafer_hash(pixCabling->find_entry_onoff(onlineId)); + offlineIdHash = m_pixel_id->wafer_hash(pixCabling->find_entry_onoff(onlineId)); - if (offlineIdHash != previous_offlineIdHash) { - m_errors->addRead(offlineIdHash); // TODO: understand this better, it seems like an additiona, transient flag denoting that the module wasdecoded for this event - mBCID_offset = mBCID; // set BCID offset if this is first LVL1A - } - mLVL1A = mBCID - mBCID_offset; // calculate the LVL1A - if (mLVL1A < 0) { - if (isIBLModule || isDBMModule) mLVL1A = mLVL1A + mBCID_max_IBL; - else mLVL1A = mLVL1A + mBCID_max_pix; - } + if (offlineIdHash != previous_offlineIdHash) { + mBCID_offset = mBCID; // set BCID offset if this is first LVL1A + } + mLVL1A = mBCID - mBCID_offset; // calculate the LVL1A + if (mLVL1A < 0) { + if (isIBLModule || isDBMModule) mLVL1A = mLVL1A + mBCID_max_IBL; + else mLVL1A = mLVL1A + mBCID_max_pix; + } #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "link header with BCID: " << mBCID << " LVL1ID: " << mLVL1ID << " LVL1A: " << mLVL1A << " link: " << mLink << " found"); - ATH_MSG_VERBOSE( "got OfflineIDHash: 0x" << std::hex << offlineIdHash << " from OnlineID: 0x" << onlineId << std::dec << " link: " << mLink); + ATH_MSG_VERBOSE( "link header with BCID: " << mBCID << " LVL1ID: " << mLVL1ID << " LVL1A: " << mLVL1A << " link: " << mLink << " found"); + ATH_MSG_VERBOSE( "got OfflineIDHash: 0x" << std::hex << offlineIdHash << " from OnlineID: 0x" << onlineId << std::dec << " link: " << mLink); #endif - if (offlineIdHash == 0xffffffff) { // if link (module) online identifier (ROBID and link number) not found by mapping - generalwarning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink - << ": Unknown OnlineId identifier in FE header - not found by mapping" << std::dec); - m_errors->addDecodingError(); // TODO Decoding error not associated wiht any hashID. Handle that somehow - link_start = false; // resetting link (module) header found flag - continue; // skip this word and process next one - } - break; + if (offlineIdHash == 0xffffffff) { // if link (module) online identifier (ROBID and link number) not found by mapping + generalwarning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << ": Unknown OnlineId identifier in FE header - not found by mapping" << std::dec); + m_numDecodingErrors++; + link_start = false; // resetting link (module) header found flag + continue; // skip this word and process next one + } + + break; - //-------------------------------------------------------------------------------------------- HIT DATA WORD FOUND - case PRB_DATAWORD: // hit data found + //-------------------------------------------------------------------------------------------- HIT DATA WORD FOUND + case PRB_DATAWORD: // hit data found - if (link_start) { // if header found before hit -> expected + if (link_start) { // if header found before hit -> expected - ATH_MSG_DEBUG("Hit word found"); + ATH_MSG_DEBUG("Hit word found"); - unsigned int mFE = 0; - unsigned int mRow = 0; - unsigned int mColumn = 0; - int mToT = 0; - uint32_t row[nHits], col[nHits]; - int tot[nHits]; + unsigned int mFE = 0; + unsigned int mRow = 0; + unsigned int mColumn = 0; + int mToT = 0; + uint32_t row[nHits], col[nHits]; + int tot[nHits]; - if (isIBLModule || isDBMModule) { // check all the different types of IBL/DBM hit words (condensed and not condensed) + if (isIBLModule || isDBMModule) { // check all the different types of IBL/DBM hit words (condensed and not condensed) #ifdef PIXEL_DEBUG - ATH_MSG_DEBUG ("Decoding IBL/DBM hit word: 0x" << std::hex << rawDataWord << std::dec); + ATH_MSG_DEBUG ("Decoding IBL/DBM hit word: 0x" << std::hex << rawDataWord << std::dec); #endif - if (((rawDataWord & PRB_DATAMASK) == PRB_FIRSTHITCONDENSEDWORD) && (countHitCondensedWords == 0)) { // it is the first of the 4 hit condensed words (IBL/DBM) - - countHitCondensedWords = 1; - are_4condensed_words = false; // All 4 words have to be found before turning it on - condensedWords[0] = rawDataWord; - continue; - } - else if (countHitCondensedWords == 1) { // it is the second of the 4 hit condensed words (IBL) - ++countHitCondensedWords; - condensedWords[1] = rawDataWord; - continue; - } - else if (countHitCondensedWords == 2) { // it is the third of the 4 hit condensed words (IBL) - ++countHitCondensedWords; - condensedWords[2] = rawDataWord; - continue; - } - else if (((rawDataWord & PRB_DATAMASK) == PRB_LASTHITCONDENSEDWORD) && (countHitCondensedWords == 3)) { // it is the fourth of the 4 hit condensed words (IBL) - are_4condensed_words = true; - receivedCondensedWords = true; - condensedWords[3] = rawDataWord; - uint32_t hitwords[nHits]; - - //Condensed words - // 101RRRRRTTTTTTTTCCCCCCCRRRRRRRRR - // 1CCCRRRRRRRRRTTTTTTTTCCCCCCCRRRR - // 1TTTCCCCCCCRRRRRRRRRTTTTTTTTCCCC - // 111TTTTTTTTCCCCCCCRRRRRRRRRTTTTT - // They become 5 hitwords with format : TTTTTTTTCCCCCCCRRRRRRRRR - - // first hitword: simple mask of the first condensed word - hitwords[0] = (condensedWords[0] & mask24); - - // second hitword: takes the "RRRRR" from the first condensed word + the "TTTTTTTTCCCCCCCRRRR" from the second (shifted left 5 bits to accomodate the "RRRRR" as LSB) - hitwords[1] = ((condensedWords[0] >> (skipRow + skipCol+ skipTOT) ) & mask5) + ((condensedWords[1] & mask19) << skip5); - - // third hitword: takes remaining "CCCRRRRRRRRR" from the second condensed word + the "TTTTTTTTCCCC" from the third (shifted left 12 bits to accomodate the LSB coming from the second condensed word - hitwords[2] = ((condensedWords[1] >> (skip4 + skipCol + skipTOT)) & mask12) + ((condensedWords[2] & mask12) << (skipRow + skip3)); - - // fourth hitword: takes remaning "TTTCCCCCCCRRRRRRRRR" from the third condensed word + the "TTTTT" from the fourth (shifted left 19 bits to accomodate the LSB coming from the third condensed word - hitwords[3] = ((condensedWords[2] >> (skipTOT + skip4)) & mask19) + ((condensedWords[3] & mask5) << (skip3 + skipRow + skipCol)); - - // fifth hitword: simply shift 5 right to eliminate the "TTTTT" and mask24 - hitwords[4] = (condensedWords[3] >> skip5) & mask24; + if (((rawDataWord & PRB_DATAMASK) == PRB_FIRSTHITCONDENSEDWORD) && (countHitCondensedWords == 0)) { // it is the first of the 4 hit condensed words (IBL/DBM) + + countHitCondensedWords = 1; + are_4condensed_words = false; // All 4 words have to be found before turning it on + condensedWords[0] = rawDataWord; + continue; + } + else if (countHitCondensedWords == 1) { // it is the second of the 4 hit condensed words (IBL) + ++countHitCondensedWords; + condensedWords[1] = rawDataWord; + continue; + } + else if (countHitCondensedWords == 2) { // it is the third of the 4 hit condensed words (IBL) + ++countHitCondensedWords; + condensedWords[2] = rawDataWord; + continue; + } + else if (((rawDataWord & PRB_DATAMASK) == PRB_LASTHITCONDENSEDWORD) && (countHitCondensedWords == 3)) { // it is the fourth of the 4 hit condensed words (IBL) + are_4condensed_words = true; + receivedCondensedWords = true; + condensedWords[3] = rawDataWord; + uint32_t hitwords[nHits]; + + //Condensed words + // 101RRRRRTTTTTTTTCCCCCCCRRRRRRRRR + // 1CCCRRRRRRRRRTTTTTTTTCCCCCCCRRRR + // 1TTTCCCCCCCRRRRRRRRRTTTTTTTTCCCC + // 111TTTTTTTTCCCCCCCRRRRRRRRRTTTTT + // They become 5 hitwords with format : TTTTTTTTCCCCCCCRRRRRRRRR + + // first hitword: simple mask of the first condensed word + hitwords[0] = (condensedWords[0] & mask24); + + // second hitword: takes the "RRRRR" from the first condensed word + the "TTTTTTTTCCCCCCCRRRR" from the second (shifted left 5 bits to accomodate the "RRRRR" as LSB) + hitwords[1] = ((condensedWords[0] >> (skipRow + skipCol+ skipTOT) ) & mask5) + ((condensedWords[1] & mask19) << skip5); + + // third hitword: takes remaining "CCCRRRRRRRRR" from the second condensed word + the "TTTTTTTTCCCC" from the third (shifted left 12 bits to accomodate the LSB coming from the second condensed word + hitwords[2] = ((condensedWords[1] >> (skip4 + skipCol + skipTOT)) & mask12) + ((condensedWords[2] & mask12) << (skipRow + skip3)); + + // fourth hitword: takes remaning "TTTCCCCCCCRRRRRRRRR" from the third condensed word + the "TTTTT" from the fourth (shifted left 19 bits to accomodate the LSB coming from the third condensed word + hitwords[3] = ((condensedWords[2] >> (skipTOT + skip4)) & mask19) + ((condensedWords[3] & mask5) << (skip3 + skipRow + skipCol)); + + // fifth hitword: simply shift 5 right to eliminate the "TTTTT" and mask24 + hitwords[4] = (condensedWords[3] >> skip5) & mask24; #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "4 consecutive IBL hit words found. Condensed hits are being decoded"); + ATH_MSG_VERBOSE( "4 consecutive IBL hit words found. Condensed hits are being decoded"); #endif - for (unsigned int i(0); i < nHits; ++i) { - row[i] = divideHits (hitwords[i], 0, 8); - col[i] = divideHits (hitwords[i], 9, 15); - tot[i] = divideHits (hitwords[i], 16, 23); - ATH_MSG_VERBOSE( "hitword[" << i << "] = 0x" << std::hex << hitwords[i] << ", row: 0x" << row[i] << ", col: 0x" << col[i] << ", 8-bit ToT: 0x" << tot[i] << std::dec); - } - countHitCondensedWords = 0; - linkNum_IBLword = linkNum_IBLheader; - // fe_IBLword = fe_IBLheader; - // sLinkWord = sLinkHeader; - } // end of the condensed hit words (IBL) - - - else if ((rawDataWord & PRB_DATAMASK) == PRB_DATAWORD) { // it's a IBL not-condensed hit word - if (countHitCondensedWords != 0) { // I received some IBL words, but less than 4, there was an error in the rod transmission - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": Interruption of IBL condensed words - hit(s) ignored (current dataword: 0x" - << std::hex << rawDataWord << std::dec << ")"); - m_errors->addDecodingError(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); - countHitCondensedWords = 0; - } - // IBL non-condensed Hit Words decoding: - are_4condensed_words = false; - mRow = decodeRow(rawDataWord, isIBLModule || isDBMModule ); - mColumn = decodeColumn(rawDataWord, isIBLModule || isDBMModule); - mToT = decodeToT(rawDataWord, isIBLModule || isDBMModule); // this needs, later in the code, to be divided into Tot(0) and Tot(1), because the IBL TOT information can give information of the ToTs from up to two adjacent pixels - - linkNum_IBLword = decodeLinkNumHit_IBL(rawDataWord); // this corresponds to the "nnnnn" bits of the bytestream convention. - //They represent: 3 LSB = number of the FE linked by the S-Link sending the block (range [0,7]); 2 MSB = S-Link number (range [1,4]) - // fe_IBLword = extractFefromLinkNum(linkNum_IBLword); - // sLinkWord = extractSLinkfromLinkNum(linkNum_IBLword); - if (linkNum_IBLword != linkNum_IBLheader) { - generalwarning("In ROB 0x" << std::hex << robId << ": Link number mismatch - nnnnn (hit word) = 0x" << linkNum_IBLword - << ", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec); - } + for (unsigned int i(0); i < nHits; ++i) { + row[i] = divideHits (hitwords[i], 0, 8); + col[i] = divideHits (hitwords[i], 9, 15); + tot[i] = divideHits (hitwords[i], 16, 23); + ATH_MSG_VERBOSE( "hitword[" << i << "] = 0x" << std::hex << hitwords[i] << ", row: 0x" << row[i] << ", col: 0x" << col[i] << ", 8-bit ToT: 0x" << tot[i] << std::dec); + } + countHitCondensedWords = 0; + linkNum_IBLword = linkNum_IBLheader; + // fe_IBLword = fe_IBLheader; + // sLinkWord = sLinkHeader; + } // end of the condensed hit words (IBL) + + + else if ((rawDataWord & PRB_DATAMASK) == PRB_DATAWORD) { // it's a IBL not-condensed hit word + if (countHitCondensedWords != 0) { // I received some IBL words, but less than 4, there was an error in the rod transmission + generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": Interruption of IBL condensed words - hit(s) ignored (current dataword: 0x" << std::hex << rawDataWord << std::dec << ")"); + m_numDecodingErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); + countHitCondensedWords = 0; + } + // IBL non-condensed Hit Words decoding: + are_4condensed_words = false; + mRow = decodeRow(rawDataWord, isIBLModule || isDBMModule ); + mColumn = decodeColumn(rawDataWord, isIBLModule || isDBMModule); + mToT = decodeToT(rawDataWord, isIBLModule || isDBMModule); // this needs, later in the code, to be divided into Tot(0) and Tot(1), because the IBL TOT information can give information of the ToTs from up to two adjacent pixels + + linkNum_IBLword = decodeLinkNumHit_IBL(rawDataWord); // this corresponds to the "nnnnn" bits of the bytestream convention. + //They represent: 3 LSB = number of the FE linked by the S-Link sending the block (range [0,7]); 2 MSB = S-Link number (range [1,4]) + // fe_IBLword = extractFefromLinkNum(linkNum_IBLword); + // sLinkWord = extractSLinkfromLinkNum(linkNum_IBLword); + if (linkNum_IBLword != linkNum_IBLheader) { + generalwarning("In ROB 0x" << std::hex << robId << ": Link number mismatch - nnnnn (hit word) = 0x" << linkNum_IBLword << ", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec); + } #ifdef PIXEL_DEBUG - ATH_MSG_DEBUG("hit dataword found for module offlineIDHash: " << offlineIdHash << " Row: 0x" - << std::hex << mRow << " Col: 0x" << mColumn << " Tot: 0x" << mToT << std::dec); + ATH_MSG_DEBUG("hit dataword found for module offlineIDHash: " << offlineIdHash << " Row: 0x" << std::hex << mRow << " Col: 0x" << mColumn << " Tot: 0x" << mToT << std::dec); #endif - } - else { // it is an IBL/DBM hit word, but it hasn't been recognised - generalwarning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink - << ": IBL/DBM hit word 0x" << rawDataWord << " not recognised" << std::dec); - m_errors->addDecodingError(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); - continue; - } - - // computing the FE number on the silicon wafer for IBL ( mFE is = 0 for IBL 3D and the lower-eta FE on the planar sensor, - // while is = 1 for the higher-eta FE on the planar sensor) - mFE = m_pixelCabling->getLocalFEI4(fe_IBLheader, onlineId); - } // end of the if (isIBLModule || isDBMModule) - - else { // Pixel Hit Case + } + else { // it is an IBL/DBM hit word, but it hasn't been recognised + generalwarning("In ROB 0x" << std::hex << robId << ", FE: 0x" << mLink << ": IBL/DBM hit word 0x" << rawDataWord << " not recognised" << std::dec); + m_numDecodingErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); + continue; + } + + // computing the FE number on the silicon wafer for IBL ( mFE is = 0 for IBL 3D and the lower-eta FE on the planar sensor, + // while is = 1 for the higher-eta FE on the planar sensor) + mFE = m_pixelCabling->getLocalFEI4(fe_IBLheader, onlineId); + } // end of the if (isIBLModule || isDBMModule) + + else { // Pixel Hit Case #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE("Decoding Pixel hit word: 0x" << std::hex << rawDataWord << std::dec); + ATH_MSG_VERBOSE("Decoding Pixel hit word: 0x" << std::hex << rawDataWord << std::dec); #endif - if (countHitCondensedWords != 0) - { // I received some IBL words, but less than 4, there was an error in the rod transmission - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": Interruption of IBL condensed words - hit(s) ignored (current dataword: 0x" - << std::hex << rawDataWord << std::dec << ")"); - m_errors->addDecodingError(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); - countHitCondensedWords = 0; - } - //Pixel Hit Words decoding: - are_4condensed_words = false; - mFE = decodeFE(rawDataWord); - mRow = decodeRow(rawDataWord, isIBLModule || isDBMModule ); - mColumn = decodeColumn(rawDataWord, isIBLModule || isDBMModule); - mToT = decodeToT(rawDataWord, isIBLModule || isDBMModule); + if (countHitCondensedWords != 0) + { // I received some IBL words, but less than 4, there was an error in the rod transmission + generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink + << ": Interruption of IBL condensed words - hit(s) ignored (current dataword: 0x" + << std::hex << rawDataWord << std::dec << ")"); + m_numDecodingErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); + countHitCondensedWords = 0; + } + //Pixel Hit Words decoding: + are_4condensed_words = false; + mFE = decodeFE(rawDataWord); + mRow = decodeRow(rawDataWord, isIBLModule || isDBMModule ); + mColumn = decodeColumn(rawDataWord, isIBLModule || isDBMModule); + mToT = decodeToT(rawDataWord, isIBLModule || isDBMModule); #ifdef PIXEL_DEBUG - ATH_MSG_DEBUG( "hit dataword found for module offlineIDHash: " << offlineIdHash << " FE: " << mFE << " Row: " << mRow << " Col: " << mColumn ); // hit found debug message + ATH_MSG_DEBUG( "hit dataword found for module offlineIDHash: " << offlineIdHash << " FE: " << mFE << " Row: " << mRow << " Col: " << mColumn ); // hit found debug message #endif - } // end of the condition "!isIBLModule" + } // end of the condition "!isIBLModule" - // ------------------------ - // Create pixel collections + // ------------------------ + // Create pixel collections - // Decode only modules in provided list of hashes (i.e. not doing full scan) - // Disabled for now. - if (offlineIdHash == skipHash) continue; + // Decode only modules in provided list of hashes (i.e. not doing full scan) + // Disabled for now. + if (offlineIdHash == skipHash) continue; - if(offlineIdHash != lastHash){ - lastHash = offlineIdHash; - if(vecHash!=nullptr ){ - std::vector<IdentifierHash>::iterator p = std::find(vecHash->begin(),vecHash->end(),offlineIdHash); + if(offlineIdHash != lastHash){ + lastHash = offlineIdHash; + if(vecHash!=nullptr ){ + std::vector<IdentifierHash>::iterator p = std::find(vecHash->begin(),vecHash->end(),offlineIdHash); - if (p == vecHash->end()){ // is the Hash to be skipped (not in the request list)? - skipHash = offlineIdHash; - continue; - } - } + if (p == vecHash->end()){ // is the Hash to be skipped (not in the request list)? + skipHash = offlineIdHash; + continue; + } + } - /* TODO =, make proper use of MT IDC - if(rdoIdc->hasExternalCache() && rdoIdc->tryAddFromCache(offlineIdHash)){ - ATH_MSG_INFO("Hash already in collection - cache hit " << offlineIdHash); - continue; - } - */ + /* TODO =, make proper use of MT IDC + if(rdoIdc->hasExternalCache() && rdoIdc->tryAddFromCache(offlineIdHash)){ + ATH_MSG_INFO("Hash already in collection - cache hit " << offlineIdHash); + continue; + } + */ - ATH_CHECK( rdoIdc->naughtyRetrieve(offlineIdHash, coll) );//Returns null if not present + ATH_CHECK( rdoIdc->naughtyRetrieve(offlineIdHash, coll) );//Returns null if not present - if( coll == nullptr ) { - coll = new PixelRawCollection (offlineIdHash); - // get identifier from the hash, this is not nice - Identifier ident = m_pixel_id->wafer_id(offlineIdHash); - // set the Identifier to be nice to downstream clients - coll->setIdentifier(ident); + if( coll == nullptr ) { + coll = new PixelRawCollection (offlineIdHash); + // get identifier from the hash, this is not nice + Identifier ident = m_pixel_id->wafer_id(offlineIdHash); + // set the Identifier to be nice to downstream clients + coll->setIdentifier(ident); - StatusCode sc = rdoIdc->addCollection(coll, offlineIdHash); - ATH_MSG_DEBUG("Adding " << offlineIdHash); - if (sc.isFailure()){ - ATH_MSG_ERROR("failed to add Pixel RDO collection to container" ); - } - } - } + StatusCode sc = rdoIdc->addCollection(coll, offlineIdHash); + ATH_MSG_DEBUG("Adding " << offlineIdHash); + if (sc.isFailure()){ + ATH_MSG_ERROR("failed to add Pixel RDO collection to container" ); + } + } + } - // ------------------------ - // Fill collections - - if (isIBLModule || isDBMModule) { - unsigned int num_cycles_toFillCollection(0); - if (are_4condensed_words) { - num_cycles_toFillCollection = nHits; - } - else { - num_cycles_toFillCollection = 1; - row[0] = mRow; - col[0] = mColumn; - tot[0] = mToT; - } - int IBLtot[2]; - for (unsigned int i(0); i < num_cycles_toFillCollection; ++i) { + // ------------------------ + // Fill collections + + if (isIBLModule || isDBMModule) { + unsigned int num_cycles_toFillCollection(0); + if (are_4condensed_words) { + num_cycles_toFillCollection = nHits; + } + else { + num_cycles_toFillCollection = 1; + row[0] = mRow; + col[0] = mColumn; + tot[0] = mToT; + } + int IBLtot[2]; + for (unsigned int i(0); i < num_cycles_toFillCollection; ++i) { #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "ROW[" << i << "] = 0x" << std::hex << row[i] << std::dec << ", COL[" << i << "] = 0x" - << std::hex << col[i] << std::dec << ", 8-bit TOT[" << i << "] = 0x" << std::hex << tot[i] << std::dec ); + ATH_MSG_VERBOSE( "ROW[" << i << "] = 0x" << std::hex << row[i] << std::dec << ", COL[" << i << "] = 0x" << std::hex << col[i] << std::dec << ", 8-bit TOT[" << i << "] = 0x" << std::hex << tot[i] << std::dec ); #endif - // ToT1 equal 0 means no hit, regardless of HitDiscCnfg - if ((tot[i] & 0xF0) == 0x00) { - generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink - << ": First IBL ToT field is 0 - hit word 0x" << rawDataWord - << " decodes to ToT1 = 0" << (tot[i] >> 4) << ", ToT2 = 0x" - << (tot[i] & 0xF) << ", row = " << std::dec << row[i] - << " col = " << col[i] << std::dec); - continue; - } + // ToT1 equal 0 means no hit, regardless of HitDiscCnfg + if ((tot[i] & 0xF0) == 0x00) { + generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink << ": First IBL ToT field is 0 - hit word 0x" << rawDataWord << " decodes to ToT1 = 0" << (tot[i] >> 4) << ", ToT2 = 0x" << (tot[i] & 0xF) << ", row = " << std::dec << row[i] << " col = " << col[i] << std::dec); + continue; + } - else { - if (((row[i] != 0) && (col[i] != 0) && (row[i] <= 336) && (col[i] <= 80)) || isDBMModule) { // FIXME : Hardcoded numbers. Should be ok as they are features of the FE-I4, but worth checking! - pixelId = m_pixelCabling ->getPixelIdfromHash (offlineIdHash, mFE, row[i], col[i]); + else { + if (((row[i] != 0) && (col[i] != 0) && (row[i] <= 336) && (col[i] <= 80)) || isDBMModule) { // FIXME : Hardcoded numbers. Should be ok as they are features of the FE-I4, but worth checking! + pixelId = m_pixelCabling ->getPixelIdfromHash (offlineIdHash, mFE, row[i], col[i]); #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "PixelId: " << pixelId ); - int eta_i = m_pixel_id->eta_index(pixelId); - int phi_i = m_pixel_id->phi_index(pixelId); - int eta_m = m_pixel_id->eta_module(pixelId); - int phi_m = m_pixel_id->phi_module(pixelId); - ATH_MSG_VERBOSE( " eta_i: " << eta_i << ", phi_i: " << phi_i << ", eta_m: " << eta_m << ", phi_m: " << phi_m ); + ATH_MSG_VERBOSE( "PixelId: " << pixelId ); + int eta_i = m_pixel_id->eta_index(pixelId); + int phi_i = m_pixel_id->phi_index(pixelId); + int eta_m = m_pixel_id->eta_module(pixelId); + int phi_m = m_pixel_id->phi_module(pixelId); + ATH_MSG_VERBOSE( " eta_i: " << eta_i << ", phi_i: " << phi_i << ", eta_m: " << eta_m << ", phi_m: " << phi_m ); #endif - if (pixelId == invalidPixelId) { - generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink - << ": Illegal pixelId - hit word 0x" << rawDataWord << " decodes to ToT1 = 0" - << (tot[i] >> 4) << ", ToT2 = 0x" << (tot[i] & 0xF) << ", row = " - << std::dec << row[i] << " col = " << col[i] << std::dec); - m_errors->addInvalidIdentifier(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); - continue; - } - IBLtot[0] = divideHits(tot[i], 4, 7); // corresponds to (col, row) - IBLtot[1] = divideHits(tot[i], 0, 3); // corresponds to (col, row+1) + if (pixelId == invalidPixelId) { + generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink << ": Illegal pixelId - hit word 0x" << rawDataWord << " decodes to ToT1 = 0" << (tot[i] >> 4) << ", ToT2 = 0x" << (tot[i] & 0xF) << ", row = " << std::dec << row[i] << " col = " << col[i] << std::dec); + m_numInvalidIdentifiers++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); + continue; + } + IBLtot[0] = divideHits(tot[i], 4, 7); // corresponds to (col, row) + IBLtot[1] = divideHits(tot[i], 0, 3); // corresponds to (col, row+1) #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE("Starting from tot = 0x" << std::hex << tot[i] << " IBLtot[0] = 0x" << std::hex << IBLtot[0] << " IBLtot[1] = 0x" << IBLtot[1] << std::dec ); + ATH_MSG_VERBOSE("Starting from tot = 0x" << std::hex << tot[i] << " IBLtot[0] = 0x" << std::hex << IBLtot[0] << " IBLtot[1] = 0x" << IBLtot[1] << std::dec ); #endif - if (!pixHitDiscCnfg) { - pixHitDiscCnfg = std::make_unique<SG::ReadCondHandle<PixelHitDiscCnfgData> > (m_condHitDiscCnfgKey); - } - // Get the hit discrimination configuration setting for this FE - if (m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::IBL_PLANAR || m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::DBM) { - hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfgPL(); - } - else if (m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::IBL_3D) { - hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfg3D(); - } - - // Now do some interpreting of the ToT values - if (hitDiscCnfg == 2 && IBLtot[0] == 2) IBLtot[0] = 16; - if (hitDiscCnfg == 2 && IBLtot[1] == 2) IBLtot[1] = 16; - - if (not m_checkDuplicatedPixel or - (m_checkDuplicatedPixel and previousPixelId!=pixelId)) { - // Insert the first part of the ToT info in the collection - coll->push_back(new RDO(pixelId, IBLtot[0], mBCID, mLVL1ID, mLVL1A)); - previousPixelId = pixelId; - } + if (!pixHitDiscCnfg) { + pixHitDiscCnfg = std::make_unique<SG::ReadCondHandle<PixelHitDiscCnfgData> > (m_condHitDiscCnfgKey); + } + // Get the hit discrimination configuration setting for this FE + if (m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::IBL_PLANAR || m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::DBM) { + hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfgPL(); + } + else if (m_pixelCabling->getModuleType(pixelId)==IPixelCablingSvc::IBL_3D) { + hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfg3D(); + } + + // Now do some interpreting of the ToT values + if (hitDiscCnfg == 2 && IBLtot[0] == 2) IBLtot[0] = 16; + if (hitDiscCnfg == 2 && IBLtot[1] == 2) IBLtot[1] = 16; + + if (not m_checkDuplicatedPixel or + (m_checkDuplicatedPixel and previousPixelId!=pixelId)) { + // Insert the first part of the ToT info in the collection + coll->push_back(new RDO(pixelId, IBLtot[0], mBCID, mLVL1ID, mLVL1A)); + previousPixelId = pixelId; + } #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "Collection filled with pixelId: " << pixelId << " TOT = 0x" << std::hex << IBLtot[0] << std::dec << " mBCID = " << mBCID << " mLVL1ID = " << mLVL1ID << " mLVL1A = " << mLVL1A ); + ATH_MSG_VERBOSE( "Collection filled with pixelId: " << pixelId << " TOT = 0x" << std::hex << IBLtot[0] << std::dec << " mBCID = " << mBCID << " mLVL1ID = " << mLVL1ID << " mLVL1A = " << mLVL1A ); #endif - // Second ToT field: - // For HitDiscCnfg 0-2, consider 0 to indicate no hit - // For HitDiscCng = 3, consider also F to indicate no hit - if (IBLtot[1] != 0x0 && (IBLtot[1] != 0xF || hitDiscCnfg != 3)) { - if ((row[i] + 1) > 336) { // FIXME: hardcoded number - but it should still be ok, because it's a feature of the FE-I4! - // this should never happen. If row[i] == 336, (row[i]+1) == 337. This row does not exist, so the TOT(337) should always be 0 (== no hit) - - - generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink - << ": Illegal IBL row number for second ToT field, hit word 0x" - << rawDataWord << " decodes to row = " << std::dec << row[i]+1 << " col = " << col[i] - << " (ToT1 = 0x" << std::hex << IBLtot[0] << " ToT2 = 0x" << IBLtot[1] << ")"); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); - m_errors->addInvalidIdentifier(); - continue; - } - else { - pixelId = m_pixelCabling ->getPixelIdfromHash (offlineIdHash, mFE, row[i] + 1, col[i]); + // Second ToT field: + // For HitDiscCnfg 0-2, consider 0 to indicate no hit + // For HitDiscCng = 3, consider also F to indicate no hit + if (IBLtot[1] != 0x0 && (IBLtot[1] != 0xF || hitDiscCnfg != 3)) { + if ((row[i] + 1) > 336) { // FIXME: hardcoded number - but it should still be ok, because it's a feature of the FE-I4! + // this should never happen. If row[i] == 336, (row[i]+1) == 337. This row does not exist, so the TOT(337) should always be 0 (== no hit) + + generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink << ": Illegal IBL row number for second ToT field, hit word 0x" << rawDataWord << " decodes to row = " << std::dec << row[i]+1 << " col = " << col[i] << " (ToT1 = 0x" << std::hex << IBLtot[0] << " ToT2 = 0x" << IBLtot[1] << ")"); + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); + m_numInvalidIdentifiers++; + continue; + } + else { + pixelId = m_pixelCabling ->getPixelIdfromHash (offlineIdHash, mFE, row[i] + 1, col[i]); #ifdef PIXEL_DEBUG - int eta_i = m_pixel_id->eta_index(pixelId); - int phi_i = m_pixel_id->phi_index(pixelId); - int eta_m = m_pixel_id->eta_module(pixelId); - int phi_m = m_pixel_id->phi_module(pixelId); - int phi_i_max = m_pixel_id->phi_index_max(pixelId); - int eta_i_max = m_pixel_id->eta_index_max(pixelId); - - ATH_MSG_VERBOSE( "PixelId = " << pixelId); - ATH_MSG_VERBOSE( " eta_i: " << eta_i << ", phi_i: " << phi_i << ", eta_m: " << eta_m << ", phi_m: " << phi_m << ", eta_i_max: " << eta_i_max << ", phi_i_max: " << phi_i_max ); + int eta_i = m_pixel_id->eta_index(pixelId); + int phi_i = m_pixel_id->phi_index(pixelId); + int eta_m = m_pixel_id->eta_module(pixelId); + int phi_m = m_pixel_id->phi_module(pixelId); + int phi_i_max = m_pixel_id->phi_index_max(pixelId); + int eta_i_max = m_pixel_id->eta_index_max(pixelId); + + ATH_MSG_VERBOSE( "PixelId = " << pixelId); + ATH_MSG_VERBOSE( " eta_i: " << eta_i << ", phi_i: " << phi_i << ", eta_m: " << eta_m << ", phi_m: " << phi_m << ", eta_i_max: " << eta_i_max << ", phi_i_max: " << phi_i_max ); #endif - if (pixelId == invalidPixelId) { - generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink - << ": Illegal pixelId - hit word 0x" << rawDataWord << " decodes to ToT1 = 0" - << (tot[i] >> 4) << ", ToT2 = 0x" << (tot[i] & 0xF) << ", row = " - << std::dec << row[i] << " col = " << col[i] << std::dec); - m_errors->addInvalidIdentifier(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); - continue; - } - - if (not m_checkDuplicatedPixel or - (m_checkDuplicatedPixel and previousPixelId!=pixelId)) { - coll->push_back(new RDO(pixelId, IBLtot[1], mBCID, mLVL1ID, mLVL1A)); - previousPixelId = pixelId; - } + if (pixelId == invalidPixelId) { + generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink << ": Illegal pixelId - hit word 0x" << rawDataWord << " decodes to ToT1 = 0" << (tot[i] >> 4) << ", ToT2 = 0x" << (tot[i] & 0xF) << ", row = " << std::dec << row[i] << " col = " << col[i] << std::dec); + m_numInvalidIdentifiers++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); + continue; + } + + if (not m_checkDuplicatedPixel or + (m_checkDuplicatedPixel and previousPixelId!=pixelId)) { + coll->push_back(new RDO(pixelId, IBLtot[1], mBCID, mLVL1ID, mLVL1A)); + previousPixelId = pixelId; + } #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "Collection filled with pixelId: " << pixelId << " TOT = 0x" << std::hex << IBLtot[1] << std::dec << " mBCID = " << mBCID << " mLVL1ID = " << mLVL1ID << " mLVL1A = " << mLVL1A ); + ATH_MSG_VERBOSE( "Collection filled with pixelId: " << pixelId << " TOT = 0x" << std::hex << IBLtot[1] << std::dec << " mBCID = " << mBCID << " mLVL1ID = " << mLVL1ID << " mLVL1A = " << mLVL1A ); #endif - } - } - } // end of the if that checks that Row and Column of the IBL have a value > 0 and smaller than the maximum of the FE-I4. - else { - generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink - << ": Illegal IBL row/col number, hit word 0x" - << rawDataWord << " decodes to row = " << std::dec << row[i] << " col = " << col[i] - << " (ToT1 = 0x" << std::hex << (tot[i] >> 4) << " ToT2 = 0x" << (tot[i] & 0xF) << ")"); - m_errors->addInvalidIdentifier(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); - continue; - } - } // end of the else from the condition "(tot[i] & 0xF0) == 0xF", corresponding to an invalid tot sent by the ROD - } // end of the loop over the hit information coming from the IBL words (condensed or not) - } // end IBL/DBM words pushed into Collection - - else { // it is a Pixel hit word to be saved into the Collection - pixelId = m_pixelCabling->getPixelIdfromHash(offlineIdHash, mFE, mRow, mColumn); - - if (pixelId == invalidPixelId) { - ATH_MSG_DEBUG("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink - << ": Illegal pixelId - row = " << std::dec << mRow << ", col = " << mColumn - << ", dataword = 0x" << std::hex << rawDataWord << std::dec); - m_errors->addInvalidIdentifier(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); - continue; - } - // Now the Collection is there for sure. Create RDO and push it into Collection. - - if (not m_checkDuplicatedPixel or - (m_checkDuplicatedPixel and previousPixelId!=pixelId)) { - coll->push_back(new RDO(pixelId, mToT, mBCID, mLVL1ID, mLVL1A)); - previousPixelId = pixelId; - } + } + } + } // end of the if that checks that Row and Column of the IBL have a value > 0 and smaller than the maximum of the FE-I4. + else { + generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink << ": Illegal IBL row/col number, hit word 0x" << rawDataWord << " decodes to row = " << std::dec << row[i] << " col = " << col[i] << " (ToT1 = 0x" << std::hex << (tot[i] >> 4) << " ToT2 = 0x" << (tot[i] & 0xF) << ")"); + m_numInvalidIdentifiers++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); + continue; + } + } // end of the else from the condition "(tot[i] & 0xF0) == 0xF", corresponding to an invalid tot sent by the ROD + } // end of the loop over the hit information coming from the IBL words (condensed or not) + } // end IBL/DBM words pushed into Collection + + else { // it is a Pixel hit word to be saved into the Collection + pixelId = m_pixelCabling->getPixelIdfromHash(offlineIdHash, mFE, mRow, mColumn); + + if (pixelId == invalidPixelId) { + ATH_MSG_DEBUG("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink << ": Illegal pixelId - row = " << std::dec << mRow << ", col = " << mColumn << ", dataword = 0x" << std::hex << rawDataWord << std::dec); + m_numInvalidIdentifiers++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Invalid ); + continue; + } + // Now the Collection is there for sure. Create RDO and push it into Collection. + + if (not m_checkDuplicatedPixel or + (m_checkDuplicatedPixel and previousPixelId!=pixelId)) { + coll->push_back(new RDO(pixelId, mToT, mBCID, mLVL1ID, mLVL1A)); + previousPixelId = pixelId; + } #ifdef PIXEL_DEBUG - ATH_MSG_VERBOSE( "Collection filled with pixelId: " << pixelId << " TOT = 0x" << std::hex << mToT << std::dec << " mBCID = " << mBCID << " mLVL1ID = " << mLVL1ID << " mLVL1A = " << mLVL1A ); + ATH_MSG_VERBOSE( "Collection filled with pixelId: " << pixelId << " TOT = 0x" << std::hex << mToT << std::dec << " mBCID = " << mBCID << " mLVL1ID = " << mLVL1ID << " mLVL1A = " << mLVL1A ); #endif - } // end Pixel words pushed into Collection - } // end of the if (link_start) - - else { // no header found before hit -> error - generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink - << ": Unexpected hit dataword: " << rawDataWord << " - hit ignored"); - m_errors->addDecodingError(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); - continue; - } - break; + } // end Pixel words pushed into Collection + } // end of the if (link_start) + + else { // no header found before hit -> error + generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink << ": Unexpected hit dataword: " << rawDataWord << " - hit ignored"); + m_numDecodingErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); + continue; + } + break; //-------------------------------------------------------------------------------------------- TRAILER WORD FOUND - case PRB_LINKTRAILER: // link (module) trailer found - if (link_start) { // if header found before trailer -> expected - ATH_MSG_DEBUG( "link trailer found" ); // trailer found debug message - } - else { // no header found before trailer -> error - generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink - << ": Unexpected trailer found: 0x" << std::hex << rawDataWord << ", data corruption"); - m_errors->addDecodingError(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); - continue; - } - previous_offlineIdHash = offlineIdHash; // save offlineId for next header; - link_start = false; // resetting link (module) header found flag - are_4condensed_words = false; - m_errors->setModuleFragmentSize(offlineIdHash, nwords_in_module_fragment); // TODO understand what this is used for, and why moduel fragment size is handled by errors tool - - // Trailer decoding and error handling - if (isIBLModule || isDBMModule) { // decode IBL/DBM Trailer word: 010nnnnnECPplbzhvMMMMMMMMMMxxxxx - - ATH_MSG_VERBOSE( "Decoding IBL/DBM trailer word: 0x" << std::hex << rawDataWord << std::dec ); - - // mSkippedTrigTrailer = decodeSkippedTrigTrailer_IBL(rawDataWord); // decode skipped trigger counter bits => M -- temporarily removed - - const uint32_t trailerError = decodeTrailerErrors_IBL(rawDataWord); // => E cPpl bzhv // taking all errors together. - - // Insert trailer errors into errorcode (except the 'c' bit) - // CCC CCCC CCCC CCCC CCCC EPpl bzhv - const uint32_t trailerError_noC = (trailerError & 0x7F) | ((trailerError & 0x100) >> 1); - errorcode = errorcode | trailerError_noC; - - checkTrailerErrorsIBL( bsErrCode, trailerError ); - if (trailerError & (1 << 7)) // condensed mode bit => W - if (!receivedCondensedWords) { - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": condensed mode bit is set, but no condensed words received" << std::dec); - } - // Write the error word to the service - if (offlineIdHash != 0xffffffff && errorcode) { - m_errors->setFeErrorCode(offlineIdHash, (mLink & 0x1), errorcode); - - // Check if error code is already set for this wafer - uint32_t existing_code = m_errors->getModuleErrors(offlineIdHash); // TODO Verify if this ever happens - if (existing_code) { - errorcode = existing_code | errorcode; - } - m_errors->setModuleErrors(offlineIdHash, errorcode); - decodingErrors.setOrDrop( offlineIdHash, bsErrCode ); - } - - - //At least temporarily removed because the data format is not clear (Franconi, 17.06.2014) - linkNum_IBLword = decodeLinkNumTrailer_IBL(rawDataWord); // => n - // mBitFlips = decodeTrailerBitflips_IBL(rawDataWord); - // if (mBitFlips != 0) - // msg(MSG::WARNING) << "The IBL trailer word has bitflips" << endmsg; - - // Do checks on info in trailer vs header - if (linkNum_IBLword != linkNum_IBLheader) { - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": Link number mismatch - nnnnn (trailer) = 0x" << linkNum_IBLword - << ", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec); - } - - if (decodeBcidTrailer_IBL(rawDataWord) != (mBCID & PRB_BCIDSKIPTRAILERmask_IBL)) { - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": Trailer BCID does not match header (trailer BCID = 0x" - << decodeBcidTrailer_IBL(rawDataWord) << ", 5LSB of header BCID = 0x" - << (mBCID & PRB_BCIDSKIPTRAILERmask_IBL) << ")" << std::dec); - } - } + case PRB_LINKTRAILER: // link (module) trailer found - else { // decode Pixel trailer word + if (link_start) { // if header found before trailer -> expected + ATH_MSG_DEBUG( "link trailer found" ); // trailer found debug message + } + else { // no header found before trailer -> error + generalwarning("In ROB = 0x" << std::hex << robId << ", link 0x" << mLink << ": Unexpected trailer found: 0x" << std::hex << rawDataWord << ", data corruption"); + m_numDecodingErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); + continue; + } - ATH_MSG_VERBOSE( "Decoding Pixel trailer word: 0x" << std::hex << rawDataWord << std::dec ); + previous_offlineIdHash = offlineIdHash; // save offlineId for next header; + link_start = false; // resetting link (module) header found flag + are_4condensed_words = false; - const uint32_t trailerError = decodeTrailerErrors(rawDataWord); // creating link (module) trailer error variable - //mBitFlips = decodeTrailerBitflips(rawDataWord); -- temporarily removed + // Trailer decoding and error handling + if (isIBLModule || isDBMModule) { // decode IBL/DBM Trailer word: 010nnnnnECPplbzhvMMMMMMMMMMxxxxx - if (trailerError != 0) { - sc = StatusCode ::RECOVERABLE; - errorcode = errorcode | trailerError; //encode error as HHHHMMMMMMMMFFFFFFFFTTTT for header, flagword, trailer errors - checkTrailerErrors( bsErrCode, trailerError); - } - } - if ( offlineIdHash != 0xffffffff ) { // now write the error word to the service - m_errors->setModuleErrors(offlineIdHash, errorcode); - decodingErrors.setOrDrop( offlineIdHash, bsErrCode ); - } - break; + ATH_MSG_VERBOSE( "Decoding IBL/DBM trailer word: 0x" << std::hex << rawDataWord << std::dec ); + // mSkippedTrigTrailer = decodeSkippedTrigTrailer_IBL(rawDataWord); // decode skipped trigger counter bits => M -- temporarily removed - //-------------------------------------------------------------------------------------------- FE ERROR TYPE 2 WORD FOUND - case PRB_FEERROR2 : // type 2 flag found + const uint32_t trailerError = decodeTrailerErrors_IBL(rawDataWord); // => E cPpl bzhv // taking all errors together. - are_4condensed_words = false; - if (isIBLModule || isDBMModule) { // IBL flag found + // Insert trailer errors into errorcode (except the 'c' bit) + // CCC CCCC CCCC CCCC CCCC EPpl bzhv + const uint32_t trailerError_noC = (trailerError & 0x7F) | ((trailerError & 0x100) >> 1); + errorcode = errorcode | trailerError_noC; - ATH_MSG_VERBOSE( "Decoding IBL/DBM FEflag word: 0x" << std::hex << rawDataWord << std::dec); + checkTrailerErrorsIBL( bsErrCode, trailerError ); + if (trailerError & (1 << 7)) { // condensed mode bit => W + if (!receivedCondensedWords) { generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": condensed mode bit is set, but no condensed words received" << std::dec); } + } + //At least temporarily removed because the data format is not clear (Franconi, 17.06.2014) + linkNum_IBLword = decodeLinkNumTrailer_IBL(rawDataWord); // => n + // mBitFlips = decodeTrailerBitflips_IBL(rawDataWord); + // if (mBitFlips != 0) + // msg(MSG::WARNING) << "The IBL trailer word has bitflips" << endmsg; - linkNum_IBLword = decodeLinkNumFEFlag_IBL(rawDataWord); - // fe_IBLword = extractFefromLinkNum(linkNum_IBLword); - // sLinkWord = extractSLinkfromLinkNum(linkNum_IBLword); - // if ((sLinkWord != sLinkHeader) || (fe_IBLword != fe_IBLheader)) - if (linkNum_IBLword != linkNum_IBLheader) { - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": Link number mismatch - nnnnn (error word) = 0x" << linkNum_IBLword - << ", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec); - } + // Do checks on info in trailer vs header + if (linkNum_IBLword != linkNum_IBLheader) { + generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": Link number mismatch - nnnnn (trailer) = 0x" << linkNum_IBLword << ", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec); + } - uint32_t serviceCodeCounter = decodeServiceCodeCounter_IBL(rawDataWord); // frequency of the serviceCode (with the exceptions of serviceCode = 14,15 or 16) - uint32_t serviceCode = decodeServiceCode_IBL(rawDataWord); // is a code. the corresponding meaning is listed in the table in the FE-I4 manual, pag. 105 + if (decodeBcidTrailer_IBL(rawDataWord) != (mBCID & PRB_BCIDSKIPTRAILERmask_IBL)) { + generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": Trailer BCID does not match header (trailer BCID = 0x" << decodeBcidTrailer_IBL(rawDataWord) << ", 5LSB of header BCID = 0x" << (mBCID & PRB_BCIDSKIPTRAILERmask_IBL) << ")" << std::dec); + } + } + else { // decode Pixel trailer word - // Treat the service code only if its meaning is valid (i.e. value < 31) - if (serviceCode < 32) { + ATH_MSG_VERBOSE( "Decoding Pixel trailer word: 0x" << std::hex << rawDataWord << std::dec ); - // Treatment of the FE flag serviceCode and serviceCodeCounter - // Returns encoded uint32_t to be added to errorcode - uint32_t encodedServiceCodes = treatmentFEFlagInfo(serviceCode, serviceCodeCounter); + const uint32_t trailerError = decodeTrailerErrors(rawDataWord); // creating link (module) trailer error variable + //mBitFlips = decodeTrailerBitflips(rawDataWord); -- temporarily removed - // Insert service codes into errorcode - // CCC CCCC CCCC CCCC CCCC EPpl bzhv - errorcode = errorcode | (encodedServiceCodes << 8); - } - else { - generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink - << ": Got out-of-bounds service code: " << std::dec << serviceCode << " (counter: " - << serviceCodeCounter << "), ignored"); - } + if (trailerError != 0) { + sc = StatusCode ::RECOVERABLE; + errorcode = errorcode | trailerError; //encode error as HHHHMMMMMMMMFFFFFFFFTTTT for header, flagword, trailer errors + checkTrailerErrors( bsErrCode, trailerError); + } + } + break; - // Temporarily removed, as the data format is not clear yet (Franconi, 08.07.2014) - // mBitFlips = decodeFEFlagBitFlips_IBL(rawDataWord); - // if (mBitFlips != 0) - // msg(MSG::WARNING) << "IBL Fe Flag error word has some bitflips: the word is 0x" << std::hex << rawDataWord << std::dec << endmsg; + //-------------------------------------------------------------------------------------------- FE ERROR TYPE 2 WORD FOUND + case PRB_FEERROR2 : // type 2 flag found + are_4condensed_words = false; + if (isIBLModule || isDBMModule) { // IBL flag found - } - else { // Pixel type2 flag found - - ATH_MSG_VERBOSE( "Decoding Pixel FEflag word: 0x" << std::hex << rawDataWord << std::dec ); - - uint32_t FEFlags = decodeFEFlags2(rawDataWord); // get FE flags - uint32_t MCCFlags = decodeMCCFlags(rawDataWord); // get MCC flags - uint32_t fe_number = (rawDataWord & 0x0F000000) >> 24; - - FEFlags = FEFlags & 0xF3; // mask out the parity bits, they don't work - if ((MCCFlags | FEFlags) != 0) { - sc = StatusCode::RECOVERABLE; - errorcode = errorcode | (MCCFlags << 12) | (FEFlags << 4); //encode error as HHHHMMMMMMMMFFFFFFFFTTTT for header, flagword, trailer errors - //for now just sum all flagged errors - if (MCCFlags & (1 << 7)) - m_errors->addFlaggedError(); - if (MCCFlags & (1 << 6)) - m_errors->addFlaggedError(); - if (MCCFlags & (1 << 5)) - m_errors->addFlaggedError(); - if (MCCFlags & (1 << 4)) - m_errors->addFlaggedError(); - if (MCCFlags & (1 << 3)) - m_errors->addFlaggedError(); - if (MCCFlags & (1 << 2)) - m_errors->addFlaggedError(); - if (MCCFlags & (1 << 1)) - m_errors->addFlaggedError(); - if (MCCFlags & (1 << 0)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 7)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 6)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 5)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 4)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 3)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 2)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 1)) - m_errors->addFlaggedError(); - if (FEFlags & (1 << 0)) - m_errors->addFlaggedError(); - if ( MCCFlags & 0xff or FEFlags & 0xff ) - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Flagged ); - m_errors->setFeErrorCode(offlineIdHash, fe_number, errorcode); - - } else { - m_errors->addDisabledFEError(); - m_errors->addBadFE(offlineIdHash,(rawDataWord & 0x0F000000) >> 24); // TODO check what is this needed for - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::BadFE ); - ATH_MSG_DEBUG( "Disabled Pixel chip " << ((rawDataWord & 0x0F000000) >> 24) ); - - } - } - break; + ATH_MSG_VERBOSE( "Decoding IBL/DBM FEflag word: 0x" << std::hex << rawDataWord << std::dec); + + + linkNum_IBLword = decodeLinkNumFEFlag_IBL(rawDataWord); + // fe_IBLword = extractFefromLinkNum(linkNum_IBLword); + // sLinkWord = extractSLinkfromLinkNum(linkNum_IBLword); + // if ((sLinkWord != sLinkHeader) || (fe_IBLword != fe_IBLheader)) + if (linkNum_IBLword != linkNum_IBLheader) { + generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": Link number mismatch - nnnnn (error word) = 0x" << linkNum_IBLword << ", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec); + } + + serviceCodeCounter = decodeServiceCodeCounter_IBL(rawDataWord); // frequency of the serviceCode (with the exceptions of serviceCode = 14,15 or 16) + serviceCode = decodeServiceCode_IBL(rawDataWord); // is a code. the corresponding meaning is listed in the table in the FE-I4 manual, pag. 105 + + // Treat the service code only if its meaning is valid (i.e. value < 31) + if (serviceCode < 32) { + // Treatment of the FE flag serviceCode and serviceCodeCounter + // Returns encoded uint32_t to be added to errorcode + uint32_t encodedServiceCodes = treatmentFEFlagInfo(serviceCode, serviceCodeCounter); + + // Insert service codes into errorcode + // CCC CCCC CCCC CCCC CCCC EPpl bzhv + errorcode = errorcode | (encodedServiceCodes << 8); + } + else { + generalwarning("In ROB 0x" << std::hex << robId << ", link 0x" << mLink << ": Got out-of-bounds service code: " << std::dec << serviceCode << " (counter: " << serviceCodeCounter << "), ignored"); + } + + + // Temporarily removed, as the data format is not clear yet (Franconi, 08.07.2014) + // mBitFlips = decodeFEFlagBitFlips_IBL(rawDataWord); + // if (mBitFlips != 0) + // msg(MSG::WARNING) << "IBL Fe Flag error word has some bitflips: the word is 0x" << std::hex << rawDataWord << std::dec << endmsg; + + + } + else { // Pixel type2 flag found + + ATH_MSG_VERBOSE( "Decoding Pixel FEflag word: 0x" << std::hex << rawDataWord << std::dec ); + + uint32_t FEFlags = decodeFEFlags2(rawDataWord); // get FE flags + uint32_t MCCFlags = decodeMCCFlags(rawDataWord); // get MCC flags + //uint32_t fe_number = (rawDataWord & 0x0F000000) >> 24; + + FEFlags = FEFlags & 0xF3; // mask out the parity bits, they don't work + if ((MCCFlags | FEFlags) != 0) { + sc = StatusCode::RECOVERABLE; + errorcode = errorcode | (MCCFlags << 12) | (FEFlags << 4); //encode error as HHHHMMMMMMMMFFFFFFFFTTTT for header, flagword, trailer errors + //for now just sum all flagged errors + if (MCCFlags & (1 << 7)) { m_numFlaggedErrors++; } + if (MCCFlags & (1 << 6)) { m_numFlaggedErrors++; } + if (MCCFlags & (1 << 5)) { m_numFlaggedErrors++; } + if (MCCFlags & (1 << 4)) { m_numFlaggedErrors++; } + if (MCCFlags & (1 << 3)) { m_numFlaggedErrors++; } + if (MCCFlags & (1 << 2)) { m_numFlaggedErrors++; } + if (MCCFlags & (1 << 1)) { m_numFlaggedErrors++; } + if (MCCFlags & (1 << 0)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 7)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 6)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 5)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 4)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 3)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 2)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 1)) { m_numFlaggedErrors++; } + if (FEFlags & (1 << 0)) { m_numFlaggedErrors++; } + + if ( MCCFlags & 0xff or FEFlags & 0xff ) { + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Flagged ); + } + } else { + m_numDisabledFEErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::BadFE ); + + ATH_MSG_DEBUG( "Disabled Pixel chip " << ((rawDataWord & 0x0F000000) >> 24) ); + + } + } - //-------------------------------------------------------------------------------------------- RAWDATA WORD FOUND - case PRB_RAWDATA : // add treatment for raw data word here! - are_4condensed_words = false; + break; - break; + //-------------------------------------------------------------------------------------------- RAWDATA WORD FOUND + case PRB_RAWDATA : // add treatment for raw data word here! - //-------------------------------------------------------------------------------------------- UNKNOWN WORD - default: - generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink - << ": Unknown word type found, 0x" << std::hex << rawDataWord << std::dec << ", ignoring"); - m_errors->addDecodingError(); - PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); + are_4condensed_words = false; + + break; + + //-------------------------------------------------------------------------------------------- UNKNOWN WORD + default: + generalwarning("In ROB 0x" << std::hex << robId << ", FE 0x" << mLink << ": Unknown word type found, 0x" << std::hex << rawDataWord << std::dec << ", ignoring"); + m_numDecodingErrors++; + PixelByteStreamErrors::addError( bsErrCode, PixelByteStreamErrors::Decoding ); } // end of switch + + if (offlineIdHash!=0xffffffff) { // now write the error word to the service + + int chFE = 0; + if (isIBLModule || isDBMModule) { // get FE channel id for IBL + linkNum_IBLheader = decodeModule_IBL(rawDataWord); + chFE = (extractFefromLinkNum(linkNum_IBLheader) & 0x1); + } + else { // for PIXEL + chFE = decodeFE(rawDataWord); + } + + if (bsErrCode) { + int indexFE = (1+chFE)*m_pixel_id->wafer_hash_max()+(int)offlineIdHash; // index for IDCInDetBSErrContainer + decodingErrors.setOrDrop( offlineIdHash, bsErrCode ); + decodingErrors.setOrDrop( indexFE, bsErrCode ); + } + if (isIBLModule) { + if (serviceCode>0 && serviceCode<32) { + if (serviceCode!=14) { + int indexOffset = 17*m_pixel_id->wafer_hash_max(); + int indexSvcCounter = indexOffset+(serviceCode-1)*280*2+2*((int)offlineIdHash-156)+chFE; + decodingErrors.setOrDrop( indexSvcCounter, serviceCodeCounter ); + } + } + } + } + } // end of loop over ROD ATH_CHECK( updateEventInfoIfEventCorruted( corruptionError ) ); - // Verify that all active IBL FEs sent the same number of headers if (isIBLModule || isDBMModule) { checkUnequalNumberOfHeaders( nFragmentsPerFE, robId ); @@ -996,12 +984,6 @@ StatusCode PixelRodDecoder::fillCollection( const ROBFragment *robFrag, IPixelRD return sc; } -StatusCode PixelRodDecoder::StoreBSError() const { - ATH_CHECK(m_errors->recordData()); - return StatusCode::SUCCESS; -} - - // ****************************************************************************************************** DECODING FUNCTIONS //////////////////////// @@ -1480,65 +1462,6 @@ uint32_t PixelRodDecoder::getDataType(unsigned int rawDataWord, bool link_start) } -//////////////////////// -// add a ROD Errors (truncation) -//////////////////////// - -void PixelRodDecoder::addRODError(uint32_t robid, uint32_t robStatus) const { - std::vector<IdentifierHash> idHashes; - - const std::deque<Identifier> offlineIdList =SG::ReadCondHandle<PixelCablingCondData>(m_condCablingKey)->find_entry_offlineList(robid); - std::deque<Identifier>::const_iterator it1 = offlineIdList.begin(); - std::deque<Identifier>::const_iterator it2 = offlineIdList.end(); - for (; it1!=it2;++it1) { - idHashes.push_back(m_pixel_id->wafer_hash(*it1)); - } - - std::vector<IdentifierHash>::iterator hashIt = idHashes.begin(); - std::vector<IdentifierHash>::iterator hashEnd = idHashes.end(); - for (; hashIt != hashEnd; ++hashIt) { - m_errors->addRODError(); - m_errors->setModuleRODErrors(*hashIt,robStatus); - } - return; -} - -void PixelRodDecoder::addRODError(const uint32_t robid, const IDCInDetBSErrContainer::ErrorCode ec, IDCInDetBSErrContainer& errorsCollection) const { - const std::deque<Identifier> offlineIdList = SG::ReadCondHandle<PixelCablingCondData>( m_condCablingKey )->find_entry_offlineList( robid ); - for ( const Identifier& id: offlineIdList ) { - IdentifierHash idHash = m_pixel_id->wafer_hash(id); - errorsCollection.setOrDrop(idHash, ec); - } -} - -StatusCode PixelRodDecoder::checkRODStatus( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, IDCInDetBSErrContainer& decodingErrors ) const { - // check the ROD status for truncation - if (robFrag->nstatus() != 0) { - const uint32_t* rob_status; - robFrag->status(rob_status); - uint32_t robId = robFrag->rob_source_id(); - if ( ATH_UNLIKELY( (*rob_status) != 0) ) { - addRODError(robId,*rob_status); - - ATH_MSG_DEBUG( "ROB status word for robid 0x"<< std::hex << robId << " is non-zero 0x" - << (*rob_status) << std::dec); - - if (((*rob_status) >> 27) & 0x1) { // TODO: find source of thse constants - addRODError( robId, PixelByteStreamErrors::TruncatedROB, decodingErrors ); - ATH_MSG_DEBUG("ROB status word for robid 0x"<< std::hex << robId << std::dec <<" indicates data truncation."); - return StatusCode::RECOVERABLE; - } - - if (((*rob_status) >> 31) & 0x1) { - addRODError( robId, PixelByteStreamErrors::MaskedROB, decodingErrors ); - ATH_MSG_DEBUG( "ROB status word for robid 0x"<< std::hex << robId<< std::dec <<" indicates resource was masked off."); - return StatusCode::RECOVERABLE; - } - } - } - return StatusCode::SUCCESS; -} - bool PixelRodDecoder::checkDataWordsCorruption( uint32_t rawDataWord) const { if ( ATH_UNLIKELY( rawDataWord==0xaa1234aa )) { generalwarning("Evt marker encountered during loop on ROD datawords"); @@ -1562,10 +1485,8 @@ uint32_t PixelRodDecoder::treatmentFEFlagInfo(unsigned int serviceCode, unsigned if (serviceCode == 16) { // I'm not like those other codes etc = (serviceCodeCounter >> 4) & 0x1F; l1req = serviceCodeCounter & 0x7; - m_errors->updateServiceRecords(serviceCode, etc); } else { - m_errors->updateServiceRecords(serviceCode, serviceCodeCounter); } // Return a 19-bit code to be used for monitoring @@ -1725,19 +1646,19 @@ uint32_t PixelRodDecoder::treatmentFEFlagInfo(unsigned int serviceCode, unsigned void PixelRodDecoder::checkHeaderErrors( uint64_t& bsErrorCode, uint32_t headerError ) const { if (headerError != 0) { // only treatment for header errors now, FIXME if (headerError & (1 << 3)) { - m_errors->addPreambleError(); + m_numPreambleErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::Preamble ); } if (headerError & (1 << 2)) { - m_errors->addTimeOutError(); + m_numTimeOutErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::TimeOut ); } if (headerError & (1 << 1)) { - m_errors->addLVL1IDError(); + m_numLVL1IDErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::LVL1ID ); } if (headerError & (1 << 0)) { - m_errors->addBCIDError(); + m_numBCIDErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::BCID ); } } @@ -1790,14 +1711,10 @@ void PixelRodDecoder::checkUnequalNumberOfHeaders( const unsigned int nFragments void PixelRodDecoder::checkTrailerErrors( uint64_t& bsErrorCode, uint32_t trailerError ) const { //for now just sum all trailer errors - if (trailerError & (1 << 3)) - m_errors->addTrailerError(); - if (trailerError & (1 << 2)) - m_errors->addTrailerError(); - if (trailerError & (1 << 1)) - m_errors->addTrailerError(); - if (trailerError & (1 << 0)) - m_errors->addTrailerError(); + if (trailerError & (1 << 3)) { m_numTrailerErrors++; } + if (trailerError & (1 << 2)) { m_numTrailerErrors++; } + if (trailerError & (1 << 1)) { m_numTrailerErrors++; } + if (trailerError & (1 << 0)) { m_numTrailerErrors++; } if ( trailerError & 0xF ) { PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::Trailer ); @@ -1807,36 +1724,36 @@ void PixelRodDecoder::checkTrailerErrors( uint64_t& bsErrorCode, uint32_t traile void PixelRodDecoder::checkTrailerErrorsIBL( uint64_t& bsErrorCode, uint32_t trailerError ) const { // Add errors to errorsvc if (trailerError & (1 << 8)) { // time out error bit => E - m_errors->addTimeOutError(); + m_numTimeOutErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::TimeOut ); } if (trailerError & (1 << 6)) {// link masked by PPC => P - m_errors->addLinkMaskedByPPC(); + m_numLinkMaskedByPPC++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::LinkMaskedByPPC ); } if (trailerError & (1 << 5)) { // preamble error bit => p - m_errors->addPreambleError(); + m_numPreambleErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::Preamble ); } if (trailerError & (1 << 4)) { // LVL1 error bit => l - m_errors->addLVL1IDError(); + m_numLVL1IDErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::LVL1ID ); } if (trailerError & (1 << 3)) {// BCID error bit => b - m_errors->addBCIDError(); + m_numBCIDErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::BCID ); } if (trailerError & (1 << 2)) { // trailer error bit => z - m_errors->addTrailerError(); + m_numTrailerErrors++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::Trailer ); } if (trailerError & (1 << 1)) { // header/trailer limit error=> h - m_errors->addLimitError(); + m_numLimitError++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::Limit ); } if (trailerError & (1 << 0)) { // data overflow error=> v - m_errors->addInvalidIdentifier(); + m_numInvalidIdentifiers++; PixelByteStreamErrors::addError( bsErrorCode, PixelByteStreamErrors::Invalid ); } } diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h index 8589c5b99f923538f4d904b1f0e24b803231578a..e070363fe419536a6936da4792e84cbde86787f7 100644 --- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h +++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecoder.h @@ -12,8 +12,6 @@ #include "GaudiKernel/ServiceHandle.h" #include "eformat/SourceIdentifier.h" -#include "PixelConditionsTools/IPixelByteStreamErrorsTool.h" - #include "PixelConditionsData/PixelCablingCondData.h" #include "PixelConditionsData/PixelHitDiscCnfgData.h" #include "StoreGate/ReadCondHandleKey.h" @@ -44,9 +42,6 @@ class PixelRodDecoder : virtual public IPixelRodDecoder, public AthAlgTool { IDCInDetBSErrContainer& decodingErrors, std::vector<IdentifierHash>* vecHash = NULL) const override; - StatusCode StoreBSError() const override; - - uint32_t getDataType(unsigned int rawDataWord, bool link_start) const; // determine module word type ////// decode IBL module header word @@ -117,10 +112,6 @@ class PixelRodDecoder : virtual public IPixelRodDecoder, public AthAlgTool { uint32_t extractFefromLinkNum (const uint32_t linkNum) const; uint32_t extractSLinkfromLinkNum (const uint32_t linkNum) const; - void addRODError(uint32_t rodid, uint32_t robStatus) const; - - - bool CheckLinkStart(const bool Link_start, const int rodId, const unsigned int mLink, const unsigned int mBCID, const unsigned int mLVL1ID, const int LVL1A); uint32_t treatmentFEFlagInfo(unsigned int serviceCode, unsigned int serviceCodeCounter) const; @@ -134,25 +125,29 @@ class PixelRodDecoder : virtual public IPixelRodDecoder, public AthAlgTool { const unsigned m_maxNumBCIDWarnings{50}; // Maximum number of BCID and LVL1ID warnings to print BooleanProperty m_checkDuplicatedPixel{this, "CheckDuplicatedPixel", true, "Check duplicated pixels in fillCollection method"}; + mutable std::atomic_uint m_numInvalidIdentifiers{0}; + mutable std::atomic_uint m_numPreambleErrors{0}; + mutable std::atomic_uint m_numTimeOutErrors{0}; + mutable std::atomic_uint m_numLVL1IDErrors{0}; + mutable std::atomic_uint m_numBCIDErrors{0}; + mutable std::atomic_uint m_numFlaggedErrors{0}; + mutable std::atomic_uint m_numTrailerErrors{0}; + mutable std::atomic_uint m_numDisabledFEErrors{0}; + mutable std::atomic_uint m_numDecodingErrors{0}; + mutable std::atomic_uint m_numRODErrors{0}; + mutable std::atomic_uint m_numLinkMaskedByPPC{0}; + mutable std::atomic_uint m_numLimitError{0}; + ServiceHandle<IPixelCablingSvc> m_pixelCabling; const PixelID* m_pixel_id=nullptr; - ToolHandle<IPixelByteStreamErrorsTool> m_errors - {this, "PixelByteStreamErrorsTool", "PixelByteStreamErrorsTool", "Tool for PixelByteStreamError"}; - SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey {this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"}; SG::ReadCondHandleKey<PixelHitDiscCnfgData> m_condHitDiscCnfgKey {this, "PixelHitDiscCnfgData", "PixelHitDiscCnfgData", "Pixel FEI4 HitDiscConfig key"}; - //!< adds given ErrorCode to all hasIDs for given ROB - void addRODError(uint32_t robid, IDCInDetBSErrContainer::ErrorCode, IDCInDetBSErrContainer& errorsCollection) const; - - //! checks status word in ROD for truncations and similar, returns success or recoverable errors, fills errors container at the same time - StatusCode checkRODStatus( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, IDCInDetBSErrContainer& decodingErrors ) const; - //! checks if data words do not look like header & trailer markers, return true if so, this is sign of data corruption bool checkDataWordsCorruption( uint32_t word ) const; diff --git a/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringPixel.py b/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringPixel.py index fc9c9a0f08e7cc54890bd01b252ff1a5e73febcc..12e28bd78ac5140ace0ccfef1a6e75ea21f9e724 100644 --- a/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringPixel.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringPixel.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # ''' @@ -81,9 +81,6 @@ if doErrorMonAlg: pixelAthMonAlgErrorMonAlg = helper.addAlgorithm(PixelAthErrorMonAlg, 'PixelAthErrorMonAlg') for k, v in kwargsErrMonAlg.items(): setattr(pixelAthMonAlgErrorMonAlg, k, v) - from PixelConditionsTools.PixelConditionsToolsConf import PixelByteStreamErrorsTool - # never attempt to write bytestream error objects - pixelAthMonAlgErrorMonAlg.PixelByteStreamErrorsTool = PixelByteStreamErrorsTool(ReadingESD = True) PixelAthErrorMonAlgCfg(helper, pixelAthMonAlgErrorMonAlg, **kwargsErrMonAlg) topSequence += helper.result() diff --git a/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.cxx b/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.cxx index 5f5669ea3d4a73aa091d4724437c25201130c3f2..ae2f07d0efc6c531acb87bac9a5e1d8ebcd89022 100644 --- a/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.cxx +++ b/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.cxx @@ -26,13 +26,112 @@ StatusCode PixelAthErrorMonAlg::initialize() { ATH_CHECK( detStore()->retrieve(m_pixelid, "PixelID") ); ATH_CHECK( m_pixelCondSummaryTool.retrieve() ); - if ( !m_pixelErrorTool.empty() ) ATH_CHECK( m_pixelErrorTool.retrieve() ); return AthMonitorAlgorithm::initialize(); } StatusCode PixelAthErrorMonAlg::fillHistograms( const EventContext& ctx ) const { + + //==================================================================================== + // This is an example how to read the Error informaiton. + // + // The Error word is defined in + // InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h + // + // The IDCInDetBSErrContainer can be accessed through + // m_pixelCondSummaryTool->getBSErrorWord(i,ctx) + // where + // i= [ 0, 2047] : module error + // + // for PIXEL(FEI3): + // = [ 2048, 4095] : FE-0 error + // = [ 4096, 6143] : FE-1 error + // = [ 6144, 8191] : FE-2 error + // ... ... ... + // ... ... ... + // = [30720, 32767] : FE-14 error + // = [32768, 34815] : FE-15 error + // + // for IBL(FEI4): + // = [ 2048, 4095] : FE-0 error + // = [ 4096, 6143] : FE-1 error + // = [34816, 35095] : Error counter in bit#=1 from ServiceRecords + // = [35096, 35375] : Error counter in bit#=2 from ServiceRecords + // ... ... ... + // ... ... ... + // = [43496, 43776] : Error counter in bit#=32 from ServiceRecords + // + //==================================================================================== + // + // Print all Module/FE errors + int maxHash = m_pixelid->wafer_hash_max(); + + for (int i=0; i<maxHash; i++) { + // Get accumulated errors (Module) + + uint64_t kErrorWord = m_pixelCondSummaryTool->getBSErrorWord(i,ctx); + + ATH_MSG_DEBUG("Module hash=" << i << " has"); + if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::TimeOut )) { ATH_MSG_DEBUG(" TimeOut state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::BCID )) { ATH_MSG_DEBUG(" BCID state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::LVL1ID )) { ATH_MSG_DEBUG(" LVL1ID state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::Preamble )) { ATH_MSG_DEBUG(" Preamble state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::Trailer )) { ATH_MSG_DEBUG(" Trailer state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::Flagged )) { ATH_MSG_DEBUG(" Flagged state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::DisableFE )) { ATH_MSG_DEBUG(" DisableFE state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::BadFE )) { ATH_MSG_DEBUG(" BadFE state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::ROD )) { ATH_MSG_DEBUG(" ROD state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::Decoding )) { ATH_MSG_DEBUG(" Decoding state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::Invalid )) { ATH_MSG_DEBUG(" Invalid state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::LinkMaskedByPPC)) { ATH_MSG_DEBUG(" LinkMaskedByPPC state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::Limit )) { ATH_MSG_DEBUG(" Limit state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::TruncatedROB )) { ATH_MSG_DEBUG(" TruncatedROB state..."); } + else if (PixelByteStreamErrors::hasError(kErrorWord,PixelByteStreamErrors::MaskedROB )) { ATH_MSG_DEBUG(" MaskedROB state..."); } + else { ATH_MSG_DEBUG(" no entry ..."); } + + // Loop over all FE + int nFE = 16; + if (i<12 || i>2035) { nFE=2; } // for DBM + if (i>155 && i<436) { nFE=2; } // for FEI4 + + for (int j=0; j<nFE; j++) { + int channelFE = (1+j)*maxHash+i; // (FE_channel+1)*2048 + moduleHash + uint64_t kErrorFEWord = m_pixelCondSummaryTool->getBSErrorWord(channelFE,ctx); + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::TimeOut )) { ATH_MSG_DEBUG(" FE ch.=" << j << " TimeOut state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::BCID )) { ATH_MSG_DEBUG(" FE ch.=" << j << " BCID state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::LVL1ID )) { ATH_MSG_DEBUG(" FE ch.=" << j << " LVL1ID state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::Preamble )) { ATH_MSG_DEBUG(" FE ch.=" << j << " Preamble state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::Trailer )) { ATH_MSG_DEBUG(" FE ch.=" << j << " Trailer state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::Flagged )) { ATH_MSG_DEBUG(" FE ch.=" << j << " Flagged state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::DisableFE )) { ATH_MSG_DEBUG(" FE ch.=" << j << " DisableFE state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::BadFE )) { ATH_MSG_DEBUG(" FE ch.=" << j << " BadFE state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::ROD )) { ATH_MSG_DEBUG(" FE ch.=" << j << " ROD state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::Decoding )) { ATH_MSG_DEBUG(" FE ch.=" << j << " Decoding state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::Invalid )) { ATH_MSG_DEBUG(" FE ch.=" << j << " Invalid state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::LinkMaskedByPPC)) { ATH_MSG_DEBUG(" FE ch.=" << j << " LinkMaskedByPPC state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::Limit )) { ATH_MSG_DEBUG(" FE ch.=" << j << " Limit state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::TruncatedROB )) { ATH_MSG_DEBUG(" FE ch.=" << j << " TruncatedROB state..."); } + if (PixelByteStreamErrors::hasError(kErrorFEWord,PixelByteStreamErrors::MaskedROB )) { ATH_MSG_DEBUG(" FE ch.=" << j << " MaskedROB state..."); } + } + + // Get IBL SearviceRecords : IBL hashID[156-435] + if (i>155 && i<436) { + for (int j=0; j<2; j++) { + for (int k=1; k<32; k++) { + int indexOffset = 17*maxHash; + int channelFE = indexOffset+(k-1)*280*2+2*(i-156)+j; // offset+(ServiceCode)*(#IBLxFE) + (#FE)x(moduleHash-156) + FE + uint64_t serviceCounter = m_pixelCondSummaryTool->getBSErrorWord(channelFE,ctx); + ATH_MSG_DEBUG(" IBL SearviceRecords bit=" << j << " " << serviceCounter); + } + } + } + } + + +//=================================================================== +// Here I let Pixel DQ people refill the Error word with new method. +/* using namespace Monitored; int lb = GetEventInfo(ctx)->lumiBlock(); @@ -330,7 +429,9 @@ StatusCode PixelAthErrorMonAlg::fillHistograms( const EventContext& ctx ) const for (unsigned int cat = 0; cat < ErrorCategory::COUNT; ++cat) { fill1DProfLumiLayers(error_names_cat_norm[cat], lb, num_errormodules_per_cat[cat]); } - + + */ + return StatusCode::SUCCESS; } diff --git a/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.h b/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.h index 6eb8baf04c6e698b15bb594f110ac2a7381f3861..76edf04142b4244134761308140916143d960306 100644 --- a/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.h +++ b/InnerDetector/InDetMonitoring/PixelMonitoring/src/PixelAthErrorMonAlg.h @@ -6,11 +6,10 @@ #define PIXELATHERRORMONTOOL_H #include "PixelAthMonitoringBase.h" -#include "PixelConditionsTools/IPixelByteStreamErrorsTool.h" #include "InDetConditionsSummaryService/IInDetConditionsTool.h" +#include "PixelConditionsData/PixelByteStreamErrors.h" class PixelID; -class IPixelByteStreamErrorsTool; class ErrorCategory { public: @@ -134,7 +133,6 @@ class PixelAthErrorMonAlg : public PixelAthMonitoringBase { private: - ToolHandle<IPixelByteStreamErrorsTool> m_pixelErrorTool{this, "PixelByteStreamErrorsTool", "PixelByteStreamErrorsTool", "Tool to retrieve PixelByteStreamErrors"}; ToolHandle<IInDetConditionsTool> m_pixelCondSummaryTool{this, "PixelConditionsSummaryTool", "PixelConditionsSummaryTool", "Tool to retrieve Pixel Conditions summary"}; const PixelID* m_pixelid; diff --git a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx index 70d9844db63cf7dc83c438c5a7fcabf16666dcf1..5b87898b5a0d0cae104d6cdbdd14be97e905f213 100644 --- a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx +++ b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx @@ -67,7 +67,26 @@ namespace InDet{ ATH_CHECK(createContainer(m_PixRDOCacheKey, m_pix_idHelper->wafer_hash_max(), ctx)); - ATH_CHECK(createValueContainer(m_PixBSErrCacheKey, m_pix_idHelper->wafer_hash_max(), ctx, std::numeric_limits<uint64_t>::min())); + //========================================================= + // Size of Pixel BS Error container + // + // The error would be stored not only for module but also each FE (x16) per module. + // In addition, IBL FEI4 provides error counter between trigger, this also extends + // the size beyond nominal module + FE ID. These numbers come from the hardware + // specification so that there is no easy way to document in the header file. + // Rather, put the hardcoded number here since m_pix_idHelper does not have it. + // + // Total number of pixel modules: 2048 + // Number of FE chips per module: 16 + // ------------------------------------- + // 2048 x 17 (module + FE) = 34816 + // + // IBL extra error information : + // 280(module) x 2(FE) x 32(error counter) = 35840 + // ------------------------------------- + // Total : 70656 + //========================================================= + ATH_CHECK(createValueContainer(m_PixBSErrCacheKey, 70656, ctx, std::numeric_limits<uint64_t>::min())); return StatusCode::SUCCESS; } diff --git a/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/python/InDetTrigPrepRawDataFormatMonitoring.py b/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/python/InDetTrigPrepRawDataFormatMonitoring.py index 642d4e7a9f7546f6294e81aedfd7de1160d7013e..0c14e8a6547f1b59a8c373183fa8d41bfa7fbb98 100755 --- a/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/python/InDetTrigPrepRawDataFormatMonitoring.py +++ b/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/python/InDetTrigPrepRawDataFormatMonitoring.py @@ -81,7 +81,7 @@ class PixelTrigPrepRawDataFormatMonitorBase(TrigGenericMonitoringToolConfig): title="Number Det Elements in ROI", xbins = 100, xmin=0., xmax=maxid)] - self.Histograms += [ defineHistogram('PixBSErr', + self.Histograms += [ defineHistogram('PixelByteStreamErrs', type='TH1F', title="Pix BS decoding errors", xbins = 10, xmin=0., xmax=20, diff --git a/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/src/Pixel_TrgClusterization.cxx b/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/src/Pixel_TrgClusterization.cxx index 329eba3de6a2c24f3c8bc8b45ed72e1cfa8ba5b1..f3ff3c4f81df9497af46625f26a26e5aa8e4f1c7 100755 --- a/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/src/Pixel_TrgClusterization.cxx +++ b/InnerDetector/InDetTrigRecAlgs/InDetTrigPrepRawDataFormat/src/Pixel_TrgClusterization.cxx @@ -83,7 +83,7 @@ namespace InDet{ declareMonitoredVariable("numPixClusters", m_numPixClusters ); declareMonitoredVariable("numPixIds", m_numPixIds ); declareMonitoredStdContainer("PixHashId", m_ClusHashId); - declareMonitoredStdContainer("PixBSErr", m_PixBSErr); + declareMonitoredStdContainer("PixelByteStreamErrs", m_PixBSErr); m_clusterCollection = NULL; diff --git a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx index a59f437c93f419e2abebf87c637d4998486422ab..313b6bd8f45d254c0386912629815f5dd39970f4 100644 --- a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx +++ b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx @@ -36,7 +36,7 @@ namespace InDet { declareInterface<InDet::ITrigRawDataProviderTool>(this); declareProperty("RDOKey", m_RDO_Key = "PixelRDOs_EFID"); declareProperty("RawDataProviderTool", m_rawDataTool); - declareProperty("DecodingErrorsKey", m_decodingErrorsKey="PixBSErr"); + declareProperty("DecodingErrorsKey", m_decodingErrorsKey="PixelByteStreamErrs"); } TrigPixRawDataProvider::~TrigPixRawDataProvider(){ @@ -112,7 +112,7 @@ namespace InDet { } if( !evtStore()->transientContains<IDCInDetBSErrContainer>(m_decodingErrorsKey) ) { - m_decodingErrors = new IDCInDetBSErrContainer(m_id->wafer_hash_max(), std::numeric_limits<IDCInDetBSErrContainer::ErrorCode>::min()); + m_decodingErrors = new IDCInDetBSErrContainer(m_rawDataTool->SizeOfIDCInDetBSErrContainer(), std::numeric_limits<int>::min()); ATH_CHECK(evtStore()->record(m_decodingErrors, m_decodingErrorsKey)); } else { ATH_CHECK(evtStore()->retrieve(m_decodingErrors, m_decodingErrorsKey)); diff --git a/Tools/PROCTools/data/master_q431_AOD_digest.ref b/Tools/PROCTools/data/master_q431_AOD_digest.ref index b639cb841c446bab64bba787cc0fe3b972dc1eb3..519f0aa6990e1daefa4bf13b64fd2dec378d4b73 100644 --- a/Tools/PROCTools/data/master_q431_AOD_digest.ref +++ b/Tools/PROCTools/data/master_q431_AOD_digest.ref @@ -1,8 +1,8 @@ run event nTopo nIdTracks nJets nMuons 330470 1183722158 1 0 0 0 - 330470 1183722342 394 409 20 0 - 330470 1183727953 532 571 11 4 - 330470 1183732647 467 450 12 1 + 330470 1183722342 394 411 20 0 + 330470 1183727953 532 572 11 4 + 330470 1183732647 467 451 13 1 330470 1183733040 381 284 6 1 330470 1183734651 361 360 14 3 330470 1183735332 406 372 9 1 @@ -11,16 +11,16 @@ 330470 1183738949 368 424 9 1 330470 1183742489 152 124 2 1 330470 1183743040 285 306 5 0 - 330470 1183746343 492 464 14 0 + 330470 1183746343 492 465 14 0 330470 1183746710 6 0 0 0 - 330470 1183751782 239 234 5 0 + 330470 1183751782 239 234 4 0 330470 1183752624 347 343 8 3 330470 1183753006 357 377 11 3 - 330470 1183754806 470 406 14 0 + 330470 1183754806 470 405 15 0 330470 1183769295 342 317 8 2 330470 1183769939 348 342 11 3 330470 1183773832 307 199 7 0 330470 1183775209 57 0 0 0 - 330470 1183787124 431 359 11 2 - 330470 1183787946 321 310 5 1 - 330470 1183795329 458 331 18 0 + 330470 1183787124 431 360 11 2 + 330470 1183787946 321 311 5 1 + 330470 1183795329 458 332 18 0 diff --git a/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py b/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py index d9435b93c60b6377651bdb0504e8925798b7e343..46d82a81dca642f3489e955262838ba5e445b106 100644 --- a/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py +++ b/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py @@ -55,6 +55,7 @@ def makeInDetAlgs( whichSignature='', separateTrackParticleCreator='', rois = 'E ( 'SCT_RDO_Cache' , InDetCacheNames.SCTRDOCacheKey ), ( 'SpacePointCache' , InDetCacheNames.SpacePointCachePix ), ( 'SpacePointCache' , InDetCacheNames.SpacePointCacheSCT ), + ( 'IDCInDetBSErrContainer_Cache' , InDetCacheNames.PixBSErrCacheKey ), ( 'IDCInDetBSErrContainer_Cache' , InDetCacheNames.SCTBSErrCacheKey ), ( 'IDCInDetBSErrContainer_Cache' , InDetCacheNames.SCTFlaggedCondCacheKey ), ( 'xAOD::EventInfo' , 'StoreGateSvc+EventInfo' ), @@ -73,9 +74,11 @@ def makeInDetAlgs( whichSignature='', separateTrackParticleCreator='', rois = 'E if not globalflags.InputFormat.is_bytestream(): ViewDataVerifier.DataObjects += [( 'PixelRDO_Container' , InDetKeys.PixelRDOs() ), ( 'SCT_RDO_Container' , InDetKeys.SCT_RDOs() ), + ( 'IDCInDetBSErrContainer' , InDetKeys.PixelByteStreamErrs() ), ( 'IDCInDetBSErrContainer' , InDetKeys.SCT_ByteStreamErrs() )] topSequence.SGInputLoader.Load += [( 'PixelRDO_Container' , InDetKeys.PixelRDOs() ), ( 'SCT_RDO_Container' , InDetKeys.SCT_RDOs() ), + ( 'IDCInDetBSErrContainer' , InDetKeys.PixelByteStreamErrs() ), ( 'IDCInDetBSErrContainer' , InDetKeys.SCT_ByteStreamErrs() )] from InDetTrigRecExample.InDetTrigFlags import InDetTrigFlags @@ -110,6 +113,7 @@ def makeInDetAlgs( whichSignature='', separateTrackParticleCreator='', rois = 'E InDetPixelRawDataProvider.isRoI_Seeded = True InDetPixelRawDataProvider.RoIs = rois InDetPixelRawDataProvider.RDOCacheKey = InDetCacheNames.PixRDOCacheKey + InDetPixelRawDataProvider.BSErrorsCacheKey = InDetCacheNames.PixBSErrCacheKey viewAlgs.append(InDetPixelRawDataProvider) diff --git a/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py b/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py index 3ab4ba75c9c98acb90a864b75fdfc7c899e0b076..e2fa44bcd74683a0e803bd48dae5b112aaef778c 100644 --- a/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py +++ b/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py @@ -199,6 +199,7 @@ def TrigInDetConfig( flags, roisKey="EMRoIs", signatureName='' ): ('SCT_RDO_Cache', 'SctRDOCache'), ('SpacePointCache', 'PixelSpacePointCache'), ('SpacePointCache', 'SctSpacePointCache'), + ('IDCInDetBSErrContainer_Cache', 'PixelBSErrCache'), ('IDCInDetBSErrContainer_Cache', 'SctBSErrCache'), ('IDCInDetBSErrContainer_Cache', 'SctFlaggedCondCache'), ('xAOD::EventInfo', 'StoreGateSvc+EventInfo'), diff --git a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref index 3875b26b3e48c298b2b4e55d88416584379773ea..60c5a3227c8e250fe199763497095ef1946e1252 100644 --- a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref +++ b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref @@ -269,14 +269,14 @@ TrigSignatureMoniMT INFO HLT_j45_ftf_pf_nojcalib TrigSignatureMoniMT INFO -- #3658890913 Events 20 20 0 0 0 0 0 0 0 0 0 0 3 - 3 TrigSignatureMoniMT INFO -- #3658890913 Features 0 0 0 0 0 0 0 0 0 0 3 - TrigSignatureMoniMT INFO HLT_j45_ftf_subjesgscIS_011jvt_L1J15 #2857031468 -TrigSignatureMoniMT INFO -- #2857031468 Events 20 20 0 0 0 0 0 0 0 0 0 0 4 - 4 -TrigSignatureMoniMT INFO -- #2857031468 Features 0 0 0 0 0 0 0 0 0 0 4 - +TrigSignatureMoniMT INFO -- #2857031468 Events 20 20 0 0 0 0 0 0 0 0 0 0 3 - 3 +TrigSignatureMoniMT INFO -- #2857031468 Features 0 0 0 0 0 0 0 0 0 0 3 - TrigSignatureMoniMT INFO HLT_j45_ftf_subjesgscIS_015jvt_L1J15 #2938374624 -TrigSignatureMoniMT INFO -- #2938374624 Events 20 20 0 0 0 0 0 0 0 0 0 0 4 - 4 -TrigSignatureMoniMT INFO -- #2938374624 Features 0 0 0 0 0 0 0 0 0 0 4 - +TrigSignatureMoniMT INFO -- #2938374624 Events 20 20 0 0 0 0 0 0 0 0 0 0 3 - 3 +TrigSignatureMoniMT INFO -- #2938374624 Features 0 0 0 0 0 0 0 0 0 0 3 - TrigSignatureMoniMT INFO HLT_j45_ftf_subjesgscIS_059jvt_L1J15 #1593009344 -TrigSignatureMoniMT INFO -- #1593009344 Events 20 20 0 0 0 0 0 0 0 0 0 0 4 - 4 -TrigSignatureMoniMT INFO -- #1593009344 Features 0 0 0 0 0 0 0 0 0 0 4 - +TrigSignatureMoniMT INFO -- #1593009344 Events 20 20 0 0 0 0 0 0 0 0 0 0 3 - 3 +TrigSignatureMoniMT INFO -- #1593009344 Features 0 0 0 0 0 0 0 0 0 0 3 - TrigSignatureMoniMT INFO HLT_j45_ftf_subjesgscIS_L1J15 #3341539267 TrigSignatureMoniMT INFO -- #3341539267 Events 20 20 0 0 0 0 0 0 0 0 0 0 7 - 7 TrigSignatureMoniMT INFO -- #3341539267 Features 0 0 0 0 0 0 0 0 0 0 7 - @@ -785,11 +785,11 @@ TrigSignatureMoniMT INFO HLT_xe30_mht_L1XE10 #36 TrigSignatureMoniMT INFO -- #3626903018 Events 20 20 0 0 0 0 0 0 0 0 0 0 14 - 14 TrigSignatureMoniMT INFO -- #3626903018 Features 0 0 0 0 0 0 0 0 0 0 14 - TrigSignatureMoniMT INFO HLT_xe30_mhtpufit_em_subjesgscIS_L1XE10 #689201557 -TrigSignatureMoniMT INFO -- #689201557 Events 20 20 0 0 0 0 0 0 0 0 0 0 4 - 4 -TrigSignatureMoniMT INFO -- #689201557 Features 0 0 0 0 0 0 0 0 0 0 4 - +TrigSignatureMoniMT INFO -- #689201557 Events 20 20 0 0 0 0 0 0 0 0 0 0 5 - 5 +TrigSignatureMoniMT INFO -- #689201557 Features 0 0 0 0 0 0 0 0 0 0 5 - TrigSignatureMoniMT INFO HLT_xe30_mhtpufit_pf_subjesgscIS_L1XE10 #1886909707 -TrigSignatureMoniMT INFO -- #1886909707 Events 20 20 0 0 0 0 0 0 0 0 0 0 3 - 3 -TrigSignatureMoniMT INFO -- #1886909707 Features 0 0 0 0 0 0 0 0 0 0 3 - +TrigSignatureMoniMT INFO -- #1886909707 Events 20 20 0 0 0 0 0 0 0 0 0 0 4 - 4 +TrigSignatureMoniMT INFO -- #1886909707 Features 0 0 0 0 0 0 0 0 0 0 4 - TrigSignatureMoniMT INFO HLT_xe30_pfopufit_L1XE10 #2252641537 TrigSignatureMoniMT INFO -- #2252641537 Events 20 20 0 0 0 0 0 0 0 0 0 0 4 - 4 TrigSignatureMoniMT INFO -- #2252641537 Features 0 0 0 0 0 0 0 0 0 0 4 - diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/PrecisionElectronRecoSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/PrecisionElectronRecoSequences.py index 371319867760d140d86e61ac15e328379a8bf18e..7887f00440ee31e300dddb585b07513f2016d705 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/PrecisionElectronRecoSequences.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/PrecisionElectronRecoSequences.py @@ -37,6 +37,7 @@ def precisionElectronRecoSequence(RoIs): ( 'SG::AuxElement' , 'StoreGateSvc+EventInfo.AveIntPerXDecor' ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_FlaggedCondData_TRIG' ), ( 'TrigRoiDescriptorCollection' , 'StoreGateSvc+precisionElectron' ), + ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' )] # the load below doesn't always work # These objects must be loaded from SGIL if not from CondInputLoader @@ -48,7 +49,7 @@ def precisionElectronRecoSequence(RoIs): ( 'TTrainedNetworkCollection' , 'ConditionStore+PixelClusterNNWithTrack' )] if globalflags.InputFormat.is_bytestream(): - ViewVerifyTrk.DataObjects += [( 'InDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), + ViewVerifyTrk.DataObjects += [( 'IDCInDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' )] else: topSequence.SGInputLoader.Load += [( 'TRT_RDO_Container' , 'StoreGateSvc+TRT_RDOs' )] diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py index 0c40fe69b518c8f7fa91c4c02f43fe00be8fd6f9..bb92b344c250a61dd3cf1333961e563c861d4b63 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py @@ -126,7 +126,7 @@ class MinBiasChainConfig(ChainConfigurationBase): ( 'SpacePointContainer' , 'StoreGateSvc+PixelTrigSpacePoints' )] if globalflags.InputFormat.is_bytestream(): - verifier.DataObjects += [( 'InDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), + verifier.DataObjects += [( 'IDCInDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' )] diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py index 024e9fd7b8824288056081a674aa404194bc1e70..6fcebe53a7efa7981972043531bc92d4940c1c42 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py @@ -725,10 +725,11 @@ def muEFCBRecoSequence( RoIs, name ): ( 'TrackCollection' , 'StoreGateSvc+'+TrackCollection ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_FlaggedCondData_TRIG' ), ( 'xAOD::IParticleContainer' , 'StoreGateSvc+'+TrackParticlesName ), + ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' )] #seems to be necessary, despite the load below if globalflags.InputFormat.is_bytestream(): - ViewVerifyTrk.DataObjects += [( 'InDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), + ViewVerifyTrk.DataObjects += [( 'IDCInDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' )] muEFCBRecoSequence += ViewVerifyTrk diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py index 3df9503a9be09b82d67b375b6d12b9d069be4816..f5ba8e2f2579b14f75674a80f596a49fca120782 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py @@ -211,8 +211,8 @@ def tauIdTrackSequence( RoIs , name): ( 'TTrainedNetworkCollection' , 'ConditionStore+PixelClusterNNWithTrack' )] if globalflags.InputFormat.is_bytestream(): - viewVerify.DataObjects += [( 'InDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), - ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' ) ] + viewVerify.DataObjects += [( 'IDCInDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), + ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' ) ] else: topSequence.SGInputLoader.Load += [( 'TRT_RDO_Container' , 'StoreGateSvc+TRT_RDOs' )] viewVerify.DataObjects += [( 'TRT_RDO_Container' , 'StoreGateSvc+TRT_RDOs' )] @@ -286,6 +286,7 @@ def tauCoreTrackSequence( RoIs, name ): TrackCollection = viewAlg.TrackName viewVerify.DataObjects += [( 'TrigRoiDescriptorCollection' , 'StoreGateSvc+' + RoIs ), + ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+PixelByteStreamErrs' ), ( 'IDCInDetBSErrContainer' , 'StoreGateSvc+SCT_ByteStreamErrs' ),#For some reason not picked up properly ( 'xAOD::TauJetContainer' , 'StoreGateSvc+HLT_TrigTauRecMerged_CaloOnly')]