/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RawDataCnv/RawDataCnv-00-04-35/src/RawDataOutputSvc.cxx

Go to the documentation of this file.
00001 //===================================================================
00002 //  Implementation of RawDataOutputSvc
00003 //  Revision:  July 11, 2002
00004 //      Modified for RawFileReader
00005 //             
00006 //===================================================================
00007 //
00008  
00009 // Include files.
00010 #include "GaudiKernel/MsgStream.h"
00011 #include "GaudiKernel/Bootstrap.h"
00012 #include "GaudiKernel/PropertyMgr.h" 
00013 #include "GaudiKernel/ISvcLocator.h"
00014 #include "GaudiKernel/IJobOptionsSvc.h"
00015 #include "RawDataCnv/RawDataOutputSvc.h"
00016  
00017 // Constructor.
00018 RawDataOutputSvc::RawDataOutputSvc(const std::string& name, ISvcLocator* svcloc)
00019    : IRawDataOutputSvc(name,svcloc),  
00020      m_fw(0)
00021 {
00022   PropertyMgr m_propMgr;
00023   m_propMgr.declareProperty("OutputFile", m_outputFile = "offline.raw");
00024 
00025   IJobOptionsSvc* jobSvc; 
00026   Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
00027   jobSvc->setMyProperties(name, &m_propMgr);
00028 
00029   m_buffer = new uint32_t[64*1024];  // 256k bytes
00030 }
00031  
00032 // Destructor.
00033 RawDataOutputSvc::~RawDataOutputSvc()
00034 {
00035   MsgStream log(messageService(), name() );
00036   log << MSG::DEBUG << "RawDataOutputSvc Destructor called " << endreq;
00037 
00038   delete [] m_buffer;
00039 }
00040  
00041  
00042 StatusCode RawDataOutputSvc::finalize()
00043 {
00044    // clean up
00045    if ( m_fw ) {
00046       delete m_fw;
00047       m_fw = 0;
00048    }
00049  
00050    return StatusCode::SUCCESS;
00051 }
00052  
00053 // Open the first input file and read the first event.
00054 StatusCode RawDataOutputSvc::initialize()
00055 {
00056    MsgStream log(messageService(), name() );
00057 
00058    // Open the first output file for writing.
00059    m_fw = new RawFileWriter(m_outputFile);
00060 
00061    log << MSG::DEBUG << "Opened output File " << m_outputFile << endreq;
00062   
00063    return StatusCode::SUCCESS;
00064 }
00065  
00066 // Write the next event.
00067 bool  RawDataOutputSvc::putEvent(WriteRawEvent* re)
00068 {
00069   MsgStream log(messageService(), name() );
00070 
00071   //uint32_t evt_size_w = re->size_word();
00072 
00073   const eformat::write::node_t* top = re->bind();
00074   if (eformat::write::copy(*top, m_buffer, 64*1024) == 0) {
00075     log << MSG::ERROR << "failed to copy Event to the buffer !" << endreq;
00076     return false;
00077   }
00078 
00079   try {
00080     RawEvent evt(m_buffer);
00081     evt.check_tree();
00082   }
00083   catch (std::exception& ex) {
00084     std::cerr << "Uncaught std exception: " << ex.what() << std::endl;
00085     std::exit(1);
00086   }
00087   catch (...) {
00088     std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
00089     std::exit(1);
00090   }
00091 
00092   m_fw->writeEvent(m_buffer);
00093 
00094   return true; 
00095 }

Generated on Tue Nov 29 22:58:32 2016 for BOSS_7.0.2 by  doxygen 1.4.7