Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:19

0001 #ifndef IOPool_Streamer_FRDEventMessage_h
0002 #define IOPool_Streamer_FRDEventMessage_h
0003 
0004 /**
0005  * This class is used to view the contents of "FED Raw Data" (FRD) events.
0006  * Initially, the only time that such events are created is
0007  * when an error occurs in the HLT.
0008  * So, in the beginning, "error event" == "FRD event".
0009  * However, if new ways of creating events of this type are added
0010  * to the HLT, hopefully this class can be used or upgraded to handle those
0011  * events as well.
0012  *
0013  * 08-Aug-2008 - KAB  - Initial Implementation
0014  * 06-Oct-2008 - KAB  - Added version number and lumi block number (version #2)
0015  * 14-Nov-2013 - RKM  - Added event size, adler32 and padding size (version #3)
0016  * 15-Oct-2014 - WDD  - Event number from 32 bits to 64 bits (version #4)
0017  * 01-Apr-2015 - SM   - replaced adler32 with crc32c which is accelerated in SSE 4.2 (version #5)
0018  * 22-Sep-2020 - SM   - reused high version 16-bits for event info via flags (version #6)
0019  *
0020  *
0021  * Version 6 Format:
0022  *   uint16 - format version number
0023  *   uint16 - event flags
0024  *   uint32 - run number
0025  *   uint32 - lumi number
0026  *   uint32 - event number
0027  *   uint32 - event size
0028  *   uint32 - crc32c checksum of FED data (excluding event header)
0029  *   variable size - FED data
0030  *
0031  * Version 5 Format:
0032  *   uint32 - format version number
0033  *   uint32 - run number
0034  *   uint32 - lumi number
0035  *   uint32 - event number
0036  *   uint32 - event size
0037  *   uint32 - crc32c checksum of FED data (excluding event header)
0038  *   variable size - FED data
0039  *
0040  * Version 4 Format:
0041  *   uint32 - format version number
0042  *   uint32 - run number
0043  *   uint32 - lumi number
0044  *   uint32 - event number low 32 bits
0045  *   uint32 - event number high 32 bits
0046  *   uint32 - event size
0047  *   uint32 - padding size needed to fill memory page size (_SC_PAGE_SIZE)
0048  *   uint32 - adler32 checksum of FED data (excluding event header)
0049  *   variable size - FED data
0050  *
0051  * Version 3 Format:
0052  *   uint32 - format version number
0053  *   uint32 - run number
0054  *   uint32 - lumi number
0055  *   uint32 - event number
0056  *   uint32 - event size
0057  *   uint32 - padding size needed to fill memory page size (_SC_PAGE_SIZE)
0058  *   uint32 - adler32 checksum of FED data (excluding event header)
0059  *   variable size - FED data
0060  *
0061  * Version 2 Format:
0062  *   uint32 - format version number
0063  *   uint32 - run number
0064  *   uint32 - lumi number
0065  *   uint32 - event number
0066  *   1024 * uint32 - size values for all 1024 FED buffers
0067  *   variable size - FED data
0068  */
0069 
0070 #include "IOPool/Streamer/interface/MsgTools.h"
0071 
0072 #include <array>
0073 
0074 struct FRDEventHeader_V6 {
0075   uint16 version_;
0076   uint16 flags_;
0077   uint32 run_;
0078   uint32 lumi_;
0079   uint32 event_;
0080   uint32 eventSize_;
0081   uint32 crc32c_;
0082 };
0083 
0084 struct FRDEventHeader_V5 {
0085   uint32 version_;
0086   uint32 run_;
0087   uint32 lumi_;
0088   uint32 event_;
0089   uint32 eventSize_;
0090   uint32 crc32c_;
0091 };
0092 
0093 struct FRDEventHeader_V4 {
0094   uint32 version_;
0095   uint32 run_;
0096   uint32 lumi_;
0097   uint32 eventLow_;
0098   uint32 eventHigh_;
0099   uint32 eventSize_;
0100   uint32 paddingSize_;
0101   uint32 adler32_;
0102 };
0103 
0104 struct FRDEventHeader_V3 {
0105   uint32 version_;
0106   uint32 run_;
0107   uint32 lumi_;
0108   uint32 event_;
0109   uint32 eventSize_;
0110   uint32 paddingSize_;
0111   uint32 adler32_;
0112 };
0113 
0114 struct FRDEventHeader_V2 {
0115   uint32 version_;
0116   uint32 run_;
0117   uint32 lumi_;
0118   uint32 event_;
0119 };
0120 
0121 struct FRDEventHeader_V1 {
0122   uint32 run_;
0123   uint32 event_;
0124 };
0125 
0126 const uint16 FRDEVENT_MASK_ISGENDATA = 1;
0127 
0128 constexpr size_t FRDHeaderMaxVersion = 6;
0129 constexpr std::array<uint32, FRDHeaderMaxVersion + 1> FRDHeaderVersionSize{{0,
0130                                                                             2 * sizeof(uint32),
0131                                                                             (4 + 1024) * sizeof(uint32),
0132                                                                             7 * sizeof(uint32),
0133                                                                             8 * sizeof(uint32),
0134                                                                             6 * sizeof(uint32),
0135                                                                             6 * sizeof(uint32)}};
0136 
0137 class FRDEventMsgView {
0138 public:
0139   FRDEventMsgView(void* buf);
0140 
0141   uint8* startAddress() const { return buf_; }
0142   void* payload() const { return payload_; }
0143   uint32 size() const { return size_; }
0144 
0145   uint16 version() const { return version_; }
0146   uint16 flags() const { return flags_; }
0147   uint32 run() const { return run_; }
0148   uint32 lumi() const { return lumi_; }
0149   uint64 event() const { return event_; }
0150   uint32 eventSize() const { return eventSize_; }
0151   uint32 paddingSize() const { return paddingSize_; }
0152   uint32 adler32() const { return adler32_; }
0153   uint32 crc32c() const { return crc32c_; }
0154 
0155   bool isRealData() const { return !(flags_ & FRDEVENT_MASK_ISGENDATA); }
0156 
0157 private:
0158   uint8* buf_;
0159   void* payload_;
0160   uint32 size_;
0161   uint16 version_;
0162   uint16 flags_;
0163   uint32 run_;
0164   uint32 lumi_;
0165   uint64 event_;
0166   uint32 eventSize_;
0167   uint32 paddingSize_;
0168   uint32 adler32_;
0169   uint32 crc32c_;
0170 };
0171 
0172 #endif