BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Builder.cxx
Go to the documentation of this file.
1#include "Gaudi/Interfaces/IOptionsSvc.h"
2#include "GaudiKernel/Bootstrap.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/Parsers.h"
5using Gaudi::Interfaces::IOptionsSvc;
6
7#include "RawDataCnv/EventManagement/Builder.h"
8
10
12 // default 128k bytes buffer size, it's dangerous!!!
13 // a smarter method is expected !!!
14 m_buf = new uint32_t[32768];
15
16 if ( !m_confFile.empty() ) return;
17
18 auto optSvc = Gaudi::svcLocator()->service<IOptionsSvc>( "JobOptionsSvc" );
19 Gaudi::Parsers::parse( m_confFile, optSvc->get( "Builder.RawDataCnvConfFile" ) ).ignore();
20 Gaudi::Parsers::parse( m_status, optSvc->get( "Builder.Status", "4294967295" ) ).ignore(); // 0xFFFFFFFF = 4294967295
21}
22
24
25bool Builder::expect( ifstream& f, string msg, string fname ) {
26 string str;
27 if ( f.bad() )
28 {
29 cerr << "Error: file " << fname << " is bad" << endl;
30 return false;
31 }
32 f >> str;
33 if ( str == msg ) return true;
34
35 cerr << "Error: expected `" << msg << "|" << str << "` in " << fname << endl;
36 return false;
37}
38
39bool Builder::expectInt( ifstream& f, string msg, string fname, uint32_t& val1,
40 uint32_t& val2 ) {
41 if ( !expect( f, msg, fname ) || f.bad() ) return false;
42 f >> val1 >> val2;
43 return true;
44}
45
46bool Builder::expectLong( ifstream& f, string msg, string fname, uint64_t& val ) {
47 if ( !expect( f, msg, fname ) || f.bad() ) return false;
48 f >> val;
49 return true;
50}
51
52bool Builder::find( ifstream& f, string msg, string fname ) {
53 if ( f.bad() )
54 {
55 cerr << "Error: file " << fname << " bad checked" << endl;
56 return false;
57 }
58
59 string str;
60 while ( !f.eof() )
61 {
62 f >> str;
63 if ( str == msg ) return true;
64 }
65
66 return false;
67}
68
69void Builder::append2event( WriteRawEvent*& re, uint32_t source_id, uint32_t size,
70 uint32_t shift ) {
71 uint32_t run_no = re->run_no();
72 uint32_t lvl1_id = re->lvl1_id();
73 uint32_t bc_id = 0; // ?
74 // ROB
75 eformat::write::ROBFragment* nrob = new eformat::write::ROBFragment( source_id, // source_id
76 run_no, // run_no
77 lvl1_id, // lvl1_id
78 bc_id, // bc_id
79 0, // lvl1_type
80 0, // detev_type
81 size, // ndata
82 m_buf + shift, // data
83 0 // status_position
84 );
85 if ( m_status == 0xFFFFFFFF )
86 {
87 nrob->status( 0, NULL );
88 nrob->rod_status( 0, NULL );
89 }
90 else
91 { // fucd
92 nrob->status( 1, &m_status );
93 nrob->rod_status( 1, &m_status );
94 }
95 // ROS
96 eformat::write::ROSFragment* nros = new eformat::write::ROSFragment( source_id, // source_id
97 run_no, // run_no
98 lvl1_id, // lvl1_id
99 bc_id // bc_id
100 );
101 if ( m_status == 0xFFFFFFFF ) nros->status( 0, NULL );
102 else nros->status( 1, &m_status ); // fucd
103 // SubDetector
106 if ( m_status == 0xFFFFFFFF ) nsd->status( 0, NULL );
107 else nsd->status( 1, &m_status ); // fucd
108 // append to FullEventFragment
109 nros->append( nrob );
110 nsd->append( nros );
111 re->append( nsd );
112}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
eformat::write::FullEventFragment WriteRawEvent
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size, uint32_t shift=0)
Definition Builder.cxx:69
static bool find(ifstream &f, string msg, string fname)
Definition Builder.cxx:52
static bool expect(ifstream &f, string msg, string fname)
Definition Builder.cxx:25
virtual ~Builder()
Definition Builder.cxx:23
static bool expectLong(ifstream &f, string msg, string fname, uint64_t &val)
Definition Builder.cxx:46
static bool expectInt(ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
Definition Builder.cxx:39
Builder()
Definition Builder.cxx:11
void append(eformat::write::SubDetectorFragment *sd)
void status(uint32_t n, const uint32_t *status)
void rod_status(uint32_t n, const uint32_t *status)
void status(uint32_t n, const uint32_t *status)
void append(eformat::write::ROBFragment *rob)
void status(uint32_t n, const uint32_t *status)
void append(eformat::write::ROSFragment *ros)