CMS 3D CMS Logo

FRDFileHeader.h
Go to the documentation of this file.
1 #ifndef IOPool_Streamer_FRDFileHeader_h
2 #define IOPool_Streamer_FRDFileHeader_h
3 
4 #include <array>
5 #include <cstddef>
6 #include <cstdint>
7 
8 /*
9  * FRD File Header optionally found at the beginning of the FRD RAW file
10  *
11  * Version 1 Format:
12  * uint8_t [4] - id contanining 4 characters: 0x52, 0x41, 0x57, 0x5f "RAW_"
13  * uint8_t [4] - version string 4 characters: 0x30, 0x30, 0x30, 0x31 "0001"
14  * uint16_t - header size: 24
15  * uint16_t - number of events in the RAW file
16  * uint32_t - lumisection
17  * uint64_t - total size of the raw file (including header)
18  *
19  * */
20 
21 namespace edm::streamer {
22  constexpr std::array<unsigned char, 4> FRDFileHeader_id{{0x52, 0x41, 0x57, 0x5f}};
23  constexpr std::array<unsigned char, 4> FRDFileVersion_1{{0x30, 0x30, 0x30, 0x31}};
24  constexpr std::array<unsigned char, 4> FRDFileVersion_2{{0x30, 0x30, 0x30, 0x32}};
25 
27  FRDFileHeaderIdentifier(const std::array<uint8_t, 4>& id, const std::array<uint8_t, 4>& version)
28  : id_(id), version_(version) {}
29 
30  std::array<uint8_t, 4> id_;
31  std::array<uint8_t, 4> version_;
32  };
33 
35  FRDFileHeaderContent_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
37  eventCount_(eventCount),
38  lumiSection_(lumiSection),
39  fileSize_(fileSize) {}
40 
41  uint16_t headerSize_;
42  uint16_t eventCount_;
43  uint32_t lumiSection_;
45  };
46 
48  FRDFileHeader_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
49  : id_(FRDFileHeader_id, FRDFileVersion_1), c_(eventCount, lumiSection, fileSize) {}
50 
53  };
54 
57  uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
60  eventCount_(eventCount),
62  lumiSection_(lumiSection),
63  fileSize_(fileSize) {}
64 
65  uint16_t headerSize_;
66  uint16_t dataType_;
67  uint32_t eventCount_;
68  uint32_t runNumber_;
69  uint32_t lumiSection_;
71  };
72 
74  FRDFileHeader_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
75  : id_(FRDFileHeader_id, FRDFileVersion_2), c_(dataType, eventCount, runNumber, lumiSection, fileSize) {}
76 
79  };
80 
81  inline uint16_t getFRDFileHeaderVersion(const std::array<uint8_t, 4>& id, const std::array<uint8_t, 4>& version) {
82  size_t i;
83  for (i = 0; i < 4; i++)
84  if (id[i] != FRDFileHeader_id[i])
85  return 0; //not FRD file header
86  uint16_t ret = 0;
87  for (i = 0; i < 4; i++) {
88  if (version[i] > '9' || version[i] < '0')
89  return 0; //NaN sequence
90  ret = ret * 10 + (uint16_t)(version[i] - '0');
91  }
92  return ret;
93  }
94 } // namespace edm::streamer
95 #endif
FRDFileHeaderContent_v2 c_
Definition: FRDFileHeader.h:78
FRDFileHeaderContent_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:35
ret
prodAgent to be discontinued
std::array< uint8_t, 4 > version_
Definition: FRDFileHeader.h:31
FRDFileHeaderIdentifier(const std::array< uint8_t, 4 > &id, const std::array< uint8_t, 4 > &version)
Definition: FRDFileHeader.h:27
constexpr std::array< unsigned char, 4 > FRDFileHeader_id
Definition: FRDFileHeader.h:22
FRDFileHeader_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:74
FRDFileHeaderIdentifier id_
Definition: FRDFileHeader.h:51
FRDFileHeaderIdentifier id_
Definition: FRDFileHeader.h:77
constexpr std::array< unsigned char, 4 > FRDFileVersion_2
Definition: FRDFileHeader.h:24
constexpr std::array< unsigned char, 4 > FRDFileVersion_1
Definition: FRDFileHeader.h:23
unsigned long long uint64_t
Definition: Time.h:13
FRDFileHeader_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:48
FRDFileHeaderContent_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:56
FRDFileHeaderContent_v1 c_
Definition: FRDFileHeader.h:52
uint16_t getFRDFileHeaderVersion(const std::array< uint8_t, 4 > &id, const std::array< uint8_t, 4 > &version)
Definition: FRDFileHeader.h:81