CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
RawFileUtil.h
Go to the documentation of this file.
1#ifndef BES_RAWFILE_UTIL_H
2#define BES_RAWFILE_UTIL_H
3
4#include <iostream>
5#include <string>
6#include <stdint.h> //uint32_t
7
8class raw_ifstream;
9class raw_ofstream;
10
11
12/*************************************************
13 * the following structs and classes are assistant
14 * data structure of the RawFileReader/Writer:
15 * ------------------------+---------------------
16 * struct name | class name
17 * ------------------------+---------------------
18 * file_start_record | FileStartRecord
19 * file_name_strings | FileNameStrings
20 * run_parameters_record | RunParametersRecord
21 * data_separator_record | DataSeparatorRecord
22 * file_end_record | FileEndRecord
23 ************************************************/
24
25//------------------------------------------------
26// Data structure of the file start record
27//------------------------------------------------
28typedef struct {
29 uint32_t marker; //0x1234aaaa
30 uint32_t record_size; //words
31 uint32_t version;
32 uint32_t file_number;
33 uint32_t date;
34 uint32_t time;
36 uint32_t sizeLimit_MB; //MB
38//------------------------------------------------
40public:
43
45
46 const file_start_record& getRecord() const { return m_record; }
47 void dump(std::ostream& os = std::cout) const;
48
49 void setFileNumber(uint32_t fn) { m_record.file_number = fn; }
50
51private:
52 file_start_record m_record;
53};
54
55//------------------------------------------------
56// Data structure of the file name strings
57//------------------------------------------------
58typedef struct {
59 uint32_t marker; //0x1234aabb
60 uint32_t length1; //bytes
61 uint32_t length2; //bytes
63//------------------------------------------------
65public:
68
70
71 const file_name_strings& getRecord() const { return m_record; }
72
73 const std::string& gerAppName() const { return m_appName; }
74 const std::string& gerUsrTag() const { return m_usrTag; }
75
76 void dump(std::ostream& os = std::cout) const;
77
78private:
79 file_name_strings m_record;
80 std::string m_appName;
81 std::string m_usrTag;
82};
83
84//------------------------------------------------
85// Data structure of the run parameters record
86//------------------------------------------------
87typedef struct {
88 uint32_t marker; //0x1234bbbb
89 uint32_t record_size; //words
90 uint32_t run_number;
91 uint32_t max_events;
92 uint32_t rec_enable;
93 uint32_t trigger_type;
94 uint32_t detector_mask;
95 uint32_t beam_type;
96 uint32_t beam_energy;
98//------------------------------------------------
100public:
103
105
106 const run_parameters_record& getRecord() const { return m_record; }
107 void dump(std::ostream& os = std::cout) const;
108
109 void setRunNumber(uint32_t runId) { m_record.run_number = runId; }
110
111private:
112 run_parameters_record m_record;
113};
114
115//------------------------------------------------
116// Data structure of the data separator record
117//------------------------------------------------
118typedef struct {
119 uint32_t marker; //0x1234cccc
120 uint32_t record_size; //words
121 uint32_t data_block_number; //event id in run
122 uint32_t data_block_size; //bytes
124//------------------------------------------------
126public:
129
131
132 const data_separator_record& getRecord() const { return m_record; }
133 void dump(std::ostream& os = std::cout) const;
134
135 void setDataBlockNumber(uint32_t dn) { m_record.data_block_number = dn; }
136 void setDataBlockSize(uint32_t ds) { m_record.data_block_size = ds; }
137
138private:
139 data_separator_record m_record;
140};
141
142//------------------------------------------------
143// Data structure of the file end record
144//------------------------------------------------
145typedef struct {
146 uint32_t marker; //0x1234dddd
147 uint32_t record_size; //words
148 uint32_t date;
149 uint32_t time;
150 uint32_t events_in_file; //events number in file
151 uint32_t data_in_file; //MB file size
152 uint32_t events_in_run; //events number in run
153 uint32_t data_in_run; //MB run size
154 uint32_t status; // !0 ==> the last file of run
155 uint32_t end_marker; //0x1234eeee
157//------------------------------------------------
159public:
163
165
166 const file_end_record& getRecord() const { return m_record; }
167 void dump(std::ostream& os = std::cout) const;
168
169 void setEventsInFile(uint32_t file_nevt) { m_record.events_in_file = file_nevt; }
170 void setDataInFile(uint32_t file_size) { m_record.data_in_file = file_size; }
171 void setEventsInRun(uint32_t run_nevt) { m_record.events_in_run = run_nevt; }
172 void setDataInRun(uint32_t run_size) { m_record.data_in_run = run_size; }
173 void setStatus(uint32_t status) { m_record.status = status; }
174
175private:
176 file_end_record m_record;
177};
178#endif
const data_separator_record & getRecord() const
void dump(std::ostream &os=std::cout) const
void setDataBlockSize(uint32_t ds)
friend raw_ofstream & operator<<(raw_ofstream &os, DataSeparatorRecord &record)
friend raw_ifstream & operator>>(raw_ifstream &is, DataSeparatorRecord &record)
void setDataBlockNumber(uint32_t dn)
friend raw_ofstream & operator<<(raw_ofstream &os, FileEndRecord &record)
void setDataInFile(uint32_t file_size)
const file_end_record & getRecord() const
void setEventsInFile(uint32_t file_nevt)
void dump(std::ostream &os=std::cout) const
friend raw_ifstream & operator>>(raw_ifstream &is, FileEndRecord &record)
void setStatus(uint32_t status)
friend raw_ifstream & makeEndRecord(DataSeparatorRecord &sep, raw_ifstream &is, FileEndRecord &record)
void setDataInRun(uint32_t run_size)
void setEventsInRun(uint32_t run_nevt)
const std::string & gerUsrTag() const
Definition RawFileUtil.h:74
friend raw_ifstream & operator>>(raw_ifstream &is, FileNameStrings &record)
const std::string & gerAppName() const
Definition RawFileUtil.h:73
friend raw_ofstream & operator<<(raw_ofstream &os, FileNameStrings &record)
const file_name_strings & getRecord() const
Definition RawFileUtil.h:71
void dump(std::ostream &os=std::cout) const
const file_start_record & getRecord() const
Definition RawFileUtil.h:46
void setFileNumber(uint32_t fn)
Definition RawFileUtil.h:49
friend raw_ifstream & operator>>(raw_ifstream &is, FileStartRecord &record)
void dump(std::ostream &os=std::cout) const
friend raw_ofstream & operator<<(raw_ofstream &os, FileStartRecord &record)
void dump(std::ostream &os=std::cout) const
void setRunNumber(uint32_t runId)
const run_parameters_record & getRecord() const
friend raw_ofstream & operator<<(raw_ofstream &os, RunParametersRecord &record)
friend raw_ifstream & operator>>(raw_ifstream &is, RunParametersRecord &record)
uint32_t end_marker
uint32_t data_in_run
uint32_t events_in_file
uint32_t record_size
uint32_t data_in_file
uint32_t events_in_run
uint32_t file_number
Definition RawFileUtil.h:32
uint32_t sizeLimit_MB
Definition RawFileUtil.h:36
uint32_t sizeLimit_dataBlocks
Definition RawFileUtil.h:35
uint32_t record_size
Definition RawFileUtil.h:30