#include #include #include #include #include #include #include #include #include namespace ratzdab { zdabfile::zdabfile(std::string filename) { f = fopen(filename.c_str(), "rb"); if (!f) { throw zfileex; } p = new PZdabFile(); if (p->Init(f) < 0) { throw zfileex; } } zdabfile::~zdabfile() { delete p; fclose(f); } TObject* zdabfile::next() { nZDAB* z = p->NextRecord(); if (!z) { return static_cast(NULL); } return convert(z); } TObject* zdabfile::convert(nZDAB* const z) { if (z->bank_name == ZDAB_RECORD) { PmtEventRecord* o = reinterpret_cast(p->GetBank(z)); return dynamic_cast(unpack::event(o)); } else if (z->bank_name == RHDR_RECORD) { RunRecord* o = reinterpret_cast(p->GetBank(z)); return dynamic_cast(unpack::rhdr(o)); } else if (z->bank_name == TRIG_RECORD) { TriggerInfo* o = reinterpret_cast(p->GetBank(z)); return dynamic_cast(unpack::trig(o)); } else if (z->bank_name == EPED_RECORD) { EpedRecord* o = reinterpret_cast(p->GetBank(z)); return dynamic_cast(unpack::eped(o)); } #ifdef RATDEBUG RAT::warn << dformat("Got a record of type %x (%c%c%c%c)\n", z->bank_name, ((char *)&z->bank_name)[3], ((char *)&z->bank_name)[2], ((char *)&z->bank_name)[1], ((char *)&z->bank_name)[0]); #endif throw record_unknown; } } // namespace ratzdab