LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LCWriter.h
Go to the documentation of this file.
1 #ifndef MT_LCWRITER_H
2 #define MT_LCWRITER_H 1
3 
4 // -- std headers
5 #include <string>
6 #include <vector>
7 #include <fstream>
8 #include <memory>
9 #include <mutex>
10 #include <atomic>
11 #include <set>
12 
13 // -- lcio headers
14 #include "MT/Types.h"
15 #include "EVENT/LCIO.h"
16 
17 // need to make forward declaration to
18 // avoid lcio dependencies to include directly sio headers
19 
20 namespace sio {
21  class buffer ;
22 }
23 
24 namespace SIO {
25  class LCIORandomAccessMgr ;
26 }
27 
28 namespace MT {
29 
42  class LCWriter {
43  public:
45  LCWriter() = default ;
47  LCWriter(const LCWriter&) = delete ;
49  LCWriter& operator=(const LCWriter&) = delete ;
51  ~LCWriter() = default ;
52 
57  void open( const std::string &filename ) ;
58 
64  void open( const std::string &filename, int writeMode ) ;
65 
78  void setCompressionLevel( int level ) ;
79 
83  void writeRunHeader( EVENT::LCRunHeader *hdr ) ;
84 
88  void writeEvent( EVENT::LCEvent *evt ) ;
89 
93  void writeEvent( EVENT::LCEvent *evt, const std::set<std::string> &colsOnly ) ;
94 
98  void close() ;
99 
100  private:
101  static std::string getSIOFileName( const std::string& filename ) ;
102 
103  private:
114  };
115 
116 }
117 
118 #endif
std::shared_ptr< SIO::LCIORandomAccessMgr > _raMgr
The random access manager for event/run random access in the file.
Definition: LCWriter.h:111
Interface for the run header.
Definition: LCRunHeader.h:23
LCWriter & operator=(const LCWriter &)=delete
no assignment operator
void close()
Closes the output file/stream.
Definition: LCWriter.cc:202
void open(const std::string &filename)
Opens a file for writing.
Definition: LCWriter.cc:21
STL class.
void writeEvent(EVENT::LCEvent *evt)
Writes the given event to file.
Definition: LCWriter.cc:140
STL class.
std::mutex _mutex
Synchronization mutex.
Definition: LCWriter.h:113
~LCWriter()=default
Destructor.
std::atomic< unsigned int > _maxBufferSize
The compression level.
Definition: LCWriter.h:107
The main event interface.
Definition: LCEvent.h:31
std::atomic< int > _compressionLevel
The compression level.
Definition: LCWriter.h:109
void setCompressionLevel(int level)
Set the compression level - needs to be called before open() otherwise call will have no effect...
Definition: LCWriter.cc:84
pair< int, string > level
Definition: lsh.cc:50
LCWriter class.
Definition: LCWriter.h:42
void writeRunHeader(EVENT::LCRunHeader *hdr)
Writes the given run header to file.
Definition: LCWriter.cc:90
std::ofstream _stream
The output file stream.
Definition: LCWriter.h:105
LCWriter()=default
Default constructor.
static std::string getSIOFileName(const std::string &filename)
Definition: LCWriter.cc:212