BOSS 7.1.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"
16
17DECLARE_COMPONENT(RawDataOutputSvc)
18// Constructor.
19RawDataOutputSvc::RawDataOutputSvc(const std::string& name, ISvcLocator* svcloc)
20 : IRawDataOutputSvc(name,svcloc),
21 m_fw(0)
22{
23 PropertyMgr m_propMgr;
24 m_propMgr.declareProperty("OutputFile", m_outputFile = "offline.raw");
25
26 IJobOptionsSvc* jobSvc;
27 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
28 jobSvc->setMyProperties(name, &m_propMgr);
29
30 m_buffer = new uint32_t[64*1024]; // 256k bytes
31}
32
33// Destructor.
35{
36 MsgStream log(messageService(), name() );
37 log << MSG::DEBUG << "RawDataOutputSvc Destructor called " << endreq;
38
39 delete [] m_buffer;
40}
41
42
44{
45 // clean up
46 if ( m_fw ) {
47 delete m_fw;
48 m_fw = 0;
49 }
50
51 return StatusCode::SUCCESS;
52}
53
54// Open the first input file and read the first event.
56{
57 MsgStream log(messageService(), name() );
58
59 // Open the first output file for writing.
60 m_fw = new RawFileWriter(m_outputFile);
61
62 log << MSG::DEBUG << "Opened output File " << m_outputFile << endreq;
63
64 return StatusCode::SUCCESS;
65}
66
67// Write the next event.
69{
70 MsgStream log(messageService(), name() );
71
72 //uint32_t evt_size_w = re->size_word();
73
74 const eformat::write::node_t* top = re->bind();
75 if (eformat::write::copy(*top, m_buffer, 64*1024) == 0) {
76 log << MSG::ERROR << "failed to copy Event to the buffer !" << endreq;
77 return false;
78 }
79
80 try {
81 RawEvent evt(m_buffer);
82 evt.check_tree();
83 }
84 catch (std::exception& ex) {
85 std::cerr << "Uncaught std exception: " << ex.what() << std::endl;
86 std::exit(1);
87 }
88 catch (...) {
89 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
90 std::exit(1);
91 }
92
93 m_fw->writeEvent(m_buffer);
94
95 return true;
96}
std::ofstream m_outputFile
The event conversion service needs an additional interface used by the converters to declare their ob...
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