CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
simple-event.cxx
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file simple-event.cxx
5 * @author <a href="mailto:[email protected]">Andre DOS ANJOS</a>
6 * $Author: zhangy $
7 * $Revision: 1.1.1.1 $
8 * $Date: 2009/06/19 07:35:41 $
9 *
10 * This application will create a very simple event that contains 1
11 * subdetector, that in turn contains 1 ROS, that in turn contains 1 ROB that
12 * contain 2 ROD's with equal contents, but different source identifiers. The
13 * event is then checked for conformity.
14 */
15
16#include "eformat/eformat.h"
18#include <sys/uio.h>
19#include <cstdlib>
20#include <ctime>
21#include <iostream>
22
23int main (int, char**)
24{
25 using namespace eformat;
26
27 //create the dummy ROD contents
28 uint32_t dummy_data[256];
29 for (size_t i=0; i<256; ++i) dummy_data[i] = i;
30
31 helper::SourceIdentifier src1(LAR_EM_BARREL_A_SIDE, 0);
32 helper::SourceIdentifier src2(LAR_EM_BARREL_A_SIDE, 1);
33 helper::SourceIdentifier src3(LAR_EM_BARREL_A_SIDE, 2);
34 const uint32_t run_no = 1001;
35 const uint32_t lvl1_id = 2222;
36 const uint32_t bc_id = 3333;
37 const uint32_t lvl1_type = 2;
38 const uint32_t event_type = 1;
39 const uint32_t global_id = 5555;
40 const uint32_t lvl2_info = 3;
41 const uint32_t ef_info[4] = { 0, 1, 2, 3 };
42
43 write::ROBFragment rob1(src1.code(), run_no, lvl1_id, bc_id,
44 lvl1_type, event_type, 256, dummy_data,
46 write::ROBFragment rob2(src2.code(), run_no, lvl1_id, bc_id,
47 lvl1_type, event_type, 256, dummy_data,
49 write::ROBFragment rob3(src3.code(), run_no, lvl1_id, bc_id,
50 lvl1_type, event_type, 256, dummy_data,
52
53 write::ROSFragment ros(src1.code(), run_no, lvl1_id, bc_id);
54 ros.append(&rob1);
55 ros.append(&rob2);
56 ros.append(&rob3);
57
59 sd.append(&ros);
60
61 write::FullEventFragment fe(src1.code(), time(0), global_id, run_no,
62 lvl1_id, lvl1_type, lvl2_info, ef_info);
63 fe.append(&sd);
64
65 //get a handle to the top node
66 const write::node_t* fe_list = fe.bind();
67 struct iovec iov[128];
68 uint32_t total_pages = write::shallow_copy(*fe_list, iov, 128);
69 PagedMemory<> mem(iov, total_pages);
70
71 try {
72 FullEventFragment <PagedMemory<>::const_iterator> ferd(mem.begin());
73 ferd.check_tree();
74 //if check is ok, print the lvl1 identifier
75 std::cout << "Generated event seems Ok." << std::endl;
76 }
77 catch (eformat::Issue& ex) {
78 std::cerr << std::endl
79 << "Uncaught eformat issue: " << ex.what() << std::endl;
80 }
81 catch (ers::Issue& ex) {
82 std::cerr << std::endl
83 << "Uncaught ERS issue: " << ex.what() << std::endl;
84 }
85 catch (std::exception& ex) {
86 std::cerr << std::endl
87 << "Uncaught std exception: " << ex.what() << std::endl;
88 }
89 catch (...) {
90 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
91 }
92
93 return 0;
94}
Double_t time
const_iterator begin(void) const
Definition: PagedMemory.h:249
void append(eformat::write::SubDetectorFragment *sd)
const eformat::write::node_t * bind(void)
void append(eformat::write::ROBFragment *rob)
void append(eformat::write::ROSFragment *ros)
Root Issue class.
const char * what() const
Human description message.
Includes all entities from the Event Format Library (eformat)
const uint32_t STATUS_FRONT
status goes in front of data block
Definition: Status.h:38
int main()
Definition: test_IFile.cxx:11