BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataOutputSvc.cxx
Go to the documentation of this file.
1//===================================================================
2// Implementation of RawDataOutputSvc
3// Revision: July 11, 2002
4// Modified for RawFileReader
5//
6//===================================================================
7//
8
9// Include files.
10#include "GaudiKernel/MsgStream.h"
11#include "GaudiKernel/Bootstrap.h"
12#include "GaudiKernel/PropertyMgr.h"
13#include "GaudiKernel/ISvcLocator.h"
14#include "GaudiKernel/IJobOptionsSvc.h"
15#include "RawDataCnv/RawDataOutputSvc.h"
16
17// Constructor.
18RawDataOutputSvc::RawDataOutputSvc(const std::string& name, ISvcLocator* svcloc)
19 : IRawDataOutputSvc(name,svcloc),
20 m_fw(0)
21{
22 PropertyMgr m_propMgr;
23 m_propMgr.declareProperty("OutputFile", m_outputFile = "offline.raw");
24
25 IJobOptionsSvc* jobSvc;
26 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
27 jobSvc->setMyProperties(name, &m_propMgr);
28
29 m_buffer = new uint32_t[64*1024]; // 256k bytes
30}
31
32// Destructor.
34{
35 MsgStream log(messageService(), name() );
36 log << MSG::DEBUG << "RawDataOutputSvc Destructor called " << endreq;
37
38 delete [] m_buffer;
39}
40
41
43{
44 // clean up
45 if ( m_fw ) {
46 delete m_fw;
47 m_fw = 0;
48 }
49
50 return StatusCode::SUCCESS;
51}
52
53// Open the first input file and read the first event.
55{
56 MsgStream log(messageService(), name() );
57
58 // Open the first output file for writing.
59 m_fw = new RawFileWriter(m_outputFile);
60
61 log << MSG::DEBUG << "Opened output File " << m_outputFile << endreq;
62
63 return StatusCode::SUCCESS;
64}
65
66// Write the next event.
68{
69 MsgStream log(messageService(), name() );
70
71 //uint32_t evt_size_w = re->size_word();
72
73 const eformat::write::node_t* top = re->bind();
74 if (eformat::write::copy(*top, m_buffer, 64*1024) == 0) {
75 log << MSG::ERROR << "failed to copy Event to the buffer !" << endreq;
76 return false;
77 }
78
79 try {
80 RawEvent evt(m_buffer);
81 evt.check_tree();
82 }
83 catch (std::exception& ex) {
84 std::cerr << "Uncaught std exception: " << ex.what() << std::endl;
85 std::exit(1);
86 }
87 catch (...) {
88 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
89 std::exit(1);
90 }
91
92 m_fw->writeEvent(m_buffer);
93
94 return true;
95}
The event conversion service needs an additional interface used by the converters to declare their ob...
RawDataOutputSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode initialize()
virtual StatusCode finalize()
virtual bool putEvent(WriteRawEvent *re)
int writeEvent(const uint32_t *pevt)
const eformat::write::node_t * bind(void)
uint32_t copy(const node_t &list, uint32_t *dest, size_t max)
Definition: node.cxx:64