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 constexpr std::array<unsigned char, 4> FRDFileHeader_id{{0x52, 0x41, 0x57, 0x5f}};
22 constexpr std::array<unsigned char, 4> FRDFileVersion_1{{0x30, 0x30, 0x30, 0x31}};
23 constexpr std::array<unsigned char, 4> FRDFileVersion_2{{0x30, 0x30, 0x30, 0x32}};
24 
26  FRDFileHeaderIdentifier(const std::array<uint8_t, 4>& id, const std::array<uint8_t, 4>& version)
27  : id_(id), version_(version) {}
28 
29  std::array<uint8_t, 4> id_;
30  std::array<uint8_t, 4> version_;
31 };
32 
34  FRDFileHeaderContent_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
36  eventCount_(eventCount),
37  lumiSection_(lumiSection),
38  fileSize_(fileSize) {}
39 
40  uint16_t headerSize_;
41  uint16_t eventCount_;
42  uint32_t lumiSection_;
44 };
45 
47  FRDFileHeader_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
48  : id_(FRDFileHeader_id, FRDFileVersion_1), c_(eventCount, lumiSection, fileSize) {}
49 
52 };
53 
56  uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
59  eventCount_(eventCount),
61  lumiSection_(lumiSection),
62  fileSize_(fileSize) {}
63 
64  uint16_t headerSize_;
65  uint16_t dataType_;
66  uint32_t eventCount_;
67  uint32_t runNumber_;
68  uint32_t lumiSection_;
70 };
71 
73  FRDFileHeader_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
74  : id_(FRDFileHeader_id, FRDFileVersion_2), c_(dataType, eventCount, runNumber, lumiSection, fileSize) {}
75 
78 };
79 
80 inline uint16_t getFRDFileHeaderVersion(const std::array<uint8_t, 4>& id, const std::array<uint8_t, 4>& version) {
81  size_t i;
82  for (i = 0; i < 4; i++)
83  if (id[i] != FRDFileHeader_id[i])
84  return 0; //not FRD file header
85  uint16_t ret = 0;
86  for (i = 0; i < 4; i++) {
87  if (version[i] > '9' || version[i] < '0')
88  return 0; //NaN sequence
89  ret = ret * 10 + (uint16_t)(version[i] - '0');
90  }
91  return ret;
92 }
93 
94 #endif
uint16_t getFRDFileHeaderVersion(const std::array< uint8_t, 4 > &id, const std::array< uint8_t, 4 > &version)
Definition: FRDFileHeader.h:80
FRDFileHeaderIdentifier id_
Definition: FRDFileHeader.h:50
ret
prodAgent to be discontinued
FRDFileHeader_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:47
FRDFileHeaderIdentifier(const std::array< uint8_t, 4 > &id, const std::array< uint8_t, 4 > &version)
Definition: FRDFileHeader.h:26
FRDFileHeaderContent_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:34
std::array< uint8_t, 4 > id_
Definition: FRDFileHeader.h:29
FRDFileHeader_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:73
constexpr std::array< unsigned char, 4 > FRDFileVersion_2
Definition: FRDFileHeader.h:23
constexpr std::array< unsigned char, 4 > FRDFileHeader_id
Definition: FRDFileHeader.h:21
std::array< uint8_t, 4 > version_
Definition: FRDFileHeader.h:30
FRDFileHeaderContent_v2 c_
Definition: FRDFileHeader.h:77
unsigned long long uint64_t
Definition: Time.h:13
constexpr std::array< unsigned char, 4 > FRDFileVersion_1
Definition: FRDFileHeader.h:22
FRDFileHeaderIdentifier id_
Definition: FRDFileHeader.h:76
FRDFileHeaderContent_v1 c_
Definition: FRDFileHeader.h:51
FRDFileHeaderContent_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize)
Definition: FRDFileHeader.h:55