diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawDataProviderTool.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawDataProviderTool.h index a3c7486deca07754de158839b17113e415b9480c..8bb1f460072f012944623bcf236ef1fb05a74f4b 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawDataProviderTool.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawDataProviderTool.h @@ -2,6 +2,12 @@ Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ +/** + * @file SCT_RawDataByteStreamCnv/ISCTRawContByteStreamTool.h + * + * Athena Algorithm Tool to fill Collections of SCT RDO Containers. + */ + #ifndef SCT_RAWDATABYTESTREAMCNV_ISCTRAWDATAPROVIDERTOOL_H #define SCT_RAWDATABYTESTREAMCNV_ISCTRAWDATAPROVIDERTOOL_H diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodDecoder.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodDecoder.h index 0fd05400e0f5d9501f1da41738f0b668adc6247d..7bfc875ad40fba8b2ceef6ba4cf90f5fa8ca1f57 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodDecoder.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodDecoder.h @@ -3,46 +3,43 @@ */ /** - * @file header for SCT_RodDecoder Class - * AlgTool class to decode ROB bytestream data into RDO - * @author: Kondo.Gnanvo@cern.ch, Maria.Jose.Costa@cern.ch - * @current developer: Kondo Gnanvo, QMUL (London), august 2005 + * @file SCT_RawDataByteStreamCnv/ISCT_RodDecoder.h + * @author Kondo.Gnanvo@cern.ch, Maria.Jose.Costa@cern.ch + * + * AlgTool class to decode ROB bytestream data into RDO */ #ifndef INDETRAWDATABYTESTREAM_ISCT_RODDECODER_H #define INDETRAWDATABYTESTREAM_ISCT_RODDECODER_H -//STL -#include <vector> #include "GaudiKernel/IAlgTool.h" -//Cannot fwd declare SCT_RDO_Container due to typedef in that file + #include "InDetRawData/SCT_RDO_Container.h" -//Cannot fwd declare RawEvent, due to typedef in the .h. Needed for OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment #include "ByteStreamData/RawEvent.h" #include "InDetByteStreamErrors/InDetBSErrContainer.h" #include "InDetByteStreamErrors/SCT_ByteStreamFractionContainer.h" -class StatusCode; +#include <vector> +class StatusCode; class IdentifierHash; -class ISCT_RodDecoder : virtual public IAlgTool { +class ISCT_RodDecoder : virtual public IAlgTool +{ public: - /** destructor */ - virtual ~ISCT_RodDecoder() = default; - - /// Creates the InterfaceID and interfaceID() method + /** Creates the InterfaceID and interfaceID() method */ DeclareInterfaceID(ISCT_RodDecoder, 1, 0); - /** @brief Decode the rob data fragment and fill the collection SCT_RDO_Collection - * with the RDO built by the makeRDO(..) method - **/ + /** Destructor */ + virtual ~ISCT_RodDecoder() = default; + + /** Fill Collection method */ virtual StatusCode fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment&, ISCT_RDO_Container&, InDetBSErrContainer* errs, SCT_ByteStreamFractionContainer* bsFracCont, - const std::vector<IdentifierHash>* vec=nullptr) const = 0; + const std::vector<IdentifierHash>* vecHash = nullptr) const = 0; }; #endif //SCT_RAWDATABYTESTREAM_ISCT_RODDECODER_H diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h index 82753ac509fe1ca35ec7e5c81d221e4fd793b5ac..6af6148e4d061face08f74259f24b76948dc73e2 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h @@ -4,7 +4,7 @@ /** * @file SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h - * @author: Nick Barlow (nbarlow@mail.cern.ch, Kondo.Gnanvo@cern.ch) + * @author Nick Barlow (nbarlow@mail.cern.ch, Kondo.Gnanvo@cern.ch) * @date 21 June 2007 (SCT_RodEncoder turned into An AlgTool) * * This class provides conversion from SCT RDO to ROD format ByteStream. diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h index e76034ace697ef7423dc727bf2d583dc36c5dbb2..647193cfb1ea25dc32b95958c65feaf9739861b0 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h @@ -55,8 +55,8 @@ class SCTRawContByteStreamCnv : public Converter * * Uses SCT RawContByteStreamTool to convert Raw Data to ByteStream. * - * @param pDataObject Pointer to data object - * @param pOpaqueAddress Opaque address to object + * @param pDataObject Pointer to data object. + * @param pOpaqueAddress Opaque address to object. */ virtual StatusCode createRep(DataObject* pDataObject, IOpaqueAddress*& pOpaqueAddress) override; diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h index 130a2a5ae1ea7b244c04c1657ee77d6aee5714ac..b667e3b37b9414b2ba298399645f659eabdf503f 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h @@ -2,12 +2,6 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -/** - * @file SCT_RawDataByteStreamCnv/SCTRawContByteStreamTool.h - * @author Hong Ma - * @date October 2002 - */ - #ifndef SCT_RAWDATABYTESTREAMCNV_SCTRAWCONTBYTESTREAMTOOL_H #define SCT_RAWDATABYTESTREAMCNV_SCTRAWCONTBYTESTREAMTOOL_H diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.cxx index e850106a7a6553d13d46b920d5019de9bff0554e..82cf6390393cb8f186a5d24d4907bf93ae0bff46 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.cxx +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.cxx @@ -4,14 +4,14 @@ #include "SCT_RodDecoder.h" -//Athena #include "ByteStreamData/RawEvent.h" #include "InDetIdentifier/SCT_ID.h" #include "InDetReadoutGeometry/SCT_DetectorManager.h" #include "InDetReadoutGeometry/SiDetectorElement.h" #include "InDetReadoutGeometry/SiDetectorElementCollection.h" -//STL +#include "Identifier/IdentifierHash.h" + #include <algorithm> #include <deque> #include <utility> @@ -21,54 +21,58 @@ union RawWord { uint16_t word16[2]; }; -//constructor -SCT_RodDecoder::SCT_RodDecoder -(const std::string& type, const std::string& name,const IInterface* parent) : +// Constructor + +SCT_RodDecoder::SCT_RodDecoder(const std::string& type, const std::string& name, + const IInterface* parent) : base_class(type, name, parent), - m_sct_id{nullptr}, + m_sctID{nullptr}, m_singleCondHitNumber{0}, m_pairedCondHitNumber{0}, m_firstExpHitNumber{0}, m_evenExpHitNumber{0}, m_lastExpHitNumber{0}, - m_headnumber{0}, - m_trailnumber{0}, - m_head_error_bcid{0}, - m_head_error_lvl1id{0}, - m_head_error_timeout{0}, - m_head_error_formatter{0}, - m_head_error_preamb{0}, - m_trail_error_overflow{0}, - m_trail_error_limit{0}, - m_trail_error_bit{0}, - m_config_data_bit{0}, - m_flag_error_bit{0}, - m_cond_hit1_error{0}, - m_cond_hit2_error{0}, - m_chip_number_error{0}, - m_unknown_data_format{0}, + m_headNumber{0}, + m_trailerNumber{0}, + m_headErrorBCID{0}, + m_headErrorLvl1ID{0}, + m_headErrorTimeout{0}, + m_headErrorFormatter{0}, + m_headErrorPreamble{0}, + m_trailerErrorOverflow{0}, + m_trailerErrorLimit{0}, + m_trailerErrorBit{0}, + m_configDataBit{0}, + m_flagErrorBit{0}, + m_condHit1Error{0}, + m_condHit2Error{0}, + m_chipNumberError{0}, + m_unknownDataFormat{0}, m_nHits{0}, m_nRDOs{0}, m_maskedLinkNumber{0}, m_maskedRODNumber{0}, - m_RODClockErrorNumber{0}, + m_rodClockErrorNumber{0}, m_truncatedRODNumber{0}, m_numMissingLinkHeader{0}, - m_numUnknownOfflineId{0}, + m_numUnknownOfflineID{0}, m_swapPhiReadoutDirection{} { } -StatusCode SCT_RodDecoder::initialize() { +// Initialize + +StatusCode SCT_RodDecoder::initialize() +{ ATH_CHECK(AlgTool::initialize()); - /** Retrieve cabling tool */ + // Retrieve cabling tool ATH_CHECK(m_cabling.retrieve()); ATH_MSG_DEBUG("Retrieved tool " << m_cabling); - ATH_CHECK(detStore()->retrieve(m_sct_id,"SCT_ID")); - m_cntx_sct = m_sct_id->wafer_context(); - m_swapPhiReadoutDirection.resize(m_sct_id->wafer_hash_max(), false); + ATH_CHECK(detStore()->retrieve(m_sctID,"SCT_ID")); + m_contextSCT = m_sctID->wafer_context(); + m_swapPhiReadoutDirection.resize(m_sctID->wafer_hash_max(), false); ATH_CHECK(m_configTool.retrieve()); @@ -77,10 +81,11 @@ StatusCode SCT_RodDecoder::initialize() { // Since this is access to SiDetectorElement during initialization, // condition object of SiDetectorElementCollection is not accessible. // SCT_DetectorManager has to be used. - const InDetDD::SCT_DetectorManager* detManager{nullptr}; - ATH_CHECK(detStore()->retrieve(detManager, "SCT")); - const InDetDD::SiDetectorElementCollection* elements{detManager->getDetectorElementCollection()}; - for (const InDetDD::SiDetectorElement* element: *elements) { + const InDetDD::SCT_DetectorManager* sctDetManager{nullptr}; + ATH_CHECK(detStore()->retrieve(sctDetManager, "SCT")); + + const InDetDD::SiDetectorElementCollection* sctDetElementColl{sctDetManager->getDetectorElementCollection()}; + for (const InDetDD::SiDetectorElement* element: *sctDetElementColl) { if (element->swapPhiReadoutDirection()) { m_swapPhiReadoutDirection[element->identifyHash()] = true; } @@ -89,42 +94,105 @@ StatusCode SCT_RodDecoder::initialize() { return StatusCode::SUCCESS; } -StatusCode -SCT_RodDecoder::finalize() { +// Finalize + +StatusCode SCT_RodDecoder::finalize() +{ + // Print out summaries of data and errors decoded + ATH_MSG_INFO("SCT BytestreamCnv summary: " << m_headNumber <<" link headers found"); + ATH_MSG_INFO("SCT BytestreamCnv summary: " << m_trailerNumber << " link trailers found"); + + ATH_MSG_INFO("SCT decoding bytestream summary: " + << m_singleCondHitNumber << " single strips with hit in condensed mode"); + ATH_MSG_INFO("SCT decoding bytestream summary: " + << m_pairedCondHitNumber << " paired strips with hit in condensed mode"); + ATH_MSG_INFO("SCT decoding bytestream summary: " + << m_firstExpHitNumber << " first strips with hit in expanded mode"); + ATH_MSG_INFO("SCT decoding bytestream summary: " + << m_evenExpHitNumber << " consecutive paired strips with hit in expanded mode"); + ATH_MSG_INFO("SCT decoding bytestream summary: " + << m_lastExpHitNumber << " last consecutive strips with hit in expanded mode"); + + if (m_headErrorBCID > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " + << m_headErrorLvl1ID << " LVL1d errors found"); + } + if (m_headErrorTimeout > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " + << m_headErrorTimeout << " timeout errors found"); + } + if (m_headErrorFormatter > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " + << m_headErrorFormatter << " formatter errors found"); + } + if (m_headErrorPreamble > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " + << m_headErrorPreamble << " preamble errors found"); + } + if (m_maskedLinkNumber > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " + << m_maskedLinkNumber << " masked links found"); + } + + if (m_trailerErrorOverflow > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: trailer-> " + << m_trailerErrorOverflow << " trailer data overflow errors found"); + } + if (m_trailerErrorLimit > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: trailer-> " + << m_trailerErrorLimit << " header trailer limit errors found"); + } + if (m_trailerErrorBit > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: trailer-> " + << m_trailerErrorBit << " trailer bit errors found"); + } + + if (m_configDataBit > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: raw Data-> " + << m_configDataBit << " raw data found: Config data mode"); + } + + if (m_flagErrorBit > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: flag-> " + << m_flagErrorBit << " module link flag bit errors found"); + } - /** print out summaries of data and errors decoded */ - ATH_MSG_INFO("SCT BytestreamCnv summary: " << m_headnumber <<" link headers found"); - - ATH_MSG_INFO("SCT decoding bytestream summary: " << m_singleCondHitNumber << " single strips with hit in condensed mode"); - ATH_MSG_INFO("SCT decoding bytestream summary: " << m_pairedCondHitNumber << " paired strips with hit in condensed mode"); - - ATH_MSG_INFO("SCT decoding bytestream summary: " << m_firstExpHitNumber << " first strips with hit in expanded mode"); - ATH_MSG_INFO("SCT decoding bytestream summary: " << m_evenExpHitNumber << " consecutive paired strips with hit in expanded mode"); - ATH_MSG_INFO("SCT decoding bytestream summary: " << m_lastExpHitNumber << " last consecutive strip with hit in expanded mode"); - - ATH_MSG_INFO("SCT BytestreamCnv summary: " << m_trailnumber << " link trailers found"); - if (m_head_error_bcid > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " << m_head_error_lvl1id << " LVL1d errors found"); - if (m_head_error_timeout > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " << m_head_error_timeout << " timeout errors found"); - if (m_head_error_formatter > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " << m_head_error_formatter << " formatter errors found"); - if (m_head_error_preamb > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " << m_head_error_preamb << " preamble errors found"); - if (m_maskedLinkNumber > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: header-> " << m_maskedLinkNumber << " masked links found"); - if (m_trail_error_overflow > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: trailer-> " << m_trail_error_overflow << " trailer data overflow errors found"); - if (m_trail_error_limit > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: trailer-> " << m_trail_error_limit << " header trailer limit errors found"); - if (m_trail_error_bit > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: trailer-> " << m_trail_error_bit << " trailer bit errors found"); - if (m_config_data_bit > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: raw Data-> " << m_config_data_bit << " raw data found: Config data mode"); - if (m_flag_error_bit > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: flag-> " << m_flag_error_bit << " module link flag bit errors found"); - if (m_cond_hit1_error > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: hit-> " << m_cond_hit1_error << " 1st hit error found in condensed mode"); - if (m_cond_hit2_error > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: hit-> " << m_cond_hit2_error << " 2nd hit error found in condensed mode"); - if (m_chip_number_error > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: hit-> " << m_chip_number_error << " Chip number > 5 error found"); - if (m_unknown_data_format > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: unknown data-> " << m_unknown_data_format << " Unknown data format found"); - if (m_RODClockErrorNumber > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: ROD status word-> " << m_RODClockErrorNumber << " ROD clock errors found"); - if (m_maskedRODNumber > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: ROB status word-> " << m_maskedRODNumber << " masked RODs found"); - if (m_truncatedRODNumber > 0) ATH_MSG_INFO("SCT BytestreamCnv summary: ROB status word-> " << m_truncatedRODNumber << " truncated ROBFragments"); + if (m_condHit1Error > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: hit-> " + << m_condHit1Error << " 1st hit error found in condensed mode"); + } + if (m_condHit2Error > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: hit-> " + << m_condHit2Error << " 2nd hit error found in condensed mode"); + } + if (m_chipNumberError > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: hit-> " + << m_chipNumberError << " Chip number > 5 error found"); + } + + if (m_unknownDataFormat > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: unknown data-> " + << m_unknownDataFormat << " Unknown data format found"); + } + + if (m_rodClockErrorNumber > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: ROD status word-> " + << m_rodClockErrorNumber << " ROD clock errors found"); + } + if (m_maskedRODNumber > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: ROB status word-> " + << m_maskedRODNumber << " masked RODs found"); + } + if (m_truncatedRODNumber > 0) { + ATH_MSG_INFO("SCT BytestreamCnv summary: ROB status word-> " + << m_truncatedRODNumber << " truncated ROBFragments"); + } + ATH_MSG_INFO("Number of SCT hits in ByteStream-> " << m_nHits); ATH_MSG_INFO("Number of SCT RDOs created-> " << m_nRDOs); if (m_numMissingLinkHeader > 0) ATH_MSG_WARNING("SCT Missing Link Headers found " << m_numMissingLinkHeader); - if (m_numUnknownOfflineId > 0) ATH_MSG_WARNING("SCT unknown onlineId found " << m_numUnknownOfflineId); + if (m_numUnknownOfflineID > 0) ATH_MSG_WARNING("SCT unknown onlineIDs found " << m_numUnknownOfflineID); ATH_CHECK(AlgTool::finalize()); ATH_MSG_DEBUG("SCT_RodDecoder::finalize()"); @@ -132,134 +200,133 @@ SCT_RodDecoder::finalize() { return StatusCode::SUCCESS; } +// fillCollection method -StatusCode -SCT_RodDecoder::fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& robFrag, - ISCT_RDO_Container& rdoIdc, - InDetBSErrContainer* errs, - SCT_ByteStreamFractionContainer* bsFracCont, - const std::vector<IdentifierHash>* vecHash) const +StatusCode SCT_RodDecoder::fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& robFrag, + ISCT_RDO_Container& rdoIDCont, + InDetBSErrContainer* errs, + SCT_ByteStreamFractionContainer* bsFracCont, + const std::vector<IdentifierHash>* vecHash) const { - const uint32_t robid{robFrag.rod_source_id()}; - /**determine whether this data was generated using the ROD simulator */ - const uint32_t rod_datatype{robFrag.rod_detev_type()}; - const bool rodSimulatedData{static_cast<bool>((rod_datatype >> 20) & 1)}; - if (bsFracCont) bsFracCont->insert(SCT_ByteStreamFractionContainer::SimulatedData, robid, rodSimulatedData); - if (rodSimulatedData) addRODError(robid, SCT_ByteStreamErrors::RODSimulatedData, errs); + const uint32_t robID{robFrag.rod_source_id()}; + // Determine whether this data was generated using the ROD simulator + const uint32_t rodDataType{robFrag.rod_detev_type()}; + const bool rodSimulatedData{static_cast<bool>((rodDataType >> 20) & 1)}; + if (bsFracCont) { + bsFracCont->insert(SCT_ByteStreamFractionContainer::SimulatedData, robID, rodSimulatedData); + } + if (rodSimulatedData) addRODError(robID, SCT_ByteStreamErrors::RODSimulatedData, errs); - /** look for the bit that denotes "Super-condensed" mode.*/ - const bool superCondensedMode{static_cast<bool>((rod_datatype >> 21) & 1)}; - if (bsFracCont) bsFracCont->insert(SCT_ByteStreamFractionContainer::SuperCondensedMode, robid, superCondensedMode); + // Look for the bit that denotes "Super-condensed" mode + const bool superCondensedMode{static_cast<bool>((rodDataType >> 21) & 1)}; + if (bsFracCont) { + bsFracCont->insert(SCT_ByteStreamFractionContainer::SuperCondensedMode, robID, superCondensedMode); + } bool condensedMode{true}; int strip{0}; - int oldstrip{-1}; - int oldside{-1}; + int oldStrip{-1}; + int oldSide{-1}; int chip{0}; int side{0}; int nStripsInWord{0}; - int linkNb{0}; - uint32_t onlineId{0}; - int tbin{0}; + int linkNumber{0}; + uint32_t onlineID{0}; + int timeBin{0}; int groupSize{0}; bool saved[768*2]{false}; - int ABCerror{0}; - int wordcount{-1}; + int abcError{0}; + int wordCount{-1}; RawWord robData; robData.word32=0; int n; - int ERRORS{0}; /** encodes the errors on the header - * bit 4: error in condensed mode 1st hit - * bit 5: error in condensed mode 2nd hit - */ + int errors{0}; // Encodes the errors on the header (bit 4: error in condensed mode 1st hit, bit 5: error in condensed mode 2nd hit) - /** These are for the trigger */ + // These are for the trigger CacheHelper cache; cache.vecHash = vecHash; - IdentifierHash currentLinkIdHash; + IdentifierHash currentLinkIDHash; std::vector<int> errorHit; StatusCode sc{StatusCode::SUCCESS}; - /// look at ROB status word //////////////////////// - + // Look at ROB status word if (robFrag.nstatus()!=0) { - const uint32_t* rob_status; - robFrag.status(rob_status); - if ((*rob_status)!=0) { - ATH_MSG_DEBUG("ROB status word for robid " << std::hex << robid << " is non-zero " << (*rob_status) << std::dec); - /// first store generic "ROBFragmentError" error type.. - addRODError(robid, SCT_ByteStreamErrors::ROBFragmentError, errs); + const uint32_t* robStatus; + robFrag.status(robStatus); + if ((*robStatus)!=0) { + ATH_MSG_DEBUG("ROB status word for robID " << std::hex << robID + << " is non-zero " << (*robStatus) << std::dec); + // First store generic "ROBFragmentError" error type. + addRODError(robID, SCT_ByteStreamErrors::ROBFragmentError, errs); sc = StatusCode::RECOVERABLE; - /// now look for specific problems, e.g. truncated or masked-off RODs - if (((*rob_status) >> 27) & 0x1) { - ATH_MSG_DEBUG("ROB status word for robid " << std::hex << robid << std::dec << " indicates data truncation."); - addRODError(robid, SCT_ByteStreamErrors::TruncatedROD, errs); + // Now look for specific problems, e.g. truncated or masked-off RODs + if (((*robStatus) >> 27) & 0x1) { + ATH_MSG_DEBUG("ROB status word for robID " << std::hex << robID + << std::dec << " indicates data truncation."); + addRODError(robID, SCT_ByteStreamErrors::TruncatedROD, errs); m_truncatedRODNumber++; return sc; } - if ((((*rob_status) >> 29) & 0x1) or (((*rob_status) >> 31) & 0x1)) { - ATH_MSG_DEBUG("ROB status word for robid " << std::hex << robid << std::dec << " indicates resource was masked off."); - addRODError(robid, SCT_ByteStreamErrors::MaskedROD, errs); + if ((((*robStatus) >> 29) & 0x1) or (((*robStatus) >> 31) & 0x1)) { + ATH_MSG_DEBUG("ROB status word for robID " << std::hex << robID + << std::dec << " indicates resource was masked off."); + addRODError(robID, SCT_ByteStreamErrors::MaskedROD, errs); m_maskedRODNumber++; return sc; } } } - /// look at ROD status words ///////// - - OFFLINE_FRAGMENTS_NAMESPACE::PointerType vRodStatus; - const long unsigned int vRodStatusSize{robFrag.rod_nstatus()}; - - robFrag.rod_status(vRodStatus); - for (long unsigned int j{0}; j<vRodStatusSize; j++) { - const uint32_t statusWord{vRodStatus[j]}; - /** check for clock errors in second ROD status word */ - if (j==1) { + // Look at ROD status words + OFFLINE_FRAGMENTS_NAMESPACE::PointerType vecRODStatus; + const long unsigned int vecRODStatusSize{robFrag.rod_nstatus()}; + + robFrag.rod_status(vecRODStatus); + for (long unsigned int i{0}; i<vecRODStatusSize; i++) { + const uint32_t statusWord{vecRODStatus[i]}; + // Check for clock errors in second ROD status word + if (i==1) { const int timClockError{static_cast<int>((statusWord >> 16) & 0x1)}; const int bocClockError{static_cast<int>((statusWord >> 17) & 0x1)}; if (timClockError or bocClockError) { ATH_MSG_DEBUG(" Clock error in ROD status word: " << timClockError << " " << bocClockError); - addRODError(robid, SCT_ByteStreamErrors::RODClockError, errs); - m_RODClockErrorNumber++; + addRODError(robID, SCT_ByteStreamErrors::RODClockError, errs); + m_rodClockErrorNumber++; sc=StatusCode::RECOVERABLE; } - /** look at bits 20-23 for DCS HV */ + // Look at bits 20-23 for DCS HV const int hvBits{static_cast<int>((statusWord >> 20) & 0xf)}; const bool hvOn{hvBits==0xf}; - if (bsFracCont) bsFracCont->insert(SCT_ByteStreamFractionContainer::HVOn, robid, hvOn); + if (bsFracCont) bsFracCont->insert(SCT_ByteStreamFractionContainer::HVOn, robID, hvOn); } } - /** now look at the data words */ - + // Now look at the data words bool foundHeader{false}; - OFFLINE_FRAGMENTS_NAMESPACE::PointerType vRobData; - const unsigned long int vRobDataSize{robFrag.rod_ndata()}; - robFrag.rod_data(vRobData); + OFFLINE_FRAGMENTS_NAMESPACE::PointerType vecROBData; + const unsigned long int vecROBDataSize{robFrag.rod_ndata()}; + robFrag.rod_data(vecROBData); - for (unsigned long int i{0}; i<vRobDataSize; i++) { - wordcount++; - robData.word32 = vRobData[i]; - /** the data is 16-bits wide packed to a 32-bit word (rob_it1). So we unpack it here. */ - uint16_t d[2]; - d[1] = robData.word16[0]; - d[0] = robData.word16[1]; + for (unsigned long int i{0}; i<vecROBDataSize; i++) { + wordCount++; + robData.word32 = vecROBData[i]; + // The data is 16-bits wide packed to a 32-bit word (rob_it1). So we unpack it here. + uint16_t data16[2]; + data16[1] = robData.word16[0]; + data16[0] = robData.word16[1]; for (n=0; n<2; n++) { - ///--------------------------------------------------------------------- - /// hit element - ///--------------------------------------------------------------------- - if (d[n]&0x8000) { + // Hit element + if (data16[n]&0x8000) { if (not foundHeader) { - ATH_MSG_INFO(" Missing link header in ROD " << std::hex << robid << std::dec); - addRODError(robid, SCT_ByteStreamErrors::MissingLinkHeaderError, errs); + ATH_MSG_INFO(" Missing link header in ROD " << std::hex << robID << std::dec); + addRODError(robID, SCT_ByteStreamErrors::MissingLinkHeaderError, errs); m_numMissingLinkHeader++; sc = StatusCode::RECOVERABLE; continue; @@ -267,166 +334,172 @@ SCT_RodDecoder::fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& r m_nHits++; if (superCondensedMode) { - - /** super-condensed mode - * chip info : 4 bits d[n]>>11)0xF - * chip number == (d[n]>>11)&0x7 and chip side == (d[n]>>14)&0x1 - * For example if d[n]>>11)0xF = 0101 => chip5 or chip5 on side0, d[n]>>11)0xF = 1101 => chip13 or chip5 on side1 - */ - chip = ((d[n]>>11)&0x7); - side = ((d[n]>>14)&0x1); - strip = chip*128 + ((d[n]>>4)&0x7F); - tbin = 0x2; /** assuming tbin is 010 in super-condensed mode */ - nStripsInWord = (d[n]&0xf)+1; + // Super-condensed mode: + // Chip info: 4 bits data16[n]>>11)0xF + // Chip number == (data16[n]>>11)&0x7 + // Chip side == (data16[n]>>14)&0x1 + // For example if data16[n]>>11)0xF = 0101 => chip5 or chip5 on side0, data16[n]>>11)0xF = 1101 => chip13 or chip5 on side1 + chip = ((data16[n]>>11)&0x7); + side = ((data16[n]>>14)&0x1); + strip = chip*128 + ((data16[n]>>4)&0x7F); + timeBin = 0x2; // Assuming timeBin is 010 in super-condensed mode + nStripsInWord = (data16[n]&0xf)+1; if (chip>5) { - ATH_MSG_DEBUG(" Hit super-condensed : xxx Chip number = " << chip << " > 5 " << " for hit " << std::hex << d[n]); - m_chip_number_error++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + ATH_MSG_DEBUG(" Hit super-condensed : xxx Chip number = " << chip << " > 5 " << " for hit " + << std::hex << data16[n]); + m_chipNumberError++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); sc=StatusCode::RECOVERABLE; continue; } - /**------------ Search for redundancy only for the master chip */ - if ((side==1) and ((linkNb%2)==0)) { - if (((strip!=oldstrip) or (side!=oldside)) and (groupSize>0)) { /** if it is a new cluster, - * make RDO with the previous cluster */ - const int rdoMade{makeRDO(oldstrip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + // Search for redundancy only for the master chip + if ((side==1) and ((linkNumber%2)==0)) { + if (((strip!=oldStrip) or (side!=oldSide)) and (groupSize>0)) { + // If it is a new cluster, make RDO with the previous cluster + const int rdoMade{makeRDO(oldStrip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { - saved[oldside*768+oldstrip] = rdoMade; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { + saved[oldSide*768+oldStrip] = rdoMade; } - oldstrip = strip; - oldside = side; + oldStrip = strip; + oldSide = side; groupSize = 0; } - linkNb++; + linkNumber++; } - if ((side==0) and ((linkNb%2)!=0)) { - if (((strip!=oldstrip) or (side!=oldside)) and (groupSize>0)) { /** if it is a new cluster, - * make RDO with the previous cluster */ - const int rdoMade{makeRDO(oldstrip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + if ((side==0) and ((linkNumber%2)!=0)) { + if (((strip!=oldStrip) or (side!=oldSide)) and (groupSize>0)) { + // If it is a new cluster, make RDO with the previous cluster + const int rdoMade{makeRDO(oldStrip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { - saved[oldside*768+oldstrip] = rdoMade; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { + saved[oldSide*768+oldStrip] = rdoMade; } - oldstrip = strip; - oldside = side; + oldStrip = strip; + oldSide = side; groupSize = 0; } - linkNb--; + linkNumber--; } - onlineId = ((robid & 0xFFFFFF)|(linkNb << 24)); + onlineID = ((robID & 0xFFFFFF)|(linkNumber << 24)); if (groupSize == 0) { - oldstrip = strip; /** if it's the first super-condensed word */ - oldside = side; + oldStrip = strip; // If it's the first super-condensed word + oldSide = side; } - if ((strip!=oldstrip) or (side!=oldside)) { - /** if it is a new cluster, - * make RDO with the previous cluster */ - const int rdoMade{makeRDO(oldstrip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + if ((strip!=oldStrip) or (side!=oldSide)) { + // If it is a new cluster, make RDO with the previous cluster + const int rdoMade{makeRDO(oldStrip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { - saved[oldside*768+oldstrip] = rdoMade; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { + saved[oldSide*768+oldStrip] = rdoMade; } - oldstrip = strip; - oldside = side; + oldStrip = strip; + oldSide = side; groupSize = 0; } groupSize+=nStripsInWord; // Split clusters have the same strip number. - } else if (condensedMode) { - - /** condensed mode - * chip info : 4 bits d[n]>>11)0xF - * chip number == (d[n]>>11)&0x7 and chip side == (d[n]>>14)&0x1 - * For example if d[n]>>11)0xF = 0101 => chip5 or chip5 on side0, d[n]>>11)0xF = 1101 => chip13 or chip5 on side1 - */ - chip = ((d[n]>>11)&0x7); - side = ((d[n]>>14)&0x1); - strip = chip*128 + ((d[n]>>4)&0x7F); - tbin = 0x2; /** assuming tbin is 010 in condensed mode */ + } + else if (condensedMode) { + // Super-condensed mode: + // Chip info: 4 bits data16[n]>>11)0xF + // Chip number == (data16[n]>>11)&0x7 + // Chip side == (data16[n]>>14)&0x1 + // For example if data16[n]>>11)0xF = 0101 => chip5 or chip5 on side0, data16[n]>>11)0xF = 1101 => chip13 or chip5 on side1 + chip = ((data16[n]>>11)&0x7); + side = ((data16[n]>>14)&0x1); + strip = chip*128 + ((data16[n]>>4)&0x7F); + timeBin = 0x2; // Assuming timeBin is 010 in condensed mode if (chip>5) { - ATH_MSG_DEBUG(" Hit condensed : xxx Chip number = " << chip << " > 5 " << " for hit " << std::hex << d[n]); - m_chip_number_error++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + ATH_MSG_DEBUG(" Hit condensed : xxx Chip number = " << chip << " > 5 " << " for hit " + << std::hex << data16[n]); + m_chipNumberError++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); sc=StatusCode::RECOVERABLE; continue; } - /**------------ Search for redundancy only for the master chip */ - if ((side==1) and ((linkNb%2)==0)) { - if (((strip!=oldstrip) or (side!=oldside)) and (groupSize>0)) { /** if it is a new cluster, - * make RDO with the previous cluster */ - const int rdoMade{makeRDO(oldstrip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + // Search for redundancy only for the master chip + if ((side==1) and ((linkNumber%2)==0)) { + if (((strip!=oldStrip) or (side!=oldSide)) and (groupSize>0)) { + // If it is a new cluster, make RDO with the previous cluster + const int rdoMade{makeRDO(oldStrip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { - saved[oldside*768+oldstrip] = rdoMade; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { + saved[oldSide*768+oldStrip] = rdoMade; } - oldstrip = strip; - oldside = side; + oldStrip = strip; + oldSide = side; groupSize = 0; } - linkNb++; + linkNumber++; } - if ((side==0) and ((linkNb%2)!=0)) { - if (((strip!=oldstrip) or (side!=oldside)) and (groupSize>0)) { /** if it is a new cluster, - * make RDO with the previous cluster */ - const int rdoMade{makeRDO(oldstrip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + if ((side==0) and ((linkNumber%2)!=0)) { + if (((strip!=oldStrip) or (side!=oldSide)) and (groupSize>0)) { + // If it is a new cluster, make RDO with the previous cluster + const int rdoMade{makeRDO(oldStrip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { - saved[oldside*768+oldstrip] = rdoMade; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { + saved[oldSide*768+oldStrip] = rdoMade; } - oldstrip = strip; - oldside = side; + oldStrip = strip; + oldSide = side; groupSize = 0; } - linkNb--; + linkNumber--; } - onlineId = ((robid & 0xFFFFFF)|(linkNb << 24)); + onlineID = ((robID & 0xFFFFFF)|(linkNumber << 24)); if (groupSize == 0) { - oldstrip = strip; /** if it's the first condensed word */ - oldside = side; + oldStrip = strip; // If it's the first condensed word + oldSide = side; } - if (not (d[n]&0x1)) { /** 1-hit */ + if (not (data16[n]&0x1)) { // 1-hit m_singleCondHitNumber++; - if ((strip!=oldstrip) or (side!=oldside)) { - /** if it is a new cluster, - * make RDO with the previous cluster */ - const int rdoMade{makeRDO(oldstrip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + if ((strip!=oldStrip) or (side!=oldSide)) { + // If it is a new cluster, make RDO with the previous cluster + const int rdoMade{makeRDO(oldStrip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { - saved[oldside*768+oldstrip] = rdoMade; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { + saved[oldSide*768+oldStrip] = rdoMade; } - oldstrip = strip; - oldside = side; + oldStrip = strip; + oldSide = side; groupSize = 0; } - if (d[n]&0x4) { /** Error in the hit */ - ATH_MSG_DEBUG(" Hit condensed : xxx ERROR in 1-hit " << std::hex << d[n]); + if (data16[n]&0x4) { // Error in the hit + ATH_MSG_DEBUG(" Hit condensed : xxx ERROR in 1-hit " << std::hex << data16[n]); errorHit.push_back(groupSize); - ERRORS = (ERRORS | 0x10); - m_cond_hit1_error++; + errors = (errors | 0x10); + m_condHit1Error++; sc=StatusCode::RECOVERABLE; } groupSize = (groupSize>=2 ? groupSize : 1); - } else { /** 2-hits */ + } + else { // 2-hits if (strip > 767) { - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); sc=StatusCode::RECOVERABLE; ATH_MSG_DEBUG("Condensed mode - strip number out of range"); @@ -434,79 +507,81 @@ SCT_RodDecoder::fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& r continue; } m_pairedCondHitNumber++; - if ((strip!=oldstrip) or (side!=oldside)) { /** if it is a new cluster, - * make RDO with the previous cluster - */ - const int rdoMade{makeRDO(oldstrip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + if ((strip!=oldStrip) or (side!=oldSide)) { + // If it is a new cluster, make RDO with the previous cluster + const int rdoMade{makeRDO(oldStrip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { - saved[oldside*768+oldstrip] = rdoMade; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { + saved[oldSide*768+oldStrip] = rdoMade; } - oldstrip = strip; - oldside = side; + oldStrip = strip; + oldSide = side; groupSize = 0; } - if (d[n]&0x4) { /** Error in the first hit */ - ATH_MSG_DEBUG(" Hit condensed : xxx ERROR in 1st hit" << std::hex << d[n]); + if (data16[n]&0x4) { // Error in the first hit + ATH_MSG_DEBUG(" Hit condensed : xxx ERROR in 1st hit" << std::hex << data16[n]); errorHit.push_back(groupSize); - m_cond_hit1_error++; - ERRORS = (ERRORS | 0x10); + m_condHit1Error++; + errors = (errors | 0x10); sc=StatusCode::RECOVERABLE; } - if (d[n]&0x8) { /** Error in the second hit */ - ATH_MSG_DEBUG(" Hit condensed : xxx ERROR in 2nd hit" << std::hex << d[n]); + if (data16[n]&0x8) { // Error in the second hit + ATH_MSG_DEBUG(" Hit condensed : xxx ERROR in 2nd hit" << std::hex << data16[n]); errorHit.push_back(groupSize); - m_cond_hit2_error++; - ERRORS = (ERRORS | 0x20); + m_condHit2Error++; + errors = (errors | 0x20); sc=StatusCode::RECOVERABLE; } groupSize = 2; } - } else { - /** Expanded mode - * chip info from the first word of expanded cluster : 4 bits d[n]>>11)0xF - * chip number == (d[n]>>11)&0x7 and chip side == (d[n]>>14)&0x1 - * For example if d[n]>>11)0xF = 0101 => chip5 or chip5 on side0, d[n]>>11)0xF = 1101 => chip13 or chip5 on side1 - */ - - if (not (d[n]&0x8)) { /** 1st hit cluster expanded */ + } + else { + // Expanded mode: + // Chip info from the first word of expanded cluster : 4 bits data16[n]>>11)0xF + // Chip number == (data16[n]>>11)&0x7 + // Chip side == (data16[n]>>14)&0x1 + // For example if data16[n]>>11)0xF = 0101 => chip5 or chip5 on side0, data16[n]>>11)0xF = 1101 => chip13 or chip5 on side1 + if (not (data16[n]&0x8)) { // 1st hit cluster expanded m_firstExpHitNumber++; - chip = ((d[n]>>11)&0x7); - side = ((d[n]>>14)&0x1); - strip = chip*128 + ((d[n]>>4)&0x7F); - tbin = d[n]&0x7; /** Real way for obtaining tbin info */ + chip = ((data16[n]>>11)&0x7); + side = ((data16[n]>>14)&0x1); + strip = chip*128 + ((data16[n]>>4)&0x7F); + timeBin = data16[n]&0x7; // Real way for obtaining timeBin info if (chip>5) { ATH_MSG_DEBUG("Expanded hit: First hit xxx ERROR chip Nb = " << chip << " > 5"); - m_chip_number_error++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + m_chipNumberError++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); continue; } - /** -------------- Search for redundancy only for the master chip */ - if ((side==1) and ((linkNb%2)==0)) { - linkNb++; + // Search for redundancy only for the master chip + if ((side==1) and ((linkNumber%2)==0)) { + linkNumber++; } - if ((side==0) and ((linkNb%2)!=0)) { - linkNb--; + if ((side==0) and ((linkNumber%2)!=0)) { + linkNumber--; } - onlineId = ((robid & 0xFFFFFF) | (linkNb << 24)); + onlineID = ((robID & 0xFFFFFF) | (linkNumber << 24)); groupSize = 1; - const int rdoMade{makeRDO(strip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + const int rdoMade{makeRDO(strip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { saved[side*768+strip] = rdoMade; } groupSize = 0; - } else { /** next hits cluster expanded */ - if (d[n]&0x80) { /** paired hits */ + } + else { // Next hits cluster expanded + if (data16[n]&0x80) { // Paired hits if (strip > 767) { - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); sc=StatusCode::RECOVERABLE; ATH_MSG_DEBUG("Expanded mode - strip number out of range"); continue; @@ -514,182 +589,181 @@ SCT_RodDecoder::fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& r m_evenExpHitNumber++; if (chip>5) { ATH_MSG_DEBUG("Expanded Hit: paired hits xxx ERROR chip Nb = " << chip << " > 5"); - m_chip_number_error++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + m_chipNumberError++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); continue; } - /** first hit from the pair */ + // First hit from the pair strip++; - tbin = d[n]&0x7; + timeBin = data16[n]&0x7; groupSize = 1; - const int rdoMade1{makeRDO(strip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + const int rdoMade1{makeRDO(strip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade1 == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { saved[side*768+strip] = rdoMade1; } - /** second hit from the pair */ + // Second hit from the pair strip++; - tbin = ((d[n] >> 4) & 0x7); - const int rdoMade2{makeRDO(strip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + timeBin = ((data16[n] >> 4) & 0x7); + const int rdoMade2{makeRDO(strip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade2 == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { saved[side*768+strip] = rdoMade2; } groupSize = 0; - } else { /** Last hit of the cluster */ + } + else { // Last hit of the cluster m_lastExpHitNumber++; if (chip>5) { ATH_MSG_DEBUG("Expanded Hit: last hit xxx ERROR chip Nb = " << chip << " > 5"); - m_chip_number_error++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + m_chipNumberError++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); continue; } strip++; - tbin = (d[n]&0x7); + timeBin = (data16[n]&0x7); groupSize = 1; - const int rdoMade{makeRDO(strip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + const int rdoMade{makeRDO(strip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { saved[side*768+strip] = rdoMade; } groupSize = 0; } } - } // end expanded mode - }// end of hit element + } // End expanded mode + } // End of hit element - ///--------------------------------------------------------------------- - /// Header - ///--------------------------------------------------------------------- - else if (((d[n]>>13)&0x7) == 0x1) { + // Header + else if (((data16[n]>>13)&0x7) == 0x1) { foundHeader=true; - m_headnumber++; - if (saved[side*768+strip]==false and oldstrip>=0) { - const int rdoMade{makeRDO(strip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + m_headNumber++; + if (saved[side*768+strip]==false and oldStrip>=0) { + const int rdoMade{makeRDO(strip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { saved[side*768+strip] = rdoMade; } } - /** Everything is set to default for a new hunt of RDO */ + // Everything is set to default for a new hunt of RDO strip =0; - oldstrip = -1; - oldside = -1; + oldStrip = -1; + oldSide = -1; groupSize = 0; - ERRORS = 0; + errors = 0; memset(saved,0,768*2); errorHit.clear(); - /** Link Number (or stream) in the ROD fragment */ - const int rodlinkNb{static_cast<int>(d[n] & 0x7F)}; + // Link Number (or stream) in the ROD fragment + const int rodlinkNumber{static_cast<int>(data16[n] & 0x7F)}; - /** This is the real calculation for the offline */ - linkNb = (((rodlinkNb >>4)&0x7)*12+(rodlinkNb &0xF)); - onlineId = ((robid & 0xFFFFFF)|(linkNb << 24)); - if ((onlineId ==0) or (linkNb > 95)) { - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + // This is the real calculation for the offline + linkNumber = (((rodlinkNumber >>4)&0x7)*12+(rodlinkNumber &0xF)); + onlineID = ((robID & 0xFFFFFF)|(linkNumber << 24)); + if ((onlineID ==0) or (linkNumber > 95)) { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); sc=StatusCode::RECOVERABLE; - ATH_MSG_DEBUG("Header: xxx Link nb out of range (skipping following data)" << std::dec << linkNb); + ATH_MSG_DEBUG("Header: xxx Link number out of range (skipping following data)" + << std::dec << linkNumber); break; - } else { - currentLinkIdHash = m_cabling->getHashFromOnlineId(onlineId); + } + else { + currentLinkIDHash = m_cabling->getHashFromOnlineId(onlineID); } - /// look for masked off links - bit 7 - if (d[n] >> 7 & 0x1) { - ATH_MSG_DEBUG("Masked link " << onlineId << " " << currentLinkIdHash); - //no counter increment here, is that correct? (sar) - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::MaskedLink, errs); + // Look for masked off links - bit 7 + if (data16[n] >> 7 & 0x1) { + ATH_MSG_DEBUG("Masked link " << onlineID << " " << currentLinkIDHash); + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::MaskedLink, errs); sc=StatusCode::RECOVERABLE; } - if (d[n]&0x800) { - ATH_MSG_DEBUG(" Header: xxx TimeOut Error " << currentLinkIdHash); - m_head_error_timeout++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::TimeOutError, errs); + if (data16[n]&0x800) { + ATH_MSG_DEBUG(" Header: xxx TimeOut Error " << currentLinkIDHash); + m_headErrorTimeout++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::TimeOutError, errs); sc=StatusCode::RECOVERABLE; } - if (d[n]&0x1000) { - ATH_MSG_DEBUG(" Header: xxx Preamble Error " << currentLinkIdHash); - m_head_error_preamb++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::PreambleError, errs); + if (data16[n]&0x1000) { + ATH_MSG_DEBUG(" Header: xxx Preamble Error " << currentLinkIDHash); + m_headErrorPreamble++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::PreambleError, errs); sc=StatusCode::RECOVERABLE; } - if (d[n]&0x400) { - ATH_MSG_DEBUG(" Header: xxx LVL1 ID Error " << currentLinkIdHash); - m_head_error_lvl1id++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::LVL1IDError, errs); + if (data16[n]&0x400) { + ATH_MSG_DEBUG(" Header: xxx LVL1 ID Error " << currentLinkIDHash); + m_headErrorLvl1ID++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::LVL1IDError, errs); sc=StatusCode::RECOVERABLE; } - if (d[n]&0x200) { - ATH_MSG_DEBUG(" Header: xxx BCID Error " << currentLinkIdHash); - m_head_error_bcid++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::BCIDError, errs); + if (data16[n]&0x200) { + ATH_MSG_DEBUG(" Header: xxx BCID Error " << currentLinkIDHash); + m_headErrorBCID++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::BCIDError, errs); sc=StatusCode::RECOVERABLE; } - if ((d[n]&0xF) > 11) { - ATH_MSG_DEBUG(" Header: xxx Error in formatter " << currentLinkIdHash); - m_head_error_formatter++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::FormatterError, errs); + if ((data16[n]&0xF) > 11) { + ATH_MSG_DEBUG(" Header: xxx Error in formatter " << currentLinkIDHash); + m_headErrorFormatter++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::FormatterError, errs); sc=StatusCode::RECOVERABLE; } - condensedMode = static_cast<bool>(d[n]&0x100); + condensedMode = static_cast<bool>(data16[n]&0x100); continue; - } // end header + } // End header - ///--------------------------------------------------------------------- - /// trailer - ///--------------------------------------------------------------------- - else if (((d[n]>>13)&0x7) == 0x2) { + // Trailer + else if (((data16[n]>>13)&0x7) == 0x2) { foundHeader=false; - m_trailnumber++; - //ErrorTrailer = false; + m_trailerNumber++; - if (d[n]&0x1000) { - //ErrorTrailer = true; - ATH_MSG_DEBUG(" Trailer: xxx Trailer ERROR " << std::hex << d[n]); - m_trail_error_bit++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::TrailerError, errs); + if (data16[n]&0x1000) { + ATH_MSG_DEBUG(" Trailer: xxx Trailer ERROR " << std::hex << data16[n]); + m_trailerErrorBit++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::TrailerError, errs); sc=StatusCode::RECOVERABLE; } - if (d[n]&0x800) { - //ErrorTrailer = true; - /** no data should appear between header and trailer - See 1.2.2 Formatter FPGA - Serial Data Decoding and Formatting of - http://www-eng.lbl.gov/~jmjoseph/Atlas-SiROD/Manuals/usersManual-v164.pdf */ - ATH_MSG_DEBUG(" Trailer: xxx Header-Trailer limit ERROR " << std::hex << d[n]); - m_trail_error_limit++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::HeaderTrailerLimitError, errs); + if (data16[n]&0x800) { + // No data should appear between header and trailer + // See 1.2.2 Formatter FPGA - Serial Data Decoding and Formatting of + // http://www-eng.lbl.gov/~jmjoseph/Atlas-SiROD/Manuals/usersManual-v164.pdf + ATH_MSG_DEBUG(" Trailer: xxx Header-Trailer limit ERROR " << std::hex << data16[n]); + m_trailerErrorLimit++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::HeaderTrailerLimitError, errs); sc=StatusCode::RECOVERABLE; } - if (d[n]&0x400) { - //ErrorTrailer = true; /** not sure if there are hit elements before (probably yes but in principle they are fine) */ - ATH_MSG_DEBUG(" Trailer: xxx Data Overflow ERROR " << std::hex << d[n]); - m_trail_error_overflow++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::TrailerOverflowError, errs); + if (data16[n]&0x400) { + // Not sure if there are hit elements before (probably yes but in principle they are fine) + ATH_MSG_DEBUG(" Trailer: xxx Data Overflow ERROR " << std::hex << data16[n]); + m_trailerErrorOverflow++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::TrailerOverflowError, errs); sc=StatusCode::RECOVERABLE; } - if (d[n] & 0xF) { - // fisrt temporarily masked chip information + if (data16[n] & 0xF) { + // First temporarily masked chip information // 0 means no masked chip (always has been 0 until April 2017) // // If Rx redundacy is not used, @@ -709,274 +783,289 @@ SCT_RodDecoder::fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& r // 6 means chip 5 is temporarily masked. // 7 means chips 6-11, 0-5 are temporarily masked. // 12 means chips 11, 0-5 are temporarily masked. - setFirstTempMaskedChip(currentLinkIdHash, (d[n] & 0xF), errs); + setFirstTempMaskedChip(currentLinkIDHash, (data16[n] & 0xF), errs); } continue; } - ///--------------------------------------------------------------------- - /// FlaggedABCD error - /// 000xxxxxxFFFFEEE - /// 000: FlaggedABCD error: xxxxxxx not used, FFFF: chip, EEE: error code - ///--------------------------------------------------------------------- - else if (((d[n]>>13)&0x7) == 0x0) { - chip = ((d[n]>>3)&0xF); - ABCerror = d[n]&0x7; - /** no data should appear for that chip but how do we - * want to transmit this information ? */ - IdentifierHash flagIdHash{0}; - if (onlineId == 0) { - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + // FlaggedABCD error + // 000xxxxxxFFFFEEE + // 000: FlaggedABCD error: xxxxxxx not used, FFFF: chip, EEE: error code + else if (((data16[n]>>13)&0x7) == 0x0) { + chip = ((data16[n]>>3)&0xF); + abcError = data16[n]&0x7; + // No data should appear for that chip but how do we want to transmit this information? + IdentifierHash flagIDHash{0}; + if (onlineID == 0) { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); continue; - } else { - flagIdHash = m_cabling->getHashFromOnlineId(onlineId); + } + else { + flagIDHash = m_cabling->getHashFromOnlineId(onlineID); } - ATH_MSG_DEBUG(" xxx Flagged ABCD ERROR in chip " << chip << " Error code ABCerror " << ABCerror << " Link Nb (or Stream) "<<linkNb); - m_flag_error_bit++; + ATH_MSG_DEBUG(" xxx Flagged ABCD ERROR in chip " << chip + << " Error code abcError " << abcError << " Link Number (or Stream) "<<linkNumber); + m_flagErrorBit++; // Error code of ABCD error should be 1, 2, 4 or 7. - if (ABCerror!=0x1 and ABCerror!=0x2 and ABCerror!=0x4 and ABCerror!=0x7) { - ATH_MSG_DEBUG("ABCD error has an invalid error code " << ABCerror << - " the 16-bit word is 0x" << std::hex << d[n] << std::dec << " for hash " << flagIdHash); - addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Invalid, errs); - } else { + if (abcError!=0x1 and abcError!=0x2 and abcError!=0x4 and abcError!=0x7) { + ATH_MSG_DEBUG("ABCD error has an invalid error code " << abcError + << " the 16-bit word is 0x" << std::hex << data16[n] << std::dec + << " for hash " << flagIDHash); + addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Invalid, errs); + } + else { // Chip is 4 bits. The highest bit 3 represents side. Chip 0-5 on side 0 and chip 8-13 on side 1. - const unsigned int side_ABCDError{static_cast<unsigned int>(chip/8)}; - if (flagIdHash.value()%2!=side_ABCDError) { + const unsigned int sideABCDError{static_cast<unsigned int>(chip/8)}; + if (flagIDHash.value()%2!=sideABCDError) { // If the sides from the ABCD error and online ID are different, // the module is expected to read side 0 via link 1 and side 1 and via link 0. // Hash Id is flipped. - ATH_MSG_DEBUG("ABCD error and online ID have different side information for hash " << flagIdHash << ". " << - side_ABCDError << " from ABCD error and " << flagIdHash.value()%2 << " from online ID"); - flagIdHash = (flagIdHash.value()/2)*2+side_ABCDError; + ATH_MSG_DEBUG("ABCD error and online ID have different side information for hash " << flagIDHash << ". " + << sideABCDError << " from ABCD error and " << flagIDHash.value()%2 << " from online ID"); + flagIDHash = (flagIDHash.value()/2)*2+sideABCDError; } // Chip should be 0-5 or 8-13. if (chip%8>=6) { - ATH_MSG_DEBUG("ABCD error has an invalid chip 0x" << std::hex << chip << std::dec << - " the 16-bit word is 0x" << std::hex << d[n] << std::dec << - " for hash " << flagIdHash.value()); - addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Invalid, errs); - } else { - if ( ABCerror==0x1) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Error1, errs); - else if (ABCerror==0x2) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Error2, errs); - else if (ABCerror==0x4) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Error4, errs); - else if (ABCerror==0x7) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Error7, errs); - if ( chip%8==0) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Chip0, errs); - else if (chip%8==1) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Chip1, errs); - else if (chip%8==2) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Chip2, errs); - else if (chip%8==3) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Chip3, errs); - else if (chip%8==4) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Chip4, errs); - else if (chip%8==5) addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError_Chip5, errs); + ATH_MSG_DEBUG("ABCD error has an invalid chip 0x" << std::hex << chip << std::dec + << " the 16-bit word is 0x" << std::hex << data16[n] << std::dec + << " for hash " << flagIDHash.value()); + addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Invalid, errs); + } + else { + if ( abcError==0x1) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Error1, errs); + else if (abcError==0x2) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Error2, errs); + else if (abcError==0x4) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Error4, errs); + else if (abcError==0x7) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Error7, errs); + if ( chip%8==0) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Chip0, errs); + else if (chip%8==1) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Chip1, errs); + else if (chip%8==2) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Chip2, errs); + else if (chip%8==3) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Chip3, errs); + else if (chip%8==4) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Chip4, errs); + else if (chip%8==5) addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError_Chip5, errs); } } - addSingleError(flagIdHash, SCT_ByteStreamErrors::ABCDError, errs); + addSingleError(flagIDHash, SCT_ByteStreamErrors::ABCDError, errs); sc=StatusCode::RECOVERABLE; continue; - } else if (((d[n]>>13)&0x7) == 0x3) { - ///--------------------------------------------------------------------- - /// Raw Data - ///--------------------------------------------------------------------- - IdentifierHash rawIdHash{0}; - if (onlineId == 0) { - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else if (((data16[n]>>13)&0x7) == 0x3) { + // Raw Data + IdentifierHash rawIDHash{0}; + if (onlineID == 0) { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); continue; - } else { - rawIdHash = m_cabling->getHashFromOnlineId(onlineId); + } + else { + rawIDHash = m_cabling->getHashFromOnlineId(onlineID); } - ATH_MSG_DEBUG(" xxx Raw Data Mode " << std::hex << d[n] << std::dec << ": Config Data Mode "); - /** too many errors in the BS for the ROD to decode the data */ - m_config_data_bit++; - addSingleError(rawIdHash, SCT_ByteStreamErrors::RawError, errs); + ATH_MSG_DEBUG(" xxx Raw Data Mode " << std::hex << data16[n] << std::dec << ": Config Data Mode "); + // Too many errors in the BS for the ROD to decode the data + m_configDataBit++; + addSingleError(rawIDHash, SCT_ByteStreamErrors::RawError, errs); sc=StatusCode::RECOVERABLE; continue; - } else { + } + else { ATH_MSG_DEBUG("Data word format unknown "); - m_unknown_data_format++; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + m_unknownDataFormat++; + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); sc=StatusCode::RECOVERABLE; } - } //end of 16-bit word loop - } //end of 32-bit word loop + } // End of 16-bit word loop + } // End of 32-bit word loop - /** create RDO of the last ink or stream of the event */ - if (saved[side*768+strip]==false and oldstrip>=0) { - const int rdoMade{makeRDO(strip, groupSize, tbin, onlineId, ERRORS, rdoIdc, cache, errorHit)}; + // Create RDO of the last ink or stream of the event + if (saved[side*768+strip]==false and oldStrip>=0) { + const int rdoMade{makeRDO(strip, groupSize, timeBin, onlineID, errors, rdoIDCont, cache, errorHit)}; if (rdoMade == -1) { sc=StatusCode::RECOVERABLE; - addSingleError(currentLinkIdHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); - } else { + addSingleError(currentLinkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs); + } + else { saved[side*768+strip] = rdoMade; } } - if (bsFracCont) bsFracCont->insert(SCT_ByteStreamFractionContainer::CondensedMode, robid, condensedMode); + if (bsFracCont) bsFracCont->insert(SCT_ByteStreamFractionContainer::CondensedMode, robID, condensedMode); if (sc.isFailure()) ATH_MSG_DEBUG("One or more ByteStream errors found "); return sc; } -/** makeRDO has 3 possible return values: - * 1 if RDO was successfully created, - * 0 if collection was deliberately skipped (for trigger) - * -1 if there was an error in the decoding - will be passed - * on as StatusCode::RECOVERABLE by fillCollection(). - */ - -int SCT_RodDecoder::makeRDO(int strip, int groupSize, int tbin, uint32_t onlineId, int ERRORS, - ISCT_RDO_Container& rdoIdc, + +// makeRDO method + +int SCT_RodDecoder::makeRDO(int strip, int groupSize, int timeBin, uint32_t onlineID, int errors, + ISCT_RDO_Container& rdoIDCont, CacheHelper& cache, const std::vector<int>& errorHit) const { - if (onlineId == 0x0) { + if (onlineID == 0x0) { ATH_MSG_WARNING("No link header found, possibly corrupt ByteStream. Will not try to make RDO"); return -1; } - /** get offlineId from the link number and ROB number */ - const IdentifierHash idCollHash{m_cabling->getHashFromOnlineId(onlineId)}; - if (not idCollHash.is_valid()) { - m_numUnknownOfflineId++; + // Get offlineId from the link number and ROB number + const IdentifierHash collIDHash{m_cabling->getHashFromOnlineId(onlineID)}; + if (not collIDHash.is_valid()) { + m_numUnknownOfflineID++; ATH_MSG_ERROR("Unknown OfflineId for OnlineId -> cannot create RDO"); - ATH_MSG_WARNING("Unknown OfflineId for OnlineId " << std::hex << onlineId << " -> cannot create RDO" << std::dec); + ATH_MSG_WARNING("Unknown OfflineId for OnlineId " << std::hex << onlineID + << " -> cannot create RDO" << std::dec); return -1; } if (((strip & 0x7f) + (groupSize-1) > 127) or (strip<0) or (strip>767)) { - ATH_MSG_WARNING("Cluster with " << groupSize << " strips, starting at strip " << strip << " in collection " << idCollHash << " out of range. Will not make RDO"); + ATH_MSG_WARNING("Cluster with " << groupSize << " strips, starting at strip " << strip + << " in collection " << collIDHash << " out of range. Will not make RDO"); return -1; } - /** this option is for the trigger, if there is a vecHash* given, test it ! */ + // This option is for the trigger, if there is a vecHash* given, test it! if (cache.vecHash) { - if (idCollHash == cache.skipHash) { + if (collIDHash == cache.skipHash) { ATH_MSG_VERBOSE("Collection for Hash not to be decoded, skip"); return 0; - } else if (idCollHash != cache.lastHash) { - cache.lastHash = idCollHash; - /** maybe the new hash is not in the list, so test it */ - std::vector<IdentifierHash>::const_iterator p{find(cache.vecHash->begin(), cache.vecHash->end(), idCollHash)}; - if (p == cache.vecHash->end()) { + } + else if (collIDHash != cache.lastHash) { + cache.lastHash = collIDHash; + // Maybe the new hash is not in the list, so test it + std::vector<IdentifierHash>::const_iterator hashIDIterator{find(cache.vecHash->begin(), + cache.vecHash->end(), + collIDHash)}; + if (hashIDIterator == cache.vecHash->end()) { ATH_MSG_VERBOSE("Collection for Hash not to be decoded, skip"); - /** remember this one, so that we do not find(...) forever */ - cache.skipHash = idCollHash; + // Remember this one, so that we do not find(...) forever + cache.skipHash = collIDHash; return 0; } } } - if(rdoIdc.hasExternalCache() and rdoIdc.tryFetch(idCollHash)){ - ATH_MSG_DEBUG("Hash already in collection - cache hit " << idCollHash); + if(rdoIDCont.hasExternalCache() and rdoIDCont.tryFetch(collIDHash)){ + ATH_MSG_DEBUG("Hash already in collection - cache hit " << collIDHash); return 0; } - /** see if strips go from 0 to 767 or vice versa */ - if (m_swapPhiReadoutDirection[idCollHash]) { + // See if strips go from 0 to 767 or vice versa + if (m_swapPhiReadoutDirection[collIDHash]) { strip = 767 - strip; strip = strip-(groupSize-1); } - /** get identifier from the hash, this is not nice */ - const Identifier idColl{m_sct_id->wafer_id(idCollHash)}; - const Identifier iddigit{m_sct_id->strip_id(idColl, strip)}; - if (not m_sct_id->is_sct(iddigit)) { + // Get identifier from the hash, this is not nice + const Identifier collID{m_sctID->wafer_id(collIDHash)}; + const Identifier digitID{m_sctID->strip_id(collID, strip)}; + if (not m_sctID->is_sct(digitID)) { ATH_MSG_WARNING("Cluster with invalid Identifier. Will not make RDO"); return -1; } - const unsigned int rawDataWord{static_cast<unsigned int>(groupSize | (strip << 11) | (tbin <<22) | (ERRORS << 25))}; - ATH_MSG_DEBUG("Output Raw Data " << std::hex << " Coll " << idColl.getString() << ":-> " << m_sct_id->print_to_string(iddigit) << std::dec); + const unsigned int rawDataWord{static_cast<unsigned int>(groupSize | (strip << 11) | (timeBin <<22) | (errors << 25))}; + + ATH_MSG_DEBUG("Output Raw Data " << std::hex << " Coll " << collID.getString() + << ":-> " << m_sctID->print_to_string(digitID) << std::dec); - SCT_RDO_Collection* col{nullptr}; - ATH_CHECK(rdoIdc.naughtyRetrieve(idCollHash, col), 0); // Returns null if not present + SCT_RDO_Collection* sctRDOColl{nullptr}; + ATH_CHECK(rdoIDCont.naughtyRetrieve(collIDHash, sctRDOColl), 0); // Returns null if not present - if (col==nullptr) { - ATH_MSG_DEBUG(" Collection ID = " << idCollHash << " does not exist, create it "); - /** create new collection */ - col = new SCT_RDO_Collection(idCollHash); - col->setIdentifier(idColl); - StatusCode sc{rdoIdc.addCollection(col, idCollHash)}; - ATH_MSG_DEBUG("Adding " << idCollHash); + if (sctRDOColl==nullptr) { + ATH_MSG_DEBUG(" Collection ID = " << collIDHash << " does not exist, create it "); + // Create new collection + sctRDOColl = new SCT_RDO_Collection(collIDHash); + sctRDOColl->setIdentifier(collID); + StatusCode sc{rdoIDCont.addCollection(sctRDOColl, collIDHash)}; + ATH_MSG_DEBUG("Adding " << collIDHash); if (sc.isFailure()){ ATH_MSG_ERROR("failed to add SCT RDO collection to container"); } } - - /** Now the Collection is there for sure. Create RDO and push it - * into Collection. - */ + + // Now the Collection is there for sure. Create RDO and push it into Collection. m_nRDOs++; - col->push_back(std::make_unique<SCT3_RawData>(iddigit, rawDataWord, &errorHit)); + sctRDOColl->push_back(std::make_unique<SCT3_RawData>(digitID, rawDataWord, &errorHit)); return 1; } -void -SCT_RodDecoder::addRODError(uint32_t rodid, int errorType, - InDetBSErrContainer* errs) const +// addRODError method + +void SCT_RodDecoder::addRODError(uint32_t rodID, int errorType, + InDetBSErrContainer* errs) const { - std::vector<IdentifierHash> idHashes; - m_cabling->getHashesForRod(idHashes, rodid); - for (const IdentifierHash& hash: idHashes) { + std::vector<IdentifierHash> hashIDs; + m_cabling->getHashesForRod(hashIDs, rodID); + for (const IdentifierHash& hash: hashIDs) { addSingleError(hash, errorType, errs); } return; } -bool -SCT_RodDecoder::addSingleError(const IdentifierHash& idHash, - int bsErrorType, - InDetBSErrContainer* errs) const +// addSingleError method + +bool SCT_RodDecoder::addSingleError(const IdentifierHash& hashID, + int bsErrorType, + InDetBSErrContainer* errs) const { - const bool ok{idHash.is_valid() and errs!=nullptr}; + const bool ok{hashID.is_valid() and errs!=nullptr}; if (ok) { - errs->push_back(std::make_unique<std::pair<IdentifierHash, int> >(idHash, bsErrorType)); + errs->push_back(std::make_unique<std::pair<IdentifierHash, int> >(hashID, bsErrorType)); } return ok; } -void -SCT_RodDecoder::setFirstTempMaskedChip(const IdentifierHash& hashId, unsigned int firstTempMaskedChip, InDetBSErrContainer* errs) const { - if (not hashId.is_valid()) { - ATH_MSG_INFO("setFirstTempMaskedChip hashId " << hashId << " is invalid."); +// setFirstTempMaskedChip method + +void SCT_RodDecoder::setFirstTempMaskedChip(const IdentifierHash& hashID, + unsigned int firstTempMaskedChip, + InDetBSErrContainer* errs) const +{ + if (not hashID.is_valid()) { + ATH_MSG_INFO("setFirstTempMaskedChip hashID " << hashID << " is invalid."); return; } if (firstTempMaskedChip==0) { - ATH_MSG_WARNING("setFirstTempMaskedChip: firstTempMaskedChip should be greater than 0. firstTempMaskedChip is " << firstTempMaskedChip); + ATH_MSG_WARNING("setFirstTempMaskedChip: firstTempMaskedChip should be greater than 0. firstTempMaskedChip is " + << firstTempMaskedChip); return; } // wafer hash -> wafer id -> module id -> wafer hash on side-0, wafer hash on side-1 - const Identifier wafId{m_sct_id->wafer_id(hashId)}; - const Identifier moduleId{m_sct_id->module_id(wafId)}; + const Identifier waferID{m_sctID->wafer_id(hashID)}; + const Identifier moduleID{m_sctID->module_id(waferID)}; // Side 0 - IdentifierHash hash_side0; - m_sct_id->get_hash(moduleId, hash_side0, &m_cntx_sct); - unsigned int firstTempMaskedChip_side0{0}; - if (hashId==hash_side0) firstTempMaskedChip_side0 = firstTempMaskedChip; + IdentifierHash hashSide0; + m_sctID->get_hash(moduleID, hashSide0, &m_contextSCT); + unsigned int firstTempMaskedChipSide0{0}; + if (hashID==hashSide0) firstTempMaskedChipSide0 = firstTempMaskedChip; // Side 1 - IdentifierHash hash_side1; - m_sct_id->get_other_side(hash_side0, hash_side1); - unsigned int firstTempMaskedChip_side1{0}; - if (hashId==hash_side1) firstTempMaskedChip_side1 = firstTempMaskedChip; + IdentifierHash hashSide1; + m_sctID->get_other_side(hashSide0, hashSide1); + unsigned int firstTempMaskedChipSide1{0}; + if (hashID==hashSide1) firstTempMaskedChipSide1 = firstTempMaskedChip; int type{0}; // Check if Rx redundancy is used or not in this module - const std::pair<bool, bool> badLinks{m_configTool->badLinks(hashId)}; + const std::pair<bool, bool> badLinks{m_configTool->badLinks(hashID)}; if (badLinks.first xor badLinks.second) { // Rx redundancy is used in this module. if (badLinks.first and not badLinks.second) { // link-1 is broken type = 1; - } else if (badLinks.second and not badLinks.first) { + } + else if (badLinks.second and not badLinks.first) { // link-0 is broken type = 2; - } else if (badLinks.first and badLinks.second) { - // both link-0 and link-1 are working + } + else if (badLinks.first and badLinks.second) { + // Both link-0 and link-1 are working ATH_MSG_WARNING("setFirstTempMaskedChip: Both link-0 and link-1 are working. But Rx redundancy is used... Why?"); return; - } else { - // both link-0 and link-1 are broken + } + else { + // Both link-0 and link-1 are broken ATH_MSG_WARNING("setFirstTempMaskedChip: Both link-0 and link-1 are broken. But data are coming... Why?"); return; } @@ -987,7 +1076,7 @@ SCT_RodDecoder::setFirstTempMaskedChip(const IdentifierHash& hashId, unsigned in // modified0 and modified1 functions of SCT_ReadoutTool.cxx and // Table 3.8 of CERN-THESIS-2008-001 https://cds.cern.ch/record/1078223 // However, there are two exceptions of the exceptions. - const unsigned long long fullSerialNumber{m_cabling->getSerialNumberFromHash(hashId).to_ulonglong()}; + const unsigned long long fullSerialNumber{m_cabling->getSerialNumberFromHash(hashID).to_ulonglong()}; if (// Readout through link-0 fullSerialNumber==20220170200183 or // hash=4662 bec=0 layer=2 eta= 6 phi=39 fullSerialNumber==20220330200606 or // hash=5032 bec=0 layer=3 eta=-2 phi= 7 @@ -1032,7 +1121,7 @@ SCT_RodDecoder::setFirstTempMaskedChip(const IdentifierHash& hashId, unsigned in }; if (type==0) { - // both link-0 and link-1 are working + // Both link-0 and link-1 are working // Chips 0-5 are on side 0 and chips 6-11 are on side 1. // Normally, modules send hits on side 0 via link-0 and side 1 via link-1. @@ -1044,43 +1133,44 @@ SCT_RodDecoder::setFirstTempMaskedChip(const IdentifierHash& hashId, unsigned in // side 1 via link-0. If the first masked chip value on side 1 (0) is // between 1 to 6 (7 to 12), it indicates the module is a special one. // In that case, information is swapped. - if ((6<firstTempMaskedChip_side0 and firstTempMaskedChip_side0<=12) or - (0<firstTempMaskedChip_side1 and firstTempMaskedChip_side1<= 6)) { - const unsigned int swapFirstTempMaskedChip_side0{firstTempMaskedChip_side0}; - firstTempMaskedChip_side0 = firstTempMaskedChip_side1; - firstTempMaskedChip_side1 = swapFirstTempMaskedChip_side0; + if ((6<firstTempMaskedChipSide0 and firstTempMaskedChipSide0<=12) or + (0<firstTempMaskedChipSide1 and firstTempMaskedChipSide1<= 6)) { + const unsigned int swapFirstTempMaskedChipSide0{firstTempMaskedChipSide0}; + firstTempMaskedChipSide0 = firstTempMaskedChipSide1; + firstTempMaskedChipSide1 = swapFirstTempMaskedChipSide0; } - if (firstTempMaskedChip_side0>0) { - for (unsigned int iChip{firstTempMaskedChip_side0-1}; iChip<6; iChip++) { - addSingleError(hash_side0, SCT_ByteStreamErrors::TempMaskedChip0+iChip, errs); + if (firstTempMaskedChipSide0>0) { + for (unsigned int iChip{firstTempMaskedChipSide0-1}; iChip<6; iChip++) { + addSingleError(hashSide0, SCT_ByteStreamErrors::TempMaskedChip0+iChip, errs); } } - if (firstTempMaskedChip_side1>6) { - for (unsigned int iChip{firstTempMaskedChip_side1-1}; iChip<12; iChip++) { - addSingleError(hash_side1, SCT_ByteStreamErrors::TempMaskedChip0+iChip-6, errs); + if (firstTempMaskedChipSide1>6) { + for (unsigned int iChip{firstTempMaskedChipSide1-1}; iChip<12; iChip++) { + addSingleError(hashSide1, SCT_ByteStreamErrors::TempMaskedChip0+iChip-6, errs); } } - } else { + } + else { // type=1, 2, 3, 4: cases using Rx redundancy bool toBeMasked{false}; for (int iChip{0}; iChip<12; iChip++) { int jChip{chipOrder[type][iChip]}; if (jChip==static_cast<int>(firstTempMaskedChip-1)) toBeMasked = true; if (toBeMasked) { - if (jChip<6) addSingleError(hash_side0, SCT_ByteStreamErrors::TempMaskedChip0+jChip, errs); - else addSingleError(hash_side1, SCT_ByteStreamErrors::TempMaskedChip0+jChip-6, errs); + if (jChip<6) addSingleError(hashSide0, SCT_ByteStreamErrors::TempMaskedChip0+jChip, errs); + else addSingleError(hashSide1, SCT_ByteStreamErrors::TempMaskedChip0+jChip-6, errs); } } } - ATH_MSG_VERBOSE("setFirstTempMaskedChip Hash " << hashId - << " SerialNumber " << m_cabling->getSerialNumberFromHash(hashId).str() - << " moduleId " << moduleId - << " barrel_ec " << m_sct_id->barrel_ec(wafId) - << " layer_disk " << m_sct_id->layer_disk(wafId) - << " eta_module " << m_sct_id->eta_module(wafId) - << " phi_module " << m_sct_id->phi_module(wafId) - << " side " << m_sct_id->side(wafId) + ATH_MSG_VERBOSE("setFirstTempMaskedChip Hash " << hashID + << " SerialNumber " << m_cabling->getSerialNumberFromHash(hashID).str() + << " moduleID " << moduleID + << " barrel_ec " << m_sctID->barrel_ec(waferID) + << " layer_disk " << m_sctID->layer_disk(waferID) + << " eta_module " << m_sctID->eta_module(waferID) + << " phi_module " << m_sctID->phi_module(waferID) + << " side " << m_sctID->side(waferID) << " firstTempMaskedChip " << firstTempMaskedChip); } diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.h index 796dc65ff3b856fda21d639330a92fdbb90d6d80..4d9b6b1ce53e06439866592a6ad6b41e2635ebcd 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodDecoder.h @@ -2,130 +2,241 @@ Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ -/** - * @file header for SCT_RodDecoder Class - * AlgTool class to decode ROB bytestream data into RDO - * @author: Kondo.Gnanvo@cern.ch, Maria.Jose.Costa@cern.ch - * @current developer: Kondo Gnanvo, QMUL (London), august 2005 - */ - #ifndef INDETRAWDATABYTESTREAM_SCT_RODDECODER_H #define INDETRAWDATABYTESTREAM_SCT_RODDECODER_H #include "SCT_RawDataByteStreamCnv/ISCT_RodDecoder.h" #include "AthenaBaseComps/AthAlgTool.h" -#include "Identifier/IdContext.h" -#include "Identifier/IdentifierHash.h" #include "InDetByteStreamErrors/InDetBSErrContainer.h" -#include "SCT_Cabling/ISCT_CablingTool.h" #include "SCT_ConditionsData/SCT_ByteStreamErrors.h" +#include "SCT_Cabling/ISCT_CablingTool.h" #include "SCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h" +#include "Identifier/IdContext.h" #include "GaudiKernel/ToolHandle.h" -//STL #include <atomic> #include <cstdint> #include <string> #include <vector> +class IdentifierHash; class SCT_ID; -//using OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment; -/** @class SCT_RodDecoder - * @brief AlgTool which decodes the SCT binary format to create RDOs - * also inserts them to the collection. - * This tool is used by the SCTRawCollByteStreamTool - **/ +/** + * @class SCT_RodDecoder + * + * @brief Athena Algorithm Tool to decode the SCT binary format to create RDOs and inserts them to the collection. + * + * This tool is used by the SCTRawCollByteStreamTool. + */ class SCT_RodDecoder : public extends<AthAlgTool, ISCT_RodDecoder> { - - struct CacheHelper{//temp object to help with trigger caching + /** Temp object to help with trigger caching. */ + struct CacheHelper{ IdentifierHash skipHash, lastHash; const std::vector<IdentifierHash>* vecHash; }; public: - //@name Usual AlgTool methods - //@{ - /** constructor*/ + + /** Constructor */ SCT_RodDecoder(const std::string& type, const std::string& name, const IInterface* parent); - /** destructor */ + /** Destructor */ virtual ~SCT_RodDecoder() = default; - /** AlgTool initialize */ + /** Initialize */ virtual StatusCode initialize() override; - /** AlgTool finalize*/ + /** Finalize */ virtual StatusCode finalize() override; - - /** @brief Decode the rob data fragment and fill the collection SCT_RDO_Collection - * with the RDO built by the makeRDO(..) method + + /** + * @brief Fill SCT RDO Collection with decoded ROB data + * + * Decode the rob data fragment and fill the collection SCT_RDO_Collection with the RDO built by the makeRDO(..) method. * rdoIdc, errs, and bsFracCont are updated based on robFrag and vecHash. - **/ + * + * @param robFrag ROB fragment. + * @param rdoIDCont RDO ID Container to be filled. + * @param errs Byte stream error container. + * @param bsFracCont Byte stream fraction container. + * @param vecHash Vector of hashes. + */ virtual StatusCode fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& robFrag, - ISCT_RDO_Container& rdoIdc, + ISCT_RDO_Container& rdoIDCont, InDetBSErrContainer* errs, SCT_ByteStreamFractionContainer* bsFracCont, const std::vector<IdentifierHash>* vecHash = nullptr) const override; private: - /// method that builds the RawData RDO and add it to the collection - /// rdoIdc and cache are updated based on other arguments - int makeRDO(int strip, int groupSize, int tbin, - uint32_t onlineId, int ERRORS, - ISCT_RDO_Container& rdoIdc, + + /** + * @brief Builds RawData RDO and adds to RDO container + * + * Method that builds the RawData RDO and add it to the collection rdoIdc and cache are + * updated based on other arguments. + * Method has 3 possible return values: + * 1 if RDO was successfully created + * 0 if collection was deliberately skipped (for trigger) + * -1 if there was an error in the decoding - will be passed on as StatusCode::RECOVERABLE by fillCollection() + * + * @param strip Strip number info from the RDO. + * @param groupSize Group size info from the RDO. + * @param timeBin Time bin info for RDO. + * @param onlineID Online Identifier from the RDO. + * @param errors Error info. + * @param rdoIDCont RDO ID Container to be filled. + * @param cache Cache. + * @param errorHit Hit error info. + */ + int makeRDO(int strip, int groupSize, int timeBin, + uint32_t onlineID, int errors, + ISCT_RDO_Container& rdoIDCont, CacheHelper& cache, const std::vector<int>& errorHit) const; - /// add an error for each wafer in a problematic ROD. - void addRODError(uint32_t rodid, int errorType, + /** + * @brief Add an error for each wafer in the problematic ROD + * + * @param rodID Identifer of ROD. + * @param errorType Error type info. + * @param errs Byte stream error container. + */ + void addRODError(uint32_t rodID, int errorType, InDetBSErrContainer* errs) const; - bool addSingleError(const IdentifierHash& idHash, + /** + * @brief Add single eror + * + * @param hashID Identifier for hash. + * @param bsErrorType Byte Stream error type info. + * @param errs Byte stream error container. + */ + bool addSingleError(const IdentifierHash& hashID, int bsErrorType, InDetBSErrContainer* errs) const; - /** Set first temporarily masked chip information from byte stream trailer */ - void setFirstTempMaskedChip(const IdentifierHash& hashId, unsigned int firstTempMaskedChip, InDetBSErrContainer* errs) const; - - const SCT_ID* m_sct_id; - IdContext m_cntx_sct; - ToolHandle<ISCT_CablingTool> m_cabling{this, "SCT_CablingTool", "SCT_CablingTool", "Tool to retrieve SCT Cabling"}; - ToolHandle<ISCT_ConfigurationConditionsTool> m_configTool{this, "ConfigTool", - "SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", "Tool to retrieve SCT Configuration Tool"}; - /** Summary of the decoding process */ - mutable std::atomic_uint m_singleCondHitNumber; //!< Total number of single hit decoded in condensed mode - mutable std::atomic_uint m_pairedCondHitNumber; //!< Total number of paired hit decoded in condensed mode - mutable std::atomic_uint m_firstExpHitNumber; //!< Total number of first hit decoded in expanded mode - mutable std::atomic_uint m_evenExpHitNumber; //!< Total number of paired hit decoded in expanded mode - mutable std::atomic_uint m_lastExpHitNumber; //!< Total number of last hit decoded in expanded mode - mutable std::atomic_uint m_headnumber; //!< Total number of decoded header data - mutable std::atomic_uint m_trailnumber; //!< Total number of decoded trailer data - mutable std::atomic_uint m_head_error_bcid; //!< Total number of bcid error in the header data - mutable std::atomic_uint m_head_error_lvl1id; //!< Total number of lvl1id error in the header data - mutable std::atomic_uint m_head_error_timeout; //!< Total number of timeout error in the header data - mutable std::atomic_uint m_head_error_formatter; //!< Total number of formatter error in the header data - mutable std::atomic_uint m_head_error_preamb; //!< Total number of preamble error in the header data - mutable std::atomic_uint m_trail_error_overflow; //!< Total number of overflow error in the trailer data - mutable std::atomic_uint m_trail_error_limit; //!< Total number of header trailer limit error in the trailer data - mutable std::atomic_uint m_trail_error_bit; //!< Total number of trailer bit error - mutable std::atomic_uint m_config_data_bit; //!< Total number of configuration data - mutable std::atomic_uint m_flag_error_bit; //!< Total number of flag error data - mutable std::atomic_uint m_cond_hit1_error; //!< Total number of first hit data error - mutable std::atomic_uint m_cond_hit2_error; //!< Total number second hit data errors - mutable std::atomic_uint m_chip_number_error; //!< Total number of chip number error - mutable std::atomic_uint m_unknown_data_format; //!< Total number of unknown data format + /** + * @brief Set first temporarily masked chip information from byte stream trailer + * + * @param hashID Identifier for hash. + * @param firstTempMaskedChip Firt temporarily masked chip info. + * @param errs Byte stream error container. + */ + void setFirstTempMaskedChip(const IdentifierHash& hashID, + unsigned int firstTempMaskedChip, + InDetBSErrContainer* errs) const; + + /** Identifier helper class for the SCT subdetector that creates compact Identifier objects and + IdentifierHash or hash IDs. Also allows decoding of these IDs. */ + const SCT_ID* m_sctID; + + /** "Context" of an expanded identifier (ExpandedIdentifier) for compact or + hash versions (Identifier32 or IdentifierHash) */ + IdContext m_contextSCT; + + /** Providing mappings of online and offline identifiers and also serial numbers. */ + ToolHandle<ISCT_CablingTool> m_cabling{this, + "SCT_CablingTool", + "SCT_CablingTool", + "Tool to retrieve SCT Cabling"}; + + /** Service that keeps track of configuration conditions. */ + ToolHandle<ISCT_ConfigurationConditionsTool> m_configTool{this, + "ConfigTool", + "SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", + "Tool to retrieve SCT Configuration Tool"}; + + /** Total number of single strips with hit decoded in condensed mode */ + mutable std::atomic_uint m_singleCondHitNumber; + + /** Total number of paired strips with hit decoded in condensed mode */ + mutable std::atomic_uint m_pairedCondHitNumber; + + /** Total number of first strips with hit decoded in expanded mode */ + mutable std::atomic_uint m_firstExpHitNumber; + + /** Total number of consecutive paired strips with hit decoded in expanded mode */ + mutable std::atomic_uint m_evenExpHitNumber; + + /** Total number of last consecutive strips with hit decoded in expanded mode */ + mutable std::atomic_uint m_lastExpHitNumber; + + /** Total number of decoded header data */ + mutable std::atomic_uint m_headNumber; + + /** Total number of decoded trailer data */ + mutable std::atomic_uint m_trailerNumber; + + /** Total number of BCID errors in the header data */ + mutable std::atomic_uint m_headErrorBCID; + + /** Total number of Lvl1ID errors in the header data */ + mutable std::atomic_uint m_headErrorLvl1ID; + + /** Total number of timeout errors in the header data */ + mutable std::atomic_uint m_headErrorTimeout; + + /** Total number of formatter errors in the header data */ + mutable std::atomic_uint m_headErrorFormatter; + + /** Total number of preamble errors in the header data */ + mutable std::atomic_uint m_headErrorPreamble; + + /** Total number of overflow errors in the trailer data */ + mutable std::atomic_uint m_trailerErrorOverflow; + + /** Total number of header trailer limit errors in the trailer data */ + mutable std::atomic_uint m_trailerErrorLimit; + + /** Total number of trailer bit errors */ + mutable std::atomic_uint m_trailerErrorBit; + + /** Total number of configuration data for raw data */ + mutable std::atomic_uint m_configDataBit; + + /** Total number of flag error data */ + mutable std::atomic_uint m_flagErrorBit; + + /** Total number of first hit data errors */ + mutable std::atomic_uint m_condHit1Error; + + /** Total number second hit data errors */ + mutable std::atomic_uint m_condHit2Error; + + /** Total number of chip number errors */ + mutable std::atomic_uint m_chipNumberError; + + /** Total number of unknown data formats */ + mutable std::atomic_uint m_unknownDataFormat; + + /** Total number of SCT hits in ByteStream */ mutable std::atomic_uint m_nHits; + + /** Total number of SCT RDOs created */ mutable std::atomic_uint m_nRDOs; + + /** Total number of masked links in the header data */ mutable std::atomic_uint m_maskedLinkNumber; + + /** Total number of masked RDOs */ mutable std::atomic_uint m_maskedRODNumber; - mutable std::atomic_uint m_RODClockErrorNumber; + + /** Total number of ROD clock errors */ + mutable std::atomic_uint m_rodClockErrorNumber; + + /** Total number of truncated ROBFragments */ mutable std::atomic_uint m_truncatedRODNumber; + + /** Total number of missing link headers */ mutable std::atomic_uint m_numMissingLinkHeader; - mutable std::atomic_uint m_numUnknownOfflineId; + /** Total number of SCT unknown online IDs */ + mutable std::atomic_uint m_numUnknownOfflineID; + + /** Swap phi readout direction */ std::vector<bool> m_swapPhiReadoutDirection; }; diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx index 72d88f32712240a84871a4ff925545b85eb29d8e..88b7b11051486bead34a6e4f37ef59a8ebd3ce55 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx @@ -42,7 +42,8 @@ namespace { // Anonymous namespace // Constructor -SCT_RodEncoder::SCT_RodEncoder(const std::string& type, const std::string& name, const IInterface* parent) : +SCT_RodEncoder::SCT_RodEncoder(const std::string& type, const std::string& name, + const IInterface* parent) : base_class(type, name, parent), m_sctID{nullptr}, m_swapModuleID{} diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h index 97795431a92d0e3a751953f4ab6190aa6ab47d69..1d9896fb44b2f2806e849cbbd6557d87d063fbd3 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h @@ -1,14 +1,6 @@ /* Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ - -/** - * @file SCT_RodEncoder.h - * @author: Nick Barlow (nbarlow@mail.cern.ch, Kondo.Gnanvo@cern.ch) - * @date 21 June 2007 (SCT_RodEncoder turned into An AlgTool) - * - * This class provides conversion from SCT RDO to ROD format ByteStream. - */ #ifndef SCT_RAWDATABYTESTREAMCNV_SCT_RODENCODER_H #define SCT_RAWDATABYTESTREAMCNV_SCT_RODENCODER_H @@ -96,9 +88,9 @@ class SCT_RodEncoder : public extends<AthAlgTool, ISCT_RodEncoder> * * @param vecTimeBins Vector of time bins for RDOs. * @param vec16Words Vector of 16 bit words to filled from encoded RDO data. - * @param rdo RDO raw data object to be encoded - * @param groupSize Group size info from the RDO - * @param strip Strip number info from the RDO + * @param rdo RDO raw data object to be encoded. + * @param groupSize Group size info from the RDO. + * @param strip Strip number info from the RDO. */ void encodeData(const std::vector<int>& vecTimeBins, std::vector<uint16_t>& vec16Words, const SCT_RDORawData* rdo, const int& groupSize, const int& strip) const; @@ -109,11 +101,10 @@ class SCT_RodEncoder : public extends<AthAlgTool, ISCT_RodEncoder> * Method us used by private method encodeData(...). * * @param vec16Words Vector containing 16 bit words. - * @param vec32Words Vector for 32 bit words to be packed + * @param vec32Words Vector for 32 bit words to be packed. */ void packFragments(std::vector<uint16_t>& vec16Words, std::vector<uint32_t>& vec32Words) const; - /// from 16 bits array to 32 bit array /** * @breif Method to set pairs of 16 bit words to a 32 bit word. * @@ -160,7 +151,7 @@ class SCT_RodEncoder : public extends<AthAlgTool, ISCT_RodEncoder> /** Add trailers with errors for ROB to the vector of 16 bit words. */ void addTrailersWithErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, - const ErrorWords& errType, std::vector<uint16_t>& vec16dDta) const; + const ErrorWords& errType, std::vector<uint16_t>& vec16Data) const; /** Add specific errors for ROB to the vector of 16 bit words. */ void addSpecificErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, @@ -177,6 +168,7 @@ class SCT_RodEncoder : public extends<AthAlgTool, ISCT_RodEncoder> "SCT_CablingTool", "SCT_CablingTool", "Tool to retrieve SCT Cabling"}; + /** Identifier helper class for the SCT subdetector that creates compact Identifier objects and IdentifierHash or hash IDs. Also allows decoding of these IDs. */ const SCT_ID* m_sctID;