BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
simple-event.cxx File Reference
#include "eformat/eformat.h"
#include "eformat/write/eformat.h"
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sys/uio.h>

Go to the source code of this file.

Functions

int main (int, char **)

Detailed Description

Author
Andre DOS ANJOS
Author
zhangy
Revision
1.1.1.1
Date
2009/06/19 07:35:41

This application will create a very simple event that contains 1 subdetector, that in turn contains 1 ROS, that in turn contains 1 ROB that contain 2 ROD's with equal contents, but different source identifiers. The event is then checked for conformity.

Definition in file simple-event.cxx.

Function Documentation

◆ main()

int main ( int ,
char **  )

Definition at line 23 of file simple-event.cxx.

23 {
24 using namespace eformat;
25
26 // create the dummy ROD contents
27 uint32_t dummy_data[256];
28 for ( size_t i = 0; i < 256; ++i ) dummy_data[i] = i;
29
33 const uint32_t run_no = 1001;
34 const uint32_t lvl1_id = 2222;
35 const uint32_t bc_id = 3333;
36 const uint32_t lvl1_type = 2;
37 const uint32_t event_type = 1;
38 const uint32_t global_id = 5555;
39 const uint32_t lvl2_info = 3;
40 const uint32_t ef_info[4] = { 0, 1, 2, 3 };
41
42 write::ROBFragment rob1( src1.code(), run_no, lvl1_id, bc_id, lvl1_type, event_type, 256,
43 dummy_data, eformat::STATUS_FRONT );
44 write::ROBFragment rob2( src2.code(), run_no, lvl1_id, bc_id, lvl1_type, event_type, 256,
45 dummy_data, eformat::STATUS_FRONT );
46 write::ROBFragment rob3( src3.code(), run_no, lvl1_id, bc_id, lvl1_type, event_type, 256,
47 dummy_data, eformat::STATUS_FRONT );
48
49 write::ROSFragment ros( src1.code(), run_no, lvl1_id, bc_id );
50 ros.append( &rob1 );
51 ros.append( &rob2 );
52 ros.append( &rob3 );
53
54 write::SubDetectorFragment sd( src1.code() );
55 sd.append( &ros );
56
57 write::FullEventFragment fe( src1.code(), time( 0 ), global_id, run_no, lvl1_id, lvl1_type,
58 lvl2_info, ef_info );
59 fe.append( &sd );
60
61 // get a handle to the top node
62 const write::node_t* fe_list = fe.bind();
63 struct iovec iov[128];
64 uint32_t total_pages = write::shallow_copy( *fe_list, iov, 128 );
65 PagedMemory<> mem( iov, total_pages );
66
67 try
68 {
70 ferd.check_tree();
71 // if check is ok, print the lvl1 identifier
72 std::cout << "Generated event seems Ok." << std::endl;
73 } catch ( eformat::Issue& ex )
74 {
75 std::cerr << std::endl << "Uncaught eformat issue: " << ex.what() << std::endl;
76 } catch ( ers::Issue& ex )
77 {
78 std::cerr << std::endl << "Uncaught ERS issue: " << ex.what() << std::endl;
79 } catch ( std::exception& ex )
80 {
81 std::cerr << std::endl << "Uncaught std exception: " << ex.what() << std::endl;
82 } catch ( ... )
83 { std::cerr << std::endl << "Uncaught unknown exception" << std::endl; }
84
85 return 0;
86}
Double_t time
Root Issue class.
const char * what() const
Human description message.
uint32_t shallow_copy(const node_t &list, struct iovec *dest, uint32_t max)
Definition node.cxx:76
const uint32_t STATUS_FRONT
status goes in front of data block