File indexing completed on 2024-04-06 12:10:29
0001 #ifndef CTPPS_CTPPSRawToDigi_CTPPSPixelDataFormatter_h
0002 #define CTPPS_CTPPSRawToDigi_CTPPSPixelDataFormatter_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include "DataFormats/CTPPSDigi/interface/CTPPSPixelDigi.h"
0035 #include "DataFormats/CTPPSDigi/interface/CTPPSPixelDataError.h"
0036 #include "CondFormats/PPSObjects/interface/CTPPSPixelDAQMapping.h"
0037 #include "DataFormats/Common/interface/DetSetVector.h"
0038
0039 #include "EventFilter/CTPPSRawToDigi/interface/RPixErrorChecker.h"
0040
0041 #include "CondFormats/PPSObjects/interface/CTPPSPixelIndices.h"
0042 #include "EventFilter/CTPPSRawToDigi/interface/ElectronicIndex.h"
0043 #include "FWCore/Utilities/interface/typedefs.h"
0044
0045 #include "EventFilter/CTPPSRawToDigi/interface/CTPPSRawToDigiErrorSummary.h"
0046
0047 #include <cstdint>
0048 #include <vector>
0049 #include <map>
0050 #include <unordered_map>
0051
0052 class FEDRawData;
0053 class RPixErrorChecker;
0054
0055 class CTPPSPixelDataFormatter {
0056 public:
0057 typedef edm::DetSetVector<CTPPSPixelDigi> Collection;
0058
0059 typedef std::unordered_map<int, FEDRawData> RawData;
0060 typedef std::vector<CTPPSPixelDigi> DetDigis;
0061
0062 typedef std::vector<CTPPSPixelDataError> DetErrors;
0063 typedef std::map<uint32_t, DetErrors> Errors;
0064
0065 typedef uint32_t Word32;
0066 typedef uint64_t Word64;
0067
0068 typedef std::unordered_map<cms_uint32_t, DetDigis> Digis;
0069
0070 CTPPSPixelDataFormatter(std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> const& mapping,
0071 CTPPSRawToDigiErrorSummary&);
0072
0073 void setErrorStatus(bool theErrorStatus);
0074
0075 int nWords() const { return m_WordCounter; }
0076
0077 void interpretRawData(
0078 const bool& isRun3, bool& errorsInEvent, int fedId, const FEDRawData& data, Collection& digis, Errors& errors);
0079
0080 int nDigis() const { return m_DigiCounter; }
0081
0082 struct PPSPixelIndex {
0083 uint32_t id;
0084 unsigned int roc;
0085 short unsigned int rocch;
0086 short unsigned int fedid;
0087 short unsigned int fedch;
0088 };
0089
0090 void formatRawData(const bool& isRun3,
0091 unsigned int lvl1_ID,
0092 RawData& fedRawData,
0093 const Digis& digis,
0094 std::vector<PPSPixelIndex> v_iDdet2fed);
0095
0096 static bool compare(const PPSPixelIndex& a, const PPSPixelIndex& b) {
0097 return a.id < b.id || (a.id == b.id && a.roc < b.roc);
0098 }
0099
0100 void printErrorSummary() const { m_ErrorSummary.printSummary(); }
0101
0102 private:
0103 int m_WordCounter;
0104
0105 bool m_IncludeErrors;
0106 RPixErrorChecker m_ErrorCheck;
0107
0108 int m_ADC_shift, m_PXID_shift, m_DCOL_shift, m_ROC_shift, m_LINK_shift, m_COL_shift, m_ROW_shift;
0109 Word32 m_LINK_mask, m_ROC_mask, m_DCOL_mask, m_PXID_mask, m_ADC_mask, m_COL_mask, m_ROW_mask;
0110
0111 int checkError(const Word32& data) const;
0112
0113 std::string print(const Word64& word) const;
0114
0115 const std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>& m_Mapping;
0116
0117 int m_DigiCounter;
0118 int m_allDetDigis;
0119 int m_hasDetDigis;
0120 CTPPSPixelIndices m_Indices;
0121 CTPPSRawToDigiErrorSummary& m_ErrorSummary;
0122 };
0123
0124 #endif