File indexing completed on 2024-04-06 12:10:59
0001 #ifndef EventFilter_SiPixelRawToDigi_interface_PixelDataFormatter_h
0002 #define EventFilter_SiPixelRawToDigi_interface_PixelDataFormatter_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
0035
0036
0037 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h"
0038 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
0039 #include "DataFormats/Common/interface/DetSetVector.h"
0040 #include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h"
0041 #include "DataFormats/SiPixelDigi/interface/SiPixelDigiConstants.h"
0042 #include "DataFormats/DetId/interface/DetIdCollection.h"
0043 #include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h"
0044 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0045 #include "EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h"
0046 #include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h"
0047 #include "FWCore/Utilities/interface/typedefs.h"
0048
0049
0050 #include <vector>
0051 #include <map>
0052 #include <set>
0053
0054 class FEDRawData;
0055 class SiPixelFedCabling;
0056 class SiPixelQuality;
0057 class SiPixelFrameConverter;
0058 class SiPixelFrameReverter;
0059 class SiPixelFedCablingTree;
0060
0061 class PixelDataFormatter {
0062 public:
0063 using DetErrors = std::vector<SiPixelRawDataError>;
0064 using Errors = std::map<cms_uint32_t, DetErrors>;
0065 using Collection = edm::DetSetVector<PixelDigi>;
0066 using RawData = std::map<int, FEDRawData>;
0067 using DetDigis = std::vector<PixelDigi>;
0068 using Digis = std::map<cms_uint32_t, DetDigis>;
0069 using DetBadChannels = std::vector<PixelFEDChannel>;
0070 using BadChannels = std::map<cms_uint32_t, DetBadChannels>;
0071 using FEDWordsMap = std::map<int, std::vector<Word32>>;
0072 using ModuleIDSet = std::set<unsigned int>;
0073
0074 PixelDataFormatter(const SiPixelFedCablingTree* map, bool phase1_ = false);
0075
0076 void setErrorStatus(bool ErrorStatus);
0077 void setQualityStatus(bool QualityStatus, const SiPixelQuality* QualityInfo);
0078 void setModulesToUnpack(const ModuleIDSet* moduleIds);
0079 void passFrameReverter(const SiPixelFrameReverter* reverter);
0080
0081 int nDigis() const { return theDigiCounter_; }
0082 int nWords() const { return theWordCounter_; }
0083
0084 void interpretRawData(bool& errorsInEvent, int fedId, const FEDRawData& data, Collection& digis, Errors& errors);
0085
0086 void formatRawData(unsigned int lvl1_ID, RawData& fedRawData, const Digis& digis, const BadChannels& badChannels);
0087
0088 void unpackFEDErrors(Errors const& errors,
0089 std::vector<int> const& tkerrorlist,
0090 std::vector<int> const& usererrorlist,
0091 edm::DetSetVector<SiPixelRawDataError>& errorcollection,
0092 DetIdCollection& tkerror_detidcollection,
0093 DetIdCollection& usererror_detidcollection,
0094 edmNew::DetSetVector<PixelFEDChannel>& disabled_channelcollection,
0095 DetErrors& nodeterrors);
0096
0097 private:
0098 mutable int theDigiCounter_;
0099 mutable int theWordCounter_;
0100
0101 SiPixelFedCablingTree const* theCablingTree_;
0102 const SiPixelFrameReverter* theFrameReverter_;
0103 const SiPixelQuality* badPixelInfo_;
0104 const ModuleIDSet* modulesToUnpack_;
0105
0106 bool includeErrors_;
0107 bool useQualityInfo_;
0108 int allDetDigis_;
0109 int hasDetDigis_;
0110 std::unique_ptr<ErrorCheckerBase> errorcheck_;
0111
0112 int maxROCIndex_;
0113 bool phase1_;
0114
0115 int checkError(const Word32& data) const;
0116
0117 int digi2word(cms_uint32_t detId, const PixelDigi& digi, FEDWordsMap& words) const;
0118 int digi2wordPhase1Layer1(cms_uint32_t detId, const PixelDigi& digi, FEDWordsMap& words) const;
0119
0120 std::string print(const PixelDigi& digi) const;
0121 std::string print(const Word64& word) const;
0122
0123 cms_uint32_t errorDetId(const SiPixelFrameConverter* converter, int fedId, int errorType, const Word32& word) const;
0124 };
0125
0126 #endif