File indexing completed on 2021-09-05 22:26:05
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 <cstdint>
0046 #include <vector>
0047 #include <map>
0048 #include <unordered_map>
0049
0050 class FEDRawData;
0051 class RPixErrorChecker;
0052
0053 class CTPPSPixelDataFormatter {
0054 public:
0055 typedef edm::DetSetVector<CTPPSPixelDigi> Collection;
0056
0057 typedef std::unordered_map<int, FEDRawData> RawData;
0058 typedef std::vector<CTPPSPixelDigi> DetDigis;
0059
0060 typedef std::vector<CTPPSPixelDataError> DetErrors;
0061 typedef std::map<uint32_t, DetErrors> Errors;
0062
0063 typedef uint32_t Word32;
0064 typedef uint64_t Word64;
0065
0066 typedef std::unordered_map<cms_uint32_t, DetDigis> Digis;
0067
0068 CTPPSPixelDataFormatter(std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> const& mapping);
0069
0070 void setErrorStatus(bool theErrorStatus);
0071
0072 int nWords() const { return m_WordCounter; }
0073
0074 void interpretRawData(
0075 const bool& isRun3, bool& errorsInEvent, int fedId, const FEDRawData& data, Collection& digis, Errors& errors);
0076
0077 int nDigis() const { return m_DigiCounter; }
0078
0079 struct PPSPixelIndex {
0080 uint32_t id;
0081 unsigned int roc;
0082 short unsigned int rocch;
0083 short unsigned int fedid;
0084 short unsigned int fedch;
0085 };
0086
0087 void formatRawData(const bool& isRun3,
0088 unsigned int lvl1_ID,
0089 RawData& fedRawData,
0090 const Digis& digis,
0091 std::vector<PPSPixelIndex> v_iDdet2fed);
0092
0093 static bool compare(const PPSPixelIndex& a, const PPSPixelIndex& b) {
0094 return a.id < b.id || (a.id == b.id && a.roc < b.roc);
0095 }
0096
0097 private:
0098 int m_WordCounter;
0099
0100 bool m_IncludeErrors;
0101 RPixErrorChecker m_ErrorCheck;
0102
0103 int m_ADC_shift, m_PXID_shift, m_DCOL_shift, m_ROC_shift, m_LINK_shift, m_COL_shift, m_ROW_shift;
0104 Word32 m_LINK_mask, m_ROC_mask, m_DCOL_mask, m_PXID_mask, m_ADC_mask, m_COL_mask, m_ROW_mask;
0105
0106 int checkError(const Word32& data) const;
0107
0108 std::string print(const Word64& word) const;
0109
0110 const std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>& m_Mapping;
0111
0112 int m_DigiCounter;
0113 int m_allDetDigis;
0114 int m_hasDetDigis;
0115 CTPPSPixelIndices m_Indices;
0116 };
0117
0118 #endif