10 const uint32_t val[4] = {
type, ver, cnt, len };
12 fOut.write(reinterpret_cast<const char*>(val),
sizeof(val));
18 fOut.write(reinterpret_cast<const char*>(&t),
sizeof(T));
23 const string name = FormFileName(
"bin");
24 if (access(name.c_str(), F_OK)==0)
26 Error(
"File '"+name+
"' already exists.");
33 fOut.open(name.c_str(), ios_base::out);
37 str <<
"ofstream::open() failed for '" << name <<
"': " << strerror(errno) <<
" [errno=" << errno <<
"]";
45 static uint32_t
FACT = 0xFAC77e1e;
47 fOut.write(reinterpret_cast<char*>(&FACT), 4);
49 WriteBlockHeader(kIdentifier, 1, 0, 8);
50 WriteValue(uint32_t(0));
51 WriteValue(GetRunId());
53 WriteBlockHeader(kRunHeader, 1, 0,
sizeof(
RUN_HEAD)-
sizeof(PEVNT_HEADER*));
54 fOut.write(reinterpret_cast<const char*>(&h),
sizeof(
RUN_HEAD)-
sizeof(PEVNT_HEADER*));
56 for (
int i=0;
i<40;
i++)
58 WriteBlockHeader(kBoardHeader, 1,
i,
sizeof(PEVNT_HEADER));
59 fOut.write(reinterpret_cast<const char*>(h.
FADhead+
i),
sizeof(PEVNT_HEADER));
63 const vector<char> block(
sizeof(uint32_t));
64 WriteBlockHeader(kRunSummary, 1, 0, block.size());
66 fPosTail = fOut.tellp();
67 fOut.write(block.data(), block.size());
72 str <<
"ofstream::write() failed for '" << name <<
"': " << strerror(errno) <<
" [errno=" << errno <<
"]";
83 const EVENT &e = *evt.
fEvent;
85 const int sh =
sizeof(EVENT)-2 +
NPIX*e.Roi*2;
87 WriteBlockHeader(kEvent, 1, fCounter++, sh);
88 fOut.write(reinterpret_cast<const char*>(&e)+2, sh);
94 WriteBlockHeader(kEndOfFile, 0, 0, 0);
109 str <<
"ofstream::write() failed for '" << GetFileName() <<
"': " << strerror(errno) <<
" [errno=" << errno <<
"]";
120 str <<
"ofstream::close() failed for '" << GetFileName() <<
"': " << strerror(errno) <<
" [errno=" << errno <<
"]";
Namespace to help with some general things in the program initialization.
bool Open(const RUN_HEAD &h, const FAD::RunDescription &d)
void WriteBlockHeader(uint32_t type, uint32_t ver, uint32_t cnt, uint32_t len)
void WriteValue(const T &t)
bool WriteEvt(const EVT_CTRL2 &)
PEVNT_HEADER FADhead[NBOARDS]