1#include "RawFile/RawFileUtil.h"
2#include "RawFile/raw_ifstream.h"
3#include "RawFile/raw_ofstream.h"
4#include "IRawFile/RawFileExceptions.h"
15 if (record.m_record.
marker != 0x1234aaaa) {
30 if (is.read((
char*)(&record.m_record.
marker),
sizeof(uint32_t)).fail()) {
36 if (record.m_record.
marker != 0x1234aabb) {
42 if (is.read((
char*)(&record.m_record.
length1),
sizeof(uint32_t)).fail()) {
47 uint32_t length1_word = (record.m_record.
length1 + 3) / 4;
48 char* appName =
new char[length1_word * 4 + 1];
49 if (is.read(appName, length1_word*4).fail()) {
53 appName[record.m_record.
length1] =
'\0';
54 record.m_appName = appName;
57 if (is.read((
char*)(&record.m_record.
length2),
sizeof(uint32_t)).fail()) {
62 uint32_t length2_word = (record.m_record.
length2 + 3) / 4;
63 char* usrTag =
new char[length2_word * 4 + 1];
64 if (is.read(usrTag, length2_word*4).fail()) {
68 usrTag[record.m_record.
length2] =
'\0';
69 record.m_usrTag = usrTag;
83 if (record.m_record.
marker != 0x1234bbbb) {
105 if (record.m_record.
marker != 0x1234cccc) {
106 if (record.m_record.
marker == 0x1234dddd) {
123 if (is.read((
char*)(&record.m_record),
sizeof(
file_end_record)).fail()) {
129 if (record.m_record.
marker != 0x1234dddd) {
133 if (record.m_record.
end_marker != 0x1234eeee) {
158 if (record.m_record.
marker != 0x1234dddd) {
162 if (record.m_record.
end_marker != 0x1234eeee) {
178 std::cerr <<
"[RawFile] Error occurred while writing file" << std::endl;
187 os.write((
char*)(&record.m_record),
sizeof(uint32_t)*2);
188 uint32_t sizebyte = record.m_record.
length1;
189 uint32_t sizeword = (sizebyte+3)/4;
190 os.write(record.m_appName.c_str(), sizeword*4);
191 os.write((
char*)(&record.m_record.
length2),
sizeof(uint32_t));
192 sizebyte = record.m_record.
length2;
193 sizeword = (sizebyte+3)/4;
194 os.write(record.m_usrTag.c_str(), sizeword*4);
196 std::cerr <<
"[RawFile] Error occurred while writing file" << std::endl;
205 std::cerr <<
"[RawFile] Error occurred while writing file" << std::endl;
215 std::cerr <<
"[RawFile] Error occurred while writing file" << std::endl;
224 if (os.write((
char*)(&record.m_record),
sizeof(
file_end_record)).fail()) {
225 std::cerr <<
"[RawFile] Error occurred while writing file" << std::endl;
234 m_record.
marker = 0x1234aaaa;
247 m_record.
marker = 0x1234aabb;
251 m_usrTag =
"offline";
256 m_record.
marker = 0x1234bbbb;
270 m_record.
marker = 0x1234cccc;
278 m_record.
marker = 0x1234dddd;
292 os <<
"[RawFile] FileStartRecord:" << std::endl << std::hex
293 <<
"[RawFile] \tmarker : 0x" << m_record.
marker << std::endl
294 <<
"[RawFile] \trecord_size : 0x" << m_record.
record_size << std::endl
295 <<
"[RawFile] \tversion : 0x" << m_record.
version << std::endl
296 <<
"[RawFile] \tfile_number : 0x" << m_record.
file_number << std::endl
297 <<
"[RawFile] \tdate : 0x" << m_record.
date << std::endl
298 <<
"[RawFile] \ttime : 0x" << m_record.
time << std::endl
300 <<
"[RawFile] \tsizeLimit_MB : 0x" << m_record.
sizeLimit_MB
301 << std::dec << std::endl;
305 os <<
"[RawFile] FileNameStrings:" << std::endl << std::hex
306 <<
"[RawFile] \tmarker : 0x" << m_record.
marker << std::endl
307 <<
"[RawFile] \tAppName length : 0x" << m_record.
length1 << std::endl
308 <<
"[RawFile] \tAppName : " << m_appName << std::endl
309 <<
"[RawFile] \tUsrTag length : 0x" << m_record.
length2 << std::endl
310 <<
"[RawFile] \tUsrTag : " << m_usrTag
311 << std::dec << std::endl;
315 os <<
"[RawFile] RunParametersRecord:" << std::endl << std::hex
316 <<
"[RawFile] \tmarker : 0x" << m_record.
marker << std::endl
317 <<
"[RawFile] \trecord_size : 0x" << m_record.
record_size << std::endl
318 <<
"[RawFile] \trun_number : 0x" << m_record.
run_number << std::endl
319 <<
"[RawFile] \tmax_events : 0x" << m_record.
max_events << std::endl
320 <<
"[RawFile] \trec_enable : 0x" << m_record.
rec_enable << std::endl
321 <<
"[RawFile] \ttrigger_type : 0x" << m_record.
trigger_type << std::endl
322 <<
"[RawFile] \tdetector_mask : 0x" << m_record.
detector_mask << std::endl
323 <<
"[RawFile] \tbeam_type : 0x" << m_record.
beam_type << std::endl
324 <<
"[RawFile] \tbeam_energy : 0x" << m_record.
beam_energy
325 << std::dec << std::endl;
329 os <<
"[RawFile] DataSeparatorRecord:" << std::endl << std::hex
330 <<
"[RawFile] \tmarker : 0x" << m_record.
marker << std::endl
331 <<
"[RawFile] \trecord_size : 0x" << m_record.
record_size << std::endl
332 <<
"[RawFile] \tdata_block_number : 0x" << m_record.
data_block_number << std::endl
334 << std::dec << std::endl;
338 os <<
"[RawFile] FileEndRecord:" << std::endl << std::hex
339 <<
"[RawFile] \tmarker : 0x" << m_record.
marker << std::endl
340 <<
"[RawFile] \trecord_size : 0x" << m_record.
record_size << std::endl
341 <<
"[RawFile] \tdate : 0x" << m_record.
date << std::endl
342 <<
"[RawFile] \ttime : 0x" << m_record.
time << std::endl
343 <<
"[RawFile] \tevents_in_file : 0x" << m_record.
events_in_file << std::endl
344 <<
"[RawFile] \tdata_in_file : 0x" << m_record.
data_in_file << std::endl
345 <<
"[RawFile] \tevents_in_run : 0x" << m_record.
events_in_run << std::endl
346 <<
"[RawFile] \tdata_in_run : 0x" << m_record.
data_in_run << std::endl
347 <<
"[RawFile] \tstatus : 0x" << m_record.
status << std::endl
348 <<
"[RawFile] \tend_marker : 0x" << m_record.
end_marker
349 << std::dec << std::endl;
raw_ifstream & makeEndRecord(DataSeparatorRecord &sep, raw_ifstream &is, FileEndRecord &record)
raw_ifstream & operator>>(raw_ifstream &is, FileStartRecord &record)
raw_ofstream & operator<<(raw_ofstream &os, FileStartRecord &record)
const data_separator_record & getRecord() const
void dump(std::ostream &os=std::cout) const
void dump(std::ostream &os=std::cout) const
void dump(std::ostream &os=std::cout) const
void dump(std::ostream &os=std::cout) const
void dump(std::ostream &os=std::cout) const
std::string currentFile() const
uint32_t data_block_number
uint32_t sizeLimit_dataBlocks