00001
00002
00016 #include <fstream>
00017 #include <iostream>
00018 #include <cstdlib>
00019
00020 #include "eformat/eformat.h"
00021
00025 const size_t MAX_EVENT_SIZE = 2500000;
00026
00030 int main (int argc, char** argv)
00031 {
00032 using namespace eformat;
00033
00034 if ( argc != 2 ) {
00035 std::cerr << "usage: " << argv[0] << " <file>" << std::endl;
00036 std::exit(1);
00037 }
00038
00039
00040 std::fstream in(argv[1], std::ios::in|std::ios::binary);
00041 if (!in) {
00042 std::cerr << "File `" << argv[1] << "' does not exist?!" << std::endl;
00043 std::exit(1);
00044 }
00045 uint32_t* event = new uint32_t[MAX_EVENT_SIZE];
00046 uint32_t sevent = 0;
00047 while(in.good() && !in.eof() && sevent != 0xaa1234aa) {
00048 in.read((char*)&sevent, 4);
00049 }
00050 if (sevent == 0xaa1234aa) in.seekg(in.tellg()-(std::streampos)4);
00051 else exit(1);
00052
00053
00054
00055
00056
00057 while (true) {
00058
00059 if (!(next_fragment(in, event, MAX_EVENT_SIZE*4))) break;
00060
00061 try {
00062 FullEventFragment<const uint32_t*> fe(event);
00063 fe.check_tree();
00064
00065 std::cout << "Event " << fe.lvl1_id() << " is Ok." << std::endl;
00066 }
00067 catch (eformat::Issue& ex) {
00068 std::cerr << std::endl
00069 << "Uncaught eformat issue: " << ex.what() << std::endl;
00070 std::cout << "Trying to continue..." << std::endl;
00071 continue;
00072 }
00073 catch (ers::Issue& ex) {
00074 std::cerr << std::endl
00075 << "Uncaught ERS issue: " << ex.what() << std::endl;
00076 delete[] event;
00077 std::exit(1);
00078 }
00079 catch (std::exception& ex) {
00080 std::cerr << std::endl
00081 << "Uncaught std exception: " << ex.what() << std::endl;
00082 delete[] event;
00083 std::exit(1);
00084 }
00085 catch (...) {
00086 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
00087 delete[] event;
00088 std::exit(1);
00089 }
00090
00091 }
00092
00093 delete[] event;
00094 return 0;
00095 }