00001
00002
00016 #include "eformat/eformat.h"
00017 #include "eformat/write/eformat.h"
00018 #include <sys/uio.h>
00019 #include <cstdlib>
00020 #include <ctime>
00021 #include <iostream>
00022
00023 int main (int, char**)
00024 {
00025 using namespace eformat;
00026
00027
00028 uint32_t dummy_data[256];
00029 for (size_t i=0; i<256; ++i) dummy_data[i] = i;
00030
00031 helper::SourceIdentifier src1(LAR_EM_BARREL_A_SIDE, 0);
00032 helper::SourceIdentifier src2(LAR_EM_BARREL_A_SIDE, 1);
00033 helper::SourceIdentifier src3(LAR_EM_BARREL_A_SIDE, 2);
00034 const uint32_t run_no = 1001;
00035 const uint32_t lvl1_id = 2222;
00036 const uint32_t bc_id = 3333;
00037 const uint32_t lvl1_type = 2;
00038 const uint32_t event_type = 1;
00039 const uint32_t global_id = 5555;
00040 const uint32_t lvl2_info = 3;
00041 const uint32_t ef_info[4] = { 0, 1, 2, 3 };
00042
00043 write::ROBFragment rob1(src1.code(), run_no, lvl1_id, bc_id,
00044 lvl1_type, event_type, 256, dummy_data,
00045 eformat::STATUS_FRONT);
00046 write::ROBFragment rob2(src2.code(), run_no, lvl1_id, bc_id,
00047 lvl1_type, event_type, 256, dummy_data,
00048 eformat::STATUS_FRONT);
00049 write::ROBFragment rob3(src3.code(), run_no, lvl1_id, bc_id,
00050 lvl1_type, event_type, 256, dummy_data,
00051 eformat::STATUS_FRONT);
00052
00053 write::ROSFragment ros(src1.code(), run_no, lvl1_id, bc_id);
00054 ros.append(&rob1);
00055 ros.append(&rob2);
00056 ros.append(&rob3);
00057
00058 write::SubDetectorFragment sd(src1.code());
00059 sd.append(&ros);
00060
00061 write::FullEventFragment fe(src1.code(), time(0), global_id, run_no,
00062 lvl1_id, lvl1_type, lvl2_info, ef_info);
00063 fe.append(&sd);
00064
00065
00066 const write::node_t* fe_list = fe.bind();
00067 struct iovec iov[128];
00068 uint32_t total_pages = write::shallow_copy(*fe_list, iov, 128);
00069 PagedMemory<> mem(iov, total_pages);
00070
00071 try {
00072 FullEventFragment <PagedMemory<>::const_iterator> ferd(mem.begin());
00073 ferd.check_tree();
00074
00075 std::cout << "Generated event seems Ok." << std::endl;
00076 }
00077 catch (eformat::Issue& ex) {
00078 std::cerr << std::endl
00079 << "Uncaught eformat issue: " << ex.what() << std::endl;
00080 }
00081 catch (ers::Issue& ex) {
00082 std::cerr << std::endl
00083 << "Uncaught ERS issue: " << ex.what() << std::endl;
00084 }
00085 catch (std::exception& ex) {
00086 std::cerr << std::endl
00087 << "Uncaught std exception: " << ex.what() << std::endl;
00088 }
00089 catch (...) {
00090 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
00091 }
00092
00093 return 0;
00094 }