| 
    LCIO
    02.17
    
   | 
 
#include <LCWriter.h>
Public Member Functions | |
| LCWriter ()=default | |
| Default constructor.  More... | |
| LCWriter (const LCWriter &)=delete | |
| no copy constructor  More... | |
| LCWriter & | operator= (const LCWriter &)=delete | 
| no assignment operator  More... | |
| ~LCWriter ()=default | |
| Destructor.  More... | |
| void | open (const std::string &filename) | 
| Opens a file for writing.  More... | |
| void | open (const std::string &filename, int writeMode) | 
| Opens a file for writing.  More... | |
| void | setCompressionLevel (int level) | 
| Set the compression level - needs to be called before open() otherwise call will have no effect.  More... | |
| void | writeRunHeader (EVENT::LCRunHeader *hdr) | 
| Writes the given run header to file.  More... | |
| void | writeEvent (EVENT::LCEvent *evt) | 
| Writes the given event to file.  More... | |
| void | writeEvent (EVENT::LCEvent *evt, const std::set< std::string > &colsOnly) | 
| Writes the given event to file, but write only the spcified collections.  More... | |
| void | close () | 
| Closes the output file/stream.  More... | |
Static Private Member Functions | |
| static std::string | getSIOFileName (const std::string &filename) | 
Private Attributes | |
| std::ofstream | _stream {} | 
| The output file stream.  More... | |
| std::atomic< unsigned int > | _maxBufferSize {2*1204*1024} | 
| The compression level.  More... | |
| std::atomic< int > | _compressionLevel {-1} | 
| The compression level.  More... | |
| std::shared_ptr < SIO::LCIORandomAccessMgr >  | _raMgr {nullptr} | 
| The random access manager for event/run random access in the file.  More... | |
| std::mutex | _mutex {} | 
| Synchronization mutex.  More... | |
LCWriter class.
    Implement a writer for events and run headers using SIO.
    Thread safety specifications:
    - Writing two events from different threads is safe
    - Writing an event and a run header from different threads is safe
    - Opening/closing a file and writing might throw an exception depending on the scheduling
    A mutex ensures that no data race will occur but won't protect
    against race conditions
Definition at line 42 of file LCWriter.h.
      
  | 
  default | 
Default constructor.
      
  | 
  delete | 
no copy constructor
      
  | 
  default | 
Destructor.
| void MT::LCWriter::close | ( | ) | 
Closes the output file/stream.
Definition at line 202 of file LCWriter.cc.
References _mutex, _raMgr, _stream, and std::ofstream::close().
      
  | 
  staticprivate | 
Definition at line 212 of file LCWriter.cc.
References SIO::LCSIO::FileExtension, std::string::length(), and std::string::rfind().
Referenced by open().
| void MT::LCWriter::open | ( | const std::string & | filename | ) | 
Opens a file for writing.
If file with given name exists, an exception is thrown. Use append or new mode instead.
Definition at line 21 of file LCWriter.cc.
References getSIOFileName().
| void MT::LCWriter::open | ( | const std::string & | filename, | 
| int | writeMode | ||
| ) | 
Opens a file for writing.
Possible write modes are: LCIO::WRITE_NEW (existing files are replaced) and LCIO::WRITE_APPEND.
Definition at line 37 of file LCWriter.cc.
References _mutex, _raMgr, _stream, getSIOFileName(), std::ofstream::good(), std::ofstream::is_open(), std::ofstream::open(), SIO::LCSIO::RandomAccessSize, std::ofstream::seekp(), std::stringstream::str(), and std::ofstream::tellp().
| void MT::LCWriter::setCompressionLevel | ( | int | level | ) | 
Set the compression level - needs to be called before open() otherwise call will have no effect.
If not called the Writer will use default compression.
 Valid compression levels are:
| level | compression level | 
Definition at line 84 of file LCWriter.cc.
References _compressionLevel.
| void MT::LCWriter::writeEvent | ( | EVENT::LCEvent * | evt | ) | 
Writes the given event to file.
Definition at line 140 of file LCWriter.cc.
| void MT::LCWriter::writeEvent | ( | EVENT::LCEvent * | evt, | 
| const std::set< std::string > & | colsOnly | ||
| ) | 
Writes the given event to file, but write only the spcified collections.
Definition at line 146 of file LCWriter.cc.
References _compressionLevel, _maxBufferSize, _mutex, _raMgr, _stream, EVENT::LCEvent::getEventNumber(), EVENT::LCEvent::getRunNumber(), std::ofstream::is_open(), std::atomic::load(), SIO::SIOEventHeaderRecord::writeRecord(), and SIO::SIOEventRecord::writeRecord().
| void MT::LCWriter::writeRunHeader | ( | EVENT::LCRunHeader * | hdr | ) | 
Writes the given run header to file.
Definition at line 90 of file LCWriter.cc.
References _compressionLevel, _maxBufferSize, _mutex, _raMgr, _stream, EVENT::LCRunHeader::getRunNumber(), std::ofstream::is_open(), std::atomic::load(), and SIO::SIORunHeaderRecord::writeRecord().
      
  | 
  private | 
The compression level.
Definition at line 109 of file LCWriter.h.
Referenced by setCompressionLevel(), writeEvent(), and writeRunHeader().
      
  | 
  private | 
The compression level.
Definition at line 107 of file LCWriter.h.
Referenced by writeEvent(), and writeRunHeader().
      
  | 
  private | 
Synchronization mutex.
Definition at line 113 of file LCWriter.h.
Referenced by close(), open(), writeEvent(), and writeRunHeader().
      
  | 
  private | 
The random access manager for event/run random access in the file.
Definition at line 111 of file LCWriter.h.
Referenced by close(), open(), writeEvent(), and writeRunHeader().
      
  | 
  private | 
The output file stream.
Definition at line 105 of file LCWriter.h.
Referenced by close(), open(), writeEvent(), and writeRunHeader().
 1.8.5