1#include "RawFile/raw_ofstream.h"
2#include "RawFile/RawFileTools.h"
5#define MAX_RAWFILE_SiZE 2000000000
8int raw_ofstream::_nHandler = 0;
10pthread_mutex_t raw_ofstream::_pthread_lock = PTHREAD_MUTEX_INITIALIZER;
17 if ( _instance == 0 ) {
32 if ( _nHandler > 0 && --_nHandler == 0 ) {
40raw_ofstream::raw_ofstream(
const std::string& fname)
48raw_ofstream::~raw_ofstream()
55 uint32_t fsize = tellp();
64 (*this) << m_dataSeparatorRecord;
65 std::ofstream::write(pbuf, size);
76 (*this) << m_fileEndRecord;
77 std::ofstream::close();
79 std::cout <<
"[RawFile] Finished writing file: " << real_fname() << std::endl;
83void raw_ofstream::init_fstream()
87 std::string fname = real_fname();
89 if ( access( fname.c_str(), F_OK ) == 0 ) {
90 std::cerr <<
"[RawFile] Attempt to create an exist file: " << fname << std::endl;
94 std::cout <<
"[RawFile] Creating a new file: " << real_fname() << std::endl;
95 open( fname.c_str(), std::ios::binary );
97 (*this) << m_fileStartRecord << m_fileNameStrings << m_runParametersRecord;
100std::string raw_ofstream::real_fname()
102 std::string fname = m_fname;
m_outputFile open("YYYY/m_txt_dir/LumTau_XXXX.txt", ios_base::app)
void setDataBlockSize(uint32_t ds)
void setDataBlockNumber(uint32_t dn)
void setEventsInFile(uint32_t file_nevt)
int write_event(const char *pbuf, int size)
static raw_ofstream * instance(const std::string &fname)